]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
fix "make dist" target
[lyx.git] / src / buffer.C
index 68e11ca773c89ceb83e0c568d4ebef6c651081a7..b70fca7b6316e2449268764dc939c4c51b639386 100644 (file)
@@ -80,6 +80,7 @@
 #include "insets/insetfloatlist.h"
 #include "support/filetools.h"
 #include "support/path.h"
+#include "support/os.h"
 #include "LaTeX.h"
 #include "Chktex.h"
 #include "LyXView.h"
@@ -1341,7 +1342,7 @@ bool Buffer::save() const
                s = fileName() + '~';
                if (!lyxrc.backupdir_path.empty())
                        s = AddName(lyxrc.backupdir_path,
-                                   subst(CleanupPath(s),'/','!'));
+                                   subst(os::slashify_path(s),'/','!'));
 
                // Rename is the wrong way of making a backup,
                // this is the correct way.
@@ -1504,10 +1505,6 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                    unsigned int linelen) const
 {
        ostringstream buffer;
-       LyXFont font1;
-       LyXFont font2;
-       Inset const * inset;
-       char c;
        char depth = 0;
        int ltype = 0;
        int ltype_depth = 0;
@@ -1517,7 +1514,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
        int noparbreak = 0;
        int islatex = 0;
        if (!par->previous()) {
-               /* begins or ends a deeper area ?*/ 
+               // begins or ends a deeper area ?
                if (depth != par->params.depth()) {
                        if (par->params.depth() > depth) {
                                while (par->params.depth() > depth) {
@@ -1530,7 +1527,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                        }
                }
                
-               /* First write the layout */
+               // First write the layout
                string const tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
                if (tmp == "Itemize") {
                        ltype = 1;
@@ -1573,7 +1570,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                lyxerr << "Should this ever happen?" << endl;
        }
       
-       font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
+       LyXFont const font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
        for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
                if (!i && !noparbreak) {
                        if (linelen > 0)
@@ -1582,17 +1579,17 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                buffer << "  ";
                        currlinelen = depth * 2;
                        switch (ltype) {
-                       case 0: /* Standard */
-                       case 4: /* (Sub)Paragraph */
-                       case 5: /* Description */
+                       case 0: // Standard
+                       case 4: // (Sub)Paragraph
+                       case 5: // Description
                                break;
-                       case 6: /* Abstract */
+                       case 6: // Abstract
                                if (linelen > 0)
                                        buffer << "Abstract\n\n";
                                else
                                        buffer << "Abstract: ";
                                break;
-                       case 7: /* Bibliography */
+                       case 7: // Bibliography
                                if (!ref_printed) {
                                        if (linelen > 0)
                                                buffer << "References\n\n";
@@ -1611,7 +1608,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                currlinelen += (ltype_depth-depth)*2;
                        }
                }
-               font2 = par->GetFontSettings(params, i);
+               LyXFont const font2 = par->GetFontSettings(params, i);
                if (font1.latex() != font2.latex()) {
                        if (font2.latex() == LyXFont::OFF)
                                islatex = 0;
@@ -1620,23 +1617,29 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                } else {
                        islatex = 0;
                }
-               c = par->GetUChar(params, i);
+               
+               char c = par->GetUChar(params, i);
                if (islatex)
                        continue;
                switch (c) {
                case LyXParagraph::META_INSET:
-                       if ((inset = par->GetInset(i))) {
+               {
+                       Inset const * inset = par->GetInset(i);
+                       if (inset) {
                                if (!inset->Ascii(this, buffer)) {
                                        string dummy;
-                                       string s = rsplit(buffer.str().c_str(),
-                                                         dummy, '\n');
+                                       string const s =
+                                               rsplit(buffer.str().c_str(),
+                                                      dummy, '\n');
                                        currlinelen += s.length();
                                } else {
                                        // to be sure it breaks paragraph
                                        currlinelen += linelen;
                                }
                        }
-                       break;
+               }
+               break;
+               
                case LyXParagraph::META_NEWLINE:
                        if (linelen > 0) {
                                buffer << "\n";
@@ -1651,12 +1654,15 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                currlinelen += (ltype_depth - depth) * 2;
                        }
                        break;
+                       
                case LyXParagraph::META_HFILL: 
                        buffer << "\t";
                        break;
+                       
                case '\\':
                        buffer << "\\";
                        break;
+                       
                default:
                        if ((linelen > 0) && (currlinelen > (linelen - 10)) &&
                            (c == ' ') && ((i + 2) < par->size()))
@@ -1764,7 +1770,7 @@ void Buffer::makeLaTeXFile(string const & fname,
                if (!original_path.empty()) {
                        ofs << "\\makeatletter\n"
                            << "\\def\\input@path{{"
-                           << original_path << "/}}\n"
+                           << os::external_path(original_path) << "/}}\n"
                            << "\\makeatother\n";
                        texrow.newline();
                        texrow.newline();
@@ -1778,8 +1784,7 @@ void Buffer::makeLaTeXFile(string const & fname,
                if (tokenPos(tclass.opt_fontsize(),
                             '|', params.fontsize) >= 0) {
                        // only write if existing in list (and not default)
-                       options << params.fontsize;
-                       options << "pt,";
+                       options << params.fontsize << "pt,";
                }
                
                
@@ -1833,7 +1838,7 @@ void Buffer::makeLaTeXFile(string const & fname,
                
                // language should be a parameter to \documentclass
                use_babel = false;
-               string language_options;
+               ostringstream language_options;
                if (params.language->babel() == "hebrew"
                    && default_language->babel() != "hebrew")
                         // This seems necessary
@@ -1846,10 +1851,10 @@ void Buffer::makeLaTeXFile(string const & fname,
                        for (LaTeXFeatures::LanguageList::const_iterator cit =
                                     features.UsedLanguages.begin();
                             cit != features.UsedLanguages.end(); ++cit)
-                               language_options += (*cit)->babel() + ',';
-                       language_options += params.language->babel();
+                               language_options << (*cit)->babel() << ',';
+                       language_options << params.language->babel();
                        if (lyxrc.language_global_options)
-                               options << language_options << ',';
+                               options << language_options.str() << ',';
                }
 
                // the user-defined options
@@ -2036,8 +2041,9 @@ void Buffer::makeLaTeXFile(string const & fname,
                        string tmp = lyxrc.language_package;
                        if (!lyxrc.language_global_options
                            && tmp == "\\usepackage{babel}")
-                               tmp = "\\usepackage[" +
-                                       language_options + "]{babel}";
+                               tmp = string("\\usepackage[") +
+                                       language_options.str().c_str() +
+                                       "]{babel}";
                        ofs << tmp << "\n";
                        texrow.newline();
                }