wee@iris (Chris Wee) (05/09/88)
Are you tired of filenames racing past your screen when you type "ls"? So was I. So I kludged some columns into the MINIX 1.2 ls.c. Here are the diffs. ls -w <- 4 column output ls -x <- place a trailing '/' after directory names. I know, i didn't use the proper -C and -F flag names, but the way the flags are handled, upper case letters are recognized - yet. Will update with a new version If i ever get around to it. chris wee (wee@ucdavis.edu) --------------------------- cut here --------------------------- 1a2,4 > /* modified: Chris Wee > * date: 7 May 1988 > */ 14c17,20 < #define LEGAL 0x1E096DL /* legal flags to ls */ --- > #define LEGAL 0xDE096DL /* legal flags to ls */ > /* xw_utsr_____l__i_gf_dc_a */ > #define N_COLUMNS 4 > #define COLWIDTH 20 /* enuf for 4 cols on 80-col display */ 15a22,23 > int column = 0; /* column # */ > 52d59 < 82a90,91 > if (column) /* if not in first column, then another newline */ > fprintf(stdout,"\n"); 99,100c108,110 < if (present('c') || present('t') || present('u')) statflag = 1; < if (present('s') || present('l')) statflag = 1; --- > if (present('c') || present('t') || present('u') || > present('s') || present('l') || present('x')) > statflag = 1; 261,263d270 < statflag = 0; < if (present('c') || present('t') || present('u')) statflag = 1; < if (present('s') || present('l')) statflag = 1; 264a272,274 > statflag = ( present('c') || present('t') || present('u') || > present('s') || present('l') || present('x') ) ? 1 : 0; > 313c323 < int blks, m, prot, s; --- > int blks, m, len, prot, s; 359c369 < m = 0; --- > len = 0; 361c371 < while (*p1 != 0 && (m < DIRNAMELEN || *p1 == '/') ) { --- > while (*p1 != 0 && (len < DIRNAMELEN || *p1 == '/') ) { 363c373 < m = (*p1 == '/' ? 0 : m + 1); --- > len = (*p1 == '/' ? 0 : len + 1); 366c376,395 < fprintf(stdout, "\n"); --- > > /* > * print tailing file indicator symbol if -F flag is present > */ > if (present('x') && ((fp->mode & I_TYPE) == I_DIRECTORY)) { > fprintf(stdout,"/"); > p1++; > } > > /* > * print filenames in columns as default > */ > if (present('l') || !present('w') || (++column == N_COLUMNS)) { > column = 0; /* reset column # */ > fprintf(stdout, "\n"); > } > else { > for (len = COLWIDTH - (int) (p1 - fp->name); len > 0 ; len--) > fprintf(stdout," "); > } 649d677 <