[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Add const
From: |
Patrice Dumas |
Subject: |
branch master updated: Add const |
Date: |
Mon, 20 May 2024 15:42:16 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 4555fbf29f Add const
4555fbf29f is described below
commit 4555fbf29f278a63a55f343515966e7639458b03
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon May 20 21:42:11 2024 +0200
Add const
---
ChangeLog | 4 +++
tp/Texinfo/XS/main/floats.c | 12 ++++---
tp/Texinfo/XS/main/floats.h | 4 +--
tp/Texinfo/XS/parsetexi/end_line.c | 69 +++++++++++++++++++++-----------------
tp/Texinfo/XS/parsetexi/macro.c | 6 ++--
tp/Texinfo/XS/parsetexi/macro.h | 6 ++--
tp/Texinfo/XS/parsetexi/parser.c | 7 ++--
7 files changed, 61 insertions(+), 47 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 99b800aeac..955689cd85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2024-05-20 Patrice Dumas <pertusus@free.fr>
+
+ Add const
+
2024-05-20 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/debug.c (debug_protect_eol): always allocate the
diff --git a/tp/Texinfo/XS/main/floats.c b/tp/Texinfo/XS/main/floats.c
index b017965595..b2055765c9 100644
--- a/tp/Texinfo/XS/main/floats.c
+++ b/tp/Texinfo/XS/main/floats.c
@@ -51,7 +51,8 @@ add_to_float_record_list (FLOAT_RECORD_LIST *float_records,
char *type,
}
static LISTOFFLOATS_TYPE *
-find_float_type (LISTOFFLOATS_TYPE_LIST *listoffloats_list, char *float_type)
+find_float_type (LISTOFFLOATS_TYPE_LIST *listoffloats_list,
+ const char *float_type)
{
size_t i;
for (i = 0; i < listoffloats_list->number; i++)
@@ -64,7 +65,8 @@ find_float_type (LISTOFFLOATS_TYPE_LIST *listoffloats_list,
char *float_type)
}
static LISTOFFLOATS_TYPE *
-add_to_listoffloats_list (LISTOFFLOATS_TYPE_LIST *listoffloats_list, char
*type)
+add_to_listoffloats_list (LISTOFFLOATS_TYPE_LIST *listoffloats_list,
+ const char *type)
{
LISTOFFLOATS_TYPE * result = find_float_type (listoffloats_list, type);
@@ -88,15 +90,15 @@ add_to_listoffloats_list (LISTOFFLOATS_TYPE_LIST
*listoffloats_list, char *type)
}
void
-float_list_to_listoffloats_list (FLOAT_RECORD_LIST *floats_list,
+float_list_to_listoffloats_list (const FLOAT_RECORD_LIST *floats_list,
LISTOFFLOATS_TYPE_LIST *result)
{
size_t i;
for (i = 0; i < floats_list->number; i++)
{
- FLOAT_RECORD *float_record = &floats_list->list[i];
- char *float_type = float_record->type;
+ const FLOAT_RECORD *float_record = &floats_list->list[i];
+ const char *float_type = float_record->type;
LISTOFFLOATS_TYPE *listoffloats_type
= add_to_listoffloats_list (result, float_type);
diff --git a/tp/Texinfo/XS/main/floats.h b/tp/Texinfo/XS/main/floats.h
index 2b417791d9..dd72d13466 100644
--- a/tp/Texinfo/XS/main/floats.h
+++ b/tp/Texinfo/XS/main/floats.h
@@ -20,10 +20,10 @@
#include "tree_types.h"
char *parse_float_type (ELEMENT *current);
-void float_list_to_listoffloats_list (FLOAT_RECORD_LIST *floats_list,
+void float_list_to_listoffloats_list (const FLOAT_RECORD_LIST *floats_list,
LISTOFFLOATS_TYPE_LIST *result);
void add_to_float_record_list (FLOAT_RECORD_LIST *float_records,
- char *type, ELEMENT *element);
+ const char *type, ELEMENT *element);
void free_listoffloats_list (LISTOFFLOATS_TYPE_LIST *listoffloats_list);
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index f439e37236..32b4ef51fa 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -150,7 +150,9 @@ parse_line_command_args (ELEMENT *line_command)
if (!isascii_alnum (*line))
goto alias_invalid;
+
existing = read_command_name (&line);
+
if (!existing)
goto alias_invalid;
@@ -712,7 +714,7 @@ end_line_def_line (ELEMENT *current)
{
if (def_info_name)
{
- char *t;
+ const char *t;
ELEMENT *arg = def_info_name->contents.list[0];
/* Set index_entry unless an empty ET_bracketed_arg. */
if (arg->type == ET_bracketed_arg
@@ -887,7 +889,7 @@ end_line_starting_block (ELEMENT *current)
KEY_PAIR *k;
if (command == CM_enumerate)
{
- char *spec = "1";
+ const char *spec = "1";
if (current->args.number > 0
&& current->args.list[0]->contents.number > 0)
@@ -1095,8 +1097,8 @@ end_line_starting_block (ELEMENT *current)
ELEMENT *arg_elt = current->args.list[0]->contents.list[0];
if (arg_elt->text.end > 0)
{
- char *name = arg_elt->text.text;
- char *p = name + strspn (name, whitespace_chars);
+ const char *p = arg_elt->text.text;
+ p += strspn (p, whitespace_chars);
if (!*p)
{
line_error ("@%s requires a name",
command_name(command));
@@ -1104,7 +1106,6 @@ end_line_starting_block (ELEMENT *current)
}
else
{
- const char *p = name;
char *flag = read_flag_name (&p);
if (flag && !*p)
{
@@ -1148,7 +1149,7 @@ end_line_starting_block (ELEMENT *current)
p = command_name(command) + 2; /* After "if". */
/* note that if a 2 letter format existed, like @ifme, the length of
- p should be checked before the call to memcpm */
+ p should be checked before the call to memcmp */
if (!memcmp (p, "not", 3))
p += 3; /* After "not". */
@@ -1360,9 +1361,8 @@ end_line_misc_line (ELEMENT *current)
}
else if (current->cmd == CM_documentencoding)
{
- int i; char *p, *normalized_text;
- int encoding_set;
- char *input_encoding = 0;
+ int i;
+ char *normalized_text;
int possible_encoding = 0;
normalized_text = normalize_encoding_name (text,
@@ -1373,17 +1373,20 @@ end_line_misc_line (ELEMENT *current)
text);
else
{
+ int encoding_set;
+ char *input_encoding = 0;
/* Warn if the encoding is not one of the encodings supported as an
argument to @documentencoding, documented in Texinfo manual */
{
- char *texinfo_encoding = 0;
- static char *canonical_encodings[] = {
+ static const char *canonical_encodings[] = {
"us-ascii", "utf-8", "iso-8859-1",
"iso-8859-15","iso-8859-2","koi8-r", "koi8-u",
0
};
+ const char *texinfo_encoding = 0;
char *text_lc;
+ char *p;
text_lc = strdup (text);
for (p = text_lc; *p; p++)
@@ -1418,7 +1421,7 @@ end_line_misc_line (ELEMENT *current)
/* the Perl Parser calls Encode::find_encoding, so knows
about more encodings than what we know about here.
*/
- static struct encoding_map map[] = {
+ static const struct encoding_map map[] = {
"utf-8", "utf-8",
"utf8", "utf-8",
"ascii", "us-ascii",
@@ -1475,7 +1478,7 @@ end_line_misc_line (ELEMENT *current)
}
else if (current->cmd == CM_documentlanguage)
{
- char *p, *q;
+ const char *p;
/* Texinfo::Common::warn_unknown_language checks with
tp/Texinfo/Documentlanguages.pm, which is an automatically
@@ -1496,26 +1499,27 @@ end_line_misc_line (ELEMENT *current)
if (p - text > 4)
{
/* looks too long */
- char saved = *p;
- *p = 0;
+ char *lang = strndup (text, p - text);
command_warn (current, "%s is not a valid language code",
- text);
- *p = saved;
+ lang);
+ free (lang);
}
if (*p == '_')
{
- q = p + 1;
- p = q;
+ const char *region_code;
+ p++;
+ region_code = p;
/* Language code should be of the form LL_CC,
language code followed by country code. */
while (isascii_alpha (*p))
p++;
- if (*p || p - q > 4)
+ if (*p || p - region_code > 4)
{
/* non-alphabetic char in country code or code
is too long. */
command_warn (current,
- "%s is not a valid region code", q);
+ "%s is not a valid region code",
+ region_code);
}
}
}
@@ -1529,24 +1533,27 @@ end_line_misc_line (ELEMENT *current)
}
if (superfluous_arg)
{
- char *texi_line, *p, *p1;
- p = convert_to_texinfo (args_child_by_index (current, 0));
+ const char *p;
+ char *p1;
+ char *texi_line
+ = convert_to_texinfo (args_child_by_index (current, 0));
- texi_line = p;
+ p = texi_line;
- texi_line += strspn (texi_line, whitespace_chars);
+ /* trim leading whitespace. */
+ p += strspn (p, whitespace_chars);
- /* Trim leading and trailing whitespace. */
- p1 = strchr (texi_line, '\0');
- if (p1 > texi_line)
+ /* Trim trailing whitespace. */
+ p1 = strchr (p, '\0');
+ if (p1 > p)
{
- while (p1 > texi_line && strchr (whitespace_chars, p1[-1]))
+ while (p1 > p && strchr (whitespace_chars, p1[-1]))
p1--;
*p1 = '\0';
}
command_error (current, "bad argument to @%s: %s",
- command_name(current->cmd), texi_line);
- free (p);
+ command_name(current->cmd), p);
+ free (texi_line);
}
}
else if (current->cmd == CM_node)
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index ef0873ae36..56a73dad21 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -1102,7 +1102,7 @@ store_parser_value (const char *name, const char *value)
}
void
-clear_value (char *name)
+clear_value (const char *name)
{
int i;
VALUE_LIST *values = &parser_values;
@@ -1134,7 +1134,7 @@ clear_value (char *name)
}
char *
-fetch_value (char *name)
+fetch_value (const char *name)
{
int i;
VALUE_LIST *values = &parser_values;
@@ -1166,7 +1166,7 @@ lookup_infoenclose (enum command_id cmd)
}
void
-add_infoenclose (enum command_id cmd, char *begin, char *end)
+add_infoenclose (enum command_id cmd, const char *begin, const char *end)
{
int i;
INFO_ENCLOSE *ie = 0;
diff --git a/tp/Texinfo/XS/parsetexi/macro.h b/tp/Texinfo/XS/parsetexi/macro.h
index c50a114516..eba5c366c4 100644
--- a/tp/Texinfo/XS/parsetexi/macro.h
+++ b/tp/Texinfo/XS/parsetexi/macro.h
@@ -45,13 +45,13 @@ MACRO *lookup_macro (enum command_id cmd);
void wipe_macros (void);
void store_value (VALUE_LIST *values, const char *name, const char *value);
-char *fetch_value (char *name);
-void clear_value (char *name);
+char *fetch_value (const char *name);
+void clear_value (const char *name);
void wipe_values (VALUE_LIST *values);
void init_values (void);
void store_parser_value (const char *name, const char *value);
INFO_ENCLOSE *lookup_infoenclose (enum command_id cmd);
-void add_infoenclose (enum command_id cmd, char *begin, char *end);
+void add_infoenclose (enum command_id cmd, const char *begin, const char *end);
#endif
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 1acb3adba8..c18bd7246b 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -489,7 +489,9 @@ int
parse_texi_document (void)
{
int document_descriptor;
- char *linep, *line = 0;
+ char *line = 0;
+ const char *linep;
+
ELEMENT *before_node_section = setup_document_root_and_before_node_section
();
ELEMENT *preamble_before_beginning = 0;
ELEMENT *document_root = before_node_section->parent;
@@ -1561,7 +1563,6 @@ process_remaining_on_line (ELEMENT **current_inout, const
char **line_inout)
e = new_element (ET_empty_line);
add_to_element_contents (current, e);
-
}
else
{
@@ -1741,7 +1742,7 @@ process_remaining_on_line (ELEMENT **current_inout, const
char **line_inout)
{
static char *allocated_line;
- line += (line_after_command - line);
+ line = line_after_command;
macro_call_element = handle_macro (current, &line, cmd);
if (macro_call_element)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Add const,
Patrice Dumas <=