gbranden pushed a commit to branch master
in repository groff.
commit eafd8c2cfe8c753f36ab24bcbf37bbca1ace9c46
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 31 06:07:20 2026 -0500
[grn]: Fix -Wmissing-declarations warning. (1/2)
* src/preproc/grn/main.cpp (operand): Relocate definition to precede
function housing its only call site (`main()`). Define functions as
`static`; external linkage is not required.
(main): Drop now unnecessary function-local declaration of
`operand()`.
---
ChangeLog | 12 ++++++++++++
src/preproc/grn/main.cpp | 51 ++++++++++++++++++++++++------------------------
2 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ed9d09f84..6b7dcd0dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-05-31 G. Branden Robinson <[email protected]>
+
+ [grn]: Rearrange code.
+
+ * src/preproc/grn/main.cpp (operand): Relocate definition to
+ precede function housing its only call site (`main()`). Define
+ functions as `static`; external linkage is not required.
+ (main): Drop now unnecessary function-local declaration of
+ `operand()`.
+
+ Fixes `-Wmissing-declarations` GCC warning.
+
2026-05-31 G. Branden Robinson <[email protected]>
[eqn]: Fix code style nit.
diff --git a/src/preproc/grn/main.cpp b/src/preproc/grn/main.cpp
index c4143f9a1..7ad4f1082 100644
--- a/src/preproc/grn/main.cpp
+++ b/src/preproc/grn/main.cpp
@@ -302,6 +302,31 @@ add_file(char **file,
}
+/*--------------------------------------------------------------------*
+ | Routine: char * operand (& argc, & argv)
+ |
+ | Results: Returns address of the operand given with a command-line
+ | option. It uses either '-Xoperand' or '-X operand',
+ | whichever is present. The program is terminated if no
+ | option is present.
+ |
+ | Side Efct: argc and argv are updated as necessary.
+ *--------------------------------------------------------------------*/
+
+static char *
+operand(int *argcp,
+ char ***argvp)
+{
+ if ((**argvp)[2])
+ return (**argvp + 2); /* operand immediately follows */
+ if ((--*argcp) <= 0) { /* no operand */
+ error("command-line option operand missing.");
+ exit(8);
+ }
+ return (*(++(*argvp))); /* operand is next word */
+}
+
+
/*--------------------------------------------------------------------*
| Routine: main (argument_count, argument_pointer)
|
@@ -323,7 +348,6 @@ main(int argc,
int gfil = 0;
char **file = NULL;
int file_cur_size = INIT_FILE_SIZE;
- char *operand(int *argcp, char ***argvp);
file = (char **) grnmalloc(file_cur_size * sizeof(char *),
"file array");
@@ -410,31 +434,6 @@ main(int argc,
}
-/*--------------------------------------------------------------------*
- | Routine: char * operand (& argc, & argv)
- |
- | Results: Returns address of the operand given with a command-line
- | option. It uses either '-Xoperand' or '-X operand',
- | whichever is present. The program is terminated if no
- | option is present.
- |
- | Side Efct: argc and argv are updated as necessary.
- *--------------------------------------------------------------------*/
-
-char *
-operand(int *argcp,
- char ***argvp)
-{
- if ((**argvp)[2])
- return (**argvp + 2); /* operand immediately follows */
- if ((--*argcp) <= 0) { /* no operand */
- error("command-line option operand missing.");
- exit(8);
- }
- return (*(++(*argvp))); /* operand is next word */
-}
-
-
/*--------------------------------------------------------------------*
| Routine: getres ()
|
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit