aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-03-12 21:23:02 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-03-12 21:23:02 -0700
commit1db28c0e4281f93445d3ded6ed518edefadd2803 (patch)
tree828a2af3c70ad8bb792e0c06a23a9f2bbf519b4b
parentd617310bda3b892fb8626151891748c1ee98106d (diff)
downloadsyslinux-elf-1db28c0e4281f93445d3ded6ed518edefadd2803.tar.gz
syslinux-elf-1db28c0e4281f93445d3ded6ed518edefadd2803.tar.xz
syslinux-elf-1db28c0e4281f93445d3ded6ed518edefadd2803.zip
libcom32: add strpcpy()
Add strpcpy() -- by analogy with mempcpy(), a strcpy() which returns a pointer to the end of the string (specifically, to the final null.)
-rw-r--r--com32/include/string.h1
-rw-r--r--com32/lib/Makefile4
-rw-r--r--com32/lib/strpcpy.c20
3 files changed, 23 insertions, 2 deletions
diff --git a/com32/include/string.h b/com32/include/string.h
index af9792b6..c964ee3b 100644
--- a/com32/include/string.h
+++ b/com32/include/string.h
@@ -23,6 +23,7 @@ __extern char *strcat(char *, const char *);
__extern char *strchr(const char *, int);
__extern int strcmp(const char *, const char *);
__extern char *strcpy(char *, const char *);
+__extern char *strpcpy(char *, const char *);
__extern size_t strcspn(const char *, const char *);
__extern char *strdup(const char *);
__extern char *strndup(const char *, size_t);
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 6f759e0c..6c137f9d 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -17,8 +17,8 @@ LIBOBJS = \
exit.o onexit.o \
perror.o printf.o puts.o qsort.o realloc.o seed48.o snprintf.o \
sprintf.o srand48.o sscanf.o stack.o strcasecmp.o strcat.o \
- strchr.o strcmp.o strcpy.o strdup.o strerror.o strlen.o \
- strnlen.o \
+ strchr.o strcmp.o strcpy.o strpcpy.o strdup.o strlen.o \
+ strerror.o strnlen.o \
strncasecmp.o strncat.o strncmp.o strncpy.o strndup.o \
stpcpy.o stpncpy.o \
strntoimax.o strntoumax.o strrchr.o strsep.o strspn.o strstr.o \
diff --git a/com32/lib/strpcpy.c b/com32/lib/strpcpy.c
new file mode 100644
index 00000000..e181e78f
--- /dev/null
+++ b/com32/lib/strpcpy.c
@@ -0,0 +1,20 @@
+/*
+ * strpcpy.c
+ *
+ * strpcpy() - strcpy() which returns a pointer to the final null
+ */
+
+#include <string.h>
+
+char *strpcpy(char *dst, const char *src)
+{
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ do {
+ *q++ = ch = *p++;
+ } while ( ch );
+
+ return q-1;
+}