]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Help avoiding shortcut clashes by discriminating strings.
[lyx.git] / src / Buffer.cpp
index f9545e4f40a5c3a541b90233fbc3083f2ce4632a..23c16406f4c1d505c7e9907644d743399001fc09 100644 (file)
@@ -1055,10 +1055,15 @@ bool Buffer::save() const
                        backupName = FileName(addName(lyxrc.backupdir_path,
                                                      mangledName));
                }
-               // do not copy because of #6587
-               if (fileName().moveTo(backupName)) {
-                       madeBackup = true;
-               } else {
+
+               // Except file is symlink do not copy because of #6587.
+               // Hard links have bad luck.
+               if (fileName().isSymLink())
+                       madeBackup = fileName().copyTo(backupName);
+               else
+                       madeBackup = fileName().moveTo(backupName);
+
+               if (!madeBackup) {
                        Alert::error(_("Backup failure"),
                                     bformat(_("Cannot create backup file %1$s.\n"
                                               "Please check whether the directory exists and is writable."),
@@ -1361,8 +1366,7 @@ void Buffer::writeLaTeXSource(odocstream & os,
        if (output_preamble) {
                if (!runparams.nice) {
                        // code for usual, NOT nice-latex-file
-                       os << "\\batchmode\n"; // changed
-                       // from \nonstopmode
+                       os << "\\batchmode\n"; // changed from \nonstopmode
                        d->texrow.newline();
                }
                if (!original_path.empty()) {
@@ -1449,7 +1453,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
        }
 
        // the real stuff
-       latexParagraphs(*this, text(), os, d->texrow, runparams);
+       otexstream ots(os);
+       latexParagraphs(*this, text(), ots, d->texrow, runparams);
 
        // Restore the parenthood if needed
        if (output_preamble)
@@ -3128,9 +3133,11 @@ void Buffer::getSourceCode(odocstream & os, string const format,
                else if (runparams.flavor == OutputParams::HTML) {
                        XHTMLStream xs(os);
                        xhtmlParagraphs(text(), *this, xs, runparams);
-               } else 
+               } else {
                        // latex or literate
-                       latexParagraphs(*this, text(), os, texrow, runparams);
+                       otexstream ots(os);
+                       latexParagraphs(*this, text(), ots, texrow, runparams);
+               }
        }
 }