summaryrefslogtreecommitdiff
path: root/macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c
diff options
context:
space:
mode:
Diffstat (limited to 'macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c')
-rw-r--r--macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c b/macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c
index 9c26ccf8d1..292e4cc08a 100644
--- a/macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c
+++ b/macros/texinfo/texinfo/tp/Texinfo/XS/parsetexi/macro.c
@@ -51,7 +51,7 @@ new_macro (char *name, ELEMENT *macro)
macro_list = realloc (macro_list,
(macro_space += 5) * sizeof (MACRO));
if (!macro_list)
- abort ();
+ fatal ("realloc failed");
}
new = add_texinfo_command (name);
m = &macro_list[macro_number];
@@ -90,8 +90,8 @@ parse_macro_command_line (enum command_id cmd, char **line_inout,
macro->line_nr = line_nr;
add_extra_string (macro, "arg_line", strdup (line));
- /* TODO: This extra value isn't used much, so is a candidate for
- simplification. */
+ /* Note this extra value isn't used much, so it might be possible
+ to get rid of it. */
line += strspn (line, whitespace_chars);
name = read_command_name (&line);
@@ -143,7 +143,7 @@ parse_macro_command_line (enum command_id cmd, char **line_inout,
if (!*q)
{
/* End of string reached before closing brace. */
- abort ();
+ goto check_trailing;
}
/* Disregard trailing whitespace. */
@@ -207,7 +207,6 @@ check_trailing:
}
//line += strlen (line); /* Discard rest of line. */
-funexit:
*line_inout = line;
return macro;
}
@@ -331,7 +330,7 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout, enum command_id cmd)
(1+(arg_space += 5)) * sizeof (char *));
/* Include space for terminating null element. */
if (!arg_list)
- abort ();
+ fatal ("realloc failed");
}
if (arg.space > 0)
arg_list[arg_number++] = arg.text;
@@ -418,9 +417,8 @@ expand_macro_body (MACRO *macro_record, char *arguments[], TEXT *expanded)
bs = strchr (ptext, '\\');
if (!bs)
{
- // TODO: error - malformed
+ /* malformed input - unpaired backslash */
return;
- abort ();
}
*bs = '\0';
@@ -507,7 +505,7 @@ handle_macro (ELEMENT *current, char **line_inout, enum command_id cmd)
macro_record = lookup_macro (cmd);
if (!macro_record)
- abort ();
+ fatal ("no macro record");
macro = macro_record->element;
/* Get number of args. - 1 for the macro name. */
@@ -542,7 +540,7 @@ handle_macro (ELEMENT *current, char **line_inout, enum command_id cmd)
if (!line)
line = "";
}
- line += strspn (line, whitespace_chars);
+ line += strspn (line, whitespace_chars_except_newline);
arguments = malloc (sizeof (char *) * 2);
arguments[0] = strdup (line);
@@ -663,14 +661,13 @@ store_value (char *name, char *value)
v->value = strdup (value);
}
-/* Clear the value the name of which is LEN bytes at NAME */
void
-clear_value (char *name, int len)
+clear_value (char *name)
{
int i;
for (i = 0; i < value_number; i++)
{
- if (!strncmp (value_list[i].name, name, len) && !value_list[i].name[len])
+ if (!strcmp (value_list[i].name, name))
{
value_list[i].name[0] = '\0';
value_list[i].value[0] = '\0';
@@ -678,14 +675,13 @@ clear_value (char *name, int len)
}
}
-/* Look for a value the name of which is LEN bytes at NAME */
char *
-fetch_value (char *name, int len)
+fetch_value (char *name)
{
int i;
for (i = 0; i < value_number; i++)
{
- if (!strncmp (value_list[i].name, name, len) && !value_list[i].name[len])
+ if (!strcmp (value_list[i].name, name))
return value_list[i].value;
}