Michael McConville <mm...@mykolab.com> writes:

> Jérémie Courrèges-Anglas wrote:
>> Tobias Stoeckmann <tob...@stoeckmann.org> writes:
>> 
>> > $ sed s/a/b/ /nofile
>> > sed: 0: /nofile: /nofile
>> >
>> > That message doesn't tell me a lot, let's better write
>> > strerror(errno) if fopen returns NULL:
>> >
>> > $ ./sed s/a/b/ /nofile
>> > sed: 0: /nofile: No such file or directory
>> 
>> That's much nicer, ok jca@
>> 
>> (misc.c:err() already prints the file name)
>
> Yikes. I was initially confused because err(3) automatically appends the
> errno. Then I realized that sed redefines err.
>
> As guenther@ (and/or millert@?) has been working on lately, redefining
> stdlib functions is risky. sed contains examples such as the pledge()
> calls in which the programmer definitely seems to think they're using
> err(3).
>
> It looks like it can be pretty easily replaced with calls to err(3),
> errx(3), warn(3), warnx(3), etc.

Not sure about this, you'd have to repeat the same code over and over to
print the line number and file name.

> However, it'd be easiest to rename the
> function to error() first.
>
> Thoughts?

Makes sense to me.

However, using "error" instead of "sed_err" would save you two
characters and avoid some of the >80 chars long lines introduced by your
diff.  Those should be fixed.

[...]

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to