* PATCH: Re: K&R compiler fix
@ 1998-05-09 22:46 Zoltan Hidvegi
0 siblings, 0 replies; only message in thread
From: Zoltan Hidvegi @ 1998-05-09 22:46 UTC (permalink / raw)
To: Zsh hacking and development
> Some very old K&R compilers do not allow initialization of automatic
> character arrays (or any automatic arrays). That was in 3.1.2, I did not
> try to compile 3.1.3 with such a compiler (the old SunOS 4.1 cc has this
> problem). There may be other such problems hiding.
Oops, I've left out a const from this patch. Here it is again. The only
difference is const mode_t *mfp instead of just mode_t *mfp.
Zoli
*** Src/Modules/stat.c.orig Sat May 2 03:45:37 1998
--- Src/Modules/stat.c Sat May 9 17:43:26 1998
*************** statmodeprint(mode_t mode, char *outbuf,
*** 50,56 ****
strcat(outbuf, " (");
}
if (flags & STF_STRING) {
! char pm[11] = "?---------";
if (S_ISBLK(mode))
*pm = 'b';
--- 50,62 ----
strcat(outbuf, " (");
}
if (flags & STF_STRING) {
! static const char *modes = "?rwxrwxrwx";
! static const mode_t mflags[] = { S_IRUSR, S_IWUSR, S_IXUSR,
! S_IRGRP, S_IWGRP, S_IXGRP,
! S_IROTH, S_IWOTH, S_IXOTH };
! const mode_t *mfp = mflags;
! char pm[11];
! int i;
if (S_ISBLK(mode))
*pm = 'b';
*************** statmodeprint(mode_t mode, char *outbuf,
*** 74,98 ****
*pm = '-';
else if (S_ISSOCK(mode))
*pm = 's';
- if(mode & S_IRUSR)
- pm[1] = 'r';
- if(mode & S_IWUSR)
- pm[2] = 'w';
- if(mode & S_IXUSR)
- pm[3] = 'x';
- if(mode & S_IRGRP)
- pm[4] = 'r';
- if(mode & S_IWGRP)
- pm[5] = 'w';
- if(mode & S_IXGRP)
- pm[6] = 'x';
- if(mode & S_IROTH)
- pm[7] = 'r';
- if(mode & S_IWOTH)
- pm[8] = 'w';
- if(mode & S_IXOTH)
- pm[9] = 'x';
if (mode & S_ISUID)
pm[3] = (mode & S_IXUSR) ? 's' : 'S';
if (mode & S_ISGID)
--- 80,91 ----
*pm = '-';
else if (S_ISSOCK(mode))
*pm = 's';
+ else
+ *pm = '?';
+
+ for (i = 1; i <= 9; i++)
+ pm[i] = (mode & *mfp++) ? modes[i] : '-';
if (mode & S_ISUID)
pm[3] = (mode & S_IXUSR) ? 's' : 'S';
if (mode & S_ISGID)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-05-09 22:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-09 22:46 PATCH: Re: K&R compiler fix Zoltan Hidvegi
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).