gbranden pushed a commit to branch master in repository groff. commit f635b2c052dccffa53804ee7506fd42fde619d90 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Mon Nov 8 07:09:44 2021 +1100
Revert "[libgroff,pic]: Use `strsave()`, not `strdup()`." This reverts commit 5b7fee5d6392edf90dc1f0fa7d013f36fea5964c. Ingo Schwarze observed[1] that we should be migrating away from this strdup() replacement, not entrenching it. [1] https://lists.gnu.org/archive/html/groff/2021-11/msg00039.html --- ChangeLog | 8 -------- src/libs/libgroff/font.cpp | 11 +++-------- src/preproc/pic/troff.cpp | 2 +- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index f349e1e..9758a40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,5 @@ 2021-11-07 G. Branden Robinson <g.branden.robin...@gmail.com> - [libgroff,pic]: Use `strsave()`, not `strdup()`. - - * src/libs/libgroff/font.cpp (font::load_desc): Do it. Also - emit shorter diagnostic if `strsave()` returned a null pointer. - * src/preproc/pic/troff.cpp (troff_output::set_location): Do it. - -2021-11-07 G. Branden Robinson <g.branden.robin...@gmail.com> - * src/libs/libgroff/fontfile.cpp (font::open_file): Don't open user-specified font file names with slashes in them; i.e., don't traverse directories outside the configured font path. Also diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp index b7960b7..2168afa 100644 --- a/src/libs/libgroff/font.cpp +++ b/src/libs/libgroff/font.cpp @@ -1144,7 +1144,7 @@ bool font::load_desc() return false; } bool found_paper = false; - char *savedp = strsave(p); + char *savedp = strdup(p); while (p) { double unscaled_paperwidth, unscaled_paperlength; if (scan_papersize(p, &papersize, &unscaled_paperlength, @@ -1157,13 +1157,8 @@ bool font::load_desc() p = strtok(0, WS); } if (!found_paper) { - if (0 == savedp) - t.error("unable to determine a paper format"); - else { - t.error("unable to determine a paper format from '%1'", - savedp); - free(savedp); - } + t.error("unable to determine a paper format from '%1'", savedp); + free(savedp); return false; } free(savedp); diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp index 810067a..3ccd681 100644 --- a/src/preproc/pic/troff.cpp +++ b/src/preproc/pic/troff.cpp @@ -560,7 +560,7 @@ void troff_output::set_location(const char *s, int n) printf(".lf %d\n", n); else { printf(".lf %d %s\n", n, s); - last_filename = strsave(s); + last_filename = strdup(s); } } _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit