summaryrefslogtreecommitdiffstats
path: root/tools/rpcgen/rpc_main.c
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2003-03-30 08:00:39 +0000
committerneilbrown <neilbrown>2003-03-30 08:00:39 +0000
commitcda9a6c6f9a4c0105956ba2595bb62b14f865739 (patch)
tree91317a908e6cb5c56a001fbfaf450725d6356777 /tools/rpcgen/rpc_main.c
parent1b4c3a6d7972b86fee563d0b22b32eda8b0afcf9 (diff)
downloadnfs-utils-cda9a6c6f9a4c0105956ba2595bb62b14f865739.tar.gz
nfs-utils-cda9a6c6f9a4c0105956ba2595bb62b14f865739.tar.xz
nfs-utils-cda9a6c6f9a4c0105956ba2595bb62b14f865739.zip
use execvp for finding cpp in rpcgen
Diffstat (limited to 'tools/rpcgen/rpc_main.c')
-rw-r--r--tools/rpcgen/rpc_main.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/tools/rpcgen/rpc_main.c b/tools/rpcgen/rpc_main.c
index 39b667e..2651060 100644
--- a/tools/rpcgen/rpc_main.c
+++ b/tools/rpcgen/rpc_main.c
@@ -45,6 +45,7 @@ static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
+#include <errno.h>
#include "rpc_parse.h"
#include "rpc_util.h"
#include "rpc_scan.h"
@@ -67,7 +68,6 @@ static char * extendfile(char *file, char *ext);
static void open_output(char *infile, char *outfile);
static void add_warning(void);
static void clear_args(void);
-static void find_cpp(void);
static void open_input(char *infile, char *define);
static int check_nettype(char *name, char **list_to_check);
static void c_output(char *infile, char *define, int extend, char *outfile);
@@ -293,26 +293,6 @@ clear_args(void)
argcount = FIXEDARGS;
}
-/* make sure that a CPP exists */
-static void
-find_cpp(void)
-{
- struct stat buf;
-
- if (stat(CPP, &buf) < 0) { /* SVR4 or explicit cpp does not exist */
- if (cppDefined) {
- fprintf(stderr, "cannot find C preprocessor: %s \n", CPP);
- crash();
- } else { /* try the other one */
- CPP = SUNOS_CPP;
- if (stat(CPP, &buf) < 0) { /* can't find any cpp */
- fprintf(stderr, "cannot find any C preprocessor (cpp)\n");
- crash();
- }
- }
- }
-}
-
/*
* Open input file with given define for C-preprocessor
*/
@@ -325,8 +305,7 @@ open_input(char *infile, char *define)
(void) pipe(pd);
switch (fork()) {
case 0:
- find_cpp();
- putarg(0, CPP);
+ putarg(0, "cpp");
putarg(1, CPPFLAGS);
addarg(define);
addarg(infile);
@@ -334,7 +313,15 @@ open_input(char *infile, char *define)
(void) close(1);
(void) dup2(pd[1], 1);
(void) close(pd[0]);
- execv(arglist[0], arglist);
+ if (cppDefined)
+ execv(CPP, arglist);
+ else {
+ execvp("cpp", arglist);
+ if (errno == ENOENT)
+ execvp(SVR4_CPP, arglist);
+ if (errno == ENOENT)
+ execvp(SUNOS_CPP, arglist);
+ }
perror("execv");
exit(1);
case -1: