Subject: Re: mail/drac fails to build
To: Hiramatsu Yoshifumi <hiramatu@boreas.dti.ne.jp>
From: James Chacon <jmc@netbsd.org>
List: tech-pkg
Date: 07/28/2003 22:16:26
Yes
James
>
>Hello.
>
>While mail/drac builds fine on NetBSD, is the patch still worth being
>sent to Problem Report?
>
>At Wed, 23 Jul 2003 16:49:46 -0400 (EDT),
>James Chacon <jmc@netbsd.org> wrote:
>>
>> Ok. I committed a work-around for this if CPP is set to "cpp".
>>
>> James
>>
>> >
>> >This looks ok. One larger issue...1.6.1 obviously doesn't have this so packages
>> >which are affected by it (this and nfsbug come to mind) need local fixes
>> >of some sort.
>> >
>> >James
>> >
>> >>
>> >>Hello.
>> >>
>> >>I think this patch does your second suggestion. I tried to build mail/drac
>> >>with this rpcgen, and succeeded.
>> >>
>> >>-----
>> >>// Hiramatsu Yoshifumi
>> >>// hiramatu@boreas.dti.ne.jp
>> >>
>> >>
>> >>At Sat, 19 Jul 2003 22:00:04 +0200,
>> >>Martin Husemann <martin@duskware.de> wrote:
>> >>> IMHO rpcgen. A minimal fix would be to add another check to find_cpp(),
>> >>> testing for the default when no ${CPP} is defined (that is /usr/bin/cpp).
>> >>> A proper fix would check for a leading "/" in ${CPP} and do a ${PATH} walk
>> >>> if it is missing.
>> >>>
>> >>> Martin
>> >>>
>> >>
>> >>diff -buNr rpcgen.orig/rpc_main.c rpcgen/rpc_main.c
>> >>--- rpcgen.orig/rpc_main.c 2003-07-23 23:38:51.000000000 +0900
>> >>+++ rpcgen/rpc_main.c 2003-07-23 23:52:46.000000000 +0900
>> >>@@ -156,6 +156,7 @@
>> >> static int parseargs __P((int, char *[], struct commandline *));
>> >> static void usage __P((void));
>> >> static void options_usage __P((void));
>> >>+static char *padvance(const char **, const char *);
>> >>
>> >>
>> >> int
>> >>@@ -321,20 +322,78 @@
>> >> find_cpp()
>> >> {
>> >> struct stat buf;
>> >>+ const char *path;
>> >>+ char *cmdname;
>> >>
>> >>- if (stat(CPP, &buf) < 0) { /* SVR4 or explicit cpp does not exist */
>> >>+ if (CPP[0] == '/') {
>> >>+ if (stat(CPP, &buf) < 0) {
>> >>+ /* SVR4 or explicit cpp does not exist */
>> >> if (cppDefined) {
>> >>- fprintf(stderr, "cannot find C preprocessor: %s\n", CPP);
>> >>+ 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");
>> >>+ if (stat(CPP, &buf) < 0) {
>> >>+ /* can't find any cpp */
>> >>+ fprintf(stderr,
>> >>+ "cannot find any C preprocessor (cpp)\n");
>> >> crash();
>> >> }
>> >> }
>> >> }
>> >>+ } else {
>> >>+ path = getenv("PATH");
>> >>+ while((cmdname = padvance(&path, "cpp")) != NULL) {
>> >>+ if (stat(cmdname, &buf) < 0) {
>> >>+ /* not found in this path */
>> >>+ free(cmdname);
>> >>+ continue;
>> >>+ } else {
>> >>+ /* found */
>> >>+ CPP = cmdname;
>> >>+ return;
>> >>+ }
>> >>+ }
>> >>+ }
>> >>+}
>> >>+
>> >>+/* padvance is taken from /bin/sh */
>> >>+/*
>> >>+ * Do a path search. The variable path (passed by reference) should be
>> >>+ * set to the start of the path before the first call; padvance will update
>> >>+ * this value as it proceeds. Successive calls to padvance will return
>> >>+ * the possible path expansions in sequence.
>> >>+ */
>> >>+char *
>> >>+padvance(const char **path, const char *name)
>> >>+{
>> >>+ int len;
>> >>+ const char *start;
>> >>+ const char *p;
>> >>+ char *q;
>> >>+ char *ret;
>> >>+
>> >>+ if (*path == NULL)
>> >>+ return NULL;
>> >>+ start = *path;
>> >>+ for (p = start ; *p && *p != ':' ; p++);
>> >>+ len = p - start + strlen(name) + 2; /* "2" is for '/' and '\0' */
>> >>+ ret = q = malloc(len);
>> >>+ if (p != start) {
>> >>+ strncpy(q, start, p - start);
>> >>+ q += p - start;
>> >>+ *q++ = '/';
>> >>+ }
>> >>+ strcpy(q, name);
>> >>+ if (*p == ':')
>> >>+ *path = p + 1;
>> >>+ else
>> >>+ *path = NULL;
>> >>+
>> >>+ return ret;
>> >> }
>> >>+
>> >> /*
>> >> * Open input file with given define for C-preprocessor
>> >> */
>> >>
>> >>
>> >>
>> >
>> >
>> >
>>
>>
>
>
>