!BLANKS and !CONCAT pass basic tests.
[pspp] / src / language / lexer / macro.c
index 584ee7f2fd3ed29e3d4880761c7176814e55c62c..628b83af01bd3d5e80a67c88baf8c5963463c5ee 100644 (file)
@@ -875,33 +875,19 @@ expand_macro_function (struct parse_macro_function_ctx *ctx,
   else if (parse_macro_function (ctx, &args, ss_cstr ("!concat"), 1, INT_MAX,
                                  input_consumed))
     {
-      struct string s;
-      bool all_strings = true;
+      struct string s = DS_EMPTY_INITIALIZER;
       for (size_t i = 0; i < args.n; i++)
         {
           if (args.mts[i].token.type == T_STRING)
             ds_put_substring (&s, args.mts[i].token.string);
           else
-            {
-              all_strings = false;
-              ds_put_substring (&s, args.mts[i].representation);
-            }
+            ds_put_substring (&s, args.mts[i].representation);
         }
 
-      if (all_strings)
-        {
-          *output = (struct macro_token) {
-            .token = { .type = T_STRING, .string = s.ss },
-          };
-          output->representation = ss_cstr (token_to_string (&output->token));
-        }
-      else
-        {
-          *output = (struct macro_token) {
-            .token = { .type = T_MACRO_ID /*XXX*/, .string = s.ss },
-          };
-          ss_alloc_substring (&output->representation, s.ss);
-        }
+      *output = (struct macro_token) {
+        .token = { .type = T_MACRO_ID /*XXX*/, .string = s.ss },
+      };
+      ss_alloc_substring (&output->representation, s.ss);
     }
   else if (parse_macro_function (ctx, &args, ss_cstr ("!quote"), 1, 1,
                                  input_consumed))
@@ -927,6 +913,17 @@ expand_macro_function (struct parse_macro_function_ctx *ctx,
       else
         macro_token_copy (output, &args.mts[0]);
     }
+  else if (ctx->n_input > 0
+           && ctx->input[0].token.type == T_MACRO_ID
+           && ss_equals_case (ctx->input[0].token.string, ss_cstr ("!null")))
+    {
+      *input_consumed = 1;
+      *output = (struct macro_token) {
+        .token = { .type = T_MACRO_ID /* XXX*/ },
+      };
+      ss_alloc_substring (&output->token.string, ss_cstr (""));
+      return true;
+    }
   else
     return false;