stardot / MatrixBrandy

Matrix Brandy BASIC VI for Linux, Windows, MacOSX
http://brandy.matrixnetwork.co.uk/
44 stars 8 forks source link

Use strl functions on other OSes that have the functions #91

Closed brad0 closed 3 months ago

brad0 commented 3 months ago

Make use of the strl functions on FreeBSD, NetBSD, macOS, MINIX, Solaris and DJGPP.

soruk42 commented 3 months ago

I've manually merged this, with some adjustments. Rather than

#define STRLCPY(x,y,z) strlcpy(x,y,z)
#define STRLCAT(x,y,z) strlcat(x,y,z)

for every instance, I set a flag BRANDY_HAS_STRL_FUNCTIONS, then below I have

#ifdef BRANDY_HAS_STRL_FUNCTIONS
#define STRLCPY(x,y,z) strlcpy(x,y,z)
#define STRLCAT(x,y,z) strlcat(x,y,z)
#else
#define STRLCPY(x,y,z) my_strlcpy(x,y,z)
#define STRLCAT(x,y,z) strncat(x,y,z - strlen(x) -1)
#define USE_MY_STRLCPY
#endif /* BRANDY_HAS_STRL_FUNCTIONS */

Similarly, in miscprocs.{c,h} I'm now using #ifndef BRANDY_HAS_STRL_FUNCTIONS to conditionally compile my local implementation of strlcpy().

Github isn't showing this as merged, since I now do all my development in dev-main instead of master, but it is there. Rebase your fork and have a look in dev-main, it's there.

brad0 commented 3 months ago

I've manually merged this, with some adjustments. Rather than

#define STRLCPY(x,y,z) strlcpy(x,y,z)
#define STRLCAT(x,y,z) strlcat(x,y,z)

for every instance, I set a flag BRANDY_HAS_STRL_FUNCTIONS, then below I have

Something like that is definitely better over the repetition.

#ifdef BRANDY_HAS_STRL_FUNCTIONS
#define STRLCPY(x,y,z) strlcpy(x,y,z)
#define STRLCAT(x,y,z) strlcat(x,y,z)
#else
#define STRLCPY(x,y,z) my_strlcpy(x,y,z)
#define STRLCAT(x,y,z) strncat(x,y,z - strlen(x) -1)
#define USE_MY_STRLCPY
#endif /* BRANDY_HAS_STRL_FUNCTIONS */

Similarly, in miscprocs.{c,h} I'm now using #ifndef BRANDY_HAS_STRL_FUNCTIONS to conditionally compile my local implementation of strlcpy().

Github isn't showing this as merged, since I now do all my development in dev-main instead of master, but it is there. Rebase your fork and have a look in dev-main, it's there.

Do I have to do anything else?

soruk42 commented 3 months ago

Nope, you're good. I'll close this, it might claim I haven't accepted your pull request, but you can see from the git log in dev-main that I have 😀