diff options
author | Marcelo Matus <mmatus@acms.arizona.edu> | 2005-12-31 10:38:29 +0000 |
---|---|---|
committer | Marcelo Matus <mmatus@acms.arizona.edu> | 2005-12-31 10:38:29 +0000 |
commit | 79acadb7773930439523c11c5f08b08aac80a7ed (patch) | |
tree | 07e664317985c6a0c45a2c0805a232480f287552 /Source/DOH | |
parent | cd0b345ebdaced1d0d960b7718fb9c8574ba9fed (diff) | |
download | swig-79acadb7773930439523c11c5f08b08aac80a7ed.tar.gz |
add better support for encoder, command including
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8149 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Source/DOH')
-rw-r--r-- | Source/DOH/fio.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index 8445043a0..0f84845f2 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -55,14 +55,24 @@ static DOH *encode(char *name, DOH *s) { DOH *handle, *ns; DOH *(*fn)(DOH *); long pos; + char *cfmt = strstr(name,":"); + DOH *tmp = 0; + if (cfmt) { + tmp = NewStringf(cfmt + 1, s); + Setfile(tmp,Getfile((DOH *)s)); + Setline(tmp,Getline((DOH *)s)); + *cfmt = '\0'; + } if (!encodings || !(handle = Getattr(encodings,name))) { return Copy(s); } + if (tmp) s = tmp; pos = Tell(s); Seek(s,0,SEEK_SET); fn = (DOH *(*)(DOH *)) Data(handle); ns = (*fn)(s); Seek(s,pos,SEEK_SET); + if (tmp) Delete(tmp); return ns; } @@ -104,6 +114,7 @@ DohvPrintf(DOH *so, const char *format, va_list ap) char *stemp; int nbytes = 0; char encoder[128], *ec = 0; + int plevel = 0; memset (newformat, 0, sizeof (newformat)); @@ -146,6 +157,7 @@ DohvPrintf(DOH *so, const char *format, va_list ap) nbytes++; state = 0; } else if (*p == '(') { + ++plevel; ec = encoder; state = 60; } else { @@ -246,9 +258,19 @@ DohvPrintf(DOH *so, const char *format, va_list ap) /* Got an encoding header */ case 60: - if (*p == ')') { - *ec = 0; - state = 10; + if (*p == '(') { + ++plevel; + *ec = *p; + ec++; + } else if (*p == ')') { + --plevel; + if (plevel <= 0) { + *ec = 0; + state = 10; + } else { + *ec = *p; + ec++; + } } else { *ec = *p; ec++; |