]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/comp_scan.c
ncurses 5.0
[ncurses.git] / ncurses / tinfo / comp_scan.c
similarity index 96%
rename from ncurses/comp_scan.c
rename to ncurses/tinfo/comp_scan.c
index e12589054dfbee41446ea804a5bd716d33232c7b..152930885ab75ffa9dc459205fd85ad44dec7ac9 100644 (file)
@@ -49,7 +49,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_scan.c,v 1.30 1998/02/11 12:14:00 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.34 1998/11/01 00:56:39 tom Exp $")
 
 /*
  * Maximum length of string capability we'll accept before raising an error.
@@ -76,6 +76,7 @@ static char separator;                /* capability separator */
 static int pushtype;           /* type of pushback token */
 static char pushname[MAX_NAME_SIZE+1];
 
+static int  last_char(void);
 static int  next_char(void);
 static long stream_pos(void);
 static bool end_of_stream(void);
@@ -129,7 +130,9 @@ static const char terminfo_punct[] = "@%&*!#";
 long           number;
 int            type;
 int            ch;
-bool           found;
+char *         numchk;
+char           numbuf[80];
+unsigned       found;
 static char    buffer[MAX_ENTRY_SIZE];
 char           *ptr;
 int            dot_flag = FALSE;
@@ -203,7 +206,7 @@ start_token:
                        {
                            if (ch == EOF)
                                _nc_err_abort("premature EOF");
-                           else if (ch == ':')
+                           else if (ch == ':' && last_char() != ',')
                            {
                                _nc_syntax = SYN_TERMCAP;
                                separator = ':';
@@ -268,11 +271,12 @@ start_token:
                         * description field for syntax-checking purposes.
                         */
                        desc = strrchr(buffer, '|');
-                       if (desc)
+                       if (desc) {
                            if (*desc == '\0')
                                _nc_warning("empty longname field");
                            else if (strchr(desc, ' ') == (char *)NULL)
                                _nc_warning("older tic versions may treat the description field as an alias");
+                       }
                        if (!desc)
                            desc = buffer + strlen(buffer);
 
@@ -337,15 +341,17 @@ start_token:
                                break;
 
                        case '#':
-                               number = 0;
-                               found  = FALSE;
-                               while (isdigit(ch = next_char())) {
-                                       number = number * 10 + ch - '0';
-                                       found  = TRUE;
+                               found  = 0;
+                               while (isalnum(ch = next_char())) {
+                                       numbuf[found++] = ch;
+                                       if (found >= sizeof(numbuf)-1)
+                                               break;
                                }
-                               if (found == FALSE)
+                               numbuf[found] = '\0';
+                               number = strtol(numbuf, &numchk, 0);
+                               if (numchk == numbuf)
                                        _nc_warning("no value given for `%s'", buffer);
-                               if (ch != separator)
+                               if ((*numchk != '\0') || (ch != separator))
                                        _nc_warning("Missing separator");
                                _nc_curr_token.tk_name = buffer;
                                _nc_curr_token.tk_valnumber = number;
@@ -374,6 +380,8 @@ start_token:
        } /* end else (ch != EOF) */
 
 end_of_token:
+
+#ifdef TRACE
        if (dot_flag == TRUE)
            DEBUG(8, ("Commented out "));
 
@@ -418,6 +426,7 @@ end_of_token:
                    _nc_warning("Bad token type");
            }
        }
+#endif
 
        if (dot_flag == TRUE)           /* if commented out, use the next one */
            type = _nc_get_token();
@@ -633,6 +642,22 @@ void _nc_reset_input(FILE *fp, char *buf)
        _nc_curr_col = 0;
 }
 
+/*
+ *     int last_char()
+ *
+ *     Returns the final nonblank character on the current input buffer
+ */
+static int
+last_char(void)
+{
+       size_t len = strlen(bufptr);
+       while (len--) {
+               if (!isspace(bufptr[len]))
+                       return bufptr[len];
+       }
+       return 0;
+}
+
 /*
  *     int next_char()
  *