Print this page
10120 smatch indenting fixes for usr/src/cmd
Reviewed by: Gergő Doma <domag02@gmail.com>
Portions contributed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>

*** 24,37 **** /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.13 */ - /* NAME infocmp - compare terminfo descriptions, or dump a terminfo description --- 24,37 ---- /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2019, Joyent, Inc. */ /* NAME infocmp - compare terminfo descriptions, or dump a terminfo description
*** 183,195 **** sizeof (struct numstruct)); str = (struct strstruct *) malloc((unsigned) numstrs * sizeof (struct strstruct)); /* Allocate array to keep track of which names have been used. */ ! if (use) used = (char *) malloc((unsigned) (argc - firstoptind) * sizeof (char)); if ((ibool == NULL) || (num == NULL) || (str == NULL) || (use && (used == NULL))) badmalloc(); --- 183,196 ---- sizeof (struct numstruct)); str = (struct strstruct *) malloc((unsigned) numstrs * sizeof (struct strstruct)); /* Allocate array to keep track of which names have been used. */ ! if (use) { used = (char *) malloc((unsigned) (argc - firstoptind) * sizeof (char)); + } if ((ibool == NULL) || (num == NULL) || (str == NULL) || (use && (used == NULL))) badmalloc();
*** 201,212 **** /* This is necessary until fnames.c is */ /* incorporated into standard curses. */ if (nullseen || (boolfnames[i] == NULL)) { ibool[i].fullname = "unknown_boolean"; nullseen = TRUE; ! } else ibool[i].fullname = boolfnames[i]; ibool[i].changed = FALSE; ibool[i].seenagain = FALSE; } nullseen = 0; for (i = 0; i < numnums; i++) { --- 202,214 ---- /* This is necessary until fnames.c is */ /* incorporated into standard curses. */ if (nullseen || (boolfnames[i] == NULL)) { ibool[i].fullname = "unknown_boolean"; nullseen = TRUE; ! } else { ibool[i].fullname = boolfnames[i]; + } ibool[i].changed = FALSE; ibool[i].seenagain = FALSE; } nullseen = 0; for (i = 0; i < numnums; i++) {
*** 213,224 **** num[i].infoname = numnames[i]; num[i].capname = numcodes[i]; if (nullseen || (numfnames[i] == NULL)) { ibool[i].fullname = "unknown_number"; nullseen = TRUE; ! } else num[i].fullname = numfnames[i]; num[i].changed = FALSE; num[i].seenagain = FALSE; } nullseen = 0; for (i = 0; i < numstrs; i++) { --- 215,227 ---- num[i].infoname = numnames[i]; num[i].capname = numcodes[i]; if (nullseen || (numfnames[i] == NULL)) { ibool[i].fullname = "unknown_number"; nullseen = TRUE; ! } else { num[i].fullname = numfnames[i]; + } num[i].changed = FALSE; num[i].seenagain = FALSE; } nullseen = 0; for (i = 0; i < numstrs; i++) {
*** 225,236 **** str[i].infoname = strnames[i]; str[i].capname = strcodes[i]; if (nullseen || (strfnames[i] == NULL)) { str[i].fullname = "unknown_string"; nullseen = TRUE; ! } else str[i].fullname = strfnames[i]; str[i].changed = FALSE; str[i].seenagain = FALSE; } } --- 228,240 ---- str[i].infoname = strnames[i]; str[i].capname = strcodes[i]; if (nullseen || (strfnames[i] == NULL)) { str[i].fullname = "unknown_string"; nullseen = TRUE; ! } else { str[i].fullname = strfnames[i]; + } str[i].changed = FALSE; str[i].seenagain = FALSE; } }
*** 520,532 **** void initfirstterm(char *term) { register int i; ! if (verbose) (void) fprintf(trace, "setting up terminal type '%s'.\n", term); (void) setupterm(term, devnull, (int *) 0); /* Save the name for later use. */ if (use) { --- 524,537 ---- void initfirstterm(char *term) { register int i; ! if (verbose) { (void) fprintf(trace, "setting up terminal type '%s'.\n", term); + } (void) setupterm(term, devnull, (int *) 0); /* Save the name for later use. */ if (use) {
*** 540,568 **** (void) strncpy(_savettytype, ttytype, TTYLEN-1); _savettytype[TTYLEN] = '\0'; savettytype = _savettytype; } ! } else (void) strcpy(_savettytype, ttytype); } if (printing != pr_none) { pr_heading(term, ttytype); pr_bheading(); } /* Save the values for the first terminal. */ for (i = 0; i < numbools; i++) { if ((ibool[i].val = tgetflag(ibool[i].capname)) && ! printing != pr_none) pr_boolean(ibool[i].infoname, ibool[i].capname, ibool[i].fullname, 1); ! if (verbose) (void) fprintf(trace, "%s=%d.\n", ibool[i].infoname, ibool[i].val); } if (printing != pr_none) { if (printing == pr_cap) pr_bcaps(); pr_bfooting(); --- 545,577 ---- (void) strncpy(_savettytype, ttytype, TTYLEN-1); _savettytype[TTYLEN] = '\0'; savettytype = _savettytype; } ! } else { (void) strcpy(_savettytype, ttytype); } + } if (printing != pr_none) { pr_heading(term, ttytype); pr_bheading(); } /* Save the values for the first terminal. */ for (i = 0; i < numbools; i++) { if ((ibool[i].val = tgetflag(ibool[i].capname)) && ! printing != pr_none) { pr_boolean(ibool[i].infoname, ibool[i].capname, ibool[i].fullname, 1); ! } ! ! if (verbose) { (void) fprintf(trace, "%s=%d.\n", ibool[i].infoname, ibool[i].val); } + } if (printing != pr_none) { if (printing == pr_cap) pr_bcaps(); pr_bfooting();
*** 569,585 **** pr_nheading(); } for (i = 0; i < numnums; i++) { if (((num[i].val = tgetnum(num[i].capname)) > -1) && ! printing != pr_none) pr_number(num[i].infoname, num[i].capname, num[i].fullname, num[i].val); ! if (verbose) (void) fprintf(trace, "%s=%d.\n", num[i].infoname, num[i].val); } if (printing != pr_none) { if (printing == pr_cap) pr_ncaps(); pr_nfooting(); --- 578,597 ---- pr_nheading(); } for (i = 0; i < numnums; i++) { if (((num[i].val = tgetnum(num[i].capname)) > -1) && ! printing != pr_none) { pr_number(num[i].infoname, num[i].capname, num[i].fullname, num[i].val); ! } ! ! if (verbose) { (void) fprintf(trace, "%s=%d.\n", num[i].infoname, num[i].val); } + } if (printing != pr_none) { if (printing == pr_cap) pr_ncaps(); pr_nfooting();
*** 586,598 **** pr_sheading(); } for (i = 0; i < numstrs; i++) { str[i].val = tgetstr(str[i].capname, (char **)0); ! if ((str[i].val != NULL) && printing != pr_none) pr_string(str[i].infoname, str[i].capname, str[i].fullname, str[i].val); if (verbose) { (void) fprintf(trace, "%s='", str[i].infoname); PR(trace, str[i].val); (void) fprintf(trace, "'.\n"); } --- 598,612 ---- pr_sheading(); } for (i = 0; i < numstrs; i++) { str[i].val = tgetstr(str[i].capname, (char **)0); ! if ((str[i].val != NULL) && printing != pr_none) { pr_string(str[i].infoname, str[i].capname, str[i].fullname, str[i].val); + } + if (verbose) { (void) fprintf(trace, "%s='", str[i].infoname); PR(trace, str[i].val); (void) fprintf(trace, "'.\n"); }
*** 617,629 **** register int i; if (use) used[n] = FALSE; ! if (verbose) (void) fprintf(trace, "adding in terminal type '%s'.\n", nterm); (void) setupterm(nterm, devnull, (int *) 0); if (printing != pr_none) { pr_heading(nterm, ttytype); --- 631,644 ---- register int i; if (use) used[n] = FALSE; ! if (verbose) { (void) fprintf(trace, "adding in terminal type '%s'.\n", nterm); + } (void) setupterm(nterm, devnull, (int *) 0); if (printing != pr_none) { pr_heading(nterm, ttytype);
*** 677,701 **** used[n] = TRUE; } } } if (boolval) { ! if (printing != pr_none) pr_boolean(ibool[i].infoname, ibool[i].capname, ibool[i].fullname, 1); if (common && (ibool[i].val == boolval)) (void) printf("\t%s= T.\n", ibool[i].infoname); ! } else if (neither && !ibool[i].val) (void) printf("\t!%s.\n", ibool[i].infoname); if (diff && (ibool[i].val != boolval)) (void) printf("\t%s: %c:%c.\n", ibool[i].infoname, ibool[i].val?'T':'F', boolval?'T':'F'); ! if (verbose) (void) fprintf(trace, "%s: %d:%d, changed=%d, " "seen=%d.\n", ibool[i].infoname, ibool[i].val, boolval, ibool[i].changed, ibool[i].seenagain); } if (printing != pr_none) { if (printing == pr_cap) pr_bcaps(); pr_bfooting(); --- 692,720 ---- used[n] = TRUE; } } } if (boolval) { ! if (printing != pr_none) { pr_boolean(ibool[i].infoname, ibool[i].capname, ibool[i].fullname, 1); + } + if (common && (ibool[i].val == boolval)) (void) printf("\t%s= T.\n", ibool[i].infoname); ! } else if (neither && !ibool[i].val) { (void) printf("\t!%s.\n", ibool[i].infoname); + } if (diff && (ibool[i].val != boolval)) (void) printf("\t%s: %c:%c.\n", ibool[i].infoname, ibool[i].val?'T':'F', boolval?'T':'F'); ! if (verbose) { (void) fprintf(trace, "%s: %d:%d, changed=%d, " "seen=%d.\n", ibool[i].infoname, ibool[i].val, boolval, ibool[i].changed, ibool[i].seenagain); } + } if (printing != pr_none) { if (printing == pr_cap) pr_bcaps(); pr_bfooting();
*** 731,757 **** used[n] = TRUE; } } } if (numval > -1) { ! if (printing != pr_none) pr_number(num[i].infoname, num[i].capname, num[i].fullname, numval); ! if (common && (num[i].val == numval)) (void) printf("\t%s= %d.\n", num[i].infoname, numval); ! } else if (neither && (num[i].val == -1)) (void) printf("\t!%s.\n", num[i].infoname); ! if (diff && (num[i].val != numval)) (void) printf("\t%s: %d:%d.\n", num[i].infoname, num[i].val, numval); ! if (verbose) (void) fprintf(trace, "%s: %d:%d, " "changed = %d, seen = %d.\n", num[i].infoname, num[i].val, numval, num[i].changed, num[i].seenagain); } if (printing != pr_none) { if (printing == pr_cap) pr_ncaps(); pr_nfooting(); --- 750,785 ---- used[n] = TRUE; } } } if (numval > -1) { ! if (printing != pr_none) { pr_number(num[i].infoname, num[i].capname, num[i].fullname, numval); ! } ! ! if (common && (num[i].val == numval)) { (void) printf("\t%s= %d.\n", num[i].infoname, numval); ! } ! ! } else if (neither && (num[i].val == -1)) { (void) printf("\t!%s.\n", num[i].infoname); ! } ! ! if (diff && (num[i].val != numval)) { (void) printf("\t%s: %d:%d.\n", num[i].infoname, num[i].val, numval); ! } ! ! if (verbose) { (void) fprintf(trace, "%s: %d:%d, " "changed = %d, seen = %d.\n", num[i].infoname, num[i].val, numval, num[i].changed, num[i].seenagain); } + } if (printing != pr_none) { if (printing == pr_cap) pr_ncaps(); pr_nfooting();
*** 789,801 **** used[n] = TRUE; } } } if (strval != NULL) { ! if (printing != pr_none) pr_string(str[i].infoname, str[i].capname, str[i].fullname, strval); if (common && EQUAL(str[i].val, strval)) { (void) printf("\t%s= '", str[i].infoname); PR(stdout, strval); (void) printf("'.\n"); } --- 817,831 ---- used[n] = TRUE; } } } if (strval != NULL) { ! if (printing != pr_none) { pr_string(str[i].infoname, str[i].capname, str[i].fullname, strval); + } + if (common && EQUAL(str[i].val, strval)) { (void) printf("\t%s= '", str[i].infoname); PR(stdout, strval); (void) printf("'.\n"); }
*** 846,897 **** pr_heading((char *)0, savettytype); pr_bheading(); /* Print out all bools that are different. */ ! for (i = 0; i < numbools; i++) ! if (!ibool[i].val && ibool[i].changed) pr_boolean(ibool[i].infoname, (char *)0, (char *)0, -1); ! else if (ibool[i].val && (ibool[i].changed || ! !ibool[i].seenagain)) pr_boolean(ibool[i].infoname, (char *)0, (char *)0, 1); pr_bfooting(); pr_nheading(); /* Print out all nums that are different. */ ! for (i = 0; i < numnums; i++) ! if (num[i].val < 0 && num[i].changed) pr_number(num[i].infoname, (char *)0, (char *)0, -1); ! else if (num[i].val >= 0 && (num[i].changed || ! !num[i].seenagain)) pr_number(num[i].infoname, (char *)0, (char *)0, num[i].val); pr_nfooting(); pr_sheading(); /* Print out all strs that are different. */ ! for (i = 0; i < numstrs; i++) ! if (str[i].val == NULL && str[i].changed) pr_string(str[i].infoname, (char *)0, (char *)0, (char *)0); ! else if ((str[i].val != NULL) && ! (str[i].changed || !str[i].seenagain)) ! pr_string(str[i].infoname, (char *)0, (char *)0, str[i].val); pr_sfooting(); /* Finish it up. */ ! for (i = firstoptind; i < argc; i++) ! if (used[i - firstoptind]) (void) printf("\tuse=%s,\n", argv[i]); ! else (void) fprintf(stderr, "%s: 'use=%s' did not add anything to the " "description.\n", progname, argv[i]); } void local_setenv(char *termNinfo) { --- 876,936 ---- pr_heading((char *)0, savettytype); pr_bheading(); /* Print out all bools that are different. */ ! for (i = 0; i < numbools; i++) { ! if (!ibool[i].val && ibool[i].changed) { pr_boolean(ibool[i].infoname, (char *)0, (char *)0, -1); ! } else if (ibool[i].val && (ibool[i].changed || ! !ibool[i].seenagain)) { pr_boolean(ibool[i].infoname, (char *)0, (char *)0, 1); + } + } pr_bfooting(); pr_nheading(); /* Print out all nums that are different. */ ! for (i = 0; i < numnums; i++) { ! if (num[i].val < 0 && num[i].changed) { pr_number(num[i].infoname, (char *)0, (char *)0, -1); ! } else if (num[i].val >= 0 && (num[i].changed || ! !num[i].seenagain)) { pr_number(num[i].infoname, (char *)0, (char *)0, num[i].val); + } + } pr_nfooting(); pr_sheading(); /* Print out all strs that are different. */ ! for (i = 0; i < numstrs; i++) { ! if (str[i].val == NULL && str[i].changed) { pr_string(str[i].infoname, (char *)0, (char *)0, (char *)0); ! } else if ((str[i].val != NULL) && ! (str[i].changed || !str[i].seenagain)) { ! pr_string(str[i].infoname, ! (char *)0, (char *)0, str[i].val); ! } ! } pr_sfooting(); /* Finish it up. */ ! for (i = firstoptind; i < argc; i++) { ! if (used[i - firstoptind]) { (void) printf("\tuse=%s,\n", argv[i]); ! } else { (void) fprintf(stderr, "%s: 'use=%s' did not add anything to the " "description.\n", progname, argv[i]); + } + } } void local_setenv(char *termNinfo) {
*** 901,913 **** static char _terminfo[BUFSIZ]; static char *terminfo = &_terminfo[0]; register int termlen; if (termNinfo && *termNinfo) { ! if (verbose) (void) fprintf(trace, "setting TERMINFO=%s.\n", termNinfo); termlen = strlen(termNinfo); if (termlen + 10 > termsize) { termsize = termlen + 20; terminfo = (char *) malloc(termsize * sizeof (char)); } --- 940,954 ---- static char _terminfo[BUFSIZ]; static char *terminfo = &_terminfo[0]; register int termlen; if (termNinfo && *termNinfo) { ! if (verbose) { (void) fprintf(trace, "setting TERMINFO=%s.\n", termNinfo); + } + termlen = strlen(termNinfo); if (termlen + 10 > termsize) { termsize = termlen + 20; terminfo = (char *) malloc(termsize * sizeof (char)); }
*** 1050,1074 **** argc = 1; argv = tempargv; optind = 0; } pr_init(printing = pr_terminfo); ! } else diff++; } /* Set the default sorting order. */ ! if (sortorder == none) switch ((int) printing) { case (int) pr_cap: sortorder = by_cap; break; case (int) pr_longnames: sortorder = by_longnames; break; case (int) pr_terminfo: case (int) pr_none: sortorder = by_terminfo; break; } firstterm = argv[optind++]; firstoptind = optind; allocvariables(argc, firstoptind); --- 1091,1117 ---- argc = 1; argv = tempargv; optind = 0; } pr_init(printing = pr_terminfo); ! } else { diff++; } + } /* Set the default sorting order. */ ! if (sortorder == none) { switch ((int) printing) { case (int) pr_cap: sortorder = by_cap; break; case (int) pr_longnames: sortorder = by_longnames; break; case (int) pr_terminfo: case (int) pr_none: sortorder = by_terminfo; break; } + } firstterm = argv[optind++]; firstoptind = optind; allocvariables(argc, firstoptind);