sys-file-reader: Handle multiple response sets with extra line feeds.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 16 Feb 2014 03:19:58 +0000 (19:19 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 16 Feb 2014 06:54:15 +0000 (22:54 -0800)
Some system files have these, although I don't know why.

doc/dev/system-file-format.texi
src/data/sys-file-reader.c
tests/data/sys-file-reader.at
utilities/pspp-dump-sav.c

index a480195857f8d027cc910d9c9ac76b6d6ff26fb7..be6433b9a0f75c3877dc5915e446a6c90e09fa4b 100644 (file)
@@ -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
 
index c999b1a655ee402e496af9e475ac4952d0a61e83..b7c5984466e43ac0439e53d69c7facfc3462388b 100644 (file)
@@ -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);
index 62d5a326bce4413965043d8b0ebb32224c11a1b6..3c29a33bbaaf0cf3ff380d17b13cce4bc10be073 100644 (file)
@@ -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]
index 788c34f76b7527612eaefe03cbfecc73d68fa1f5..c31c02a9277185f05cb7cadc5103cd370cd1dd70 100644 (file)
@@ -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;