+2003-03-30 NeilBrown <neilb@cse.unsw.edu.au>
+
+ * tools/rpcgen/rpc_main.c(find_cpp): removed
+ * tools/rpcgen/rpc_main.c(open_input): use execvp to find "ccp",
+ then try hard-coded paths.
+
2003-03-26 Chip Salzenberg <chip@pobox.com>
* debian/changelog: Version 1.0.3-1.
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
+#include <errno.h>
#include "rpc_parse.h"
#include "rpc_util.h"
#include "rpc_scan.h"
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);
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
*/
(void) pipe(pd);
switch (fork()) {
case 0:
- find_cpp();
- putarg(0, CPP);
+ putarg(0, "cpp");
putarg(1, CPPFLAGS);
addarg(define);
addarg(infile);
(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: