Hello,
I skimmed through the manual, but I didn't find what I was looking
for, so I thought I would ask.
There does not seem to an option to put the null statement on a
separate line. Is this right? Also, shouldn't the -kr style be using
this option?
Consider the following code fragment:
1 #include <ctype.h>
2
3 int getch(void);
4 void ungetch(int);
5
6 void skipwc(void)
7 {
8 int c;
9 while (isspace(c = getch()))
10 ;
11 ungetch(c);
12 }
Running this through
indent -kr -i8
I would expect to get the same exact output back. What I get instead
is:
1 #include <ctype.h>
2
3 int getch(void);
4 void ungetch(int);
5
6 void skipwc(void)
7 {
8 int c;
9 while (isspace(c = getch()));
10 ungetch(c);
11 }
The null statement is joined with the while loop (the -nss
flag). AFAIK, the actual K&R books does not do this. See page 18 of
the 2nd edition for example.
Interestingly, if there's a comment between the while and the null
statement
1 #include <ctype.h>
2
3 int getch(void);
4 void ungetch(int);
5
6 void skipwc(void)
7 {
8 int c;
9 while (isspace(c = getch())) /* skip whitespace */
10 ;
11 ungetch(c);
12 }
I get the same exact output back. No issues there.
I'm using GNU indent 2.2.12 on Debian.
Apologies if I'm missing something here. I don't think I am though.
Best regards,
Mattias Märka