bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

seems like _nc_get_token() should take a "silent" arg


From: Todd C. Miller
Subject: seems like _nc_get_token() should take a "silent" arg
Date: Thu, 01 Mar 2001 14:14:03 -0700

Otherwise, the silent parameter to _nc_parse_entry() doesn't really
make things silent.  The following is what I'm using but perhaps
that makes things a bit too silent.

 - todd

--- ncurses/tinfo/comp_scan.c   Wed Feb 21 21:01:37 2001
+++ /usr/src/lib/libcurses/tinfo/comp_scan.c    Thu Feb 22 04:38:58 2001
@@ -143,7 +143,7 @@
  */
 
 NCURSES_EXPORT(int)
-_nc_get_token(void)
+_nc_get_token(bool silent)
 {
     static const char terminfo_punct[] = "@%&*!#";
     long number;
@@ -211,8 +211,9 @@
            && !(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,7 +287,7 @@
             * field for syntax-checking purposes.
             */
            desc = strrchr(buffer, '|');
-           if (desc) {
+           if (!silent && desc) {
                if (*desc == '\0')
                    _nc_warning("empty longname field");
                else if (strchr(desc, ' ') == (char *) NULL)
@@ -302,13 +303,16 @@
             */
            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;
                }
            }
@@ -341,7 +345,7 @@
                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;
@@ -357,10 +361,12 @@
                }
                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;
@@ -368,7 +374,7 @@
 
            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;
@@ -381,7 +387,8 @@
            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) */
@@ -433,7 +440,7 @@
 #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 :
--- ncurses/tinfo/parse_entry.c Sun Jan 21 21:36:39 2001
+++ /usr/src/lib/libcurses/tinfo/parse_entry.c  Thu Feb 22 04:38:58 2001
@@ -203,7 +205,7 @@
     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);
@@ -249,9 +251,9 @@
 
     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);
--- include/tic.h       Sun Jan 21 21:36:30 2001
+++ /usr/src/lib/libcurses/tic.h        Thu Feb 22 04:38:55 2001
@@ -247,7 +249,7 @@
        (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 *);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]