aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
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 /com32/lib
parentd617310bda3b892fb8626151891748c1ee98106d (diff)
downloadsyslinux.git-1db28c0e4281f93445d3ded6ed518edefadd2803.tar.gz
syslinux.git-1db28c0e4281f93445d3ded6ed518edefadd2803.tar.xz
syslinux.git-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.)
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/Makefile4
-rw-r--r--com32/lib/strpcpy.c20
2 files changed, 22 insertions, 2 deletions
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;
+}