]> andersk Git - moira.git/commitdiff
Initial revision
authorwesommer <wesommer>
Wed, 2 Sep 1987 17:16:20 +0000 (17:16 +0000)
committerwesommer <wesommer>
Wed, 2 Sep 1987 17:16:20 +0000 (17:16 +0000)
lib/strs.c [new file with mode: 0644]

diff --git a/lib/strs.c b/lib/strs.c
new file mode 100644 (file)
index 0000000..86f96c9
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *     $Source$
+ *     $Author$
+ *     $Header$
+ *
+ *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *
+ *     Miscellaneous string functions.
+ */
+
+#ifndef lint
+static char *rcsid_strs_c = "$Header$";
+#endif lint
+
+
+/*
+ * Random string functions which should be in the C library..
+ */
+
+/*
+ * Make a copy of a string.
+ */
+char *
+strsave(s)
+    char *s;
+{
+    register int len = strlen(s) + 1;
+    register char *p = malloc((u_int)len);
+    if (p) bcopy(s, p, len);
+    return p;
+}
+/*
+ * Trim whitespace off both ends of a string.
+ */
+char *strtrim(s)
+    register char *s;
+{
+    register char *t;
+    
+    while (isspace(*s)) s++;
+    /* skip to end of string */
+
+    for (t = s; *t; t++) continue; 
+    while (t > s) {
+       --t;
+       if (!isspace(*t)) {
+           t++;
+           break;
+       }
+    }
+    *t = '\0';
+    return s;
+}
+
+/*
+ * Case insensitive string compare.
+ */
+
+int cistrcmp(cp1, cp2)
+    char *cp1, *cp2;
+{
+    register int c1, c2;
+    
+    do {
+       if (isupper(c1 = (*cp1++))) c1 = tolower(c1);
+       if (isupper(c2 = (*cp2++))) c2 = tolower(c2);
+       if (c1 != c2) return c1-c2;
+    } while (c1 && c2);
+    return 0;
+}
+
This page took 0.040378 seconds and 5 git commands to generate.