face2ps

Eric Roskos roskos at IDA.ORG
Wed Aug 2 23:29:36 AEST 1989


> it dumps core on a Sun

That's because the person who wrote it, alas, is suffering from a
DOS-induced coding disorder.  He assumes that when you invoke it,
argv[0] contains slashes in it, since that's what DOS does (it puts the
full path name in there and you have to take it off yourself), and if it
doesn't, he doesn't detect the NULL coming back from strrchr properly. 
Notice he remembered that Unix uses forward slashes instead of backwards
slashes, but forgot that it doesn't always stick in the full path name
for argv[0] the way DOS (or, more accurately, that C compiler) does. 

The corrected code segment for the Sun should look like this (I compiled under
gcc to avoid having to remove the ANSI additions):

main(argc,argv)
int argc;
char *argv[];
{
        int option;                     /* the option letter */
 
#ifdef __MSDOS__
        char *progend;
        program = max(strrchr(argv[0], '\\'),strrchr(argv[0], '/'));
        progend = strchr(program, '.');
        if (progend)
                *progend = '\0';
#else
        program = strrchr(argv[0], '/');
        if (program == NULL)
                program = argv[0];
        else
#endif
        program++;
-- 
Eric Roskos (roskos at CS.IDA.ORG or Roskos at DOCKMASTER.NCSC.MIL)
-- 
Eric Roskos (roskos at CS.IDA.ORG or Roskos at DOCKMASTER.NCSC.MIL)



More information about the Alt.sources.d mailing list