* libc/string/Makefile.am (lib_a_SOURCES): Added swab.c.
(CHEWOUT_FILES): Added swab.def. * libc/string/Makefile.in: Rebuilt. * libc/string/string.tex: Include swab.def. * libc/include/string.h (swab): Declare. * libc/string/swab.c: New file.
This commit is contained in:
parent
c505305855
commit
85dd2e5b73
|
@ -1,3 +1,12 @@
|
||||||
|
Wed Mar 8 00:43:07 2000 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
|
||||||
|
|
||||||
|
* libc/string/Makefile.am (lib_a_SOURCES): Added swab.c.
|
||||||
|
(CHEWOUT_FILES): Added swab.def.
|
||||||
|
* libc/string/Makefile.in: Rebuilt.
|
||||||
|
* libc/string/string.tex: Include swab.def.
|
||||||
|
* libc/include/string.h (swab): Declare.
|
||||||
|
* libc/string/swab.c: New file.
|
||||||
|
|
||||||
Wed Mar 8 00:38:35 2000 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
|
Wed Mar 8 00:38:35 2000 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
|
||||||
|
|
||||||
* libc/stdio/Makefile.am (lib_a_SOURCES): Added getw.c and putw.c.
|
* libc/stdio/Makefile.am (lib_a_SOURCES): Added getw.c and putw.c.
|
||||||
|
|
|
@ -69,6 +69,7 @@ char *_EXFUN(strupr,(char *));
|
||||||
char *_EXFUN(strsignal, (int __signo));
|
char *_EXFUN(strsignal, (int __signo));
|
||||||
int _EXFUN(strtosigno, (const char *__name));
|
int _EXFUN(strtosigno, (const char *__name));
|
||||||
#endif
|
#endif
|
||||||
|
void _EXFUN(swab,(const void *, void *, ssize_t));
|
||||||
|
|
||||||
/* These function names are used on Windows and perhaps other systems. */
|
/* These function names are used on Windows and perhaps other systems. */
|
||||||
#ifndef strcmpi
|
#ifndef strcmpi
|
||||||
|
|
|
@ -39,13 +39,14 @@ lib_a_SOURCES = \
|
||||||
strupr.c \
|
strupr.c \
|
||||||
strxfrm.c \
|
strxfrm.c \
|
||||||
strstr.c \
|
strstr.c \
|
||||||
|
swab.c \
|
||||||
u_strerr.c
|
u_strerr.c
|
||||||
|
|
||||||
CHEWOUT_FILES=\
|
CHEWOUT_FILES=\
|
||||||
bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
|
bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
|
||||||
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
|
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
|
||||||
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
|
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
|
||||||
index.def rindex.def strcspn.def strpbrk.def \
|
index.def rindex.def strcspn.def strpbrk.def swab.def \
|
||||||
memchr.def strcat.def strerror.def strrchr.def \
|
memchr.def strcat.def strerror.def strrchr.def \
|
||||||
memcmp.def strchr.def strlen.def strspn.def \
|
memcmp.def strchr.def strlen.def strspn.def \
|
||||||
strcasecmp.def strncasecmp.def strlwr.def strupr.def
|
strcasecmp.def strncasecmp.def strlwr.def strupr.def
|
||||||
|
|
|
@ -121,6 +121,7 @@ lib_a_SOURCES = \
|
||||||
strupr.c \
|
strupr.c \
|
||||||
strxfrm.c \
|
strxfrm.c \
|
||||||
strstr.c \
|
strstr.c \
|
||||||
|
swab.c \
|
||||||
u_strerr.c
|
u_strerr.c
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ CHEWOUT_FILES = \
|
||||||
bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
|
bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
|
||||||
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
|
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
|
||||||
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
|
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
|
||||||
index.def rindex.def strcspn.def strpbrk.def \
|
index.def rindex.def strcspn.def strpbrk.def swab.def \
|
||||||
memchr.def strcat.def strerror.def strrchr.def \
|
memchr.def strcat.def strerror.def strrchr.def \
|
||||||
memcmp.def strchr.def strlen.def strspn.def \
|
memcmp.def strchr.def strlen.def strspn.def \
|
||||||
strcasecmp.def strncasecmp.def strlwr.def strupr.def
|
strcasecmp.def strncasecmp.def strlwr.def strupr.def
|
||||||
|
@ -155,7 +156,7 @@ lib_a_OBJECTS = bcmp.o bcopy.o bzero.o index.o memchr.o memcmp.o \
|
||||||
memcpy.o memmove.o memset.o rindex.o strcat.o strchr.o strcmp.o \
|
memcpy.o memmove.o memset.o rindex.o strcat.o strchr.o strcmp.o \
|
||||||
strcasecmp.o strcoll.o strcpy.o strcspn.o strerror.o strlen.o strlwr.o \
|
strcasecmp.o strcoll.o strcpy.o strcspn.o strerror.o strlen.o strlwr.o \
|
||||||
strncat.o strncmp.o strncasecmp.o strncpy.o strpbrk.o strrchr.o \
|
strncat.o strncmp.o strncasecmp.o strncpy.o strpbrk.o strrchr.o \
|
||||||
strspn.o strtok.o strtok_r.o strupr.o strxfrm.o strstr.o u_strerr.o
|
strspn.o strtok.o strtok_r.o strupr.o strxfrm.o strstr.o swab.o u_strerr.o
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
CCLD = $(CC)
|
CCLD = $(CC)
|
||||||
|
|
|
@ -37,6 +37,7 @@ managing areas of memory. The corresponding declarations are in
|
||||||
* strtok:: Get next token from a string
|
* strtok:: Get next token from a string
|
||||||
* strupr:: Convert string to upper case
|
* strupr:: Convert string to upper case
|
||||||
* strxfrm:: Transform string
|
* strxfrm:: Transform string
|
||||||
|
* swab:: Swap adjacent bytes
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
@page
|
@page
|
||||||
|
@ -131,3 +132,6 @@ managing areas of memory. The corresponding declarations are in
|
||||||
|
|
||||||
@page
|
@page
|
||||||
@include string/strxfrm.def
|
@include string/strxfrm.def
|
||||||
|
|
||||||
|
@page
|
||||||
|
@include string/swab.def
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
<<swab>>---swap adjacent bytes
|
||||||
|
|
||||||
|
ANSI_SYNOPSIS
|
||||||
|
#include <string.h>
|
||||||
|
void swab(const void *<[in]>, void *<[out]>, size_t <[n]>);
|
||||||
|
|
||||||
|
TRAD_SYNOPSIS
|
||||||
|
void swab(<[in]>, <[out]>, <[n]>
|
||||||
|
void *<[in]>;
|
||||||
|
void *<[out]>;
|
||||||
|
size_t <[n]>;
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
This function copies <[n]> bytes from the memory region
|
||||||
|
pointed to by <[in]> to the memory region pointed to by
|
||||||
|
<[out]>, exchanging adjacent even and odd bytes.
|
||||||
|
|
||||||
|
PORTABILITY
|
||||||
|
<<swab>> requires no supporting OS subroutines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_DEFUN (swab, (b1, b2, length),
|
||||||
|
_CONST void *b1 _AND
|
||||||
|
void *b2 _AND
|
||||||
|
ssize_t length)
|
||||||
|
{
|
||||||
|
const char *from = b1;
|
||||||
|
char *to = b2;
|
||||||
|
ssize_t ptr;
|
||||||
|
for (ptr = 1; ptr < length; ptr += 2)
|
||||||
|
{
|
||||||
|
char p = from[ptr];
|
||||||
|
char q = from[ptr-1];
|
||||||
|
to[ptr-1] = p;
|
||||||
|
to[ptr ] = q;
|
||||||
|
}
|
||||||
|
if (ptr == length) /* I.e., if length is odd, */
|
||||||
|
to[ptr-1] = 0; /* then pad with a NUL. */
|
||||||
|
}
|
Loading…
Reference in New Issue