Deleted Added
full compact
print.c (86922) print.c (88583)
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Michael Fischbein.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38#if 0
39static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
40#else
41static const char rcsid[] =
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Michael Fischbein.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38#if 0
39static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
40#else
41static const char rcsid[] =
42 "$FreeBSD: head/bin/ls/print.c 86922 2001-11-26 22:21:15Z green $";
42 "$FreeBSD: head/bin/ls/print.c 88583 2001-12-28 18:14:50Z joe $";
43#endif
44#endif /* not lint */
45
46#include <sys/param.h>
47#include <sys/stat.h>
48
49#include <err.h>
50#include <errno.h>

--- 38 unchanged lines hidden (view full) ---

89 C_CHR, /* character special */
90 C_SUID, /* setuid executable */
91 C_SGID, /* setgid executable */
92 C_WSDIR, /* directory writeble to others, with sticky bit */
93 C_WDIR, /* directory writeble to others, without sticky bit */
94 C_NUMCOLORS /* just a place-holder */
95} Colors ;
96
43#endif
44#endif /* not lint */
45
46#include <sys/param.h>
47#include <sys/stat.h>
48
49#include <err.h>
50#include <errno.h>

--- 38 unchanged lines hidden (view full) ---

89 C_CHR, /* character special */
90 C_SUID, /* setuid executable */
91 C_SGID, /* setgid executable */
92 C_WSDIR, /* directory writeble to others, with sticky bit */
93 C_WDIR, /* directory writeble to others, without sticky bit */
94 C_NUMCOLORS /* just a place-holder */
95} Colors ;
96
97char *defcolors = "4x5x2x3x1x464301060203";
97char *defcolors = "exfxcxdxbxegedabagacad";
98
98
99static int colors[C_NUMCOLORS][2];
99/* colors for file types */
100static struct {
101 int num[2];
102 int bold;
103} colors[C_NUMCOLORS];
104
100#endif
101
102void
103printscol(dp)
104 DISPLAY *dp;
105{
106 FTSENT *p;
107

--- 273 unchanged lines hidden (view full) ---

381}
382
383static void
384printcolor(c)
385 Colors c;
386{
387 char *ansiseq;
388
105#endif
106
107void
108printscol(dp)
109 DISPLAY *dp;
110{
111 FTSENT *p;
112

--- 273 unchanged lines hidden (view full) ---

386}
387
388static void
389printcolor(c)
390 Colors c;
391{
392 char *ansiseq;
393
389 if (colors[c][0] != -1) {
390 ansiseq = tgoto(ansi_fgcol, 0, colors[c][0]);
394 if (colors[c].bold)
395 tputs(enter_bold, 1, putch);
396
397 if (colors[c].num[0] != -1) {
398 ansiseq = tgoto(ansi_fgcol, 0, colors[c].num[0]);
391 if (ansiseq)
392 tputs(ansiseq, 1, putch);
393 }
394
399 if (ansiseq)
400 tputs(ansiseq, 1, putch);
401 }
402
395 if (colors[c][1] != -1) {
396 ansiseq = tgoto(ansi_bgcol, 0, colors[c][1]);
403 if (colors[c].num[1] != -1) {
404 ansiseq = tgoto(ansi_bgcol, 0, colors[c].num[1]);
397 if (ansiseq)
398 tputs(ansiseq, 1, putch);
399 }
400}
401
402static void
403endcolor(sig)
404 int sig;
405{
406 tputs(ansi_coloff, 1, sig ? writech : putch);
405 if (ansiseq)
406 tputs(ansiseq, 1, putch);
407 }
408}
409
410static void
411endcolor(sig)
412 int sig;
413{
414 tputs(ansi_coloff, 1, sig ? writech : putch);
415 tputs(attrs_off, 1, sig ? writech : putch);
407}
408
409static int
410colortype(mode)
411 mode_t mode;
412{
413 switch(mode & S_IFMT) {
414 case S_IFDIR:

--- 34 unchanged lines hidden (view full) ---

449}
450
451void
452parsecolors(cs)
453char *cs;
454{
455 int i, j, len;
456 char c[2];
416}
417
418static int
419colortype(mode)
420 mode_t mode;
421{
422 switch(mode & S_IFMT) {
423 case S_IFDIR:

--- 34 unchanged lines hidden (view full) ---

458}
459
460void
461parsecolors(cs)
462char *cs;
463{
464 int i, j, len;
465 char c[2];
466 short legacy_warn = 0;
457
458 if (cs == NULL) cs = ""; /* LSCOLORS not set */
459 len = strlen(cs);
460 for (i = 0 ; i < C_NUMCOLORS ; i++) {
467
468 if (cs == NULL) cs = ""; /* LSCOLORS not set */
469 len = strlen(cs);
470 for (i = 0 ; i < C_NUMCOLORS ; i++) {
471 colors[i].bold = 0;
472
461 if (len <= 2*i) {
462 c[0] = defcolors[2*i];
463 c[1] = defcolors[2*i+1];
464 }
465 else {
466 c[0] = cs[2*i];
467 c[1] = cs[2*i+1];
468 }
469 for (j = 0 ; j < 2 ; j++) {
473 if (len <= 2*i) {
474 c[0] = defcolors[2*i];
475 c[1] = defcolors[2*i+1];
476 }
477 else {
478 c[0] = cs[2*i];
479 c[1] = cs[2*i+1];
480 }
481 for (j = 0 ; j < 2 ; j++) {
470 if ((c[j] < '0' || c[j] > '7') &&
471 tolower((unsigned char)c[j]) != 'x') {
482 /* Legacy colours used 0-7 */
483 if (c[j] >= '0' && c[j] <= '7') {
484 colors[i].num[j] = c[j] - '0';
485 if (!legacy_warn) {
486 fprintf(stderr,
487 "warn: colors are now defined "
488 "using a-h instead of 0-9. "
489 "see manual page.\n");
490 }
491 legacy_warn = 1;
492 } else if (c[j] >= 'a' && c[j] <= 'h')
493 colors[i].num[j] = c[j] - 'a';
494 else if (c[j] >= 'A' && c[j] <= 'H') {
495 colors[i].num[j] = c[j] - 'A';
496 colors[i].bold = 1;
497 } else if (tolower((unsigned char)c[j] == 'x'))
498 colors[i].num[j] = -1;
499 else {
472 fprintf(stderr,
500 fprintf(stderr,
473 "error: invalid character '%c' in LSCOLORS env var\n",
474 c[j]);
475 c[j] = defcolors[2*i+j];
501 "error: invalid character '%c' in LSCOLORS"
502 " env var\n", c[j]);
503 colors[i].num[j] = defcolors[2*i+j]-'0';
476 }
504 }
477 if (tolower((unsigned char)c[j]) == 'x')
478 colors[i][j] = -1;
479 else
480 colors[i][j] = c[j]-'0';
481 }
482 }
483}
484
485void
486colorquit(sig)
487 int sig;
488{

--- 27 unchanged lines hidden ---
505 }
506 }
507}
508
509void
510colorquit(sig)
511 int sig;
512{

--- 27 unchanged lines hidden ---