summaryrefslogtreecommitdiff
path: root/components/finsh
diff options
context:
space:
mode:
authorhezlog <[email protected]>2016-01-19 12:16:30 +0800
committerhezlog <[email protected]>2016-01-19 12:16:30 +0800
commita1745986e9ffa96575f580247dcc59e8bcd620dc (patch)
tree09b8aae38a77630242beae9aaad7fd6e9723df05 /components/finsh
parente2d596ae0f1afc4a0e13718ca69ba899f5af102f (diff)
Update finsh_token.c
修正finsh不能正确处理"\""和"\x1A"转义;
Diffstat (limited to 'components/finsh')
-rw-r--r--components/finsh/finsh_token.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/components/finsh/finsh_token.c b/components/finsh/finsh_token.c
index 91110bec26..799553cd68 100644
--- a/components/finsh/finsh_token.c
+++ b/components/finsh/finsh_token.c
@@ -35,6 +35,7 @@
#define is_alpha(ch) ((ch | 0x20) - 'a') < 26u
#define is_digit(ch) ((ch) >= '0' && (ch) <= '9')
+#define is_xdigit(ch) (((ch) >= '0' && (ch) <= '9') || (((ch | 0x20) - 'a') < 6u))
#define is_separator(ch) !(((ch) >= 'a' && (ch) <= 'z') \
|| ((ch) >= 'A' && (ch) <= 'Z') || ((ch) >= '0' && (ch) <= '9') || ((ch) == '_'))
#define is_eof(self) (self)->eof
@@ -439,12 +440,16 @@ static int token_proc_escape(struct finsh_token* self)
case 'a':
result = '\007';
break;
+ case '"':
+ result = '"';
+ break;
case 'x':
+ case 'X':
result = 0;
ch = token_next_char(self);
- while ( (ch - '0')<16u )
+ while (is_xdigit(ch))
{
- result = result*16 + ch - '0';
+ result = result * 16 + ((ch < 'A') ? (ch - '0') : (ch | 0x20) - 'a' + 10);
ch = token_next_char(self);
}
token_prev_char(self);