Add a couple of extensions to GET DATA TYPE=TXT. Patch #6412. Thanks
[pspp-builds.git] / src / language / data-io / get-data.c
index 189054a507058c38b17b1ba027d0f69b5a995613..54bb5653ecc2086456624e7923b9a02443b77b57 100644 (file)
@@ -24,6 +24,7 @@
 #include <data/dictionary.h>
 #include <data/format.h>
 #include <data/procedure.h>
+#include <data/settings.h>
 #include <language/command.h>
 #include <language/data-io/data-parser.h>
 #include <language/data-io/data-reader.h>
@@ -69,6 +70,7 @@ parse_get_psql (struct lexer *lexer, struct dataset *ds)
   psql.allow_clear = false;
   psql.conninfo = NULL;
   psql.str_width = -1;
+  psql.bsize = -1;
   ds_init_empty (&psql.sql);
 
   lex_force_match (lexer, '/');
@@ -93,6 +95,12 @@ parse_get_psql (struct lexer *lexer, struct dataset *ds)
          psql.str_width = lex_integer (lexer);
          lex_get (lexer);
        }
+      else if ( lex_match_id (lexer, "BSIZE"))
+       {
+         lex_match (lexer, '=');
+         psql.bsize = lex_integer (lexer);
+         lex_get (lexer);
+       }
       else if ( lex_match_id (lexer, "UNENCRYPTED"))
        {
          psql.allow_clear = true;
@@ -422,18 +430,29 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds)
 
           lex_get (lexer);
         }
-      else if (lex_match_id (lexer, "QUALIFIER"))
+      else if (lex_match_id (lexer, "QUALIFIERS"))
         {
-          if (!set_type (parser, "QUALIFIER", DP_DELIMITED, &has_type))
+          if (!set_type (parser, "QUALIFIERS", DP_DELIMITED, &has_type))
             goto error;
           lex_match (lexer, '=');
 
           if (!lex_force_string (lexer))
             goto error;
 
+          if (settings_get_syntax () == COMPATIBLE
+              && ds_length (lex_tokstr (lexer)) != 1)
+            {
+              msg (SE, _("In compatible syntax mode, the QUALIFIER string "
+                         "must contain exactly one character."));
+              goto error;
+            }
+
           data_parser_set_quotes (parser, ds_ss (lex_tokstr (lexer)));
           lex_get (lexer);
         }
+      else if (settings_get_syntax () == ENHANCED
+               && lex_match_id (lexer, "ESCAPE"))
+        data_parser_set_quote_escape (parser, true);
       else if (lex_match_id (lexer, "VARIABLES"))
         break;
       else