small cosmetic change to manage parentesis () closed in different lines, and make compact mode more compact
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7688 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
08176a361a
commit
cc9f9be00f
1 changed files with 17 additions and 4 deletions
|
|
@ -77,6 +77,8 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
int level = 0;
|
int level = 0;
|
||||||
int c, i;
|
int c, i;
|
||||||
int empty = 1;
|
int empty = 1;
|
||||||
|
int indent = 4;
|
||||||
|
int plevel = 0;
|
||||||
|
|
||||||
ts = NewString("");
|
ts = NewString("");
|
||||||
Seek(str,0, SEEK_SET);
|
Seek(str,0, SEEK_SET);
|
||||||
|
|
@ -104,6 +106,14 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
if (c == '\'') break;
|
if (c == '\'') break;
|
||||||
}
|
}
|
||||||
empty = 0;
|
empty = 0;
|
||||||
|
} else if (c == '(') {
|
||||||
|
Putc(c,ts);
|
||||||
|
plevel+=indent;
|
||||||
|
empty = 0;
|
||||||
|
} else if (c == ')') {
|
||||||
|
Putc(c,ts);
|
||||||
|
plevel-=indent;
|
||||||
|
empty = 0;
|
||||||
} else if (c == '{') {
|
} else if (c == '{') {
|
||||||
Putc(c,ts);
|
Putc(c,ts);
|
||||||
Putc('\n',ts);
|
Putc('\n',ts);
|
||||||
|
|
@ -111,7 +121,7 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
Putc(' ',f);
|
Putc(' ',f);
|
||||||
Printf(f,"%s", ts);
|
Printf(f,"%s", ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
level+=4;
|
level+=indent;
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (!isspace(c)) {
|
if (!isspace(c)) {
|
||||||
Ungetc(c,str);
|
Ungetc(c,str);
|
||||||
|
|
@ -127,7 +137,7 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
Printf(f,"%s",ts);
|
Printf(f,"%s",ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
}
|
}
|
||||||
level-=4;
|
level-=indent;
|
||||||
Putc(c,ts);
|
Putc(c,ts);
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == '\n') {
|
} else if (c == '\n') {
|
||||||
|
|
@ -139,6 +149,8 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
Putc(' ',f);
|
Putc(' ',f);
|
||||||
}
|
}
|
||||||
Printf(f,"%s",ts);
|
Printf(f,"%s",ts);
|
||||||
|
for (i = 0; i < plevel; i++)
|
||||||
|
Putc(' ',f);
|
||||||
}
|
}
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
empty = 1;
|
empty = 1;
|
||||||
|
|
@ -197,6 +209,7 @@ Wrapper_compact_print(String *str, File *f) {
|
||||||
int level = 0;
|
int level = 0;
|
||||||
int c, i;
|
int c, i;
|
||||||
int empty = 1;
|
int empty = 1;
|
||||||
|
int indent = 2;
|
||||||
|
|
||||||
ts = NewString("");
|
ts = NewString("");
|
||||||
tf = NewString("");
|
tf = NewString("");
|
||||||
|
|
@ -244,7 +257,7 @@ Wrapper_compact_print(String *str, File *f) {
|
||||||
}
|
}
|
||||||
Printf(tf,"%s",ts);
|
Printf(tf,"%s",ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
level+=4;
|
level+=indent;
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (!isspace(c)) {
|
if (!isspace(c)) {
|
||||||
Ungetc(c,str);
|
Ungetc(c,str);
|
||||||
|
|
@ -268,7 +281,7 @@ Wrapper_compact_print(String *str, File *f) {
|
||||||
Printf(tf, "%s", ts);
|
Printf(tf, "%s", ts);
|
||||||
Putc(c, tf);
|
Putc(c, tf);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
level-=4;
|
level-=indent;
|
||||||
} else if (c == '\n') { /* line end */
|
} else if (c == '\n') { /* line end */
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (!isspace(c))
|
if (!isspace(c))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue