diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-02-22 04:37:57 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-02-22 04:37:57 +0000 |
commit | 16e69bd571f3368a2d623062034f6927a7cef453 (patch) | |
tree | 2b6449308a69ea58651deb1fcd5d0a38569dbb74 /lib/libcurses/tinfo/comp_scan.c | |
parent | 47767cbd43feda78200669d6eb1ef877e83c3085 (diff) |
Make _nc_get_token() take a "silent" argument and only warn if it
is not set. Propagate "silent" flag in _nc_parse_entry() to _nc_get_token().
Set the silent flag when reading termcap files, including $TERMCAP.
Diffstat (limited to 'lib/libcurses/tinfo/comp_scan.c')
-rw-r--r-- | lib/libcurses/tinfo/comp_scan.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c index f757493654f..1b6607d8f75 100644 --- a/lib/libcurses/tinfo/comp_scan.c +++ b/lib/libcurses/tinfo/comp_scan.c @@ -143,7 +143,7 @@ eat_escaped_newline(int ch) */ NCURSES_EXPORT(int) -_nc_get_token(void) +_nc_get_token(bool silent) { static const char terminfo_punct[] = "@%&*!#"; long number; @@ -211,8 +211,9 @@ _nc_get_token(void) && !(ch == '.' && _nc_disable_period) #endif && !strchr(terminfo_punct, (char) ch)) { - _nc_warning("Illegal character (expected alphanumeric or %s) - %s", - terminfo_punct, unctrl((chtype) ch)); + if (!silent) + _nc_warning("Illegal character (expected alphanumeric or %s) - %s", + terminfo_punct, unctrl((chtype) ch)); _nc_panic_mode(separator); goto start_token; } @@ -286,13 +287,11 @@ _nc_get_token(void) * field for syntax-checking purposes. */ desc = strrchr(buffer, '|'); - if (desc) { + if (!silent && desc) { if (*desc == '\0') _nc_warning("empty longname field"); -#ifndef __OpenBSD__ else if (strchr(desc, ' ') == (char *) NULL) _nc_warning("older tic versions may treat the description field as an alias"); -#endif } if (!desc) desc = buffer + strlen(buffer); @@ -304,13 +303,16 @@ _nc_get_token(void) */ for (ptr = buffer; ptr < desc; ptr++) { if (isspace(CharOf(*ptr))) { - _nc_warning("whitespace in name or alias field"); + if (!silent) + _nc_warning("whitespace in name or alias field"); break; } else if (*ptr == '/') { - _nc_warning("slashes aren't allowed in names or aliases"); + if (!silent) + _nc_warning("slashes aren't allowed in names or aliases"); break; } else if (strchr("$[]!*?", *ptr)) { - _nc_warning("dubious character `%c' in name or alias field", *ptr); + if (!silent) + _nc_warning("dubious character `%c' in name or alias field", *ptr); break; } } @@ -343,7 +345,7 @@ _nc_get_token(void) type = BOOLEAN; break; case '@': - if ((ch = next_char()) != separator) + if ((ch = next_char()) != separator && !silent) _nc_warning("Missing separator after `%s', have %s", buffer, unctrl((chtype) ch)); _nc_curr_token.tk_name = buffer; @@ -359,10 +361,12 @@ _nc_get_token(void) } numbuf[found] = '\0'; number = strtol(numbuf, &numchk, 0); - if (numchk == numbuf) - _nc_warning("no value given for `%s'", buffer); - if ((*numchk != '\0') || (ch != separator)) - _nc_warning("Missing separator"); + if (!silent) { + if (numchk == numbuf) + _nc_warning("no value given for `%s'", buffer); + if ((*numchk != '\0') || (ch != separator)) + _nc_warning("Missing separator"); + } _nc_curr_token.tk_name = buffer; _nc_curr_token.tk_valnumber = number; type = NUMBER; @@ -370,7 +374,7 @@ _nc_get_token(void) case '=': ch = _nc_trans_string(ptr, buffer + sizeof(buffer)); - if (ch != separator) + if (!silent && ch != separator) _nc_warning("Missing separator"); _nc_curr_token.tk_name = buffer; _nc_curr_token.tk_valstring = ptr; @@ -383,7 +387,8 @@ _nc_get_token(void) default: /* just to get rid of the compiler warning */ type = UNDEF; - _nc_warning("Illegal character - %s", unctrl((chtype) ch)); + if (!silent) + _nc_warning("Illegal character - %s", unctrl((chtype) ch)); } } /* end else (first_column == FALSE) */ } /* end else (ch != EOF) */ @@ -435,7 +440,7 @@ _nc_get_token(void) #endif if (dot_flag == TRUE) /* if commented out, use the next one */ - type = _nc_get_token(); + type = _nc_get_token(silent); DEBUG(3, ("token: `%s', class %d", _nc_curr_token.tk_name != 0 ? _nc_curr_token.tk_name : |