Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: K&R compiler fix



> 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)



Messages sorted by: Reverse Date, Date, Thread, Author