aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-06-05 15:33:39 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:02:01 -0700
commitbce9c9d793a708c0741f99341b70c7b8dffad415 (patch)
tree16505a4172e4f785a586b70787f50acb31e44ecb
parent[PATCH] More mode attribute recognition (diff)
downloadsparse-bce9c9d793a708c0741f99341b70c7b8dffad415.tar.gz
sparse-bce9c9d793a708c0741f99341b70c7b8dffad415.tar.bz2
sparse-bce9c9d793a708c0741f99341b70c7b8dffad415.zip
Allow underscores in integer constants for readability.
Thus 0x1234_5678 is a valid constant, as is 100_000_ul. The parser doesn't care where they are.
-rw-r--r--expression.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/expression.c b/expression.c
index a8f39d3..c628d1e 100644
--- a/expression.c
+++ b/expression.c
@@ -118,10 +118,16 @@ static void get_number_value(struct expression *expr, struct token *token)
base -= 2; // the fall-through will make this 8
}
}
- while ((digit = hexval(*str)) < base) {
+ for (;;) {
+ char c = *str++;
+ if (c == '_')
+ continue;
+ digit = hexval(c);
+ if (digit >= base)
+ break;
value = value * base + digit;
- str++;
}
+ str--;
modifiers = 0;
for (;;) {
char c = *str++;