[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/convert_to_text.c (ascii_acc
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/convert_to_text.c (ascii_accent) (ascii_accents_internal), tp/Texinfo/XS/main/unicode.c (unicode_accent, format_eight_bit_accents_stack) (format_unicode_accents_stack_internal, encoded_accents), tp/Texinfo/XS/main/utils.c (normalize_encoding_name): make some variables const to make sure that the accent formatting function do not modify their associated elements, texts or accent commands lists. |
Date: |
Sun, 12 Nov 2023 12:39:11 -0500 |
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 b2aa59ec4d * tp/Texinfo/XS/main/convert_to_text.c (ascii_accent)
(ascii_accents_internal), tp/Texinfo/XS/main/unicode.c (unicode_accent,
format_eight_bit_accents_stack) (format_unicode_accents_stack_internal,
encoded_accents), tp/Texinfo/XS/main/utils.c (normalize_encoding_name): make
some variables const to make sure that the accent formatting function do not
modify their associated elements, texts or accent commands lists.
b2aa59ec4d is described below
commit b2aa59ec4dfe92cbdb437c43817d58ecabc1a285
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 12 18:39:05 2023 +0100
* tp/Texinfo/XS/main/convert_to_text.c (ascii_accent)
(ascii_accents_internal), tp/Texinfo/XS/main/unicode.c
(unicode_accent, format_eight_bit_accents_stack)
(format_unicode_accents_stack_internal, encoded_accents),
tp/Texinfo/XS/main/utils.c (normalize_encoding_name): make some
variables const to make sure that the accent formatting function do
not modify their associated elements, texts or accent commands lists.
---
ChangeLog | 10 ++++++++++
tp/Texinfo/XS/main/convert_to_text.c | 9 +++++----
tp/Texinfo/XS/main/unicode.c | 24 +++++++++++++-----------
tp/Texinfo/XS/main/unicode.h | 7 ++++---
tp/Texinfo/XS/main/utils.c | 4 ++--
tp/Texinfo/XS/main/utils.h | 2 +-
6 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0a4b610e32..424bc3c6af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-11-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/convert_to_text.c (ascii_accent)
+ (ascii_accents_internal), tp/Texinfo/XS/main/unicode.c
+ (unicode_accent, format_eight_bit_accents_stack)
+ (format_unicode_accents_stack_internal, encoded_accents),
+ tp/Texinfo/XS/main/utils.c (normalize_encoding_name): make some
+ variables const to make sure that the accent formatting function do
+ not modify their associated elements, texts or accent commands lists.
+
2023-11-12 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/convert_to_text.c (ascii_accent)
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index e0cc675868..1870c40d17 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -43,9 +43,9 @@
#include "cmd_text.c"
char *
-ascii_accent (char *text, ELEMENT *command, int set_case)
+ascii_accent (const char *text, const ELEMENT *command, int set_case)
{
- enum command_id cmd = command->cmd;
+ const enum command_id cmd = command->cmd;
TEXT accent_text;
text_init (&accent_text);
@@ -81,7 +81,8 @@ ascii_accent (char *text, ELEMENT *command, int set_case)
}
char *
-ascii_accents_internal (char *text, ELEMENT_LIST *stack, int set_case)
+ascii_accents_internal (const char *text, const ELEMENT_LIST *stack,
+ int set_case)
{
char *result;
int i;
@@ -93,7 +94,7 @@ ascii_accents_internal (char *text, ELEMENT_LIST *stack, int
set_case)
for (i = stack->number - 1; i >= 0; i--)
{
- ELEMENT *accent_command = stack->list[i];
+ const ELEMENT *accent_command = stack->list[i];
char *formatted_accent = ascii_accent (result, accent_command, set_case);
free (result);
result = formatted_accent;
diff --git a/tp/Texinfo/XS/main/unicode.c b/tp/Texinfo/XS/main/unicode.c
index ff02bb9d2c..b6eb061586 100644
--- a/tp/Texinfo/XS/main/unicode.c
+++ b/tp/Texinfo/XS/main/unicode.c
@@ -76,7 +76,7 @@ normalize_NFKD (const char *text)
}
char *
-unicode_accent (const char *text, ELEMENT *e)
+unicode_accent (const char *text, const ELEMENT *e)
{
char *result = 0;
@@ -172,16 +172,16 @@ compare_strings (const void *a, const void *b)
}
char *
-format_eight_bit_accents_stack (char *text, ELEMENT_LIST *stack,
+format_eight_bit_accents_stack (const char *text, const ELEMENT_LIST *stack,
int encoding_index,
- char *(*format_accent)(char *text, ELEMENT *element, int set_case),
+ char *(*format_accent)(const char *text, const ELEMENT *element, int
set_case),
int set_case)
{
int i, j, k;
char *result = strdup (text);
char *prev_eight_bit;
char *new_eight_bit;
- int stack_nr = stack->number;
+ int const stack_nr = stack->number;
char **results_stack
= malloc ((stack_nr +1) * sizeof (char *));
@@ -191,7 +191,7 @@ format_eight_bit_accents_stack (char *text, ELEMENT_LIST
*stack,
for (i = stack_nr -1; i >= 0; i--)
{
- ELEMENT *accent_command = stack->list[i];
+ const ELEMENT *accent_command = stack->list[i];
results_stack[i] = unicode_accent (results_stack[i+1],
accent_command);
if (!results_stack[i])
@@ -308,8 +308,9 @@ format_eight_bit_accents_stack (char *text, ELEMENT_LIST
*stack,
/* FIXME converter in perl for (*format_accent), see encoded_accents comment*/
char *
-format_unicode_accents_stack_internal (char *text, ELEMENT_LIST *stack,
- char *(*format_accent)(char *text, ELEMENT *element, int set_case),
+format_unicode_accents_stack_internal (const char *text,
+ const ELEMENT_LIST *stack,
+ char *(*format_accent)(const char *text, const ELEMENT *element, int
set_case),
int set_case)
{
int i;
@@ -317,7 +318,7 @@ format_unicode_accents_stack_internal (char *text,
ELEMENT_LIST *stack,
for (i = stack->number - 1; i >= 0; i--)
{
- ELEMENT *accent_command = stack->list[i];
+ const ELEMENT *accent_command = stack->list[i];
char *formatted_result = unicode_accent (result, accent_command);
if (formatted_result)
{
@@ -337,7 +338,7 @@ format_unicode_accents_stack_internal (char *text,
ELEMENT_LIST *stack,
for (; i >= 0; i--)
{
- ELEMENT *accent_command = stack->list[i];
+ const ELEMENT *accent_command = stack->list[i];
char *formatted_result
= (*format_accent) (result, accent_command, set_case);
free (result);
@@ -350,8 +351,9 @@ format_unicode_accents_stack_internal (char *text,
ELEMENT_LIST *stack,
directly and through functions. It is not clear whether it is
actually used in perl, nor if it could be useful in C */
char *
-encoded_accents (char *text, ELEMENT_LIST *stack, char *encoding,
- char *(*format_accent)(char *text, ELEMENT *element, int set_case),
+encoded_accents (const char *text, const ELEMENT_LIST *stack,
+ const char *encoding,
+ char *(*format_accent)(const char *text, const ELEMENT *element, int
set_case),
int set_case)
{
if (encoding)
diff --git a/tp/Texinfo/XS/main/unicode.h b/tp/Texinfo/XS/main/unicode.h
index 85d67d5ec8..b5f7f28bfd 100644
--- a/tp/Texinfo/XS/main/unicode.h
+++ b/tp/Texinfo/XS/main/unicode.h
@@ -23,10 +23,11 @@ extern COMMAND_UNICODE
unicode_character_brace_no_arg_commands[];
char *normalize_NFC (const char *text);
char *normalize_NFKD (const char *text);
-char *unicode_accent (const char *text, ELEMENT *e);
+char *unicode_accent (const char *text, const ELEMENT *e);
-char *encoded_accents (char *text, ELEMENT_LIST *stack, char *encoding,
- char *(*format_accent)(char *text, ELEMENT *element, int set_case),
+char *encoded_accents (const char *text, const ELEMENT_LIST *stack,
+ const char *encoding,
+ char *(*format_accent)(const char *text, const ELEMENT *element, int
set_case),
int set_case);
char *unicode_brace_no_arg_command (enum command_id cmd, char *encoding);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 8f066380a8..e86fddc63c 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -676,9 +676,9 @@ parse_line_directive (char *line, int *retval, int
*out_line_no)
/* return should be freed by the caller */
char *
-normalize_encoding_name (char *text, int *possible_encoding)
+normalize_encoding_name (const char *text, int *possible_encoding)
{
- char *p;
+ const char *p;
char *normalized_text = strdup (text);
char *q = normalized_text;
*possible_encoding = 0;
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 15eb8fc03a..c695cdcef2 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -226,7 +226,7 @@ int width_multibyte (const char *text);
void delete_global_info (GLOBAL_INFO *global_info_ref);
void delete_global_commands (GLOBAL_COMMANDS *global_commands_ref);
-char *normalize_encoding_name (char *text, int *possible_encoding);
+char *normalize_encoding_name (const char *text, int *possible_encoding);
ELEMENT *item_line_parent (ELEMENT *current);
ELEMENT *get_label_element (ELEMENT *e);
INDEX *indices_info_index_by_name (INDEX **indices_information, char *name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/convert_to_text.c (ascii_accent) (ascii_accents_internal), tp/Texinfo/XS/main/unicode.c (unicode_accent, format_eight_bit_accents_stack) (format_unicode_accents_stack_internal, encoded_accents), tp/Texinfo/XS/main/utils.c (normalize_encoding_name): make some variables const to make sure that the accent formatting function do not modify their associated elements, texts or accent commands lists.,
Patrice Dumas <=