Soft'N'Design Software
/
projects
/
indent.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add missing include
[indent.git]
/
indent.c
diff --git
a/indent.c
b/indent.c
index a37dad77691017571e161d42ddd78d38ad9a029c..26b19288163877e594201fe048c3e0d0273f2fcb 100644
(file)
--- a/
indent.c
+++ b/
indent.c
@@
-3,6
+3,7
@@
/* linker: debug.o */
#include <assert.h>
/* linker: debug.o */
#include <assert.h>
+#include <errno.h>
#include <getopt.h>
#include <malloc.h>
#include <stdio.h>
#include <getopt.h>
#include <malloc.h>
#include <stdio.h>
@@
-62,6
+63,7
@@
int indent (FILE *fin, FILE *fout, cmode_t cmode) {
int string = 0;
int character = 0;
int special = 0;
int string = 0;
int character = 0;
int special = 0;
+ int space = 0;
while (!feof (fin)) {
memset (bufin, 0, sizeof (bufin));
while (!feof (fin)) {
memset (bufin, 0, sizeof (bufin));
@@
-107,7
+109,9
@@
int indent (FILE *fin, FILE *fout, cmode_t cmode) {
case ' ':
case '\t':
if (begin == 0) {
case ' ':
case '\t':
if (begin == 0) {
- *ptout++ = *ptin;
+ if ((string) || (!space)) {
+ *ptout++ = *ptin;
+ }
}
break;
case '{':
}
break;
case '{':
@@
-168,6
+172,7
@@
int indent (FILE *fin, FILE *fout, cmode_t cmode) {
}
*ptout++ = *ptin;
}
}
*ptout++ = *ptin;
}
+ space = ((*ptin == ' ') || (*ptin == '\t'));
special = (*ptin == '\\');
parent += (*ptin == '(') ? +1 : (*ptin == ')') ? -1 : 0;
ptin++;
special = (*ptin == '\\');
parent += (*ptin == '(') ? +1 : (*ptin == ')') ? -1 : 0;
ptin++;