ddb: just move cursor when the lexer backs up
Get rid of db_look_char because it's not compatible with db_get_line(). This fixes the following issue: db> script lockinfo=show alllocks db> run lockinfo db:0:lockinfo> how alllocks No such command; use "help" to list available commands Reported by: markj Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D28725
This commit is contained in:
parent
d85c9cef13
commit
d8404b7ec3
@ -97,18 +97,12 @@ db_flush_line()
|
|||||||
db_endlp = db_line;
|
db_endlp = db_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int db_look_char = 0;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
db_read_char(void)
|
db_read_char(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (db_look_char != 0) {
|
if (db_lp >= db_endlp)
|
||||||
c = db_look_char;
|
|
||||||
db_look_char = 0;
|
|
||||||
}
|
|
||||||
else if (db_lp >= db_endlp)
|
|
||||||
c = -1;
|
c = -1;
|
||||||
else
|
else
|
||||||
c = *db_lp++;
|
c = *db_lp++;
|
||||||
@ -116,10 +110,22 @@ db_read_char(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
db_unread_char(c)
|
db_unread_char(int c)
|
||||||
int c;
|
|
||||||
{
|
{
|
||||||
db_look_char = c;
|
|
||||||
|
if (c == -1) {
|
||||||
|
/* Unread EOL at EOL is okay. */
|
||||||
|
if (db_lp < db_endlp)
|
||||||
|
db_error("db_unread_char(-1) before end of line\n");
|
||||||
|
} else {
|
||||||
|
if (db_lp > db_line) {
|
||||||
|
db_lp--;
|
||||||
|
if (*db_lp != c)
|
||||||
|
db_error("db_unread_char() wrong char\n");
|
||||||
|
} else {
|
||||||
|
db_error("db_unread_char() at beginning of line\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int db_look_token = 0;
|
static int db_look_token = 0;
|
||||||
@ -155,7 +161,6 @@ void
|
|||||||
db_flush_lex(void)
|
db_flush_lex(void)
|
||||||
{
|
{
|
||||||
db_flush_line();
|
db_flush_line();
|
||||||
db_look_char = 0;
|
|
||||||
db_look_token = 0;
|
db_look_token = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user