separate sack integration test binary
[pspp] / src / ui / terminal / main.c
index 630089b2d2bac927e96cda377f24b6de4c8de234..60f9313840c625daca70cea1ed66d603c1bbe57b 100644 (file)
@@ -65,7 +65,7 @@ static void add_syntax_reader (struct lexer *, const char *file_name,
                                const char *encoding, enum segmenter_mode);
 static void bug_handler(int sig);
 static void fpu_init (void);
-static void output_msg (const struct msg *, void *);
+static void output_msg (const struct msg *, struct lexer *);
 
 /* Program entry point. */
 int
@@ -109,7 +109,7 @@ main (int argc, char **argv)
   terminal_opts_done (terminal_opts, argc, argv);
   argv_parser_destroy (parser);
 
-  msg_set_handler (output_msg, lexer);
+  lex_set_message_handler (lexer, output_msg);
   session_set_default_syntax_encoding (the_session, syntax_encoding);
 
   /* Add syntax files to source stream. */
@@ -142,17 +142,25 @@ main (int argc, char **argv)
        break;
       else if (cmd_result_is_failure (result) && lex_token (lexer) != T_STOP)
         {
-          if (lex_get_error_mode (lexer) == LEX_ERROR_STOP)
+          switch (lex_get_error_mode (lexer))
             {
+            case LEX_ERROR_STOP:
               msg (MW, _("Error encountered while ERROR=STOP is effective."));
               lex_discard_noninteractive (lexer);
-            }
-          else if (result == CMD_CASCADING_FAILURE
-                   && lex_get_error_mode (lexer) != LEX_ERROR_TERMINAL)
-            {
-              msg (SE, _("Stopping syntax file processing here to avoid "
-                         "a cascade of dependent command failures."));
-              lex_discard_noninteractive (lexer);
+              break;
+
+            case LEX_ERROR_CONTINUE:
+              if (result == CMD_CASCADING_FAILURE)
+                {
+                  msg (SE, _("Stopping syntax file processing here to avoid "
+                             "a cascade of dependent command failures."));
+                  lex_discard_noninteractive (lexer);
+                }
+              break;
+
+            case LEX_ERROR_TERMINAL:
+            case LEX_ERROR_IGNORE:
+              break;
             }
         }
 
@@ -215,23 +223,30 @@ bug_handler(int sig)
 }
 
 static void
-output_msg (const struct msg *m_, void *lexer_)
+output_msg (const struct msg *m_, struct lexer *lexer)
 {
-  struct lexer *lexer = lexer_;
-  struct msg m = *m_;
-
-  if (m.file_name == NULL)
+  struct msg_location *location = m_->location;
+  if (!location && lexer)
     {
-      m.file_name = CONST_CAST (char *, lex_get_file_name (lexer));
-      m.first_line = lex_get_first_line_number (lexer, 0);
-      m.last_line = lex_get_last_line_number (lexer, 0);
+      location = lex_get_location (lexer, 0, 0);
+      msg_location_remove_columns (location);
     }
 
-  m.command_name = output_get_uppercase_command_name ();
+  struct msg m = {
+    .category = m_->category,
+    .severity = m_->severity,
+    .stack = m_->stack,
+    .n_stack = m_->n_stack,
+    .location = location,
+    .command_name = output_get_uppercase_command_name (),
+    .text = m_->text,
+  };
 
   output_item_submit (message_item_create (&m));
 
   free (m.command_name);
+  if (m.location != m_->location)
+    msg_location_destroy (m.location);
 }
 
 static void