X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Fstrcalc.c;h=208a2b38a995a10d90e30362e60d235d37e812c7;hb=dbc419164cf5e14cdf5757f1e105d02693bacb9f;hp=1a078ebacd6c6aef827b7e1285058164c420e164;hpb=c28fcf22c08f71b02ccd8edb2e091c1b6c22e540;p=libfirm diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c index 1a078ebac..208a2b38a 100644 --- a/ir/tv/strcalc.c +++ b/ir/tv/strcalc.c @@ -25,9 +25,7 @@ * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #ifdef HAVE_STDLIB_H # include @@ -1325,7 +1323,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig static const char small_digits[] = "0123456789abcdef"; char *base_val, *div1_res, *div2_res, *rem_res; - int counter, nibbles, i, sign; + int counter, nibbles, i, sign, mask; char x; const char *val = (const char *)value; @@ -1365,7 +1363,8 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig /* last nibble must be masked */ if (bits & 3) { - x = and_table[_val(val[++counter])][bits & 3]; + mask = zex_digit[bits & 3]; + x = and_table[_val(val[counter++])][mask]; *(--pos) = digits[_val(x)]; } @@ -1391,7 +1390,8 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig /* last nibble must be masked */ if (bits & 3) { - x = and_table[_val(val[++counter])][bits & 3]; + mask = zex_digit[bits & 3]; + x = and_table[_val(val[counter++])][mask]; pos -= 4; p = binary_table[_val(x)]; @@ -1430,9 +1430,9 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig /* last nibble must be masked */ if (bits & 3) { + mask = zex_digit[bits & 3]; + div1_res[counter] = and_table[_val(p[counter])][mask]; ++counter; - - div1_res[counter] = and_table[_val(p[counter])][bits & 3]; } m = div1_res; @@ -1472,8 +1472,8 @@ void init_strcalc(int precision) { calc_buffer_size = (precision / 2); max_value_size = (precision / 4); - calc_buffer = xmalloc(calc_buffer_size+1 * sizeof(char)); - output_buffer = xmalloc(bit_pattern_size+1 * sizeof(char)); + calc_buffer = XMALLOCN(char, calc_buffer_size + 1); + output_buffer = XMALLOCN(char, bit_pattern_size + 1); DEBUGPRINTF(("init strcalc: \n\tPRECISION: %d\n\tCALC_BUFFER_SIZE = %d\n\tMAX_VALUE_SIZE = %d\n\tbuffer pointer: %p\n", precision, calc_buffer_size, max_value_size, calc_buffer)); }