Commit 029bcc09 by Kaveh R. Ghazi Committed by Kaveh Ghazi

mempcpy.c, [...]: New files.

	* mempcpy.c, stpcpy.c, stpncpy.c: New files.
	* configure.in (funcs, AC_CHECK_FUNCS): Add mempcpy, stpcpy
	and stpncpy.
	* Makefile.in (CFILES): Add mempcpy.c, stpcpy.c and stpncpy.c.
	(CONFIGURED_OFILES): Add mempcpy.o, stpcpy.o and stpncpy.o.
	Regenerate dependencies.

	* functions.texi, configure, config.in: Regenerated.

From-SVN: r65674
parent 6a1b7acd
2003-04-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* mempcpy.c, stpcpy.c, stpncpy.c: New files.
* configure.in (funcs, AC_CHECK_FUNCS): Add mempcpy, stpcpy
and stpncpy.
* Makefile.in (CFILES): Add mempcpy.c, stpcpy.c and stpncpy.c.
(CONFIGURED_OFILES): Add mempcpy.o, stpcpy.o and stpncpy.o.
Regenerate dependencies.
* functions.texi, configure, config.in: Regenerated.
2003-04-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* argv.c: Fix comments.
* calloc.c: Don't unnecessarily include "libiberty.h".
(bzero): Add prototype.
......
......@@ -140,7 +140,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \
lrealpath.c \
make-relative-prefix.c \
make-temp-file.c md5.c memchr.c memcmp.c memcpy.c memmove.c \
memset.c mkstemps.c \
mempcpy.c memset.c mkstemps.c \
objalloc.c obstack.c \
partition.c \
pex-djgpp.c pex-mpw.c pex-msdos.c pex-os2.c \
......@@ -148,9 +148,9 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \
physmem.c putenv.c \
random.c regex.c rename.c rindex.c \
safe-ctype.c setenv.c sigsetmask.c sort.c spaces.c \
splay-tree.c strcasecmp.c strchr.c strdup.c strerror.c \
strncasecmp.c strncmp.c strrchr.c strsignal.c strstr.c \
strtod.c strtol.c strtoul.c \
splay-tree.c stpcpy.c stpncpy.c strcasecmp.c strchr.c strdup.c \
strerror.c strncasecmp.c strncmp.c strrchr.c strsignal.c \
strstr.c strtod.c strtol.c strtoul.c \
ternary.c tmpnam.c \
vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c \
waitpid.c \
......@@ -186,14 +186,14 @@ CONFIGURED_OFILES = asprintf.o atexit.o \
ffs.o \
getcwd.o getpagesize.o \
index.o insque.o \
memchr.o memcmp.o memcpy.o memmove.o memset.o mkstemps.o \
memchr.o memcmp.o memcpy.o memmove.o mempcpy.o memset.o mkstemps.o \
pex-djgpp.o pex-mpw.o pex-msdos.o pex-os2.o \
pex-unix.o pex-win32.o \
putenv.o \
random.o rename.o rindex.o \
setenv.o sigsetmask.o strcasecmp.o strchr.o strdup.o \
strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o strtol.o \
strtoul.o \
setenv.o sigsetmask.o stpcpy.o stpncpy.o strcasecmp.o strchr.o \
strdup.o strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o \
strtol.o strtoul.o \
tmpnam.o \
vasprintf.o vfork.o vfprintf.o vprintf.o vsprintf.o \
waitpid.o
......@@ -459,6 +459,7 @@ memchr.o: $(INCDIR)/ansidecl.h
memcmp.o: $(INCDIR)/ansidecl.h
memcpy.o: $(INCDIR)/ansidecl.h
memmove.o: $(INCDIR)/ansidecl.h
mempcpy.o: $(INCDIR)/ansidecl.h
memset.o: $(INCDIR)/ansidecl.h
mkstemps.o: config.h $(INCDIR)/ansidecl.h
objalloc.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/objalloc.h
......@@ -490,6 +491,8 @@ sort.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
spaces.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
splay-tree.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
$(INCDIR)/splay-tree.h
stpcpy.o: $(INCDIR)/ansidecl.h
stpncpy.o: $(INCDIR)/ansidecl.h
strcasecmp.o: $(INCDIR)/ansidecl.h
strchr.o: $(INCDIR)/ansidecl.h
strdup.o: $(INCDIR)/ansidecl.h
......
......@@ -105,6 +105,9 @@
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
/* Define if you have the mempcpy function. */
#undef HAVE_MEMPCPY
/* Define if you have the memset function. */
#undef HAVE_MEMSET
......@@ -147,6 +150,12 @@
/* Define if you have the sigsetmask function. */
#undef HAVE_SIGSETMASK
/* Define if you have the stpcpy function. */
#undef HAVE_STPCPY
/* Define if you have the stpncpy function. */
#undef HAVE_STPNCPY
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
......
......@@ -177,6 +177,7 @@ funcs="$funcs memchr"
funcs="$funcs memcmp"
funcs="$funcs memcpy"
funcs="$funcs memmove"
funcs="$funcs mempcpy"
funcs="$funcs memset"
funcs="$funcs mkstemps"
funcs="$funcs putenv"
......@@ -185,6 +186,8 @@ funcs="$funcs rename"
funcs="$funcs rindex"
funcs="$funcs setenv"
funcs="$funcs sigsetmask"
funcs="$funcs stpcpy"
funcs="$funcs stpncpy"
funcs="$funcs strcasecmp"
funcs="$funcs strchr"
funcs="$funcs strdup"
......@@ -214,8 +217,8 @@ checkfuncs="$checkfuncs getsysinfo table sysctl"
if test "x" = "y"; then
AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
AC_CHECK_FUNCS(memmove mempcpy memset putenv random rename rindex sigsetmask)
AC_CHECK_FUNCS(strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr)
AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
......
......@@ -398,7 +398,7 @@ and a path ending in @code{/} returns the empty string after it.
Given a pointer to a string containing a pathname, returns a canonical
version of the filename. Symlinks will be resolved, and ``.'' and ``..''
components will be simplified. The returned value will be allocated using
@code{xmalloc} or @code{malloc}.
@code{malloc}, or @code{NULL} will be returned on a memory allocation error.
@end deftypefn
......@@ -476,6 +476,14 @@ Copies @var{count} bytes from memory area @var{from} to memory area
@end deftypefn
@c mempcpy.c:23
@deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. Returns a pointer to @var{out} + @var{length}.
@end deftypefn
@c memset.c:6
@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
......@@ -674,6 +682,24 @@ valid until at least the next call.
@end deftypefn
@c stpcpy.c:23
@deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
Copies the string @var{src} into @var{dst}. Returns a pointer to
@var{dst} + strlen(@var{src}).
@end deftypefn
@c stpncpy.c:23
@deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len})
Copies the string @var{src} into @var{dst}, copying exactly @var{len}
and padding with zeros if necessary. If @var{len} < strlen(@var{src})
then return @var{dst} + @var{len}, otherwise returns @var{dst} +
strlen(@var{src}).
@end deftypefn
@c strcasecmp.c:15
@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
......
/* Implement the mempcpy function.
Copyright (C) 2003 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. Returns a pointer to @var{out} + @var{length}.
@end deftypefn
*/
#include <ansidecl.h>
#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
extern PTR memcpy PARAMS ((PTR, const PTR, size_t));
PTR
mempcpy (dst, src, len)
PTR dst;
const PTR src;
size_t len;
{
return (char *) memcpy (dst, src, len) + len;
}
/* Implement the stpcpy function.
Copyright (C) 2003 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
Copies the string @var{src} into @var{dst}. Returns a pointer to
@var{dst} + strlen(@var{src}).
@end deftypefn
*/
#include <ansidecl.h>
#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
extern size_t strlen PARAMS ((const char *));
extern PTR memcpy PARAMS ((PTR, const PTR, size_t));
char *
stpcpy (dst, src)
char *dst;
const char *src;
{
const size_t len = strlen (src);
return (char *) memcpy (dst, src, len + 1) + len;
}
/* Implement the stpncpy function.
Copyright (C) 2003 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len})
Copies the string @var{src} into @var{dst}, copying exactly @var{len}
and padding with zeros if necessary. If @var{len} < strlen(@var{src})
then return @var{dst} + @var{len}, otherwise returns @var{dst} +
strlen(@var{src}).
@end deftypefn
*/
#include <ansidecl.h>
#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
extern size_t strlen PARAMS ((const char *));
extern PTR strncpy PARAMS ((char *, const char *, size_t));
char *
stpncpy (dst, src, len)
char *dst;
const char *src;
size_t len;
{
size_t n = strlen (src);
if (n > len)
n = len;
return strncpy (dst, src, len) + n;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment