]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbibtex.C
hopefully fix tex2lyx linking.
[lyx.git] / src / insets / insetbibtex.C
index 4ab1d097dcf15c8dc254d4a63cc1f7c2266d811d..d0f8ff7d6690a88aff86e0ae4110a380223ffe65 100644 (file)
@@ -44,7 +44,7 @@ using support::ascii_lowercase;
 using support::changeExtension;
 using support::contains;
 using support::copy;
-using support::FileName;
+using support::DocFileName;
 using support::findtexfile;
 using support::isFileReadable;
 using support::latex_path;
@@ -151,26 +151,31 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
        // use such filenames.)
        // Otherwise, store the (maybe absolute) path to the original,
        // unmangled database name.
-       typedef boost::char_separator<char> Separator;
-       typedef boost::tokenizer<Separator> Tokenizer;
-
-       Separator const separator(",");
-       Tokenizer const tokens(to_utf8(getParam("bibfiles")), separator);
+       typedef boost::char_separator<char_type> Separator;
+       typedef boost::tokenizer<Separator, docstring::const_iterator, docstring> Tokenizer;
+
+       Separator const separator(from_ascii(",").c_str());
+       // The tokenizer must not be called with temporary strings, since
+       // it does not make a copy and uses iterators of the string further
+       // down. getParam returns a reference, so this is OK.
+       Tokenizer const tokens(getParam("bibfiles"), separator);
        Tokenizer::const_iterator const begin = tokens.begin();
        Tokenizer::const_iterator const end = tokens.end();
 
-       std::ostringstream dbs;
+       odocstringstream dbs;
        for (Tokenizer::const_iterator it = begin; it != end; ++it) {
-               string const input = trim(*it);
+               docstring const input = trim(*it);
+               // FIXME UNICODE
+               string utf8input(to_utf8(input));
                string database =
-                       normalize_name(buffer, runparams, input, ".bib");
+                       normalize_name(buffer, runparams, utf8input, ".bib");
                string const in_file = database + ".bib";
 
                if (!runparams.inComment && !runparams.dryrun && !runparams.nice &&
                    isFileReadable(in_file)) {
 
                        // mangledFilename() needs the extension
-                       database = removeExtension(FileName(in_file).mangledFilename());
+                       database = removeExtension(DocFileName(in_file).mangledFilename());
                        string const out_file = makeAbsPath(database + ".bib",
                                        buffer.getMasterBuffer()->temppath());
 
@@ -184,10 +189,10 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
 
                if (it != begin)
                        dbs << ',';
-               dbs << latex_path(database);
+               // FIXME UNICODE
+               dbs << from_utf8(latex_path(database));
        }
-       // FIXME UNICODE
-       docstring const db_out = from_utf8(dbs.str());
+       docstring const db_out = dbs.str();
 
        // Post this warning only once.
        static bool warned_about_spaces = false;
@@ -226,7 +231,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
                    isFileReadable(in_file)) {
                        // use new style name
                        base = removeExtension(
-                                       FileName(in_file).mangledFilename());
+                                       DocFileName(in_file).mangledFilename());
                        string const out_file = makeAbsPath(base + ".bst",
                                        buffer.getMasterBuffer()->temppath());
                        bool const success = copy(in_file, out_file);