perror - (was Re: redirecting output)

Peter da Silva peter at ficc.ferranti.com
Wed Jul 4 01:32:13 AEST 1990


In article <1792 at necisa.ho.necisa.oz> boyd at necisa.ho.necisa.oz (Boyd Roberts) writes:
> perror(3) is good, but this is better:

[ lots of code deleted ]

Yep, that's probably better than perror by itself. You should probably call
"sysmess" "strerror" and wrap it in a "#ifndef __STDC__" (or a macro derived
from __STDC__), but that's a nitpick supreme. But one thing:

> 	if ((my_name = strrchr(argv[0], '/')) == NULLSTR || *++my_name == '\0')
> 		my_name = argv[0];

First, this is needlessly obscure. Second, it modifies argv[0], which is not
ps-friendly on UNIX.

How about:

	my_name = strrchr(argv[0], '/');
	if(my_name)
		my_name++;
	else
		my_name = argv[0];
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.
<peter at ficc.ferranti.com>



More information about the Comp.lang.c mailing list