Initial revision
authoreck <none@none>
Thu, 11 May 1989 10:09:52 +0000 (10:09 +0000)
committereck <none@none>
Thu, 11 May 1989 10:09:52 +0000 (10:09 +0000)
22 files changed:
lang/cem/libcc.ansi/string/memchr.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/memcmp.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/memcpy.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/memmove.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/memset.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strcat.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strchr.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strcmp.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strcoll.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strcpy.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strcspn.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strerror.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strlen.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strncat.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strncmp.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strncpy.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strpbrk.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strrchr.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strspn.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strstr.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strtok.c [new file with mode: 0644]
lang/cem/libcc.ansi/string/strxfrm.c [new file with mode: 0644]

diff --git a/lang/cem/libcc.ansi/string/memchr.c b/lang/cem/libcc.ansi/string/memchr.c
new file mode 100644 (file)
index 0000000..f5dbd0a
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..0f9bd84
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..a36010a
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..baa45bc
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..6fa8b97
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..30ae224
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..1a14e67
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..19813ff
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..36d0a5f
--- /dev/null
@@ -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       <string.h>
+#include       <locale.h>
+
+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 (file)
index 0000000..1f06073
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..8db4d1a
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..7bb41b5
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..bd4cb81
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..2502826
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..3bbac1b
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..18a7e08
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..a0c4cdb
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..1bf6cea
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..322b703
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..18d7ae8
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..6b5e9f2
--- /dev/null
@@ -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       <string.h>
+
+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 (file)
index 0000000..3ec1b3a
--- /dev/null
@@ -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       <string.h>
+
+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;
+}