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 | |
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')
-rw-r--r-- | lib/libcurses/tic.h | 4 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_scan.c | 39 | ||||
-rw-r--r-- | lib/libcurses/tinfo/parse_entry.c | 8 | ||||
-rw-r--r-- | lib/libcurses/tinfo/read_termcap.c | 9 |
4 files changed, 30 insertions, 30 deletions
diff --git a/lib/libcurses/tic.h b/lib/libcurses/tic.h index bbec5f2a88a..c9539af91f9 100644 --- a/lib/libcurses/tic.h +++ b/lib/libcurses/tic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tic.h,v 1.11 2001/01/22 18:01:35 millert Exp $ */ +/* $OpenBSD: tic.h,v 1.12 2001/02/22 04:37:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998-2000 Free Software Foundation, Inc. * @@ -249,7 +249,7 @@ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry (const char *, int, const struct name_table_entry *); /* comp_scan.c: lexical analysis */ -extern NCURSES_EXPORT(int) _nc_get_token (void); +extern NCURSES_EXPORT(int) _nc_get_token (bool); extern NCURSES_EXPORT(void) _nc_panic_mode (char); extern NCURSES_EXPORT(void) _nc_push_token (int); extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *); 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 : diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c index 2327915b9db..724c9969871 100644 --- a/lib/libcurses/tinfo/parse_entry.c +++ b/lib/libcurses/tinfo/parse_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_entry.c,v 1.9 2001/01/22 18:01:55 millert Exp $ */ +/* $OpenBSD: parse_entry.c,v 1.10 2001/02/22 04:37:56 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -205,7 +205,7 @@ _nc_parse_entry struct name_table_entry const *entry_ptr; char *ptr, *base; - token_type = _nc_get_token(); + token_type = _nc_get_token(silent); if (token_type == EOF) return (EOF); @@ -251,9 +251,9 @@ _nc_parse_entry entryp->nuses = 0; - for (token_type = _nc_get_token(); + for (token_type = _nc_get_token(silent); token_type != EOF && token_type != NAMES; - token_type = _nc_get_token()) { + token_type = _nc_get_token(silent)) { if (strcmp(_nc_curr_token.tk_name, "use") == 0 || strcmp(_nc_curr_token.tk_name, "tc") == 0) { entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring); diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c index 5240db23745..16a4df5a99e 100644 --- a/lib/libcurses/tinfo/read_termcap.c +++ b/lib/libcurses/tinfo/read_termcap.c @@ -944,7 +944,7 @@ _nc_read_termcap_entry _nc_curr_line = lineno; _nc_set_source(source); } - _nc_read_entry_source((FILE *) 0, tc, FALSE, FALSE, NULLHOOK); + _nc_read_entry_source((FILE *) 0, tc, FALSE, TRUE, NULLHOOK); #else /* * Here is what the 4.4BSD termcap(3) page prescribes: @@ -1025,12 +1025,7 @@ _nc_read_termcap_entry /* parse the sources */ if (use_buffer) { _nc_set_source("TERMCAP"); - - /* - * We don't suppress warning messages here. The presumption is - * that since it's just a single entry, they won't be a pain. - */ - _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, FALSE, NULLHOOK); + _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, TRUE, NULLHOOK); } else { int i; |