From 41a0546e577009ef8b8eac45793968d7519ca5cf Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 15 Feb 2014 19:19:58 -0800 Subject: [PATCH] sys-file-reader: Handle multiple response sets with extra line feeds. Some system files have these, although I don't know why. --- doc/dev/system-file-format.texi | 7 ++++--- src/data/sys-file-reader.c | 4 ++++ tests/data/sys-file-reader.at | 9 +++++---- utilities/pspp-dump-sav.c | 3 +++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/doc/dev/system-file-format.texi b/doc/dev/system-file-format.texi index a480195857..be6433b9a0 100644 --- a/doc/dev/system-file-format.texi +++ b/doc/dev/system-file-format.texi @@ -735,8 +735,8 @@ The size of each element in the @code{mrsets} member. Always set to 1. The total number of bytes in @code{mrsets}. @item char mrsets[]; -A series of multiple response sets, each of which consists of the -following: +Zero or more line feeds (byte 0x0a), followed by a series of multiple +response sets, each of which consists of the following: @itemize @bullet @item @@ -786,7 +786,8 @@ The short names of the variables in the set, converted to lowercase, each separated from the previous by a single space. @item -A line feed (byte 0x0a). +One line feed (byte 0x0a). Sometimes multiple, even hundreds, of line +feeds are present. @end itemize @end table diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index c999b1a655..b7c5984466 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -1403,6 +1403,10 @@ parse_mrsets (struct sfm_reader *r, const struct sfm_extension_record *record, char delimiter; int width; + /* Skip extra line feeds if present. */ + while (text_match (text, '\n')) + continue; + mrset = xzalloc (sizeof *mrset); name = text_get_token (text, ss_cstr ("="), NULL); diff --git a/tests/data/sys-file-reader.at b/tests/data/sys-file-reader.at index 62d5a326bc..3c29a33bba 100644 --- a/tests/data/sys-file-reader.at +++ b/tests/data/sys-file-reader.at @@ -599,13 +599,14 @@ dnl Machine integer info record. 7; 7; 1; COUNT( "$a=C 10 my mcgroup "; i8 0x82; i8 0xa0; " b c"; i8 10; - "$b=D2 55 0 g e f d"; i8 10; + "$b=D2 55 0 g e f d"; i8 10; i8 10; "$c=D4 "; i8 0x82; i8 0xcd; i8 0x82; i8 0xa2; " 10 mdgroup #2 h i j"; i8 10); 7; 19; 1; COUNT( + i8 10; "$d=E 1 2 34 13 third mdgroup k l m"; i8 10; - "$e=E 11 6 choice 0 n o p"; i8 10); + "$e=E 11 6 choice 0 n o p"; i8 10; i8 10; i8 10; i8 10); dnl Character encoding record. 7; 20; 1; 9; "shift_jis"; @@ -614,8 +615,8 @@ dnl Dictionary termination record. 999; 0; ]) for variant in \ - "be fdf260a05220e08c748967dcb90d8b15" \ - "le 4c9b0c0636bc0aa0cc16684c8188d1c7" + "be eab38c68398324ac1663161512a8516a" \ + "le afc6173eed7f4c4e63dc4252bc18f6a2" do set $variant AT_CHECK_UNQUOTED([sack --$[1] sys-file.sack > sys-file.sav], [0], [], [$[2] diff --git a/utilities/pspp-dump-sav.c b/utilities/pspp-dump-sav.c index 788c34f76b..c31c02a927 100644 --- a/utilities/pspp-dump-sav.c +++ b/utilities/pspp-dump-sav.c @@ -768,6 +768,9 @@ read_mrsets (struct sfm_reader *r, size_t size, size_t count) const char *label; const char *variables; + while (text_match (text, '\n')) + continue; + name = text_tokenize (text, '='); if (name == NULL) break; -- 2.30.2