]> andersk Git - moira.git/blobdiff - lib/strs.c
added the function lowercase()
[moira.git] / lib / strs.c
index 284c1f367cc3072e3832435287c2ec167f1b4fb9..15459b47fb838f94eec127caff3395885c27d5cc 100644 (file)
@@ -4,6 +4,8 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  *
  *     Miscellaneous string functions.
  */
@@ -12,6 +14,7 @@
 static char *rcsid_strs_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include <sys/types.h>
 #include <strings.h>
 #include <ctype.h>
@@ -35,7 +38,7 @@ strsave(s)
     if (!s) {
            printf("NULL != \"\" !!!!\r\n");
            p = malloc(1);
-           *p = "\0";
+           *p = '\0';
            return p;
     }
     len = strlen(s) + 1;
@@ -46,13 +49,18 @@ strsave(s)
 /*
  * Trim whitespace off both ends of a string.
  */
-char *strtrim(s)
-    register char *s;
+char *strtrim(save)
+    register char *save;
 {
-    register char *t;
-    
+    register char *t, *s;
+
+    s = save;
     while (isspace(*s)) s++;
     /* skip to end of string */
+    if (*s == '\0') {
+       *save = '\0';
+       return(save);
+    }
 
     for (t = s; *t; t++) continue; 
     while (t > s) {
@@ -66,20 +74,28 @@ char *strtrim(s)
     return s;
 }
 
-/*
- * Case insensitive string compare.
- */
 
-int cistrcmp(cp1, cp2)
-    char *cp1, *cp2;
+/* Modify a string for all of the letters to be uppercase. */
+
+char *uppercase(s)
+char *s;
 {
-    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;
+    register char *p;
+
+    for (p = s; *p; p++)
+      if (islower(*p))
+       *p = toupper(*p);
+    return(s);
 }
 
+
+char *lowercase(s)
+char *s;
+{
+    register char *p;
+
+    for (p = s; *p; p++)
+      if (isupper(*p))
+       *p = tolower(*p);
+    return(s);
+}
This page took 0.048036 seconds and 4 git commands to generate.