summaryrefslogtreecommitdiff
path: root/sunrpc/rpc_main.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2012-08-04 12:19:09 +1000
committerMike Frysinger <vapier@gentoo.org>2012-08-07 19:17:02 -0400
commitbf9b740a119eecf01499b4de0dc8cbd27b7c47bd (patch)
tree977e1bf52b3bc0e1f8e0d77bd2797495422f7da8 /sunrpc/rpc_main.c
parent93df14eee81cf5514fe96e9143201a75d9391c7b (diff)
downloadglibc-bf9b740a119eecf01499b4de0dc8cbd27b7c47bd.tar.gz
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.
Diffstat (limited to 'sunrpc/rpc_main.c')
-rw-r--r--sunrpc/rpc_main.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/sunrpc/rpc_main.c b/sunrpc/rpc_main.c
index 06d951aa6a..2103b10d5f 100644
--- a/sunrpc/rpc_main.c
+++ b/sunrpc/rpc_main.c
@@ -75,12 +75,9 @@ struct commandline
static const char *cmdname;
-#define SVR4_CPP "/usr/ccs/lib/cpp"
-#define SUNOS_CPP "/lib/cpp"
-
static const char *svcclosetime = "120";
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 char *pathbuf;
static int cpp_pid;
@@ -327,23 +324,17 @@ find_cpp (void)
{
struct stat buf;
- if (stat (CPP, &buf) < 0)
- { /* /lib/cpp or explicit cpp does not exist */
- if (cppDefined)
- {
- fprintf (stderr, _ ("cannot find C preprocessor: %s \n"), CPP);
- crash ();
- }
- else
- { /* try the other one */
- CPP = SVR4_CPP;
- if (stat (CPP, &buf) < 0)
- { /* can't find any cpp */
- fputs (_ ("cannot find any C preprocessor (cpp)\n"), stdout);
- crash ();
- }
- }
+ if (stat (CPP, &buf) == 0)
+ return;
+
+ if (cppDefined) /* user specified cpp but it does not exist */
+ {
+ fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP);
+ crash ();
}
+
+ /* fall back to system CPP */
+ CPP = "cpp";
}
/*
@@ -374,8 +365,13 @@ open_input (const char *infile, const char *define)
close (1);
dup2 (pd[1], 1);
close (pd[0]);
- execv (arglist[0], (char **) arglist);
- perror ("execv");
+ execvp (arglist[0], (char **) arglist);
+ if (errno == ENOENT)
+ {
+ fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP);
+ exit (1);
+ }
+ perror ("execvp");
exit (1);
case -1:
perror ("fork");