From 0bddf6c31e2dc664e50eed6609ac36a1a86e1536 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sun, 6 May 2012 20:17:06 +0200 Subject: [PATCH] Teach new_tarval_from_str_int() to parse binary numbers: 0[bB][01]+. --- include/libfirm/tv.h | 1 + ir/tv/tv.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/libfirm/tv.h b/include/libfirm/tv.h index a013d8432..9e10ec80e 100644 --- a/include/libfirm/tv.h +++ b/include/libfirm/tv.h @@ -70,6 +70,7 @@ * if mode is int_number: * - [+-]?0[xX][0-9a-fA-F]+ (hexadecimal representation) * - [+-]?0[0-7]* (octal representation) + * - [+-]?0[bB][01]+ (binary representation) * - [+-]?[1-9][0-9]* (decimal representation) * * if mode is float_number: diff --git a/ir/tv/tv.c b/ir/tv/tv.c index b6bb77094..d926aea20 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -344,6 +344,10 @@ static ir_tarval *new_tarval_from_str_int(const char *str, size_t len, str += 2; len -= 2; base = 16; + } else if (str[1] == 'b' || str[1] == 'B') { + str += 2; + len -= 2; + base = 2; } else { ++str; --len; -- 2.20.1