]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/parse_entry.c
ncurses 6.0 - patch 20170624
[ncurses.git] / ncurses / tinfo / parse_entry.c
index 1a786f664b2f7ed4a0cb2c42d54a9b63b31c521f..86a03b37244e78ec22a3694b8e9c3de831f39a23 100644 (file)
@@ -47,7 +47,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: parse_entry.c,v 1.84 2017/04/21 21:09:54 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.85 2017/06/24 22:59:46 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
@@ -527,43 +527,50 @@ NCURSES_EXPORT(int)
 _nc_capcmp(const char *s, const char *t)
 /* compare two string capabilities, stripping out padding */
 {
-    if (!VALID_STRING(s) && !VALID_STRING(t))
-       return (0);
-    else if (!VALID_STRING(s) || !VALID_STRING(t))
-       return (1);
-
-    for (;;) {
-       if (s[0] == '$' && s[1] == '<') {
-           for (s += 2;; s++)
-               if (!(isdigit(UChar(*s))
-                     || *s == '.'
-                     || *s == '*'
-                     || *s == '/'
-                     || *s == '>'))
-                   break;
-       }
+    bool ok_s = VALID_STRING(s);
+    bool ok_t = VALID_STRING(t);
+
+    if (ok_s && ok_t) {
+       for (;;) {
+           if (s[0] == '$' && s[1] == '<') {
+               for (s += 2;; s++) {
+                   if (!(isdigit(UChar(*s))
+                         || *s == '.'
+                         || *s == '*'
+                         || *s == '/'
+                         || *s == '>')) {
+                       break;
+                   }
+               }
+           }
 
-       if (t[0] == '$' && t[1] == '<') {
-           for (t += 2;; t++)
-               if (!(isdigit(UChar(*t))
-                     || *t == '.'
-                     || *t == '*'
-                     || *t == '/'
-                     || *t == '>'))
-                   break;
-       }
+           if (t[0] == '$' && t[1] == '<') {
+               for (t += 2;; t++) {
+                   if (!(isdigit(UChar(*t))
+                         || *t == '.'
+                         || *t == '*'
+                         || *t == '/'
+                         || *t == '>')) {
+                       break;
+                   }
+               }
+           }
 
-       /* we've now pushed s and t past any padding they were pointing at */
+           /* we've now pushed s and t past any padding they pointed at */
 
-       if (*s == '\0' && *t == '\0')
-           return (0);
+           if (*s == '\0' && *t == '\0')
+               return (0);
 
-       if (*s != *t)
-           return (*t - *s);
+           if (*s != *t)
+               return (*t - *s);
 
-       /* else *s == *t but one is not NUL, so continue */
-       s++, t++;
+           /* else *s == *t but one is not NUL, so continue */
+           s++, t++;
+       }
+    } else if (ok_s || ok_t) {
+       return 1;
     }
+    return 0;
 }
 
 static void