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>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/echo/echo.c
+++ new/usr/src/cmd/echo/echo.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
26 26 /* All Rights Reserved */
27 27
28 +/*
29 + * Copyright (c) 2018, Joyent, Inc.
30 + */
28 31
29 32 #include <stdio.h>
30 33 #include <stdlib.h>
31 34 #include <wchar.h>
32 35 #include <string.h>
33 36 #include <locale.h>
34 37
35 38 int
36 39 main(int argc, char *argv[])
37 40 {
38 41
39 42 register char *cp;
40 43 register int i, wd;
41 44 int j;
42 45 wchar_t wc;
43 46 int b_len;
44 47 char *ep;
45 48
46 49 (void) setlocale(LC_ALL, "");
47 50
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
48 51 if (--argc == 0) {
49 52 (void) putchar('\n');
50 53 if (fflush(stdout) != 0)
51 54 return (1);
52 55 return (0);
53 56 }
54 57
55 58 for (i = 1; i <= argc; i++) {
56 59 for (cp = argv[i], ep = cp + (int)strlen(cp);
57 60 cp < ep; cp += b_len) {
58 - if ((b_len = mbtowc(&wc, cp, MB_CUR_MAX)) <= 0) {
59 - (void) putchar(*cp);
60 - b_len = 1;
61 - continue;
62 - }
61 + if ((b_len = mbtowc(&wc, cp, MB_CUR_MAX)) <= 0) {
62 + (void) putchar(*cp);
63 + b_len = 1;
64 + continue;
65 + }
63 66
64 - if (wc != '\\') {
65 - (void) putwchar(wc);
66 - continue;
67 - }
67 + if (wc != '\\') {
68 + (void) putwchar(wc);
69 + continue;
70 + }
68 71
69 72 cp += b_len;
70 73 b_len = 1;
71 74 switch (*cp) {
72 75 case 'a': /* alert - XCU4 */
73 76 (void) putchar('\a');
74 77 continue;
75 78
76 79 case 'b':
77 80 (void) putchar('\b');
78 81 continue;
79 82
80 83 case 'c':
81 84 if (fflush(stdout) != 0)
82 85 return (1);
83 86 return (0);
84 87
85 88 case 'f':
86 89 (void) putchar('\f');
87 90 continue;
88 91
89 92 case 'n':
90 93 (void) putchar('\n');
91 94 continue;
92 95
93 96 case 'r':
94 97 (void) putchar('\r');
95 98 continue;
96 99
97 100 case 't':
98 101 (void) putchar('\t');
99 102 continue;
100 103
101 104 case 'v':
102 105 (void) putchar('\v');
103 106 continue;
104 107
105 108 case '\\':
106 109 (void) putchar('\\');
107 110 continue;
108 111 case '0':
109 112 j = wd = 0;
110 113 while ((*++cp >= '0' && *cp <= '7') &&
111 114 j++ < 3) {
112 115 wd <<= 3;
113 116 wd |= (*cp - '0');
114 117 }
115 118 (void) putchar(wd);
116 119 --cp;
117 120 continue;
118 121
119 122 default:
120 123 cp--;
121 124 (void) putchar(*cp);
122 125 }
123 126 }
124 127 (void) putchar(i == argc? '\n': ' ');
125 128 if (fflush(stdout) != 0)
126 129 return (1);
127 130 }
128 131 return (0);
129 132 }
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX