gbranden pushed a commit to branch master
in repository groff.
commit 7d9d69c8d4e7531e38960cbef3483354a3ee70db
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jan 15 15:49:00 2025 -0600
[grohtml]: Fix code style nits.
* src/devices/grohtml/html-table.cpp (tabs::compatible, tabs::init):
* src/devices/grohtml/output.cpp (word::word):
* src/devices/grohtml/post-html.cpp (text_glob::get_arg)
(text_glob::get_tab_args, replace_negate_str)
(html_printer::do_job_name, html_printer::set_char_and_width)
(get_str): Spell null character using the C/C++ language literal for
expressing it, instead of C-casting `0` to `char`. Reorder equality
comparisons to avoid inadvertent lvalue assignment. Parenthesize
complex expressions.
---
ChangeLog | 15 +++++++++++++++
src/devices/grohtml/html-table.cpp | 22 +++++++++++-----------
src/devices/grohtml/output.cpp | 4 ++--
src/devices/grohtml/post-html.cpp | 28 ++++++++++++++--------------
4 files changed, 42 insertions(+), 27 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a26f6693d..45440b33f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-01-15 G. Branden Robinson <[email protected]>
+
+ [grohtml]: Fix code style nits.
+
+ * src/devices/grohtml/html-table.cpp (tabs::compatible)
+ (tabs::init):
+ * src/devices/grohtml/output.cpp (word::word):
+ * src/devices/grohtml/post-html.cpp (text_glob::get_arg)
+ (text_glob::get_tab_args, replace_negate_str)
+ (html_printer::do_job_name, html_printer::set_char_and_width)
+ (get_str): Spell null character using the C/C++ language literal
+ for expressing it, instead of C-casting `0` to `char`. Reorder
+ equality comparisons to avoid inadvertent lvalue assignment.
+ Parenthesize complex expressions.
+
2025-01-14 G. Branden Robinson <[email protected]>
* tmac/an.tmac (an*abbreviate-page-topic): (Actually, it's the
diff --git a/src/devices/grohtml/html-table.cpp
b/src/devices/grohtml/html-table.cpp
index b06341891..5d97c49b4 100644
--- a/src/devices/grohtml/html-table.cpp
+++ b/src/devices/grohtml/html-table.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2025 Free Software Foundation, Inc.
*
* Gaius Mulley ([email protected]) wrote html-table.cpp
*
@@ -95,24 +95,24 @@ int tabs::compatible (const char *s)
return FALSE; // no tab stops defined
// move over tag name
- while ((*s != (char)0) && !isspace(*s))
+ while ((*s != '\0') && !isspace(*s))
s++;
- while (*s != (char)0 && last != NULL) {
+ while (*s != '\0' && last != NULL) {
// move over whitespace
- while ((*s != (char)0) && isspace(*s))
+ while ((*s != '\0') && isspace(*s))
s++;
// collect alignment
align = *s;
// move over alignment
s++;
// move over whitespace
- while ((*s != (char)0) && isspace(*s))
+ while ((*s != '\0') && isspace(*s))
s++;
// collect tab position
total = atoi(s);
// move over tab position
- while ((*s != (char)0) && !isspace(*s))
+ while ((*s != '\0') && !isspace(*s))
s++;
if (last->alignment != align || last->position != total)
return FALSE;
@@ -135,24 +135,24 @@ void tabs::init (const char *s)
clear(); // remove any tab stops
// move over tag name
- while ((*s != (char)0) && !isspace(*s))
+ while ((*s != '\0') && !isspace(*s))
s++;
- while (*s != (char)0) {
+ while (*s != '\0') {
// move over whitespace
- while ((*s != (char)0) && isspace(*s))
+ while ((*s != '\0') && isspace(*s))
s++;
// collect alignment
align = *s;
// move over alignment
s++;
// move over whitespace
- while ((*s != (char)0) && isspace(*s))
+ while ((*s != '\0') && isspace(*s))
s++;
// collect tab position
total = atoi(s);
// move over tab position
- while ((*s != (char)0) && !isspace(*s))
+ while ((*s != '\0') && !isspace(*s))
s++;
if (last == NULL) {
tab = new tab_position;
diff --git a/src/devices/grohtml/output.cpp b/src/devices/grohtml/output.cpp
index d524a4a9f..773a75ccc 100644
--- a/src/devices/grohtml/output.cpp
+++ b/src/devices/grohtml/output.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
*
* Gaius Mulley ([email protected]) wrote output.cpp
* but it owes a huge amount of ideas and raw code from
@@ -66,7 +66,7 @@ word::word (const char *w, int n)
{
s = new char[n+1];
strncpy(s, w, n);
- s[n] = (char)0;
+ s[n] = '\0';
}
/*
diff --git a/src/devices/grohtml/post-html.cpp
b/src/devices/grohtml/post-html.cpp
index f5ffb1956..18594efa4 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
*
* Gaius Mulley ([email protected]) wrote post-html.cpp
* but it owes a huge amount of ideas and raw code from
@@ -892,11 +892,11 @@ int text_glob::get_arg (void)
if (strncmp("devtag:", text_string, strlen("devtag:")) == 0) {
const char *p = text_string;
- while ((*p != (char)0) && (!isspace(*p)))
+ while ((*p != '\0') && (!isspace(*p)))
p++;
- while ((*p != (char)0) && (isspace(*p)))
+ while ((*p != '\0') && (isspace(*p)))
p++;
- if (*p == (char)0)
+ if ('\0' == *p)
return -1;
return atoi(p);
}
@@ -913,17 +913,17 @@ int text_glob::get_tab_args (char *align)
const char *p = text_string;
// firstly the alignment C|R|L
- while ((*p != (char)0) && (!isspace(*p)))
+ while ((*p != '\0') && (!isspace(*p)))
p++;
- while ((*p != (char)0) && (isspace(*p)))
+ while ((*p != '\0') && (isspace(*p)))
p++;
*align = *p;
// now the int value
- while ((*p != (char)0) && (!isspace(*p)))
+ while ((*p != '\0') && (!isspace(*p)))
p++;
- while ((*p != (char)0) && (isspace(*p)))
+ while ((*p != '\0') && (isspace(*p)))
p++;
- if (*p == (char)0)
+ if ('\0' == *p)
return -1;
return atoi(p);
}
@@ -1874,7 +1874,7 @@ const char *replace_negate_str (const char *before, char
*after)
after[0] = '1';
else
after[0] = '0';
- after[1] = (char)0;
+ after[1] = '\0';
}
return after;
}
@@ -3092,7 +3092,7 @@ void html_printer::do_job_name (char *name)
{
if (! multiple_files) {
multiple_files = TRUE;
- while (name != 0 && (*name != (char)0) && (*name == ' '))
+ while (name != 0 && (*name != '\0') && (*name == ' '))
name++;
job_name = name;
}
@@ -4896,7 +4896,7 @@ glyph *html_printer::set_char_and_width(const char *nm,
return UNDEFINED_GLYPH;
}
if (!(*f)->contains(g)) {
- if (nm[0] != '\0' && nm[1] == '\0')
+ if ((nm[0] != '\0') && ('\0' == nm[1]))
error("font '%1' does not contain ordinary character '%2'",
(*f)->get_name(), nm[0]);
else
@@ -5314,12 +5314,12 @@ static char *get_str (const char *s, char **n)
int i = 0;
char *v;
- while ((s[i] != (char)0) && (s[i] != ',') && (s[i] != ']'))
+ while ((s[i] != '\0') && (s[i] != ',') && (s[i] != ']'))
i++;
if (i>0) {
v = new char[i+1];
memcpy(v, s, i+1);
- v[i] = (char)0;
+ v[i] = '\0';
if (s[i] == ',')
(*n) = (char *)&s[i+1];
else
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit