#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.
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);
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;
{
if (ch == EOF)
_nc_err_abort("premature EOF");
- else if (ch == ':')
+ else if (ch == ':' && last_char() != ',')
{
_nc_syntax = SYN_TERMCAP;
separator = ':';
* 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);
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;
} /* end else (ch != EOF) */
end_of_token:
+
+#ifdef TRACE
if (dot_flag == TRUE)
DEBUG(8, ("Commented out "));
_nc_warning("Bad token type");
}
}
+#endif
if (dot_flag == TRUE) /* if commented out, use the next one */
type = _nc_get_token();
_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()
*