This is compatible and easier to read.
output_submit__ (e, item);
}
-/* 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 *
+/* Returns the name of the command currently being parsed, or NULL if no
+ command is being parsed. */
+const char *
output_get_command_name (void)
{
struct output_engine *e = engine_stack_top ();
for (size_t i = e->n_groups; i-- > 0;)
if (e->groups[i])
- return utf8_to_upper (e->groups[i]);
+ return e->groups[i];
return NULL;
}
+char *
+output_get_uppercase_command_name (void)
+{
+ const char *command_name = output_get_command_name ();
+ return command_name ? utf8_to_upper (command_name) : NULL;
+}
+
/* Flushes output to screen devices, so that the user can see
output that doesn't fill up an entire page. */
void
void output_set_subtitle (const char *);
void output_set_filename (const char *);
-char *output_get_command_name (void);
+const char *output_get_command_name (void);
+char *output_get_uppercase_command_name (void);
size_t output_get_group_level (void);
table->weight_format = (struct fmt_spec) { FMT_F, 40, 0 };
table->title = title;
table->subtype = subtype ? pivot_value_new_text (subtype) : NULL;
- table->command_c = output_get_command_name ();
+ table->command_c = xstrdup_if_nonempty (output_get_command_name ());
table->look = pivot_table_look_ref (pivot_table_look_get_default ());
table->settings = fmt_settings_copy (settings_get_fmt_settings ());
table->small = settings_get_small ();
else if (is_image_item (item))
spv_writer_put_image (w, item, to_image_item (item)->image);
else if (is_text_item (item))
- {
- char *command_id = output_get_command_name ();
- spv_writer_put_text (w, to_text_item (item),
- command_id);
- free (command_id);
- }
+ spv_writer_put_text (w, to_text_item (item),
+ output_get_command_name ());
else if (is_page_break_item (item))
w->need_page_break = true;
else if (is_page_setup_item (item))
m.first_column = lex_get_first_column (lexer, 0);
m.last_column = lex_get_last_column (lexer, 0);
}
- m.command_name = output_get_command_name ();
+ m.command_name = output_get_uppercase_command_name ();
message_item_submit (message_item_create (&m));
m.last_line = lex_get_last_line_number (lexer, 0);
}
- m.command_name = output_get_command_name ();
+ m.command_name = output_get_uppercase_command_name ();
message_item_submit (message_item_create (&m));
m.last_line = lex_get_last_line_number (lexer, 0);
}
- m.command_name = output_get_command_name ();
+ m.command_name = output_get_uppercase_command_name ();
message_item_submit (message_item_create (&m));