[BACK]Return to opt_ce.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / usr.bin / indent

Annotation of src/tests/usr.bin/indent/opt_ce.c, Revision 1.4

1.4     ! rillig      1: /* $NetBSD: opt_ce.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
1.1       rillig      2: /* $FreeBSD$ */
                      3:
1.3       rillig      4: /*
                      5:  * Tests for the options '-ce' and '-nce'.
                      6:  *
1.4     ! rillig      7:  * The option '-ce' places the 'else' on the same line as the preceding '}'.
1.3       rillig      8:  *
                      9:  * The option '-nce' places the 'else' on the next line.
1.4     ! rillig     10:  *
        !            11:  * See also:
        !            12:  *     opt_ei.c
1.3       rillig     13:  */
                     14:
1.1       rillig     15: #indent input
                     16: void
                     17: example(int n)
                     18: {
                     19:        if (n > 99) { print("large"); }
                     20:        else if (n > 9) { print("double-digit"); }
                     21:        else if (n > 0) print("positive");
                     22:        else { print("negative"); }
                     23: }
                     24: #indent end
                     25:
                     26: #indent run -ce
                     27: void
                     28: example(int n)
                     29: {
                     30:        if (n > 99) {
                     31:                print("large");
                     32:        } else if (n > 9) {
                     33:                print("double-digit");
                     34:        } else if (n > 0)
                     35:                print("positive");
                     36:        else {
                     37:                print("negative");
                     38:        }
                     39: }
                     40: #indent end
                     41:
                     42: #indent run -nce
                     43: void
                     44: example(int n)
                     45: {
                     46:        if (n > 99) {
                     47:                print("large");
                     48:        }
                     49:        else if (n > 9) {
                     50:                print("double-digit");
                     51:        }
                     52:        else if (n > 0)
                     53:                print("positive");
                     54:        else {
                     55:                print("negative");
                     56:        }
                     57: }
                     58: #indent end

CVSweb <webmaster@jp.NetBSD.org>