Support bases other than 10 in numbers (using option ISC_LEXOPT_CNUMBER)

Fixed bug in keeping track of input line numbers inside comments.
This commit is contained in:
James Brister
1999-06-08 12:45:23 +00:00
parent 5fc7ba3e1a
commit ab5657cabf
2 changed files with 16 additions and 4 deletions

View File

@@ -74,7 +74,7 @@ ISC_LANG_BEGINDECLS
#define ISC_LEXOPT_INITIALWS 0x04 /* Want initial whitespace. */
#define ISC_LEXOPT_NUMBER 0x08 /* Recognize numbers. */
#define ISC_LEXOPT_QSTRING 0x10 /* Recognize qstrings. */
#define ISC_LEXOPT_ESCAPE 0x20 /* Recognize escapes. */
/*
* The ISC_LEXOPT_DNSMULTILINE option handles the processing of '(' and ')' in
* the DNS master file format. If this option is set, then the
@@ -85,6 +85,10 @@ ISC_LANG_BEGINDECLS
#define ISC_LEXOPT_DNSMULTILINE 0x20 /* Handle '(' and ')'. */
#define ISC_LEXOPT_NOMORE 0x40 /* Want "no more" token. */
#define ISC_LEXOPT_CNUMBER 0x80 /* Regognise octal and hex */
#define ISC_LEXOPT_ESCAPE 0x100 /* Recognize escapes. */
/*
* Various commenting styles, which may be changed at any time with
* isc_lex_setcomments().

View File

@@ -381,6 +381,10 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
}
}
if (c == '\n') {
source->line++;
}
if (lex->comment_ok && !no_comments) {
if (!escaped && c == ';' &&
((lex->comments & ISC_LEXCOMMENT_DNSMASTERFILE)
@@ -434,7 +438,6 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
tokenp->type = isc_tokentype_eol;
done = ISC_TRUE;
}
source->line++;
lex->last_was_eol = ISC_TRUE;
} else if (c == '\r') {
if ((options & ISC_LEXOPT_EOL) != 0)
@@ -493,7 +496,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
INSIST(source->char_count < 2);
source->chars[source->char_count++] =
c;
ulong = strtoul(lex->data, &e, 10);
ulong = strtoul(lex->data, &e, 0);
if (*e == 0) {
tokenp->type =
isc_tokentype_number;
@@ -513,8 +516,13 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
}
done = ISC_TRUE;
continue;
} else
} else if (!(options & ISC_LEXOPT_CNUMBER) ||
((c != 'x' && c != 'X') ||
(curr != &lex->data[1]) ||
(lex->data[0] != '0'))) {
/* Above test supports hex numbers */
state = lexstate_string;
}
}
if (remaining > 0) {
*curr++ = c;