gbranden pushed a commit to branch master
in repository groff.

commit 330e6de3cc50feb027b0df79d902af983be95e8b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 29 20:46:52 2026 -0500

    [libgroff]: Improve #include discipline (3/5).
    
    * src/libs/libgroff/strsave.cpp: Improve header file inclusion
      discipline.  Use preprocessor to include "lib.h" header, which
      declares the `strsave()` function defined here.
---
 ChangeLog                     | 6 ++++++
 src/include/lib.h             | 3 +++
 src/libs/libgroff/strsave.cpp | 9 +++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 984d09b94..13003eb17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-03-29  G. Branden Robinson <[email protected]>
+
+       * src/libs/libgroff/strsave.cpp: Improve header file
+       inclusion discipline.  Use preprocessor to include "lib.h"
+       header, which declares the `strsave()` function defined here.
+
 2026-03-29  G. Branden Robinson <[email protected]>
 
        * src/libs/libgroff/prime.cpp: Improve header file inclusion
diff --git a/src/include/lib.h b/src/include/lib.h
index 4c4b917ae..f58a57e6f 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -46,7 +46,10 @@ extern "C" {
 
 #include <stdbool.h>
 
+// libgroff/strsave.cpp
+// TODO: Migrate all callers to `strdup()`.  See Savannah #66518.
 char *strsave(const char *s);
+
 // libgroff/prime.cpp
 unsigned int ceil_prime(unsigned int);
 
diff --git a/src/libs/libgroff/strsave.cpp b/src/libs/libgroff/strsave.cpp
index ccf285c87..e8ac56104 100644
--- a/src/libs/libgroff/strsave.cpp
+++ b/src/libs/libgroff/strsave.cpp
@@ -17,12 +17,17 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
+// TODO: Migrate all callers to `strdup()`.  See Savannah #66518.
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#include <string.h>
-#include <stdlib.h>
+#include <string.h> // strlen()
+#include <stdlib.h> // malloc()
+
+// libgroff
+#include "lib.h" // strsave()
 
 char *strsave(const char *s)
 {

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to