Re: Use `strsave()`, not `strdup()`.

2021-11-14 Thread James K. Lowden
On Tue, 9 Nov 2021 20:17:56 +1100 "G. Branden Robinson" wrote: > We can either: > * Use a nonstandard allocator; or > * Handle exceptions. Hi Brandon, If it's C++, you have only one choice: handle exceptions. Otherwise, you're using so little of the language that you might as well use C.

Re: Use `strsave()`, not `strdup()`.

2021-11-09 Thread Ralph Corderoy
Hi Branden, > Stroustrup bangs the exception drum pretty hard in Chapter 14 of the > special edition of _The C++ Programming Language_ Groff's source was a light-touch use of C++, more C with Classes, AIUI, but even so it was enough to deter contributors who knew to avoid the language and the

Re: Use `strsave()`, not `strdup()`.

2021-11-09 Thread Ralph Corderoy
Hi Ingo, > Actually, just exit(1) is better than abort(). The abort() facility > is intended for catching violations of invariants (i.e., catching > bugs). abort(3)'s only intention is to terminate the program abnormally with dumping core by default to aid investigation. When to do that is

Re: Use `strsave()`, not `strdup()`.

2021-11-09 Thread G. Branden Robinson
[Sorry, Ralph--it's another doorstop of a message. If it's any consolation, I tried to ensure that all 10 external references were authoritative.] Hi, Ingo! At 2021-11-08T01:28:19+0100, Ingo Schwarze wrote: > Not so for me; i learned C with a Microsoft Visual Studio compiler > in the late

[groff] 01/19: Revert "[libgroff, pic]: Use `strsave()`, not `strdup()`."

2021-11-08 Thread G. Branden Robinson
gbranden pushed a commit to branch master in repository groff. commit f635b2c052dccffa53804ee7506fd42fde619d90 Author: G. Branden Robinson AuthorDate: Mon Nov 8 07:09:44 2021 +1100 Revert "[libgroff,pic]: Use `strsave()`, not `strdup()`." This reve

Re: Use `strsave()`, not `strdup()`.

2021-11-08 Thread Ingo Schwarze
Hi Ralph, i agree with (almost) all you are saying in this mail. Ralph Corderoy wrote on Mon, Nov 08, 2021 at 02:05:00PM +: > Ingo Schwarze wrote: >> 3. Using your own replacement functions for Standard C and/or >> POSIX functions is a bad idea because: >> >> 3.1. It makes the code

Re: Use `strsave()`, not `strdup()`.

2021-11-08 Thread Ralph Corderoy
I wrote: > glyph.c:42:estrdup failed: 31415 'foo bar xyzzy...' I forgot progname, i.e. the basename of argv[0]. troff:glyph.c:42:estrdup failed: 31415 'foo bar xyzzy...' -- Cheers, Ralph.

Re: Use `strsave()`, not `strdup()`.

2021-11-08 Thread Ralph Corderoy
Hi Ingo, > If the intention of strsave() was to replace strdup(), then the > correct implementation would have been > > size_t sz = strlen(s) + 1; > char *p = malloc(sz); > if (p != NULL) > memcpy(p, s, sz); > return p: An estrdup() would be: if (!s)

Re: Use `strsave()`, not `strdup()`.

2021-11-08 Thread Ralph Corderoy
Hi Ingo, > 3. Using your own replacement functions for Standard C and/or > POSIX functions is a bad idea because: > > 3.1. It makes the code harder to read and audit for experienced > programmers. Instead of being able to use their knowledge > of standards, they have to figure

Re: Use `strsave()`, not `strdup()`.

2021-11-07 Thread Ingo Schwarze
Hi Brandon, thanks for your nice reply; i'm snipping what i agree with. G. Branden Robinson wrote on Mon, Nov 08, 2021 at 06:55:55AM +1100: > The Linux man-pages version of the strdup(3) page did not have a history > as extensive as yours. The function has been available in every C >

Re: Use `strsave()`, not `strdup()`.

2021-11-07 Thread G. Branden Robinson
Hi Ingo, At 2021-11-07T14:57:28+0100, Ingo Schwarze wrote: > > [libgroff,pic]: Use `strsave()`, not `strdup()`. > > That's a bad idea. > The opposite should be done, see below for multiple reasons. [...] > So even though strdup(3) was invented for BSD in 1982, it wasn't &g

Re: Use `strsave()`, not `strdup()`.

2021-11-07 Thread Ingo Schwarze
> > [libgroff,pic]: Use `strsave()`, not `strdup()`. That's a bad idea. The opposite should be done, see below for multiple reasons. > * src/libs/libgroff/font.cpp (font::load_desc): Do it. Also emit > shorter diagnostic if `strsave()` returned a null pointer. >

[groff] 03/03: [libgroff,pic]: Use `strsave()`, not `strdup()`.

2021-11-07 Thread G. Branden Robinson
gbranden pushed a commit to branch master in repository groff. commit 5b7fee5d6392edf90dc1f0fa7d013f36fea5964c Author: G. Branden Robinson AuthorDate: Sun Nov 7 09:40:14 2021 +1100 [libgroff,pic]: Use `strsave()`, not `strdup()`. * src/libs/libgroff/font.cpp (font::load_desc): Do