From: Ben Pfaff Date: Sat, 7 Dec 2019 19:07:11 +0000 (+0000) Subject: command: Put command_ids in output into title case. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0536ee7f632fbc31e54d4f6782940b107bcc7efe;p=pspp command: Put command_ids in output into title case. This is closer to compatibility. --- diff --git a/src/language/command.c b/src/language/command.c index 0a198bc94c..1ce51d63e7 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -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) diff --git a/src/output/driver.c b/src/output/driver.c index e6fc0ca950..82556c81d0 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -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; } diff --git a/src/output/driver.h b/src/output/driver.h index dfefa3f69d..acf052aeb2 100644 --- a/src/output/driver.h +++ b/src/output/driver.h @@ -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); diff --git a/src/output/group-item.c b/src/output/group-item.c index fd172accdc..4fbc08630a 100644 --- a/src/output/group-item.c +++ b/src/output/group-item.c @@ -27,12 +27,19 @@ 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; } diff --git a/src/output/group-item.h b/src/output/group-item.h index 09bde59023..5bc3d8e756 100644 --- a/src/output/group-item.h +++ b/src/output/group-item.h @@ -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 diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 92825a4f9c..d2262e45e6 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -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 diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index c78756383a..bbcc896958 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -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 diff --git a/tests/automake.mk b/tests/automake.mk index 1dba99efa1..c7e0d4f9d8 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -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