command: Put command_ids in output into title case.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 7 Dec 2019 19:07:11 +0000 (19:07 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Dec 2019 01:04:15 +0000 (01:04 +0000)
This is closer to compatibility.

src/language/command.c
src/output/driver.c
src/output/driver.h
src/output/group-item.c
src/output/group-item.h
src/ui/gui/psppire.c
src/ui/terminal/main.c
tests/automake.mk

index 0a198bc94c4f6015c128477cd9641abc42136030..1ce51d63e7ddceadf045c339ced11f18401be1e1 100644 (file)
@@ -199,7 +199,8 @@ do_parse_command (struct lexer *lexer,
       result = CMD_FAILURE;
       goto finish;
     }
-  group_open_item_submit (group_open_item_create (command->name));
+  group_open_item_submit (group_open_item_create_nocopy (
+                            utf8_to_title (command->name)));
   opened = true;
 
   if (command->function == NULL)
index e6fc0ca9506de146ab8f48d7b5c41a97d01240a5..82556c81d0c41d858f816eb41939be613bfc8f51 100644 (file)
@@ -32,6 +32,7 @@
 #include "data/settings.h"
 #include "libpspp/array.h"
 #include "libpspp/assertion.h"
+#include "libpspp/i18n.h"
 #include "libpspp/message.h"
 #include "libpspp/llx.h"
 #include "libpspp/string-map.h"
@@ -273,7 +274,11 @@ output_submit (struct output_item *item)
   output_submit__ (e, item);
 }
 
-const char *
+/* Returns the name of the command currently being parsed, in all uppercase.
+   The caller must free the returned value.
+
+   Returns NULL if no command is being parsed. */
+char *
 output_get_command_name (void)
 {
   struct output_engine *e = engine_stack_top ();
@@ -282,7 +287,7 @@ output_get_command_name (void)
 
   for (size_t i = e->n_groups; i-- > 0; )
     if (e->groups[i])
-      return e->groups[i];
+      return utf8_to_upper (e->groups[i]);
 
   return NULL;
 }
index dfefa3f69de8ae04a27c972c1c5ef2bcec529bdb..acf052aeb20b4781cfdac37c1813211860eb3151 100644 (file)
@@ -36,7 +36,7 @@ void output_set_title (const char *);
 void output_set_subtitle (const char *);
 void output_set_filename (const char *);
 
-const char *output_get_command_name (void);
+char *output_get_command_name (void);
 
 size_t output_get_group_level (void);
 
index fd172accdca40f912705cd3ab90743b8c31e5533..4fbc08630a91d888e6e0675b8b8dc4e1bc82031f 100644 (file)
 
 struct group_open_item *
 group_open_item_create (const char *command_name)
+{
+  return group_open_item_create_nocopy (
+    command_name ? xstrdup (command_name) : NULL);
+}
+
+struct group_open_item *
+group_open_item_create_nocopy (char *command_name)
 {
   struct group_open_item *item;
 
   item = xmalloc (sizeof *item);
   output_item_init (&item->output_item, &group_open_item_class);
-  item->command_name = command_name ? xstrdup (command_name) : NULL;
+  item->command_name = command_name;
 
   return item;
 }
index 09bde590231ae2d61a8e257759e4552d99f08f86..5bc3d8e7562d433791a89dfa7135d63c12f5902a 100644 (file)
@@ -33,6 +33,7 @@ struct group_open_item
   };
 
 struct group_open_item *group_open_item_create (const char *command_name);
+struct group_open_item *group_open_item_create_nocopy (char *command_name);
 
 /* A group_close item. */
 struct group_close_item
index 92825a4f9cfc07aa9d3a567f57f54eb3dc607071..d2262e45e67ba634b6aac8b152d6fb80590028de 100644 (file)
@@ -159,9 +159,11 @@ handle_msg (const struct msg *m_, void *lexer_)
       m.first_column = lex_get_first_column (lexer, 0);
       m.last_column = lex_get_last_column (lexer, 0);
     }
