aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Beazley <dave-swig@dabeaz.com>2003-03-23 14:13:34 +0000
committerDave Beazley <dave-swig@dabeaz.com>2003-03-23 14:13:34 +0000
commit3851e222d0f93460886764541b6def8379645de4 (patch)
tree5ff9de6ceb13f8faf2ef8aa00a464e376fc920b7
parentcbfec5e05985dd8bf580e64daa826aa606e23002 (diff)
downloadswig-3851e222d0f93460886764541b6def8379645de4.tar.gz
Fixed xml sym:name problem.
**** SPECIAL CAUTION TO DEVELOPERS **** The strings that represent attribute key names like "name", "sym:name", "type", and so forth are extensively shared to save memory. If a key name is modified for some reason (which is not recommended), be aware that those change may affect thousands of parse tree nodes. Moreover, changes to a key name will break the hashing algorithm used to perform attribute lookup. Bottom line: don't modify hash table key strings. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4618 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Source/Modules/xml.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx
index 6101109e8..f1d0edb6b 100644
--- a/Source/Modules/xml.cxx
+++ b/Source/Modules/xml.cxx
@@ -178,21 +178,25 @@ public:
print_indent(0);
if (DohIsString(Getattr(obj,k)))
{
+ String *ck = NewString(k);
o = Str(Getattr(obj,k));
- Replaceall( k, ":", "_" );
+ Replaceall( ck, ":", "_" );
/* Do first to avoid aliasing errors. */
Replaceall( o, "&", "&amp;" );
Replaceall( o, "<", "&lt;" );
Replaceall( o, "\"", "&quot;" );
Replaceall( o, "\\", "\\\\" );
- Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", k, o, ++id, o );
+ Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
Delete(o);
+ Delete(ck);
}
else
{
o = Getattr(obj,k);
- Replaceall( k, ":", "_" );
- Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", k, o, ++id, o );
+ String *ck = NewString(k);
+ Replaceall( ck, ":", "_" );
+ Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
+ Delete(ck);
}
}
k = Nextkey(obj);