[or-cvs] Handle strlcat/strlcpy correctly on platforms that have them.

Nick Mathewson nickm at seul.org
Tue Nov 2 19:25:55 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv13436/src/common

Modified Files:
	compat.c compat.h util.c util.h 
Log Message:
Handle strlcat/strlcpy correctly on platforms that have them.

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/src/common/compat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- compat.c	1 Nov 2004 22:41:32 -0000	1.2
+++ compat.c	2 Nov 2004 19:25:52 -0000	1.3
@@ -68,6 +68,14 @@
 #include "log.h"
 #include "util.h"
 
+/* Inline the strl functions if the plaform doesn't have them. */
+#ifndef HAVE_STRLCPY
+#include "strlcpy.c"
+#endif
+#ifndef HAVE_STRLCAT
+#include "strlcat.c"
+#endif
+
 /** Replacement for snprintf.  Differs from platform snprintf in two
  * ways: First, always NUL-terminates its output.  Second, always
  * returns -1 if the result is truncated.  (Note that this return

Index: compat.h
===================================================================
RCS file: /home/or/cvsroot/src/common/compat.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- compat.h	1 Nov 2004 22:41:32 -0000	1.2
+++ compat.h	2 Nov 2004 19:25:52 -0000	1.3
@@ -55,6 +55,12 @@
 #define strncasecmp strnicmp
 #define strcasecmp stricmp
 #endif
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
 
 int tor_snprintf(char *str, size_t size, const char *format, ...)
      CHECK_PRINTF(3,4);

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- util.c	2 Nov 2004 02:28:42 -0000	1.163
+++ util.c	2 Nov 2004 19:25:52 -0000	1.164
@@ -88,14 +88,6 @@
 #define INADDR_NONE ((unsigned long) -1)
 #endif
 
-/* Inline the strl functions if the plaform doesn't have them. */
-#ifndef HAVE_STRLCPY
-#include "strlcpy.c"
-#endif
-#ifndef HAVE_STRLCAT
-#include "strlcat.c"
-#endif
-
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- util.h	2 Nov 2004 02:28:42 -0000	1.110
+++ util.h	2 Nov 2004 19:25:52 -0000	1.111
@@ -46,9 +46,6 @@
 
 /* String manipulation */
 #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
-size_t strlcat(char *dst, const char *src, size_t siz);
-size_t strlcpy(char *dst, const char *src, size_t siz);
-
 void tor_strlower(char *s);
 int strcmpstart(const char *s1, const char *s2);
 int tor_strstrip(char *s, const char *strip);



More information about the tor-commits mailing list