OSDN Git Service

Work around uClibc weirdness.
authorRob Landley <rob@landley.net>
Thu, 7 Jun 2007 19:19:44 +0000 (15:19 -0400)
committerRob Landley <rob@landley.net>
Thu, 7 Jun 2007 19:19:44 +0000 (15:19 -0400)
lib/lib.c
lib/lib.h

index 1f37eb5..8430ae6 100644 (file)
--- a/lib/lib.c
+++ b/lib/lib.c
 
 #include "toys.h"
 
+#ifndef __UCLIBC__
+
+// uClibc has this, and if we define our own it conflicts.
+
+// Like strncpy but always null terminated.
+void strlcpy(char *dest, char *src, size_t size)
+{
+       strncpy(dest,src,size);
+       dest[size-1] = 0;
+}
+#endif
+
+
 void verror_msg(char *msg, int err, va_list va)
 {
        fprintf(stderr, "%s: ", toys.which->name);
@@ -68,13 +81,6 @@ void usage_exit(void)
        exit(1);
 }
 
-// Like strncpy but always null terminated.
-void strlcpy(char *dest, char *src, size_t size)
-{
-       strncpy(dest,src,size);
-       dest[size-1] = 0;
-}
-
 // Die unless we can allocate memory.
 void *xmalloc(size_t size)
 {
index c95a743..f0d9241 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -31,13 +31,16 @@ struct dirtree {
 void get_optflags(void);
 
 // functions.c
+#ifndef __UCLIBC__
+void strlcpy(char *dest, char *src, size_t size);
+#endif
+
 void verror_msg(char *msg, int err, va_list va);
 void error_msg(char *msg, ...);
 void perror_msg(char *msg, ...);
 void error_exit(char *msg, ...);
 void perror_exit(char *msg, ...);
 void usage_exit(void);
-void strlcpy(char *dest, char *src, size_t size);
 void *xmalloc(size_t size);
 void *xzalloc(size_t size);
 void *xrealloc(void *ptr, size_t size);