ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/neat.c
Revision: 1.1
Committed: Sat Feb 22 02:07:20 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     /*
5     * neat.c - program to tidy up columns.
6     *
7     * 10/24/86
8     */
9    
10     #include <stdio.h>
11    
12     #include <ctype.h>
13    
14    
15     char *format = "8.8"; /* default format */
16    
17    
18     main(argc, argv)
19     int argc;
20     char *argv[];
21     {
22     int left, anchor, right;
23     char buf[512];
24     register char *cp, *word;
25     register int i;
26    
27     if (argc == 2)
28     format = argv[1];
29     else if (argc > 2)
30     goto userror;
31     left = 0;
32     for (cp = format; isdigit(*cp); cp++)
33     left = left*10 + *cp - '0';
34     right = 0;
35     if (anchor = *cp)
36     for (cp++; isdigit(*cp); cp++)
37     right = right*10 + *cp - '0';
38     if (*cp)
39     goto userror;
40    
41     while ((cp = fgets(buf, sizeof(buf), stdin)) != NULL)
42     for ( ; ; ) {
43     while (isspace(*cp))
44     cp++;
45     if (!*cp) {
46     putchar('\n');
47     break;
48     }
49     word = cp;
50     while (*cp && *cp != anchor && !isspace(*cp))
51     cp++;
52     i = left-(cp-word);
53     while (i-- > 0)
54     putchar(' ');
55     while (word < cp)
56     putchar(*word++);
57     i = right+1;
58     if (*cp == anchor)
59     do {
60     putchar(*cp++);
61     i--;
62     } while (*cp && !isspace(*cp));
63     while (i-- > 0)
64     putchar(' ');
65     }
66     exit(0);
67     userror:
68     fputs("Usage: ", stderr);
69     fputs(argv[0], stderr);
70     fputs(" [format]\n", stderr);
71     exit(1);
72     }