X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fparse_entry.c;fp=ncurses%2Ftinfo%2Fparse_entry.c;h=86a03b37244e78ec22a3694b8e9c3de831f39a23;hp=1a786f664b2f7ed4a0cb2c42d54a9b63b31c521f;hb=3e7e5f8b5c4e8e499f682a1c414c576c16d47532;hpb=af3d0ee323cbb22d2a7596d564bf68f7307f5076 diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c index 1a786f66..86a03b37 100644 --- a/ncurses/tinfo/parse_entry.c +++ b/ncurses/tinfo/parse_entry.c @@ -47,7 +47,7 @@ #include #include -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