Skip to content

Commit

Permalink
eliminated the need for strlcat in the library
Browse files Browse the repository at this point in the history
  • Loading branch information
nmav authored and arr2036 committed Mar 2, 2015
1 parent a25afc5 commit 4c6bd94
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 48 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ AC_FUNC_STRFTIME
AC_FUNC_ALLOCA
AC_REPLACE_FUNCS(strdup strerror strcasecmp)
AC_CHECK_FUNCS(flock fcntl uname gethostname sysinfo getdomainname)
AC_CHECK_FUNCS(stricmp random rand snprintf vsnprintf strlcpy strlcat)
AC_CHECK_FUNCS(stricmp random rand snprintf vsnprintf strlcpy)

if test "$ac_cv_func_uname" = 'yes' && test "$cross_compiling" = 'no'
then
Expand Down
42 changes: 0 additions & 42 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,48 +347,6 @@ rc_getctime(void)
return timev.tv_sec + ((double)timev.tv_usec) / 1000000.0;
}

#ifndef HAVE_STRLCAT
/*
* Replacement for a missing strlcat.
*
* Provides the same functionality as the *BSD function strlcat, originally
* developed by Todd Miller and Theo de Raadt. strlcat works similarly to
* strncat, except simpler. The result is always nul-terminated even if the
* source string is longer than the space remaining in the destination string,
* and the total space required is returned. The third argument is the total
* space available in the destination buffer, not just the amount of space
* remaining.
*
* The canonical version of this file is maintained in the rra-c-util package,
* which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <[email protected]>
*
* The authors hereby relinquish any claim to any copyright that they may have
* in this work, whether granted under contract or by operation of law or
* international treaty, and hereby commit to the public, at large, that they
* shall not, at any time in the future, seek to enforce any copyright in this
* work against any person or entity, or prevent any person or entity from
* copying, publishing, distributing or creating derivative works of this
* work.
*/

size_t
rc_strlcat(char *dst, const char *src, size_t size)
{
size_t used, length, copy;

used = strlen(dst);
length = strlen(src);
if (size > 0 && used < size - 1) {
copy = (length >= size - used) ? size - used - 1 : length;
memcpy(dst + used, src, copy);
dst[used + copy] = '\0';
}
return used + length;
}
#endif

/*
* Copyright (c) 1998 Todd C. Miller <[email protected]>
*
Expand Down
5 changes: 0 additions & 5 deletions lib/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,5 @@ size_t rc_strlcpy(char *dst, char const *src, size_t siz);
# define strlcpy rc_strlcpy
#endif

#ifndef HAVE_STRLCAT
size_t rc_strlcat(char *dst, const char *src, size_t size);
# define strlcat rc_strlcat
#endif

#endif /* UTIL_H */

0 comments on commit 4c6bd94

Please sign in to comment.