delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/02/27/10:13:51

X-Sybari-Space: 00000000 00000000 00000000 00000000
From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200302271513.QAA12423@lws256.lu.erisoft.se>
Subject: Re: perror
To: djgpp-workers AT delorie DOT com
Date: Thu, 27 Feb 2003 16:13:47 +0100 (MET)
In-Reply-To: <20030227150458.GA3476@kendall.sfbr.org> from "JT Williams" at Feb 27, 2003 09:04:58 AM
X-Mailer: ELM [version 2.5 PL3]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Hello.

JT said:
> I happened to see this in the Solaris man page for `errno':
> 
>      The perror() function produces a  message  on  the  standard
>      error  output.... 
>      The  argument string s is printed, followed by a colon and a
>      blank, followed by the message and a NEWLINE character.   If
>      s is a null pointer or points to a null string, the colon is
>      not printed.
> 
> So perhaps this patch to our perror.c is in order?  (The manpage says
> only that the colon is not printed; should the blank still be printed?)
> 
> --- perror.orig 1994-12-10 21:52:02.000000000 -0600
> +++ perror.c    2003-02-27 08:58:59.960438000 -0600
> @@ -6,5 +6,8 @@
>  void
>  perror(const char *s)
>  {
> -  fprintf(stderr, "%s: %s\n", s, strerror(errno));
> +  if (s)
> +    fprintf(stderr, "%s: %s\n", s, strerror(errno));
> +  else
> +    fprintf(stderr, "%s\n", s, strerror(errno));
>  }

Besides that silly error keeping s in that last fprintf() call, you
don't handle the case that s == "".

You'll need to update the info page as well.


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019