[patch] rpcgen - fall back to looking for cpp in system path
Allan McRae
allan@archlinux.org
Thu Jul 26 02:18:00 GMT 2012
rpcgen currently looks for the C preprocessor in /lib/cpp and
/usr/ccs/lib/cpp. This patch allows it to fall back to looking for the
system cpp when neither of these are found.
2012-07-20 Allan McRae <allan@archlinux.org>
[BZ #14303]
* sunrpc/auth_des.c (find_cpp): Fall back to selecting system
cpp when no found in defined paths
* sunrpc/auth_des.c (open_input): Call cpp using execvp
diff --git a/sunrpc/rpc_main.c b/sunrpc/rpc_main.c
index 3096455..18bbe40 100644
--- a/sunrpc/rpc_main.c
+++ b/sunrpc/rpc_main.c
@@ -327,23 +327,21 @@ 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 ();
}
+
+ CPP = SVR4_CPP;
+ if (stat (CPP, &buf) == 0)
+ return;
+
+ /* fall back to system CPP */
+ CPP = "cpp";
}
/*
@@ -374,8 +372,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");
More information about the Libc-alpha
mailing list