From: eck Date: Thu, 11 May 1989 10:09:52 +0000 (+0000) Subject: Initial revision X-Git-Tag: release-5-5~2439 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=749c36481623ea7a169c86eac65c6aa703679c71;p=ack.git Initial revision --- diff --git a/lang/cem/libcc.ansi/string/memchr.c b/lang/cem/libcc.ansi/string/memchr.c new file mode 100644 index 000000000..f5dbd0a1b --- /dev/null +++ b/lang/cem/libcc.ansi/string/memchr.c @@ -0,0 +1,21 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +void * +memchr(const void *s, int c, register size_t n) +{ + register unsigned char *s1 = (unsigned char *)s; + unsigned char c1 = (unsigned char) c; + + while (n > 0) { + n--; + if (*s1++ == c1) + return (void *) --s1; + } + return (void *) NULL; +} diff --git a/lang/cem/libcc.ansi/string/memcmp.c b/lang/cem/libcc.ansi/string/memcmp.c new file mode 100644 index 000000000..0f9bd84ee --- /dev/null +++ b/lang/cem/libcc.ansi/string/memcmp.c @@ -0,0 +1,18 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +int +memcmp(register const void *s1, register const void *s2, size_t n) +{ + while (n > 0) { + n--; + if (*s1++ != *s2++) + return *--s1 - *--s2; + } + return 0; +} diff --git a/lang/cem/libcc.ansi/string/memcpy.c b/lang/cem/libcc.ansi/string/memcpy.c new file mode 100644 index 000000000..a36010ac8 --- /dev/null +++ b/lang/cem/libcc.ansi/string/memcpy.c @@ -0,0 +1,19 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +void * +memcpy(register void *s1, register const void *s2, register size_t n) +{ + void *ret = s1; + + while (n > 0) { + n--; + *s1++ = *s2++; + } + return ret; +} diff --git a/lang/cem/libcc.ansi/string/memmove.c b/lang/cem/libcc.ansi/string/memmove.c new file mode 100644 index 000000000..baa45bcfe --- /dev/null +++ b/lang/cem/libcc.ansi/string/memmove.c @@ -0,0 +1,28 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +void * +memmove(register void *s1, register const void *s2, register size_t n) +{ + void *ret = s1; + + if (s2 <= s1 && s2 + (n-1) >= s1) { + /* overlap, copy backwards */ + s1 += n; + s2 += n; + while (n > 0) { + n--; + *--s1 = *--s2; + } + } else + while (n > 0) { + n--; + *s1++ = *s2++; + } + return ret; +} diff --git a/lang/cem/libcc.ansi/string/memset.c b/lang/cem/libcc.ansi/string/memset.c new file mode 100644 index 000000000..6fa8b9785 --- /dev/null +++ b/lang/cem/libcc.ansi/string/memset.c @@ -0,0 +1,19 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +void * +memset(void *s, int c, register size_t n) +{ + register void *s1 = s; + + while (n > 0) { + n--; + *s1++ = c; + } + return s; +} diff --git a/lang/cem/libcc.ansi/string/strcat.c b/lang/cem/libcc.ansi/string/strcat.c new file mode 100644 index 000000000..30ae22463 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strcat.c @@ -0,0 +1,20 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strcat(register char *s1, register const char *s2) +{ + char *ret = s1; + + while (*s1++ != '\0') + /* EMPTY */ ; + s1--; + while (*s1++ = *s2++) + /* EMPTY */ ; + return ret; +} diff --git a/lang/cem/libcc.ansi/string/strchr.c b/lang/cem/libcc.ansi/string/strchr.c new file mode 100644 index 000000000..1a14e672b --- /dev/null +++ b/lang/cem/libcc.ansi/string/strchr.c @@ -0,0 +1,20 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strchr(register const char *s, int c) +{ + register char c1 = (char) c; + + do { + if (*s == c1) + return s; + } while (*s++ != '\0'); + + return (char *)NULL; +} diff --git a/lang/cem/libcc.ansi/string/strcmp.c b/lang/cem/libcc.ansi/string/strcmp.c new file mode 100644 index 000000000..19813ffaf --- /dev/null +++ b/lang/cem/libcc.ansi/string/strcmp.c @@ -0,0 +1,19 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +int +strcmp(register const char *s1, register const char *s2) +{ + for(;;) { + if (*s1 != *s2) + return *s1 - *s2; + if (*s1++ == '\0') + return 0; + s2++; + } +} diff --git a/lang/cem/libcc.ansi/string/strcoll.c b/lang/cem/libcc.ansi/string/strcoll.c new file mode 100644 index 000000000..36d0a5f7c --- /dev/null +++ b/lang/cem/libcc.ansi/string/strcoll.c @@ -0,0 +1,20 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include +#include + +int +strcoll(register const char *s1, register const char *s2) +{ + for(;;) { + if (*s1 != *s2) + return *s1 - *s2; + if (*s1++ == '\0') + return 0; + s2++; + } +} diff --git a/lang/cem/libcc.ansi/string/strcpy.c b/lang/cem/libcc.ansi/string/strcpy.c new file mode 100644 index 000000000..1f0607367 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strcpy.c @@ -0,0 +1,18 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strcpy(register char *s1, register const char *s2) +{ + char *ret = s1; + + while (*s1++ = *s2++) + /* EMPTY */ ; + + return ret; +} diff --git a/lang/cem/libcc.ansi/string/strcspn.c b/lang/cem/libcc.ansi/string/strcspn.c new file mode 100644 index 000000000..8db4d1a33 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strcspn.c @@ -0,0 +1,21 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +size_t +strcspn(const char *string, const char *notin) +{ + register char *s1, *s2; + + for (s1 = string; *s1; s1++) { + for(s2 = notin; *s2 != *s1 && *s2; s2++) + /* EMPTY */ ; + if (*s2) + break; + } + return s1 - string; +} diff --git a/lang/cem/libcc.ansi/string/strerror.c b/lang/cem/libcc.ansi/string/strerror.c new file mode 100644 index 000000000..7bb41b503 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strerror.c @@ -0,0 +1,18 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strerror(register int errnum) +{ + extern const char *_sys_errlist[]; + extern const int _sys_nerr; + + if (errnum < 0 || errnum >= _sys_nerr) + return "unknown error"; + return _sys_errlist[errnum]; +} diff --git a/lang/cem/libcc.ansi/string/strlen.c b/lang/cem/libcc.ansi/string/strlen.c new file mode 100644 index 000000000..bd4cb81bc --- /dev/null +++ b/lang/cem/libcc.ansi/string/strlen.c @@ -0,0 +1,18 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +size_t +strlen(register const char *s) +{ + char *org = s; + + while (*s++) + /* EMPTY */ ; + + return (s - 1) - org; +} diff --git a/lang/cem/libcc.ansi/string/strncat.c b/lang/cem/libcc.ansi/string/strncat.c new file mode 100644 index 000000000..250282628 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strncat.c @@ -0,0 +1,26 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strncat(register char *s1, register const char *s2, size_t n) +{ + char *ret = s1; + + if (n <= 0) + return s1; + while (*s1++) + /* EMPTY */ ; + s1--; + while (*s1++ = *s2++) { + if (--n == 0) { + *s1 = '\0'; + break; + } + } + return ret; +} diff --git a/lang/cem/libcc.ansi/string/strncmp.c b/lang/cem/libcc.ansi/string/strncmp.c new file mode 100644 index 000000000..3bbac1b2c --- /dev/null +++ b/lang/cem/libcc.ansi/string/strncmp.c @@ -0,0 +1,21 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +int +strncmp(register const char *s1, register const char *s2, size_t n) +{ + while (n > 0) { + n--; + if (*s1 != *s2) + return *s1 - *s2; + if (*s1++ == '\0') + return 0; + s2++; + } + return 0; +} diff --git a/lang/cem/libcc.ansi/string/strncpy.c b/lang/cem/libcc.ansi/string/strncpy.c new file mode 100644 index 000000000..18a7e0897 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strncpy.c @@ -0,0 +1,23 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strncpy(register char *s1, register const char *s2, size_t n) +{ + char *ret = s1; + + while (*s2 && n > 0) { + n--; + *s1++ = *s2++; + } + while (n > 0) { + n--; + *s1++ = '\0'; + } + return ret; +} diff --git a/lang/cem/libcc.ansi/string/strpbrk.c b/lang/cem/libcc.ansi/string/strpbrk.c new file mode 100644 index 000000000..a0c4cdb40 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strpbrk.c @@ -0,0 +1,22 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strpbrk(register const char *string, register const char *brk) +{ + register char *s1; + + while (*string) { + for (s1 = brk; *s1 && *s1 != *string; s1++) + /* EMPTY */ ; + if (*s1) + return string; + string++; + } + return (char *)NULL; +} diff --git a/lang/cem/libcc.ansi/string/strrchr.c b/lang/cem/libcc.ansi/string/strrchr.c new file mode 100644 index 000000000..1bf6cea43 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strrchr.c @@ -0,0 +1,22 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strrchr(register const char *s, int c) +{ + register char *result; + register char c1 = (char) c; + + result = (char *)NULL; + do { + if (*s == c1) + result = s; + } while (*s++); + + return(result); +} diff --git a/lang/cem/libcc.ansi/string/strspn.c b/lang/cem/libcc.ansi/string/strspn.c new file mode 100644 index 000000000..322b70363 --- /dev/null +++ b/lang/cem/libcc.ansi/string/strspn.c @@ -0,0 +1,21 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +size_t +strspn(const char *string, const char *in) +{ + register const char *s1, *s2; + + for (s1 = string; *s1; s1++) { + for (s2 = in; *s2 && *s2 != *s1; s2++) + /* EMPTY */ ; + if (*s2 == '\0') + break; + } + return s1 - string; +} diff --git a/lang/cem/libcc.ansi/string/strstr.c b/lang/cem/libcc.ansi/string/strstr.c new file mode 100644 index 000000000..18d7ae8fd --- /dev/null +++ b/lang/cem/libcc.ansi/string/strstr.c @@ -0,0 +1,18 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strstr(register const char *s, register const char *wanted) +{ + int len = strlen(wanted); + + while (*s != *wanted || strncmp(s, wanted, len)) + if (*s++ == '\0') + return (char *)NULL; + return s; +} diff --git a/lang/cem/libcc.ansi/string/strtok.c b/lang/cem/libcc.ansi/string/strtok.c new file mode 100644 index 000000000..6b5e9f22b --- /dev/null +++ b/lang/cem/libcc.ansi/string/strtok.c @@ -0,0 +1,30 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +char * +strtok(register char *string, const char *separators) +{ + register char *s1, *s2; + static char *savestring; + + if (!string) + string = savestring; + + if (!string) + return (char *)NULL; + + if (*(s1 = string + strspn(string, separators)) == '\0') { + savestring = NULL; + return (char *)NULL; + } + + if (s2 = strpbrk(s1, separators)) + *s2++ = '\0'; + savestring = s2; + return s1; +} diff --git a/lang/cem/libcc.ansi/string/strxfrm.c b/lang/cem/libcc.ansi/string/strxfrm.c new file mode 100644 index 000000000..3ec1b3acb --- /dev/null +++ b/lang/cem/libcc.ansi/string/strxfrm.c @@ -0,0 +1,24 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +size_t +strxfrm(register char *s1, register const char *s2, register size_t n) +{ + char *save = s2; + + while (*s2) { + if (n > 1) { + n--; + *s1++ = *s2++; + } else + s2++; + } + if (n >= 1) + *s1++ = '\0'; + return s2 - save; +}