From: Ben Pfaff Date: Fri, 7 Nov 2014 06:41:29 +0000 (-0800) Subject: Factor out more code. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a912c9228d42bef16b98e6ddd34b8bb914dbebd7;p=pspp Factor out more code. --- diff --git a/dump.c b/dump.c index c310023f4d..64b6ca74fc 100644 --- a/dump.c +++ b/dump.c @@ -207,7 +207,7 @@ dump_value_31(void) static void dump_value(int level); static void -dump_value__(int level) +dump_value__(int level, bool match1) { if (match_byte (3)) { @@ -221,7 +221,8 @@ dump_value__(int level) printf("string \"%s\" and \"%s\"", s1, s2); if (!match_byte (0)) match_byte_assert(1); - match_byte (1); + if (match1) + match_byte (1); } else if (match_byte (5)) { @@ -271,7 +272,8 @@ dump_value__(int level) format = get_u32 (); value = get_double (); printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff); - match_byte (1); + if (match1) + match_byte (1); } else { @@ -334,7 +336,7 @@ dump_value(int level) match_byte (0); match_byte (0); match_byte (0); - dump_value__(level); + dump_value__(level, true); match_byte(0); match_byte(0); match_byte(0); @@ -347,7 +349,7 @@ dump_dim_value(int level) printf (" "); if (data[pos] == 3 || data[pos] == 5) - dump_value__(level); + dump_value__(level, true); else dump_value(level); } @@ -430,27 +432,8 @@ dump_data_value(void) match_byte(0); match_byte(0); match_byte(0); - if (match_byte (1)) - { - unsigned int format; - double value; - - dump_value_31(); - format = get_u32 (); - value = get_double (); - printf (" value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff); - } - else if (match_byte (3)) - { - get_string(); - dump_value_31(); - get_string(); - printf("string \"%s\"", get_string()); - if (!match_byte (0)) - match_byte_assert(1); - } - else if (data[pos] == 2 || data[pos] == 4) - dump_value__(0); + if (data[pos] == 2 || data[pos] == 4 || data[pos] == 3 || data[pos] == 1) + dump_value__(0, false); else if (data[pos] == 5) dump_value (0); else @@ -516,7 +499,7 @@ dump_title_value(int level) if (data[pos] == 3 || data[pos] == 2 || data[pos] == 4 || data[pos] == 1) dump_value(level); else if (data[pos] == 5) - dump_value__(level); + dump_value__(level, true); else { dump_value_31(); @@ -555,27 +538,8 @@ dump_footnote_value(int level) match_byte (0); if (data[pos] == 2 || data[pos] == 4) dump_value(level); - else if (data[pos] == 5) - dump_value__(level); - else if (match_byte (3)) - { - get_string(); - dump_value_31(); - get_string(); - printf("string \"%s\"", get_string()); - if (!match_byte (0)) - match_byte_assert (1); - } - else if (match_byte (1)) - { - unsigned int format; - double value; - - dump_value_31(); - format = get_u32 (); - value = get_double (); - printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff); - } + else if (data[pos] == 5 || data[pos] == 3 || data[pos] == 1) + dump_value__(level, false); else { dump_value_31();