Fixed the pretty-printing code.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@565 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-07-11 15:04:08 +00:00
commit ea8496bd99

View file

@ -51,28 +51,22 @@ DelWrapper(Wrapper *w) {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Wrapper_print() * Wrapper_pretty_print()
* *
* Print out a wrapper function. Does pretty printing as well. * Formats a wrapper function and fixes up the indentation.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
void void
Wrapper_print(Wrapper *w, DOHFile *f) { Wrapper_pretty_print(DOHString *str, DOHFile *f) {
DOHString *str, *ts; DOHString *ts;
int level = 0; int level = 0;
int c, i; int c, i;
int empty = 1; int empty = 1;
str = NewString("");
ts = NewString(""); ts = NewString("");
Printf(str,"%s\n", w->def);
Printf(str,"%s\n", w->locals);
Printf(str,"%s\n", w->code);
Seek(str,0, SEEK_SET); Seek(str,0, SEEK_SET);
Clear(ts); Clear(ts);
while ((c = Getc(str)) != EOF) { while ((c = Getc(str)) != EOF) {
if (c == '{') { if (c == '{') {
Putc(c,ts); Putc(c,ts);
Putc('\n',ts); Putc('\n',ts);
@ -105,15 +99,34 @@ Wrapper_print(Wrapper *w, DOHFile *f) {
Clear(ts); Clear(ts);
empty = 1; empty = 1;
} else { } else {
Putc(c,ts); if (!empty || !isspace(c)) {
empty = 0; Putc(c,ts);
empty = 0;
}
} }
} }
Delete(ts); Delete(ts);
Delete(str);
Printf(f,"\n"); Printf(f,"\n");
} }
/* -----------------------------------------------------------------------------
* Wrapper_print()
*
* Print out a wrapper function. Does pretty printing as well.
* ----------------------------------------------------------------------------- */
void
Wrapper_print(Wrapper *w, DOHFile *f) {
DOHString *str;
str = NewString("");
Printf(str,"%s\n", w->def);
Printf(str,"%s\n", w->locals);
Printf(str,"%s\n", w->code);
Wrapper_pretty_print(str,f);
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Wrapper_add_local() * Wrapper_add_local()
* *