Page MenuHomeFreeBSD

D21459.id61435.diff
No OneTemporary

D21459.id61435.diff

Index: sys/ddb/db_command.c
===================================================================
--- sys/ddb/db_command.c
+++ sys/ddb/db_command.c
@@ -479,7 +479,15 @@
db_enable_pager();
else
db_disable_pager();
+
+ db_lex_wspace = ((cmd->flag & CS_LEX_SPACE) != 0);
+ db_cmd_radix = -1;
+
(*cmd->fcn)(addr, have_addr, count, modif);
+
+ db_lex_wspace = false;
+ db_cmd_radix = -1;
+
if (dopager)
db_disable_pager();
Index: sys/ddb/db_lex.h
===================================================================
--- sys/ddb/db_lex.h
+++ sys/ddb/db_lex.h
@@ -45,6 +45,7 @@
int db_read_token(void);
void db_unread_token(int t);
+extern bool db_lex_wspace;
extern db_expr_t db_tok_number;
#define TOK_STRING_SIZE 120
extern char db_tok_string[TOK_STRING_SIZE];
@@ -84,5 +85,6 @@
#define tSTRING 32
#define tQUESTION 33
#define tBIT_NOT 34
+#define tWSPACE 35
#endif /* !_DDB_DB_LEX_H_ */
Index: sys/ddb/db_lex.c
===================================================================
--- sys/ddb/db_lex.c
+++ sys/ddb/db_lex.c
@@ -42,6 +42,8 @@
#include <ddb/ddb.h>
#include <ddb/db_lex.h>
+bool db_lex_wspace;
+
static char db_line[DB_MAXLINE];
static char * db_lp, *db_endlp;
@@ -148,6 +150,14 @@
char db_tok_string[TOK_STRING_SIZE];
db_expr_t db_radix = 16;
+/*
+ * When db_cmd_radix is not -1, it overrides auto-detection, as well as
+ * user-specified db_radix, in db_lex() tNUMBER.
+ *
+ * db_cmd_radix is set by DDB command(s) and its value is scoped to that
+ * command only; when the command completes, it is reset to -1.
+ */
+db_expr_t db_cmd_radix = -1;
void
db_flush_lex(void)
@@ -160,20 +170,26 @@
static int
db_lex(void)
{
- int c;
+ int c, n;
c = db_read_char();
- while (c <= ' ' || c > '~') {
+ for (n = 0; c <= ' ' || c > '~'; n++) {
if (c == '\n' || c == -1)
return (tEOL);
c = db_read_char();
}
+ if (db_lex_wspace && n != 0) {
+ db_unread_char(c);
+ return (tWSPACE);
+ }
if (c >= '0' && c <= '9') {
/* number */
int r, digit = 0;
- if (c > '0')
+ if (db_cmd_radix != -1)
+ r = db_cmd_radix;
+ else if (c > '0')
r = db_radix;
else {
c = db_read_char();
Index: sys/ddb/ddb.h
===================================================================
--- sys/ddb/ddb.h
+++ sys/ddb/ddb.h
@@ -120,6 +120,8 @@
#define CS_OWN 0x1 /* non-standard syntax */
#define CS_MORE 0x2 /* standard syntax, but may have other words
* at end */
+#define CS_LEX_SPACE 0x4 /* Switch the lexer to explicitly yield
+ whitespace (tWSPACE) during cmd. */
#define CS_SET_DOT 0x100 /* set dot after command */
struct command_table *more; /* another level of command */
LIST_ENTRY(command) next; /* next entry in the command table */
@@ -188,6 +190,7 @@
extern int db_store_count;
extern volatile int db_pager_quit;
extern db_expr_t db_radix;
+extern db_expr_t db_cmd_radix;
extern db_expr_t db_max_width;
extern db_expr_t db_tab_stop_width;
extern db_expr_t db_lines_per_page;

File Metadata

Mime Type
text/plain
Expires
Fri, Jul 24, 12:43 AM (11 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35422023
Default Alt Text
D21459.id61435.diff (2 KB)

Event Timeline