[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [PATCH] allow binary coded literals
- From: Rene Rebe <rene@...>
- Date: Wed, 04 Feb 2009 20:50:38 +0100
Hi all,
this simple two-liner allows for binary coded literal constants
in the lexxer.
Signed-off-by: René Rebe <rene@exactcode.de>
===================================================================
--- src/lobject.c
+++ src/lobject.c
@@ -93,6 +93,8 @@
if (endptr == s) return 0; /* conversion failed */
if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
*result = cast_num(strtoul(s, &endptr, 16));
+ else if (*endptr == 'b' || *endptr == 'B') /* maybe an binary constant? */
+ *result = cast_num(strtoul(endptr + 1, &endptr, 2));
if (*endptr == '\0') return 1; /* most common case */
while (isspace(cast(unsigned char, *endptr))) endptr++;
if (*endptr != '\0') return 0; /* invalid trailing characters? */
--
René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
http://exactcode.de | http://t2-project.org | http://rene.rebe.name