rpcgen - fall back to looking for cpp in system path

Fall back to the system cpp when /lib/cpp is not present. Removes
searching for /usr/ccs/lib/cpp which is not supported on any system that
uses glibc.
This commit is contained in:
Allan McRae 2012-08-04 12:19:09 +10:00 committed by Mike Frysinger
parent 93df14eee8
commit bf9b740a11
2 changed files with 27 additions and 22 deletions

View File

@ -1,3 +1,12 @@
2012-08-07 Allan McRae <allan@archlinux.org>
[BZ #14303]
* sunrpc/rpc_main.c (SVR4_CPP): Remove.
(SUNOS_CPP): Likewise.
(find_cpp): Fall back to selecting system cpp when /lib/cpp is
not found.
(open_input): Call CPP using execvp.
2012-08-07 Joseph Myers <joseph@codesourcery.com> 2012-08-07 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/kernel-features.h * sysdeps/unix/sysv/linux/kernel-features.h

View File

@ -75,12 +75,9 @@ struct commandline
static const char *cmdname; static const char *cmdname;
#define SVR4_CPP "/usr/ccs/lib/cpp"
#define SUNOS_CPP "/lib/cpp"
static const char *svcclosetime = "120"; static const char *svcclosetime = "120";
static int cppDefined; /* explicit path for C preprocessor */ static int cppDefined; /* explicit path for C preprocessor */
static const char *CPP = SUNOS_CPP; static const char *CPP = "/lib/cpp";
static const char CPPFLAGS[] = "-C"; static const char CPPFLAGS[] = "-C";
static char *pathbuf; static char *pathbuf;
static int cpp_pid; static int cpp_pid;
@ -327,23 +324,17 @@ find_cpp (void)
{ {
struct stat buf; struct stat buf;
if (stat (CPP, &buf) < 0) if (stat (CPP, &buf) == 0)
{ /* /lib/cpp or explicit cpp does not exist */ return;
if (cppDefined)
if (cppDefined) /* user specified cpp but it does not exist */
{ {
fprintf (stderr, _ ("cannot find C preprocessor: %s \n"), CPP); fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP);
crash (); crash ();
} }
else
{ /* try the other one */ /* fall back to system CPP */
CPP = SVR4_CPP; CPP = "cpp";
if (stat (CPP, &buf) < 0)
{ /* can't find any cpp */
fputs (_ ("cannot find any C preprocessor (cpp)\n"), stdout);
crash ();
}
}
}
} }
/* /*
@ -374,8 +365,13 @@ open_input (const char *infile, const char *define)
close (1); close (1);
dup2 (pd[1], 1); dup2 (pd[1], 1);
close (pd[0]); close (pd[0]);
execv (arglist[0], (char **) arglist); execvp (arglist[0], (char **) arglist);
perror ("execv"); if (errno == ENOENT)
{
fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP);
exit (1);
}
perror ("execvp");
exit (1); exit (1);
case -1: case -1:
perror ("fork"); perror ("fork");