Commit 27027a60 by Richard Kenner

#if VMS, don't define `stat' macro to be VMS_stat.

#if VMS, don't define `stat' macro to be VMS_stat.
Compare enums explicitly to 0 to work around VAX C bug.

From-SVN: r9660
parent 5583c64f
...@@ -240,7 +240,6 @@ my_bzero (b, length) ...@@ -240,7 +240,6 @@ my_bzero (b, length)
#define freopen(fname,mode,ofile) VMS_freopen (fname,mode,ofile) #define freopen(fname,mode,ofile) VMS_freopen (fname,mode,ofile)
#define strncat(dst,src,cnt) VMS_strncat (dst,src,cnt) #define strncat(dst,src,cnt) VMS_strncat (dst,src,cnt)
#define fstat(fd,stbuf) VMS_fstat (fd,stbuf) #define fstat(fd,stbuf) VMS_fstat (fd,stbuf)
#define stat(name,stbuf) VMS_stat (name,stbuf)
static int VMS_fstat (), VMS_stat (); static int VMS_fstat (), VMS_stat ();
static char * VMS_strncat (); static char * VMS_strncat ();
static int VMS_read (); static int VMS_read ();
...@@ -682,7 +681,7 @@ struct macrodef ...@@ -682,7 +681,7 @@ struct macrodef
}; };
enum sharp_token_type { enum sharp_token_type {
NO_SHARP_TOKEN, /* token not present */ NO_SHARP_TOKEN = 0, /* token not present */
SHARP_TOKEN = '#', /* token spelled with # only */ SHARP_TOKEN = '#', /* token spelled with # only */
WHITE_SHARP_TOKEN, /* token spelled with # and white space */ WHITE_SHARP_TOKEN, /* token spelled with # and white space */
...@@ -8155,7 +8154,7 @@ macroexpand (hp, op) ...@@ -8155,7 +8154,7 @@ macroexpand (hp, op)
for (ap = defn->pattern; ap != NULL; ap = ap->next) { for (ap = defn->pattern; ap != NULL; ap = ap->next) {
if (ap->stringify) if (ap->stringify)
xbuf_len += args[ap->argno].stringified_length; xbuf_len += args[ap->argno].stringified_length;
else if (ap->raw_before || ap->raw_after || traditional) else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional)
/* Add 4 for two newline-space markers to prevent /* Add 4 for two newline-space markers to prevent
token concatenation. */ token concatenation. */
xbuf_len += args[ap->argno].raw_length + 4; xbuf_len += args[ap->argno].raw_length + 4;
...@@ -8201,9 +8200,9 @@ macroexpand (hp, op) ...@@ -8201,9 +8200,9 @@ macroexpand (hp, op)
/* If followed by an empty rest arg with concatenation, /* If followed by an empty rest arg with concatenation,
delete the last run of nonwhite chars. */ delete the last run of nonwhite chars. */
if (rest_zero && totlen > count_before if (rest_zero && totlen > count_before
&& ((ap->rest_args && ap->raw_before) && ((ap->rest_args && ap->raw_before != 0)
|| (last_ap != NULL && last_ap->rest_args || (last_ap != NULL && last_ap->rest_args
&& last_ap->raw_after))) { && last_ap->raw_after != 0))) {
/* Delete final whitespace. */ /* Delete final whitespace. */
while (totlen > count_before && is_space[xbuf[totlen - 1]]) { while (totlen > count_before && is_space[xbuf[totlen - 1]]) {
totlen--; totlen--;
...@@ -8281,10 +8280,10 @@ macroexpand (hp, op) ...@@ -8281,10 +8280,10 @@ macroexpand (hp, op)
} }
if (!traditional) if (!traditional)
xbuf[totlen++] = '\"'; /* insert ending quote */ xbuf[totlen++] = '\"'; /* insert ending quote */
} else if (ap->raw_before || ap->raw_after || traditional) { } else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional) {
U_CHAR *p1 = arg->raw; U_CHAR *p1 = arg->raw;
U_CHAR *l1 = p1 + arg->raw_length; U_CHAR *l1 = p1 + arg->raw_length;
if (ap->raw_before) { if (ap->raw_before != 0) {
while (p1 != l1 && is_space[*p1]) p1++; while (p1 != l1 && is_space[*p1]) p1++;
while (p1 != l1 && is_idchar[*p1]) while (p1 != l1 && is_idchar[*p1])
xbuf[totlen++] = *p1++; xbuf[totlen++] = *p1++;
...@@ -8299,7 +8298,7 @@ macroexpand (hp, op) ...@@ -8299,7 +8298,7 @@ macroexpand (hp, op)
xbuf[totlen++] = '\n'; xbuf[totlen++] = '\n';
xbuf[totlen++] = ' '; xbuf[totlen++] = ' ';
} }
if (ap->raw_after) { if (ap->raw_after != 0) {
/* Arg is concatenated after: delete trailing whitespace, /* Arg is concatenated after: delete trailing whitespace,
whitespace markers, and no-reexpansion markers. */ whitespace markers, and no-reexpansion markers. */
while (p1 != l1) { while (p1 != l1) {
...@@ -8320,7 +8319,7 @@ macroexpand (hp, op) ...@@ -8320,7 +8319,7 @@ macroexpand (hp, op)
bcopy ((char *) p1, (char *) (xbuf + totlen), l1 - p1); bcopy ((char *) p1, (char *) (xbuf + totlen), l1 - p1);
totlen += l1 - p1; totlen += l1 - p1;
if (!traditional && !ap->raw_after) { if (!traditional && ap->raw_after == 0) {
/* Ordinary expanded use of the argument. /* Ordinary expanded use of the argument.
Put in newline-space markers to prevent token pasting. */ Put in newline-space markers to prevent token pasting. */
xbuf[totlen++] = '\n'; xbuf[totlen++] = '\n';
...@@ -8365,7 +8364,7 @@ macroexpand (hp, op) ...@@ -8365,7 +8364,7 @@ macroexpand (hp, op)
if (exp[i] == ')') if (exp[i] == ')')
rest_zero = 0; rest_zero = 0;
if (! (rest_zero && last_ap != NULL && last_ap->rest_args if (! (rest_zero && last_ap != NULL && last_ap->rest_args
&& last_ap->raw_after)) && last_ap->raw_after != 0))
xbuf[totlen++] = exp[i]; xbuf[totlen++] = exp[i];
} }
...@@ -9399,7 +9398,7 @@ dump_single_macro (hp, of) ...@@ -9399,7 +9398,7 @@ dump_single_macro (hp, of)
default: abort (); default: abort ();
} }
} }
if (ap->raw_before) { if (ap->raw_before != 0) {
if (concat) { if (concat) {
switch (ap->raw_before) { switch (ap->raw_before) {
case WHITE_SHARP_TOKEN: case WHITE_SHARP_TOKEN:
...@@ -9422,7 +9421,7 @@ dump_single_macro (hp, of) ...@@ -9422,7 +9421,7 @@ dump_single_macro (hp, of)
concat = 0; concat = 0;
} }
dump_arg_n (defn, ap->argno, of); dump_arg_n (defn, ap->argno, of);
if (!traditional && ap->raw_after) { if (!traditional && ap->raw_after != 0) {
switch (ap->raw_after) { switch (ap->raw_after) {
case SHARP_TOKEN: fprintf (of, "##"); break; case SHARP_TOKEN: fprintf (of, "##"); break;
case WHITE_SHARP_TOKEN: fprintf (of, " ##"); break; case WHITE_SHARP_TOKEN: fprintf (of, " ##"); break;
...@@ -10354,12 +10353,13 @@ extern unsigned long sys$parse(), sys$search(); ...@@ -10354,12 +10353,13 @@ extern unsigned long sys$parse(), sys$search();
bad enough, but then compounding the problem by reporting the reason for bad enough, but then compounding the problem by reporting the reason for
failure as "normal successful completion." */ failure as "normal successful completion." */
#undef fstat /* get back to library version */
static int static int
fstat (fd, statbuf) VMS_fstat (fd, statbuf)
int fd; int fd;
struct stat *statbuf; struct stat *statbuf;
{ {
#undef fstat
int result = fstat (fd, statbuf); int result = fstat (fd, statbuf);
if (result < 0) if (result < 0)
...@@ -10368,7 +10368,7 @@ fstat (fd, statbuf) ...@@ -10368,7 +10368,7 @@ fstat (fd, statbuf)
char nambuf[NAM$C_MAXRSS+1]; char nambuf[NAM$C_MAXRSS+1];
if ((fp = fdopen (fd, "r")) != 0 && fgetname (fp, nambuf) != 0) if ((fp = fdopen (fd, "r")) != 0 && fgetname (fp, nambuf) != 0)
result = stat (nambuf, statbuf); result = VMS_stat (nambuf, statbuf);
/* No fclose(fp) here; that would close(fd) as well. */ /* No fclose(fp) here; that would close(fd) as well. */
} }
...@@ -10376,11 +10376,10 @@ fstat (fd, statbuf) ...@@ -10376,11 +10376,10 @@ fstat (fd, statbuf)
} }
static int static int
stat (name, statbuf) VMS_stat (name, statbuf)
const char *name; const char *name;
struct stat *statbuf; struct stat *statbuf;
{ {
#undef stat
int result = stat (name, statbuf); int result = stat (name, statbuf);
if (result < 0) if (result < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment