add better support for encoder, command including
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8149 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
eacf63d041
commit
a32d40e0f1
1 changed files with 25 additions and 3 deletions
|
|
@ -55,14 +55,24 @@ static DOH *encode(char *name, DOH *s) {
|
||||||
DOH *handle, *ns;
|
DOH *handle, *ns;
|
||||||
DOH *(*fn)(DOH *);
|
DOH *(*fn)(DOH *);
|
||||||
long pos;
|
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))) {
|
if (!encodings || !(handle = Getattr(encodings,name))) {
|
||||||
return Copy(s);
|
return Copy(s);
|
||||||
}
|
}
|
||||||
|
if (tmp) s = tmp;
|
||||||
pos = Tell(s);
|
pos = Tell(s);
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s,0,SEEK_SET);
|
||||||
fn = (DOH *(*)(DOH *)) Data(handle);
|
fn = (DOH *(*)(DOH *)) Data(handle);
|
||||||
ns = (*fn)(s);
|
ns = (*fn)(s);
|
||||||
Seek(s,pos,SEEK_SET);
|
Seek(s,pos,SEEK_SET);
|
||||||
|
if (tmp) Delete(tmp);
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,6 +114,7 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
char *stemp;
|
char *stemp;
|
||||||
int nbytes = 0;
|
int nbytes = 0;
|
||||||
char encoder[128], *ec = 0;
|
char encoder[128], *ec = 0;
|
||||||
|
int plevel = 0;
|
||||||
|
|
||||||
memset (newformat, 0, sizeof (newformat));
|
memset (newformat, 0, sizeof (newformat));
|
||||||
|
|
||||||
|
|
@ -146,6 +157,7 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
nbytes++;
|
nbytes++;
|
||||||
state = 0;
|
state = 0;
|
||||||
} else if (*p == '(') {
|
} else if (*p == '(') {
|
||||||
|
++plevel;
|
||||||
ec = encoder;
|
ec = encoder;
|
||||||
state = 60;
|
state = 60;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -246,9 +258,19 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
|
|
||||||
/* Got an encoding header */
|
/* Got an encoding header */
|
||||||
case 60:
|
case 60:
|
||||||
if (*p == ')') {
|
if (*p == '(') {
|
||||||
*ec = 0;
|
++plevel;
|
||||||
state = 10;
|
*ec = *p;
|
||||||
|
ec++;
|
||||||
|
} else if (*p == ')') {
|
||||||
|
--plevel;
|
||||||
|
if (plevel <= 0) {
|
||||||
|
*ec = 0;
|
||||||
|
state = 10;
|
||||||
|
} else {
|
||||||
|
*ec = *p;
|
||||||
|
ec++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
*ec = *p;
|
*ec = *p;
|
||||||
ec++;
|
ec++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue