]> andersk Git - moira.git/commitdiff
string trimming fix for binary fields
authormar <mar>
Wed, 8 Jul 1992 16:36:43 +0000 (16:36 +0000)
committermar <mar>
Wed, 8 Jul 1992 16:36:43 +0000 (16:36 +0000)
server/mr_util.c

index e5d2d8e7f63696680323f8053a34a1101396fec6..ccc9a1e068c4a6999805c8dc3f037241338b97e6 100644 (file)
@@ -99,7 +99,8 @@ void mr_com_err(whoami, code, fmt, pvar)
 
 
 /* mr_trim_args: passed an argument vector, it will trim any trailing
- * spaces on the args by writing a null into the string.
+ * spaces on the args by writing a null into the string.  If an argument
+ * appears to be binary instead of ASCII, it will not be trimmed.
  */
 
 int mr_trim_args(argc, argv)
@@ -110,9 +111,19 @@ char **argv;
     register char *p, *lastch;
 
     for (arg = argv; argc--; arg++) {
-       for (lastch = p = *arg; *p; p++)
-         if (!isspace(*p))
-           lastch = p;
+       for (lastch = p = *arg; *p; p++) {
+           /* If any byte in the string has the high bit set, assume
+            * that it is binary and we do not want to trim it.
+            * Setting p = lastch will cause us not to trim the string
+            * when we break out of this inner loop.
+            */
+           if (*p >= 0x80) {
+               p = lastch;
+               break;
+           }
+           if (!isspace(*p))
+             lastch = p;
+       }
        if (p != lastch) {
            if (isspace(*lastch))
              *lastch = 0;
This page took 0.038699 seconds and 5 git commands to generate.