X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsgml.cpp;h=75802c2bd44d2113da87253c0c31ffb0fc267df0;hb=f58638c704b0b4ac66e5f88431901977cc7801be;hp=f895287195b5c55aabc8d7e8301cb572fb6c8057;hpb=caa4e94bf02b9d3131bc280390fae44683fd5e9a;p=lyx.git diff --git a/src/sgml.cpp b/src/sgml.cpp index f895287195..75802c2bd4 100644 --- a/src/sgml.cpp +++ b/src/sgml.cpp @@ -28,6 +28,7 @@ #include "support/textutils.h" #include +#include using namespace std; using namespace lyx::support; @@ -102,8 +103,11 @@ docstring sgml::escapeString(docstring const & raw) } -docstring const sgml::uniqueID(docstring const label) +docstring const sgml::uniqueID(docstring const & label) { + // FIXME THREAD + // It seems unlikely there could be a problem here, + // but we could have concurrent access, in principle. static unsigned int seed = 1000; return label + convert(++seed); } @@ -133,8 +137,10 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams, docstring content; typedef map MangledMap; - static MangledMap mangledNames; - static int mangleID = 1; + static QThreadStorage tMangledNames; + static QThreadStorage tMangleID; + + MangledMap & mangledNames = tMangledNames.localData(); MangledMap::const_iterator const known = mangledNames.find(orig); if (known != mangledNames.end()) @@ -163,9 +169,10 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams, } } - if (mangle) + if (mangle) { + int & mangleID = tMangleID.localData(); content += "-" + convert(mangleID++); - else if (isDigitASCII(content[content.size() - 1])) + } else if (isDigitASCII(content[content.size() - 1])) content += "."; mangledNames[orig] = content; @@ -181,7 +188,12 @@ void sgml::openTag(odocstream & os, string const & name, string const & attribut string param = subst(attribute, "<", "\""); param = subst(param, ">", "\""); - if (!name.empty() && name != "!-- --") { + // Note: we ignore the name if it empty or if it is a comment "" or + // if the name is *dummy*. + // We ignore dummy because dummy is not a valid docbook element and it is + // the internal name given to single paragraphs in the latex output. + // This allow us to simplify the code a lot and is a reasonable compromise. + if (!name.empty() && name != "!-- --" && name != "dummy") { os << '<' << from_ascii(name); if (!param.empty()) os << ' ' << from_ascii(param); @@ -192,7 +204,7 @@ void sgml::openTag(odocstream & os, string const & name, string const & attribut void sgml::closeTag(odocstream & os, string const & name) { - if (!name.empty() && name != "!-- --") + if (!name.empty() && name != "!-- --" && name != "dummy") os << "'; } @@ -220,10 +232,12 @@ void sgml::openTag(Buffer const & buf, odocstream & os, if (param.find('#') != string::npos) { // FIXME UNICODE if (!style.counter.empty()) - // NOTE This could use OutputUpdate and track the counters. - counters.step(style.counter); + // This uses InternalUpdate at the moment becuase sgml output + // does not do anything with tracked counters, and it would need + // to track layouts if it did want to use them. + counters.step(style.counter, InternalUpdate); else - counters.step(from_ascii(name)); + counters.step(from_ascii(name), InternalUpdate); int i = counters.value(from_ascii(name)); attribute = subst(param, "#", convert(i)); } else {