]> andersk Git - moira.git/blobdiff - lib/strs.c
sms -> mr
[moira.git] / lib / strs.c
index 86f96c9e1dd689e1e6c77f2b47c4caf8b0149831..692dd1008fbc738ff9c2c5e60fa71b7440f27600 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.
  */
 static char *rcsid_strs_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
+#include <sys/types.h>
+#include <strings.h>
+#include <ctype.h>
+
+extern char *malloc(), *realloc();
 
 /*
  * Random string functions which should be in the C library..
@@ -24,21 +32,35 @@ char *
 strsave(s)
     char *s;
 {
-    register int len = strlen(s) + 1;
-    register char *p = malloc((u_int)len);
+    register int len;
+    register char *p;
+    /* Kludge for sloppy string semantics */
+    if (!s) {
+           printf("NULL != \"\" !!!!\r\n");
+           p = malloc(1);
+           *p = '\0';
+           return p;
+    }
+    len = strlen(s) + 1;
+    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;
+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) {
This page took 0.39556 seconds and 4 git commands to generate.