fmt.c (9b50d9027575220cb6dd09b3e62f03f511e908b8) | fmt.c (d293af2d2ecc6f8c0abeee6a7c87829f686b10c1) |
---|---|
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 120 unchanged lines hidden (view full) --- 129 * Read up characters from the passed input file, forming lines, 130 * doing ^H processing, expanding tabs, stripping trailing blanks, 131 * and sending each line down for analysis. 132 */ 133fmt(fi) 134 FILE *fi; 135{ 136 char linebuf[BUFSIZ], canonb[BUFSIZ]; | 1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 120 unchanged lines hidden (view full) --- 129 * Read up characters from the passed input file, forming lines, 130 * doing ^H processing, expanding tabs, stripping trailing blanks, 131 * and sending each line down for analysis. 132 */ 133fmt(fi) 134 FILE *fi; 135{ 136 char linebuf[BUFSIZ], canonb[BUFSIZ]; |
137 register char *cp, *cp2; | 137 register char *cp, *cp2, cc; |
138 register int c, col; 139 140 c = getc(fi); 141 while (c != EOF) { 142 /* 143 * Collect a line, doing ^H processing. 144 * Leave tabs for now. 145 */ 146 cp = linebuf; 147 while (c != '\n' && c != EOF && cp-linebuf < BUFSIZ-1) { 148 if (c == '\b') { 149 if (cp > linebuf) 150 cp--; 151 c = getc(fi); 152 continue; 153 } | 138 register int c, col; 139 140 c = getc(fi); 141 while (c != EOF) { 142 /* 143 * Collect a line, doing ^H processing. 144 * Leave tabs for now. 145 */ 146 cp = linebuf; 147 while (c != '\n' && c != EOF && cp-linebuf < BUFSIZ-1) { 148 if (c == '\b') { 149 if (cp > linebuf) 150 cp--; 151 c = getc(fi); 152 continue; 153 } |
154 if ((c < ' ' || c >= 0177) && c != '\t') { | 154 if (!isprint(c) && c != '\t') { |
155 c = getc(fi); 156 continue; 157 } 158 *cp++ = c; 159 c = getc(fi); 160 } 161 *cp = '\0'; 162 --- 4 unchanged lines hidden (view full) --- 167 c = getc(fi); 168 169 /* 170 * Expand tabs on the way to canonb. 171 */ 172 col = 0; 173 cp = linebuf; 174 cp2 = canonb; | 155 c = getc(fi); 156 continue; 157 } 158 *cp++ = c; 159 c = getc(fi); 160 } 161 *cp = '\0'; 162 --- 4 unchanged lines hidden (view full) --- 167 c = getc(fi); 168 169 /* 170 * Expand tabs on the way to canonb. 171 */ 172 col = 0; 173 cp = linebuf; 174 cp2 = canonb; |
175 while (c = *cp++) { 176 if (c != '\t') { | 175 while (cc = *cp++) { 176 if (cc != '\t') { |
177 col++; 178 if (cp2-canonb < BUFSIZ-1) | 177 col++; 178 if (cp2-canonb < BUFSIZ-1) |
179 *cp2++ = c; | 179 *cp2++ = cc; |
180 continue; 181 } 182 do { 183 if (cp2-canonb < BUFSIZ-1) 184 *cp2++ = ' '; 185 col++; 186 } while ((col & 07) != 0); 187 } --- 18 unchanged lines hidden (view full) --- 206 * it on a line by itself. 207 */ 208prefix(line) 209 char line[]; 210{ 211 register char *cp, **hp; 212 register int np, h; 213 | 180 continue; 181 } 182 do { 183 if (cp2-canonb < BUFSIZ-1) 184 *cp2++ = ' '; 185 col++; 186 } while ((col & 07) != 0); 187 } --- 18 unchanged lines hidden (view full) --- 206 * it on a line by itself. 207 */ 208prefix(line) 209 char line[]; 210{ 211 register char *cp, **hp; 212 register int np, h; 213 |
214 if (strlen(line) == 0) { | 214 if (!*line) { |
215 oflush(); 216 putchar('\n'); 217 return; 218 } 219 for (cp = line; *cp == ' '; cp++) 220 ; 221 np = cp - line; 222 --- 245 unchanged lines hidden --- | 215 oflush(); 216 putchar('\n'); 217 return; 218 } 219 for (cp = line; *cp == ' '; cp++) 220 ; 221 np = cp - line; 222 --- 245 unchanged lines hidden --- |