gbranden pushed a commit to branch master
in repository groff.
commit ff164053a7fd9c23f87f56097db050e2f851f641
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon May 19 15:30:09 2025 -0500
[libgroff,pre-grohtml]: `const`-ify some `char *`s.
* src/include/lib.h (xtmpfile): Update declaration to add `const`
qualifier to `char **` argument `namep`.
* src/libs/libgroff/tmpfile.cpp (xtmpfile): Do the same for the
definition. This way C++ string literals can be passed to these
functions without provoking `-Wwrite-string` complaints from the
compiler.
* src/preproc/html/pre-html.cpp: Add `const` qualifier to `char *`
globals `psFileName`, `psPageName`, `regionFileName`, `imagePageName`,
`troffFileName`, and `htmlFileName`.
(generateImages): Add `const` qualifier to `char *` argument.
* src/preproc/html/pushback.h: Add `const` qualifier to `char *` private
member variable `fileName` and to argumentful constructor.
* src/preproc/html/pushback.cpp (pushBackBuffer::pushBackBuffer): Add
`const` qualifier to `char *` argument.
Longer-term, surely gnulib has a capable temporary file creation
function we can migrate to.
---
ChangeLog | 19 +++++++++++++++++++
src/include/lib.h | 4 ++--
src/libs/libgroff/tmpfile.cpp | 4 ++--
src/preproc/html/pre-html.cpp | 43 +++++++++++++++++++++++++------------------
src/preproc/html/pushback.cpp | 4 ++--
src/preproc/html/pushback.h | 13 ++++++++-----
6 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2ee753aae..cc3438647 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2025-05-19 G. Branden Robinson <[email protected]>
+
+ * src/include/lib.h (xtmpfile): Update declaration to add
+ `const` qualifier to `char **` argument `namep`.
+ * src/libs/libgroff/tmpfile.cpp (xtmpfile): Do the same for the
+ definition. This way C++ string literals can be passed to these
+ functions without provoking `-Wwrite-string` complaints from the
+ compiler.
+ * src/preproc/html/pre-html.cpp: Add `const` qualifier to `char
+ *` globals `psFileName`, `psPageName`, `regionFileName`,
+ `imagePageName`, `troffFileName`, and `htmlFileName`.
+ (generateImages): Add `const` qualifier to `char *` argument.
+ * src/preproc/html/pushback.h: Add `const` qualifier to `char *`
+ private member variable `fileName` and to argumentful
+ constructor.
+ * src/preproc/html/pushback.cpp
+ (pushBackBuffer::pushBackBuffer): Add `const` qualifier to `char
+ *` argument.
+
2025-05-19 G. Branden Robinson <[email protected]>
* src/preproc/html/pre-html.cpp (imageList::createImage)
diff --git a/src/include/lib.h b/src/include/lib.h
index a2de10cff..5e92e3f4d 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
Written by James Clark ([email protected])
This file is part of groff.
@@ -75,7 +75,7 @@ int mkstemp(char *tmpl);
int mksdir(char *tmpl);
#ifdef __cplusplus
- FILE *xtmpfile(char **namep = 0 /* nullptr */,
+ FILE *xtmpfile(const char **namep = 0 /* nullptr */,
const char *postfix_long = 0 /* nullptr */,
const char *postfix_short = 0 /* nullptr */);
char *xtmptemplate(const char *postfix_long,
diff --git a/src/libs/libgroff/tmpfile.cpp b/src/libs/libgroff/tmpfile.cpp
index 62118e981..eb1034821 100644
--- a/src/libs/libgroff/tmpfile.cpp
+++ b/src/libs/libgroff/tmpfile.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
Written by James Clark ([email protected])
This file is part of groff.
@@ -175,7 +175,7 @@ static void add_tmp_file(const char *name)
// Open a temporary file; any failure is fatal.
-FILE *xtmpfile(char **namep,
+FILE *xtmpfile(const char **namep,
const char *postfix_long, const char *postfix_short)
{
// `xtmptemplate()` allocates storage for `templ` with `new`.
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index b971502fc..69d98d506 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
* Written by Gaius Mulley ([email protected]).
*
* This file is part of groff.
@@ -190,16 +190,22 @@ static int postscriptRes = -1; // PostScript
resolution,
static int stdoutfd = 1; // output file descriptor -
// normally 1 but might move
// -1 means closed
-static char *psFileName = 0 /* nullptr */; // PostScript file name
-static char *psPageName = 0 /* nullptr */; // name of file
- // containing current
- // PostScript page
-static char *regionFileName = 0 /* nullptr */; // name of file
- // containing all image
- // regions
-static char *imagePageName = 0 /* nullptr */; // name of bitmap image
- // file containing
- // current page
+static const char *psFileName = 0 /* nullptr */; // PostScript
+ // file name
+static const char *psPageName = 0 /* nullptr */; // name of file
+ // containing
+ // current
+ // PostScript
+ // page
+static const char *regionFileName = 0 /* nullptr */; // name of file
+ // containing
+ // all image
+ // regions
+static const char *imagePageName = 0 /* nullptr */; // name of
+ // bitmap image
+ // file
+ // containing
+ // current page
static const char *image_device = "pnmraw";
static int image_res = DEFAULT_IMAGE_RES;
static int vertical_offset = 0;
@@ -219,13 +225,14 @@ static char *antiAlias = 0 /* nullptr */; // anti-alias
arguments
static bool want_progress_report = false; // display page numbers
// as they are processed
static int currentPageNo = -1; // current image page number
-#if defined(DEBUGGING)
static bool debugging = false;
-static char *troffFileName = 0 /* nullptr */; // pre-html output sent
- // to troff -Tps
-static char *htmlFileName = 0 /* nullptr */; // pre-html output sent
- // to troff -Thtml
-#endif
+static const char *troffFileName = 0 /* nullptr */; // pre-html
+ // output sent
+ // to troff -Tps
+static const char *htmlFileName = 0 /* nullptr */; // pre-html
+ // output sent
+ // to troff
+ // -Thtml
static bool need_eqn = false; // must we preprocess via eqn?
static char *linebuf = 0 /* nullptr */; // for scanning devps/DESC
@@ -1095,7 +1102,7 @@ static imageList listOfImages; // list of images
defined by region file
* x1,y1--x2,y2 extents of each image.
*/
-static void generateImages(char *region_file_name)
+static void generateImages(const char *region_file_name)
{
pushBackBuffer *f=new pushBackBuffer(region_file_name);
diff --git a/src/preproc/html/pushback.cpp b/src/preproc/html/pushback.cpp
index 6d2cecb48..ebd783993 100644
--- a/src/preproc/html/pushback.cpp
+++ b/src/preproc/html/pushback.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
Written by Gaius Mulley ([email protected]).
This file is part of groff.
@@ -56,7 +56,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
* constructor for pushBackBuffer
*/
-pushBackBuffer::pushBackBuffer (char *filename)
+pushBackBuffer::pushBackBuffer (const char *filename)
{
charStack = (char *)malloc(MAXPUSHBACKSTACK);
if (charStack == 0) {
diff --git a/src/preproc/html/pushback.h b/src/preproc/html/pushback.h
index 263a6c5e8..7015b5cb9 100644
--- a/src/preproc/html/pushback.h
+++ b/src/preproc/html/pushback.h
@@ -1,5 +1,4 @@
-// -*- C -*-
-/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
Written by Gaius Mulley ([email protected]).
This file is part of groff.
@@ -32,12 +31,12 @@ class pushBackBuffer
int stackPtr; /* index to push back stack */
int verbose;
int eofFound;
- char *fileName;
+ const char *fileName;
int lineNo;
int stdIn;
public:
- pushBackBuffer (char *);
+ pushBackBuffer (const char *);
~ pushBackBuffer ();
char getPB (void);
char putPB (char ch);
@@ -49,4 +48,8 @@ class pushBackBuffer
int isString (const char *string);
};
-
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit