git: d8404b7ec36d - main - ddb: just move cursor when the lexer backs up
Ryan Libby
rlibby at FreeBSD.org
Wed Feb 24 23:59:13 UTC 2021
The branch main has been updated by rlibby:
URL: https://cgit.FreeBSD.org/src/commit/?id=d8404b7ec36d4974e7ac586df1d74be4ef6b141e
commit d8404b7ec36d4974e7ac586df1d74be4ef6b141e
Author: Ryan Libby <rlibby at FreeBSD.org>
AuthorDate: 2021-02-24 23:56:16 +0000
Commit: Ryan Libby <rlibby at FreeBSD.org>
CommitDate: 2021-02-24 23:56:16 +0000
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
---
sys/ddb/db_lex.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/sys/ddb/db_lex.c b/sys/ddb/db_lex.c
index 457790ee8605..215e7cd7f2ab 100644
--- a/sys/ddb/db_lex.c
+++ b/sys/ddb/db_lex.c
@@ -97,18 +97,12 @@ db_flush_line()
db_endlp = db_line;
}
-static int db_look_char = 0;
-
static int
db_read_char(void)
{
int c;
- if (db_look_char != 0) {
- c = db_look_char;
- db_look_char = 0;
- }
- else if (db_lp >= db_endlp)
+ if (db_lp >= db_endlp)
c = -1;
else
c = *db_lp++;
@@ -116,10 +110,22 @@ db_read_char(void)
}
static void
-db_unread_char(c)
- int c;
+db_unread_char(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;
@@ -155,7 +161,6 @@ void
db_flush_lex(void)
{
db_flush_line();
- db_look_char = 0;
db_look_token = 0;
}
More information about the dev-commits-src-all
mailing list