-  m.command_name = CONST_CAST (char *, output_get_command_name ());
+  m.command_name = output_get_command_name ();
 
   message_item_submit (message_item_create (&m));
+
+  free (m.command_name);
 }
 
 void
index c78756383adbd1d590bd6ffe965e46837eb0820d..bbcc896958052b4c1a0b2c69042bfaed8629156b 100644 (file)
@@ -226,9 +226,11 @@ output_msg (const struct msg *m_, void *lexer_)
       m.last_line = lex_get_last_line_number (lexer, 0);
     }
 
-  m.command_name = CONST_CAST (char *, output_get_command_name ());
+  m.command_name = output_get_command_name ();
 
   message_item_submit (message_item_create (&m));
+
+  free (m.command_name);
 }
 
 static void
index 1dba99efa1a64af7dc908280499fa67731609ad8..c7e0d4f9d84686e3e00fd0ae260963321f1f52ca 100644 (file)
@@ -66,7 +66,7 @@ tests_data_sack_LDADD = src/libpspp-core.la
 tests_data_sack_CFLAGS = $(AM_CFLAGS)
 
 tests_libpspp_line_reader_test_SOURCES = tests/libpspp/line-reader-test.c
-tests_libpspp_line_reader_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
+tests_libpspp_line_reader_test_LDADD = src/libpspp-core.la
 
 tests_libpspp_ll_test_SOURCES = \
        src/libpspp/ll.c \
@@ -81,9 +81,7 @@ tests_libpspp_llx_test_CFLAGS = $(AM_CFLAGS)
 
 tests_libpspp_encoding_guesser_test_SOURCES = \
        tests/libpspp/encoding-guesser-test.c
-tests_libpspp_encoding_guesser_test_LDADD = \
-       src/libpspp/liblibpspp.la \
-       gl/libgl.la
+tests_libpspp_encoding_guesser_test_LDADD = src/libpspp-core.la
 
 tests_libpspp_heap_test_SOURCES = \
        tests/libpspp/heap-test.c
@@ -102,7 +100,7 @@ tests_libpspp_hmapx_test_SOURCES = \
 tests_libpspp_hmapx_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10
 
 tests_libpspp_i18n_test_SOURCES = tests/libpspp/i18n-test.c
-tests_libpspp_i18n_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
+tests_libpspp_i18n_test_LDADD = src/libpspp-core.la
 
 tests_libpspp_abt_test_SOURCES = \
        src/libpspp/abt.c \
@@ -147,7 +145,7 @@ tests_libpspp_string_map_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
 tests_libpspp_stringi_map_test_SOURCES = \
        tests/libpspp/stringi-map-test.c
 tests_libpspp_stringi_map_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10
-tests_libpspp_stringi_map_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
+tests_libpspp_stringi_map_test_LDADD = src/libpspp-core.la
 
 tests_libpspp_string_set_test_SOURCES = \
        src/libpspp/hash-functions.c \
@@ -159,7 +157,7 @@ tests_libpspp_string_set_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10
 tests_libpspp_stringi_set_test_SOURCES = \
        tests/libpspp/stringi-set-test.c
 tests_libpspp_stringi_set_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10
-tests_libpspp_stringi_set_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
+tests_libpspp_stringi_set_test_LDADD = src/libpspp-core.la
 
 tests_libpspp_tower_test_SOURCES = \
        tests/libpspp/tower-test.c
@@ -167,7 +165,7 @@ tests_libpspp_tower_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10
 tests_libpspp_tower_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
 
 tests_libpspp_u8_istream_test_SOURCES = tests/libpspp/u8-istream-test.c
-tests_libpspp_u8_istream_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
+tests_libpspp_u8_istream_test_LDADD = src/libpspp-core.la
 
 tests_libpspp_sparse_array_test_SOURCES = \
        tests/libpspp/sparse-array-test.c