Soft'N'Design Software
/
projects
/
indent.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b51fe42
)
manage space
author
Laurent Mazet
<laurent.mazet@thalesgroup.com>
Thu, 14 Dec 2023 11:00:18 +0000
(12:00 +0100)
committer
Laurent Mazet
<laurent.mazet@thalesgroup.com>
Thu, 14 Dec 2023 11:00:18 +0000
(12:00 +0100)
indent.c
patch
|
blob
|
blame
|
history
diff --git
a/indent.c
b/indent.c
index a37dad77691017571e161d42ddd78d38ad9a029c..025aac814799a3b66180f10ab25206d2c16d51e7 100644
(file)
--- a/
indent.c
+++ b/
indent.c
@@
-62,6
+62,7
@@
int indent (FILE *fin, FILE *fout, cmode_t cmode) {
int string = 0;
int character = 0;
int special = 0;
+ int space = 0;
while (!feof (fin)) {
memset (bufin, 0, sizeof (bufin));
@@
-107,7
+108,9
@@
int indent (FILE *fin, FILE *fout, cmode_t cmode) {
case ' ':
case '\t':
if (begin == 0) {
- *ptout++ = *ptin;
+ if ((string) || (!space)) {
+ *ptout++ = *ptin;
+ }
}
break;
case '{':
@@
-168,6
+171,7
@@
int indent (FILE *fin, FILE *fout, cmode_t cmode) {
}
*ptout++ = *ptin;
}
+ space = ((*ptin == ' ') || (*ptin == '\t'));
special = (*ptin == '\\');
parent += (*ptin == '(') ? +1 : (*ptin == ')') ? -1 : 0;
ptin++;