From: Ben Pfaff Date: Fri, 31 Oct 2014 01:33:07 +0000 (-0700) Subject: Allow non-ascii strings. Handle substitutions in dimension titles. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adb1a7d3f55e0f2305cfa584970bb33cd803bf07;p=pspp Allow non-ascii strings. Handle substitutions in dimension titles. --- diff --git a/dump.c b/dump.c index 60056f55b9..d42580895e 100644 --- a/dump.c +++ b/dump.c @@ -128,7 +128,7 @@ static char * get_string(void) { if (data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0 - && all_ascii(&data[pos + 4], data[pos])) + /*&& all_ascii(&data[pos + 4], data[pos])*/) { int len = data[pos]; char *s = malloc(len + 1); @@ -249,6 +249,105 @@ dump_value(int level) } } +static void +dump_dim_value(int level) +{ + for (int i = 0; i <= level; i++) + printf (" "); + + if (match_byte (3)) + { + get_string(); + if (match_byte (0x31)) + { + match_u32 (1); + printf("(footnote %d) ", get_u32()); + match_byte_assert (0); + match_byte_assert (0); + int subn = get_u32 (); + printf ("nested %d bytes", subn); + pos += subn; + } + else + match_byte_assert (0x58); + get_string(); + printf("string \"%s\"", get_string()); + match_byte (0); + match_byte_assert (1); + match_byte (0); + match_byte (0); + match_byte (0); + match_byte (1); + } + else if (match_byte (5)) + { + match_byte_assert (0x58); + printf ("variable \"%s\"", get_string()); + get_string(); + match_byte_assert (2); + } + else if (match_byte (2)) + { + unsigned int format; + char *var, *vallab; + double value; + + match_byte_assert (0x58); + format = get_u32 (); + value = get_double (); + var = get_string (); + vallab = get_string (); + printf ("value %g format %d(%d.%d) var \"%s\" vallab \"%s\"", + value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab); + if (!match_u32 (3)) + match_u32_assert (2); + match_byte (0); + } + else if (match_byte (1)) + { + unsigned int format; + double value; + + match_byte_assert (0x58); + format = get_u32 (); + value = get_double (); + printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff); + match_byte (1); + match_byte (0); + match_byte (0); + match_byte (0); + match_byte (1); + } + else + { + int subn; + int total_subs = 1; + + match_byte (0); + match_byte_assert (0x31); + match_u32_assert (0); + match_u32_assert (0); + subn = get_u32 (); + printf ("nested %d bytes", subn); + pos += subn; + printf ("; \"%s\", substitutions:", get_string()); + for (;;) + { + int n_subst = get_u32(); + if (!n_subst) + break; + printf (" %d", n_subst); + total_subs *= n_subst; + } + + for (int i = 0; i < total_subs; i++) + { + putc ('\n', stdout); + dump_value (level + 1); + } + } +} + static void dump_category(int level) { @@ -285,6 +384,8 @@ static void dump_dim(void) { int n_categories; + printf("next dim\n"); + match_byte(0); if (match_byte(3)) { get_string(); @@ -293,7 +394,7 @@ dump_dim(void) printf("string \"%s\": ", get_string()); match_byte_assert(1); } - else if (match_byte(5)) + else if (match_byte(5)) { match_byte_assert(0x58); printf("variable \"%s\": ", get_string()); @@ -303,8 +404,30 @@ dump_dim(void) } else { - fprintf(stderr, "%08x: unexpected byte\n", pos); - exit(1); + int subn; + int total_subs = 1; + + match_byte_assert(0x31); + match_u32_assert (0); + match_u32_assert (0); + subn = get_u32 (); + printf ("nested %d bytes", subn); + pos += subn; + printf ("; \"%s\", substitutions:", get_string()); + for (;;) + { + int n_subst = get_u32(); + if (!n_subst) + break; + printf (" %d", n_subst); + total_subs *= n_subst; + } + + for (int i = 0; i < total_subs; i++) + { + putc ('\n', stdout); + dump_dim_value (0); + } } match_byte_assert(0); diff --git a/notes b/notes index f5b8cf3a6f..1a8c1234bb 100644 --- a/notes +++ b/notes @@ -817,6 +817,50 @@ tdump25 ./germano/Crosstabs/00000000013_lightTableData.bin 05 58 "post1.3" 00 00 00 00 i2 i2 i5 00 00 00 00 00 ... +web/1ae63a04381624dac939ac62eca63fec/00000000053_lightTableData.bin (descriptives) + + i2 + + 03 "Variables" 58 "variable_s_1" "Variables" 01 00 00 i2 01 00 i1 00 i8 + 05 58 "GODINEPACIJENTA" "GODINE PACIJENTA" i2 i2 00 00 00 00 00 00 00 00 + 05 58 "HLOCORPUS" "HLO CORPUS" i2 i2 i1 00 00 00 00 + 05 58 "INFLCORPUS" "INFL CORPUS" i2 i2 i2 00 00 00 00 + 05 58 "AKT.CORPUS" "AKT. CORPUS" i2 i2 i3 00 00 00 00 + 05 58 "VgmCORPUS" "Vgm CORPUS" i2 i2 i4 00 00 00 00 + 05 58 "VgfCORPUS" "Vgf CORPUS" i2 i2 i5 00 00 00 00 + 05 58 i9 56 67 9e 43 4f 52 50 55 53 i10 56 67 9e 20 43 4f 52 50 55 53 i2 i2 i6 00 00 00 00 + 05 58 "VglpCORPUS" "Vglp CORPUS" i2 i2 i7 00 00 00 00 + + 03 "Statistics" 58 "statistics_10" "Statistics" 01 00 01 i2 01 00 01 i1 i3 + 03 "Mean" 58 "mean" "Mean" i1 i2 00 00 00 00 00 00 00 00 + 03 "Std. Deviation" 58 "gbar11" "Std. Deviation" i1 i2 i1 00 00 00 00 + 03 "N" 58 "n" "N" i1 i2 i2 00 00 00 00 00 00 00 00 + +./web/76e9b53e9f775fb690a88919ccdbb03c/000000007251_lightTableData.bin: + + i6 + + 05 58 "Gender_R" "" 02 00 02 i2 00 00 i1 00 i2 + 02 58 F40.0(0) "Gender_R" "Male" i2 i2 00 00 00 00 00 00 00 00 + 02 58 F40.0(1) "Gender_R" "Female" i2 i2 i1 00 00 00 00 + + 03 "Statistics" 58 "statistics_10" "Statistics" 01 00 00 i2 01 00 01 i1 i4 + 03 "Mean Difference (I-J)" 58 "mean_difference_i-j" "Mean Difference (I-J)" i1 i2 00 00 00 00 00 00 00 00 + 03 "Std. Error" 58 "standard_error" "Std. Error" i1 i2 i1 00 00 00 00 + 03 "Sig." 58 "significance_level" "Significance" i1 i2 i2 00 00 00 00 + 00 31 i0 i0 i38: (i32: (i0 31 "^1% Confidence Interval") 58 58) "^1% Confidence Interval" i1 00 00 00 00 + 01 58 00 03 i5 00 00 00 c0 57 40 00 00 01 i2 i-1 i2 + 03 "Lower Bound" 58 "lower_bound" "Lower Bound" i1 i2 i3 00 00 00 00 + 03 "Upper Bound" 58 "upper_bound" "Upper Bound" i1 i2 i4 00 00 00 00 + + 00 31 i0 i0 i21: (i15: (i0 31 "(J) ^1") 58 58) "(J) ^1" i1 00 00 00 00 + 05 58 "sexorient_r" "" 02 00 00 i2 00 00 01 i2 i3 + 02 58 F40.0(0) "sexorient_r" "Straight" i2 i2 00 00 00 00 00 00 00 00 + 02 58 F40.0(1)"sexorient_r" "Bisexual" i2 i2 i1 00 00 00 00 + 02 58 F40.0(2) "sexorient_r" "Gay/Lesbian/Homosexual" i2 i2 i2 00 00 00 00 00 + + ... + Data: tdump21 (germano/Crosstabs.pdf) ------------- @@ -834,7 +878,7 @@ i32 i0 01 58 F40.3(0.026) i52 i0 01 58 F40.3(0.030) i36 i0 01 58 F40.3(0.196) i56 i0 01 58 F40.3(0.077) - +- i1 i0 01 58 F40.3(0.055) i21 i0 01 58 F40.3(0.077) i41 i0 01 58 F40.3(0.056)