diff --git a/config.mk b/config.mk index f681d09..307e6fe 100644 --- a/config.mk +++ b/config.mk @@ -1,4 +1,3 @@ - VERSION="0.3" # paths @@ -10,12 +9,10 @@ INCS = -I. -I/usr/include # BSD #LIBS = -L/usr/lib -lc -# Linux -LIBS = -L/usr/lib -lc -lbsd # flags # Linux -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=1 +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -DNEED_STRLCPY # BSD #CPPFLAGS = -DVERSION=\"${VERSION}\" @@ -24,4 +21,3 @@ LDFLAGS += -g ${LIBS} # compiler and linker # CC = cc - diff --git a/md2point.c b/md2point.c index 1599b27..259cdde 100644 --- a/md2point.c +++ b/md2point.c @@ -8,6 +8,30 @@ #include #include +#ifdef NEED_STRLCPY /* OpenBSD implementation */ +size_t +strlcpy(char *dst, const char *src, size_t dsize) { + const char *osrc = src; + size_t nleft = dsize; + + if (nleft != 0) { + while (--nleft != 0) { + if ((*dst++= *src++) == '\0') + break; + } + } + + if (nleft == 0) { + if (dsize != 0) + *dst = '\0'; + while (*src++) + ; + } + + return(src - osrc - 1); +} +#endif /* NEED_STRLCPY */ + /* from git://bitreich.org/utf8expr */ size_t utf8strlen(const char *s)