From ea8496bd993eb2b41d9ea3687bf6dec3a20acbd0 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Tue, 11 Jul 2000 15:04:08 +0000 Subject: [PATCH] Fixed the pretty-printing code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@565 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Swig/wrapfunc.c | 39 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/SWIG/Source/Swig/wrapfunc.c b/SWIG/Source/Swig/wrapfunc.c index 522bb705b..551369fde 100644 --- a/SWIG/Source/Swig/wrapfunc.c +++ b/SWIG/Source/Swig/wrapfunc.c @@ -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 -Wrapper_print(Wrapper *w, DOHFile *f) { - DOHString *str, *ts; +Wrapper_pretty_print(DOHString *str, DOHFile *f) { + DOHString *ts; int level = 0; int c, i; int empty = 1; - str = 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); Clear(ts); while ((c = Getc(str)) != EOF) { - if (c == '{') { Putc(c,ts); Putc('\n',ts); @@ -105,15 +99,34 @@ Wrapper_print(Wrapper *w, DOHFile *f) { Clear(ts); empty = 1; } else { - Putc(c,ts); - empty = 0; + if (!empty || !isspace(c)) { + Putc(c,ts); + empty = 0; + } } } Delete(ts); - Delete(str); 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() *