[gnu.gcc.bug] bug in cccp

lgondor@csri.toronto.edu (Les Gondor) (11/09/88)

Small bug in cccp: the preprocessor exits with a fatal error when
given no output file argument (as when invoked by gcc -E or gcc -M).

Version: gcc version 1.30

Test input: any file at all (gcc's version.c is sufficient).

Test invocation:

nex% gcc -v -E version.c
gcc version 1.30
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dvax -Dunix version.c
GNU CPP version 1.30
cpp: Is a directory for `'
nex% ls -l tm.h config.h aux-output.c md
lrwxr-xr-x  1 les            12 Oct 28 16:31 aux-output.c -> output-vax.c
lrwxr-xr-x  1 les            12 Oct 28 16:32 config.h -> config-vax.h
lrwxr-xr-x  1 les             6 Oct 28 16:27 md -> vax.md
lrwxr-xr-x  1 les             8 Oct 28 16:30 tm.h -> tm-vax.h
nex% 

Host description: VAX 11/750 running 4.3 BSD

Suggested fix: patch cccp.c as below

*** cccp.c~	Fri Oct 28 10:17:56 1988
--- cccp.c	Mon Nov  7 10:40:25 1988
***************
*** 967,973 ****
  
    /* Now that we know the input file is valid, open the output.  */
  
!   if (out_fname && !strcmp (out_fname, ""))
      out_fname = "stdout";
    else if (! freopen (out_fname, "w", stdout))
      pfatal_with_name (out_fname);
--- 967,973 ----
  
    /* Now that we know the input file is valid, open the output.  */
  
!   if (out_fname == NULL || (out_fname && !strcmp (out_fname, "")))
      out_fname = "stdout";
    else if (! freopen (out_fname, "w", stdout))
      pfatal_with_name (out_fname);

-- 
Les Gondor, Trigraph Inc.	"Why not just do it by knife?"
{uunet!ai.toronto.edu!utcsri, decvax!utzoo}!trigraph!les
DOMAIN: lgondor@csri.toronto.edu
Canada Post: 5 Lower Sherbourne St., Toronto, Ontario, CANADA, M5A 2P3
Phone: (416) 363-8841