diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fl_string_functions.cxx | 32 | ||||
| -rw-r--r-- | src/flstring.c | 32 | ||||
| -rw-r--r-- | src/flstring.h | 4 |
3 files changed, 35 insertions, 33 deletions
diff --git a/src/fl_string_functions.cxx b/src/fl_string_functions.cxx index 6b7fcead7..2e5e5d5d4 100644 --- a/src/fl_string_functions.cxx +++ b/src/fl_string_functions.cxx @@ -32,3 +32,35 @@ char *fl_strdup(const char *s) { return Fl::system_driver()->strdup(s); } + +/* + * 'fl_strlcpy()' - Safely copy two strings. + */ +size_t /* O - Length of string */ +fl_strlcpy(char *dst, /* O - Destination string */ + const char *src, /* I - Source string */ + size_t size) { /* I - Size of destination string buffer */ + size_t srclen; /* Length of source string */ + + + /* + * Figure out how much room is needed... + */ + + size --; + + srclen = strlen(src); + + /* + * Copy the appropriate amount... + */ + + if (srclen > size) srclen = size; + + memcpy(dst, src, srclen); + dst[srclen] = '\0'; + + return (srclen); +} + + diff --git a/src/flstring.c b/src/flstring.c index 6298a6d70..fab89feed 100644 --- a/src/flstring.c +++ b/src/flstring.c @@ -56,38 +56,6 @@ fl_strlcat(char *dst, /* O - Destination string */ return (dstlen + srclen); } - -/* - * 'fl_strlcpy()' - Safely copy two strings. - */ - -size_t /* O - Length of string */ -fl_strlcpy(char *dst, /* O - Destination string */ - const char *src, /* I - Source string */ - size_t size) { /* I - Size of destination string buffer */ - size_t srclen; /* Length of source string */ - - - /* - * Figure out how much room is needed... - */ - - size --; - - srclen = strlen(src); - - /* - * Copy the appropriate amount... - */ - - if (srclen > size) srclen = size; - - memcpy(dst, src, srclen); - dst[srclen] = '\0'; - - return (srclen); -} - #define C_RANGE(c,l,r) ( (c) >= (l) && (c) <= (r) ) /** diff --git a/src/flstring.h b/src/flstring.h index d902c0a9f..e4c7ea491 100644 --- a/src/flstring.h +++ b/src/flstring.h @@ -35,6 +35,7 @@ # include <strings.h> # endif /* HAVE_STRINGS_H */ # include <ctype.h> +# include <FL/fl_string_functions.h> /* * Apparently Unixware defines "index" to strchr (!) rather than @@ -81,7 +82,8 @@ FL_EXPORT extern size_t fl_strlcat(char *, const char *, size_t); # define strlcat fl_strlcat # endif /* !HAVE_STRLCAT */ -FL_EXPORT extern size_t fl_strlcpy(char *, const char *, size_t); +// promoted to <FL/fl_string_functions.h> +//FL_EXPORT extern size_t fl_strlcpy(char *, const char *, size_t); # ifndef HAVE_STRLCPY # define strlcpy fl_strlcpy # endif /* !HAVE_STRLCPY */ |
