]> git.lyx.org Git - features.git/commitdiff
Remove the optional bool argument to ChangeExtension().
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 11 May 2000 16:12:46 +0000 (16:12 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 11 May 2000 16:12:46 +0000 (16:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@730 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
ChangeLog
README.OS2
development/OS2/quick_fix.patch [new file with mode: 0644]
src/Chktex.C
src/ImportLaTeX.C
src/LaTeX.C
src/LaTeXLog.C
src/LyXSendto.C
src/buffer.C
src/bufferlist.C
src/insets/insetbib.C
src/insets/insetinclude.C
src/lyx_cb.C
src/lyxfunc.C
src/support/filetools.C
src/support/filetools.h

index 6978d652e1bff774a00fcb45701322b5838fba07..5553394acf0e4d35c0f97cb1a49c88b1a7b65be5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
+2000-05-11  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * add addendum to README.OS2 and small patch (from SMiyata)
+
 2000-05-10  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
+       * many files: correct the calls to ChangeExtension().
+
+       * src/support/filetools.C (ChangeExtension): remove the no_path
+       argument, which does not belong there. Use OnlyFileName() instead.
+
+       * src/insets/insetbib.C (Latex): use absolute paths for bibtex
+       files when LaTeXing a non-nice latex file.
+
        * src/lyxlookup.C (isDeadEvent): use a switch statement instead of
        a chain of "if". Return false when deadkeys are not handled.
        
index 4491efd1e49b7dd3ed1ea534c4741b0276aee023..895baf6aff370ec218fcd9e2785d4b3bcf566200 100644 (file)
@@ -1,3 +1,74 @@
+These are temporary instructions from Shigeru Miyata <miyata@kusm.kyoto-u.ac.jp>
+===========================================================================
+
+(The top level) configure.cmd is obsoleted by.  Please follow the
+step like this:
+
+1. Install GNU m4, gnu?utils, aclocal/2, autoheader/2, automake/2,
+   autoconf/2, perl, GNU patch and a UNIX type shell like pdksh.
+2. Apply the patch development/OS2/quick_fix.patch
+   // os2_defines.h needs a modification because bmtable.c is C.
+   // Now it hits me, why don't we patch "test -x" (gnufutils)?
+   // However, we can't modify the behavior of "test -f", so
+   // it is still necessary to modify script files for LyX.
+3. Install xforms 0.88 and rename
+      forms.a   -> forms_d.a
+      forms_s.a -> forms.a
+   // Ever since 1.1.5pre1, you cannot link xforms dynamically.
+   // If you don't like this, please ask Holger Veit to export
+   // fl_get_scrollbar_bounds, fl_get_scrollbar_increment and
+   // fl_get_scrollbar_value from the DLL.  They're already there!
+4. Install Hung-Chi Chu's port of GNU gettext.  Other ports will
+   not work.
+5. Set environment variables
+      MAKE_SHELL=sh
+      LIBS=-lulib -lsocket -lbsd -lshm -lstdcpp
+   // ulib must be linked if we use static xforms library.
+   // Unless you are using pgcc, we use gcc rather than g++.
+   // Hence stdc++ must be linked explicitely.  Also please
+   // note that ld for pgcc often fails to link big executables
+   // like unstripped lyx.exe
+6. From sh prompt, type
+      autogen.sh
+   and then
+      configure --prefix=/XFree86 --datadir=/XFree86/lib/X11
+      x11make
+   // Please do not use make.cmd  make.exe should be OK.
+   // x11make.exe is the safest choice
+   // While you are running configure, make sure that it is not
+   // a background process to other CPU intensive processes.
+   // While OS/2 kernel is much more efficient, faster and
+   // more responsive than other systems like LINUX (you can
+   // easily *FEEL* this if you stop PM/WPS and run XFree86
+   // only), its TTY interface is lousy, to say the least.
+   // If the synchronization to the children breaks, configure
+   // often detects wrongfully.
+
+> Or it is possible to download the compiled program?
+
+7. If you are going to make a binary distribution, you have
+   to prepare lib/configure.cmd noweb2lyx.cmd and reLyX.cmd,
+   since end users may not have a UNIX type shell installed.
+   At this stage, lib/configure.cmd in the 1.1.5pre1 should work
+   without change.
+   // If Dekel Tsur introduces the converter_command tag to lyxrc,
+   // the situation changes.
+   In order to create noweb2lyx.cmd and reLyX.cmd, first rename
+   noweb2lyx and reLyX and open them in a text editor.  You
+   have to remove hardcoded path in the first line:
+#!perl
+   Also in reLyX.cmd, $lyxdir should be changed to include the
+   drive letter (the line 21):
+$lyxdir = "$ENV{X11ROOT}/XFree86/lib/X11/lyx";
+   Finally, prepend a line
+extproc perl.exe -S
+   so that cmd.exe pass the execution control to perl.
+   // I know configure.cmd had done this automatically.
+   // So you can compare the result with the scripts in 1.0.4
+   // distribution.
+
+
+===========================================================================
 
 README file for OS/2 version of LyX 1.0.1
 by Shigeru Miyata <miyata@kusm.kyoto-u.ac.jp>
diff --git a/development/OS2/quick_fix.patch b/development/OS2/quick_fix.patch
new file mode 100644 (file)
index 0000000..5ea8b43
--- /dev/null
@@ -0,0 +1,155 @@
+diff -ubr -X g:/exclude lyx-devel/config/progtest.m4 lyx-build/config/progtest.m4
+--- lyx-devel/config/progtest.m4       Tue Feb 22 06:44:28 2000
++++ lyx-build/config/progtest.m4       Wed May 10 10:12:44 2000
+@@ -11,6 +11,19 @@
+ dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
+ dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
+ AC_DEFUN(AM_PATH_PROG_WITH_TEST,
++[case "`uname -s 2> /dev/null`" in
++OS/2)
++  PATH=`echo -E "$PATH" | sed 's+\\\\+/+g'`
++  PATH_IFS=';'
++  EXE_EXT='.exe'
++  CMD_EXT='.cmd'
++  ;;
++*)
++  PATH_IFS=':'
++  EXE_EXT=''
++  CMD_EXT=''
++  ;;
++esac]
+ [# Extract the first word of "$2", so it can be a program name with args.
+ set dummy $2; ac_word=[$]2
+ AC_MSG_CHECKING([for $ac_word])
+@@ -20,10 +33,12 @@
+   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
+   ;;
+   *)
+-  IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
++  IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}$PATH_IFS"
+   for ac_dir in ifelse([$5], , $PATH, [$5]); do
+     test -z "$ac_dir" && ac_dir=.
+-    if test -f $ac_dir/$ac_word; then
++    if test -f $ac_dir/$ac_word \
++       -o -f $ac_dir/$ac_word$EXE_EXT \
++       -o -f $ac_dir/$ac_word$CMD_EXT; then
+       if [$3]; then
+       ac_cv_path_$1="$ac_dir/$ac_word"
+       break
+diff -ubr -X g:/exclude lyx-devel/lib/configure.m4 lyx-build/lib/configure.m4
+--- lyx-devel/lib/configure.m4 Tue Feb 22 06:44:42 2000
++++ lyx-build/lib/configure.m4 Wed May 10 07:24:02 2000
+@@ -28,6 +28,19 @@
+ dnl
+ define(SEARCH_PROG,[dnl
+ changequote([,])dnl
++case "`uname -s 2> /dev/null`" in
++OS/2)
++  PATH=`echo -E "$PATH" | sed 's+\\\\+/+g'`
++  PATH_IFS=';'
++  EXE_EXT='.exe'
++  CMD_EXT='.cmd'
++  ;;
++*)
++  PATH_IFS=':'
++  EXE_EXT=''
++  CMD_EXT=''
++  ;;
++esac
+ MSG_CHECKING($1)
+ MSG_RESULT(($3))
+ $2=
+@@ -37,10 +50,12 @@
+ set dummy $ac_prog ; ac_word=$[2]
+ if test -n "$ac_word"; then
+   MSG_CHECKING([for \"$ac_word\"],[+])
+-  IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS=":"
++  IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="$PATH_IFS"
+   for ac_dir in $PATH; do
+     test -z "$ac_dir" && ac_dir=.
+-    if test -x [$ac_dir/$ac_word]; then
++    if test -x [$ac_dir/$ac_word] \
++       -o -x [$ac_dir/$ac_word$EXE_EXT] \
++       -o -x [$ac_dir/$ac_word$CMD_EXT]; then
+       $2="$ac_prog"
+       break
+     fi
+@@ -179,8 +194,17 @@
+ fi
+ # Search for an installed reLyX or a ready-to-install one
++case "`uname -s 2> /dev/null`" in
++OS/2)
++save_PATH=`echo -E "$PATH" | sed 's+\\\\+/+g'`
++PATH_IFS=';'
++;;
++*)
+ save_PATH=${PATH}
+-PATH=${PATH}:./reLyX/
++PATH_IFS=':'
++;;
++esac
++PATH=${PATH}${PATH_IFS}./reLyX/
+ SEARCH_PROG([for reLyX LaTeX-to-LyX translator],RELYX,reLyX)
+ PATH=${save_PATH}
+diff -ubr -X g:/exclude lyx-devel/lib/reLyX/acinclude.m4 lyx-build/lib/reLyX/acinclude.m4
+--- lyx-devel/lib/reLyX/acinclude.m4   Tue Sep 28 03:44:34 1999
++++ lyx-build/lib/reLyX/acinclude.m4   Wed May 10 05:38:36 2000
+@@ -11,15 +11,24 @@
+ dnl RELYX_SEARCH_PROG(VARIABLE-NAME,PROGRAMS-LIST,ACTION-IF-FOUND)
+ dnl             
+ define(RELYX_SEARCH_PROG,[dnl
++case "`uname -s 2> /dev/null`" in
++OS/2)
++  PATH=`echo -E "$PATH" | sed 's+\\\\+/+g'`
++  PATH_IFS=';'
++  ;;
++*)
++  PATH_IFS=':'
++  ;;
++esac
+ for ac_prog in $2 ; do
+ # Extract the first word of "$ac_prog", so it can be a program name with
+ # args.
+   set dummy $ac_prog ; ac_word=$[2]
+   if test ! -n "[$]$1"; then
+-    IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
++    IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}$PATH_IFS"
+     for ac_dir in $PATH; do
+       test -z "$ac_dir" && ac_dir=.
+-      if test -f [$ac_dir/$ac_word]; then
++      if test -f [$ac_dir/$ac_word] -o -f [$ac_dir/$ac_word$ac_exeext]; then
+         $1="$ac_prog"
+         break
+       fi
+diff -ubr -X g:/exclude lyx-devel/lib/reLyX/configure.in lyx-build/lib/reLyX/configure.in
+--- lyx-devel/lib/reLyX/configure.in   Tue Feb 22 06:45:24 2000
++++ lyx-build/lib/reLyX/configure.in   Wed May 10 05:38:34 2000
+@@ -2,6 +2,7 @@
+ AC_INIT(reLyX.in)
+ AC_PREREQ(2.13) dnl We want to use autoconf 2.13
+ AC_CONFIG_AUX_DIR(../../config)
++AC_EXEEXT
+ dnl PACKAGE=reLyX
+ dnl Do this to install in $datadir/lyx/reLyX instead of $datadir/reLyX/reLyX
+diff -ubr -X g:/exclude lyx-devel/src/os2_defines.h lyx-build/src/os2_defines.h
+--- lyx-devel/src/os2_defines.h        Fri Mar 10 06:25:50 2000
++++ lyx-build/src/os2_defines.h        Fri May  5 11:37:48 2000
+@@ -13,9 +13,14 @@
+ #ifndef OS2_DEFINES_H
+ #define OS2_DEFINES_H
++#if defined (__cplusplus)
+ #include <cctype>
+-#include <process.h>
+ #include <cstdlib>
++#else
++#include <ctype.h>
++#include <stdlib.h>
++#endif
++#include <process.h>
+ #include <unistd.h>
+ #include <X11/Xlocale.h>
+ /* #include <malloc.h> */
index 0dab6668c32616ce5fe90c9c08b7d61a3ec34d95..87a8c18972b34c038a4f93d57dfbf646d6823da1 100644 (file)
@@ -47,7 +47,7 @@ Chktex::Chktex(string const & chktex, string const & f, string const & p)
 int Chktex::run(TeXErrors &terr)
 {
        // run bibtex
-       string log = ChangeExtension(file, ".log", true);
+       string log = OnlyFilename(ChangeExtension(file, ".log"));
        string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
         Systemcalls one;
        int result= one.startscript(Systemcalls::System, tmp);
@@ -65,7 +65,7 @@ int Chktex::scanLogFile(TeXErrors & terr)
        string token;
        int retval = 0;
 
-       string tmp = ChangeExtension(file, ".log", true);
+       string tmp = OnlyFilename(ChangeExtension(file, ".log"));
 
        ifstream ifs(tmp.c_str());
        while (getline(ifs, token)) {
index 0ada1dc76fb68afab113e0426887be4209bffbdf..acafd3b822ff046f03786dd6738c297783bd792b 100644 (file)
@@ -43,7 +43,7 @@ Buffer * ImportLaTeX::run()
        Buffer * buf = 0;
        int result = one.startscript(Systemcalls::System, tmp);
        if (result == 0) {
-               string filename = ChangeExtension(file, ".lyx", false);
+               string filename = ChangeExtension(file, ".lyx");
                // File was generated without problems. Load it.
                buf = bufferlist.loadLyXFile(filename);
        }
index 951e5c91e0e6dba997e6533d3bf5491842408235..310cc49ec383241bc8f5f228b648d320b9977787 100644 (file)
@@ -110,16 +110,18 @@ void LaTeX::deleteFilesOnError() const
 
        // but the reason for the error might be in a generated file...
 
+       string ofname = OnlyFilename(file);
+
        // bibtex file
-       string bbl = ChangeExtension(file, ".bbl", true);
+       string bbl = ChangeExtension(ofname, ".bbl");
        ::unlink(bbl.c_str());
 
        // makeindex file
-       string ind = ChangeExtension(file, ".ind", true);
+       string ind = ChangeExtension(ofname, ".ind");
        ::unlink(ind.c_str());
        
        // Also remove the aux file
-       string aux = ChangeExtension(file, ".aux", true);
+       string aux = ChangeExtension(ofname, ".aux");
        ::unlink(aux.c_str());
 }
 
@@ -222,12 +224,12 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
        // if needed.
        
        // run makeindex
-       if (head.haschanged(ChangeExtension(file, ".idx", true))) {
+       if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
                // no checks for now
                lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
                minib->Set(_("Running MakeIndex."));
                minib->Store();
-               rerun = runMakeIndex(ChangeExtension(file, ".idx", true));
+               rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
        }
 
        // run bibtex
@@ -241,7 +243,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
                lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
                minib->Set(_("Running BibTeX."));
                minib->Store();
-               rerun = runBibTeX(ChangeExtension(file, ".aux", true), head);
+               rerun = runBibTeX(OnlyFilename(ChangeExtension(file, ".aux")), 
+                                 head);
        }
        
        // 1
@@ -288,12 +291,12 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
        // more after this.
        
        // run makeindex if the <file>.idx has changed or was generated.
-       if (head.haschanged(ChangeExtension(file, ".idx", true))) {
+       if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
                // no checks for now
                lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
                minib->Set(_("Running MakeIndex."));
                minib->Store();
-               rerun = runMakeIndex(ChangeExtension(file, ".idx", true));
+               rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
        }
        
        // 2
@@ -370,7 +373,7 @@ bool LaTeX::scanAux(DepTable & dep)
        if (dep.extchanged(".bib")
            || dep.extchanged(".bst")) return true;
        
-       string aux = ChangeExtension(file, ".aux", true);
+       string aux = OnlyFilename(ChangeExtension(file, ".aux"));
        ifstream ifs(aux.c_str());
        string token;
        LRegex reg1("\\\\bibdata\\{([^}]+)\\}");
@@ -392,7 +395,7 @@ bool LaTeX::scanAux(DepTable & dep)
                                }
                                string full_l =
                                        findtexfile(
-                                               ChangeExtension(l, "bib", false), "bib");
+                                               ChangeExtension(l, "bib"), "bib");
                                if (!full_l.empty()) {
                                        if (!dep.exist(full_l))
                                                return true;
@@ -406,7 +409,7 @@ bool LaTeX::scanAux(DepTable & dep)
                        // pass it to the helper
                        string full_l =
                                findtexfile(
-                                       ChangeExtension(style, "bst", false),
+                                       ChangeExtension(style, "bst"),
                                        "bst");
                        if (!full_l.empty()) {
                                if (!dep.exist(full_l))
@@ -450,7 +453,7 @@ bool LaTeX::runBibTeX(string const & f, DepTable & dep)
                                }
                                string full_l = 
                                        findtexfile(
-                                               ChangeExtension(l, "bib", false),
+                                               ChangeExtension(l, "bib"),
                                                "bib");
                                lyxerr[Debug::LATEX] << "Bibtex database: `"
                                                     << full_l << "'" << endl;
@@ -468,7 +471,7 @@ bool LaTeX::runBibTeX(string const & f, DepTable & dep)
                        // pass it to the helper
                        string full_l = 
                                findtexfile(
-                                       ChangeExtension(style, "bst", false),
+                                       ChangeExtension(style, "bst"),
                                        "bst");
                        lyxerr[Debug::LATEX] << "Bibtex style: `"
                                             << full_l << "'" << endl;
@@ -481,7 +484,7 @@ bool LaTeX::runBibTeX(string const & f, DepTable & dep)
        if (using_bibtex) {
                // run bibtex and
                string tmp = "bibtex ";
-               tmp += ChangeExtension(file, string(), true);
+               tmp += OnlyFilename(ChangeExtension(file, string()));
                Systemcalls one;
                one.startscript(Systemcalls::System, tmp);
                return true;
@@ -496,7 +499,7 @@ int LaTeX::scanLogFile(TeXErrors & terr)
        int last_line = -1;
        int line_count = 1;
        int retval = NO_ERRORS;
-       string tmp = ChangeExtension(file, ".log", true);
+       string tmp = OnlyFilename(ChangeExtension(file, ".log"));
        lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
        ifstream ifs(tmp.c_str());
 
@@ -615,7 +618,7 @@ void LaTeX::deplog(DepTable & head)
        // files used by the LaTeX run. The files are then entered into the
        // dependency file.
 
-       string logfile = ChangeExtension(file, ".log", true);
+       string logfile = OnlyFilename(ChangeExtension(file, ".log"));
        
        ifstream ifs(logfile.c_str());
        while (ifs) {
@@ -694,9 +697,8 @@ void LaTeX::deptex(DepTable & head)
        FileInfo fi;
        for (int i = 0; i < file_count; ++i) {
                if (!(all_files[i].file & except)) {
-                       tmp = ChangeExtension(file,
-                                             all_files[i].extension,
-                                             true);
+                       tmp = OnlyFilename(ChangeExtension(file,
+                                                          all_files[i].extension));
                        lyxerr[Debug::DEPEND] << "deptex: " << tmp << endl;
                        if (fi.newFile(tmp).exist())
                                head.insert(tmp);
index e5b0d0e5610964e8668b88c86138c3250f27dbfb..a79a05c6370acc3b2a66a3d4ffcd57db86ce1d2a 100644 (file)
@@ -24,10 +24,9 @@ void ShowLatexLog()
 
        filename = current_view->buffer()->getLatexName();
        if (!filename.empty()) {
-               fname = ChangeExtension(filename, ".log", true);
-               bname = ChangeExtension(filename,
-                                       lyxrc.literate_extension + ".out", 
-                                       true);
+               fname = OnlyFilename(ChangeExtension(filename, ".log"));
+               bname = OnlyFilename(ChangeExtension(filename,
+                                       lyxrc.literate_extension + ".out"));
                path = OnlyPath(filename);
                if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
                        path = current_view->buffer()->tmppath;
index 0ef41824f1b59fa7b6d9200669d409c28425ed8b..2730d26663dd2d7cc62a13dd03ffae6a1756b0d1 100644 (file)
@@ -81,7 +81,7 @@ void SendtoApplyCB(FL_OBJECT *, long)
        }
     }
 
-    string fname = ChangeExtension(buffer->getLatexName(), ftypeext, true);
+    string fname = OnlyFilename(ChangeExtension(buffer->getLatexName(), ftypeext));
     if (!contains(command, "$$FName"))
         command = "( " + command + " ) <$$FName";
     command = subst(command, "$$FName", fname);
index 46471e97dd354538d35b0380acf5d9e0e685e482..5ad15c8feac170f93b1449ed459fb22c58fd2d76 100644 (file)
@@ -157,8 +157,12 @@ Buffer::~Buffer()
 
 string Buffer::getLatexName(bool no_path) const
 {
-       return ChangeExtension(MakeLatexName(filename), 
-                              ".tex", no_path); 
+       if (no_path)
+               return OnlyFilename(ChangeExtension(MakeLatexName(filename), 
+                                                   ".tex"));
+       else
+               return ChangeExtension(MakeLatexName(filename), 
+                                      ".tex"); 
 }
 
 
@@ -3285,8 +3289,8 @@ int Buffer::runLiterate()
        // get LaTeX-Filename
        string name = getLatexName();
         // get Literate-Filename
-        string lit_name = ChangeExtension (getLatexName(), 
-                                          lyxrc.literate_extension, true);
+        string lit_name = OnlyFilename(ChangeExtension (getLatexName(), 
+                                          lyxrc.literate_extension));
 
        string path = OnlyPath(filename);
 
@@ -3356,8 +3360,8 @@ int Buffer::buildProgram()
         // get LaTeX-Filename
         string name = getLatexName();
         // get Literate-Filename
-        string lit_name = ChangeExtension(getLatexName(), 
-                                         lyxrc.literate_extension, true);
+        string lit_name = OnlyFilename(ChangeExtension(getLatexName(), 
+                                                      lyxrc.literate_extension));
  
         string path = OnlyPath(filename);
  
@@ -3727,7 +3731,7 @@ string Buffer::getIncludeonlyList(char delim)
                                    && insetinc->isNoLoad()) {
                                        if (!lst.empty())
                                                lst += delim;
-                                       lst += ChangeExtension(insetinc->getContents(), string(), true);
+                                       lst += OnlyFilename(ChangeExtension(insetinc->getContents(), string()));
                                }
                        }
                        ++pos;
index e4497ba2343298619a505eef8b2dd88d9a08af2f..68be219fddc892e3a385c0cedec4ce6978cf3c56 100644 (file)
@@ -225,8 +225,7 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
                if (!(*it)->isDepClean(mastertmpdir)) {
                        string writefile = mastertmpdir;
                        writefile += '/';
-                       writefile += ChangeExtension((*it)->fileName(),
-                                                    ".tex", true);
+                       writefile += (*it)->getLatexName();
                        (*it)->makeLaTeXFile(writefile, mastertmpdir,
                                             false, true);
                        (*it)->markDepClean(mastertmpdir);
index fa7c45034136aec8eb32f61b31c271432655afa0..d9dcfed3b6e88847781e022a6373e437c325984d 100644 (file)
@@ -339,9 +339,13 @@ int InsetBibtex::Latex(ostream & os,
        string db_in = getContents();
        db_in = split(db_in, adb, ',');
        while(!adb.empty()) {
-               if (!owner->niceFile &&
-                   IsFileReadable(MakeAbsPath(adb, owner->filepath)+".bib")) 
-                       adb = MakeAbsPath(adb, owner->filepath);
+               if (!owner->niceFile) {
+                       string fname 
+                               = findtexfile(ChangeExtension(adb, "bib"),
+                                             "bib");
+                       if (!fname.empty())
+                               adb = ChangeExtension(fname, string());
+               }
                db_out += adb;
                db_out += ',';
                db_in= split(db_in, adb,',');
@@ -379,7 +383,7 @@ string InsetBibtex::getKeys(char delim)
        string bibfiles = getContents();
        bibfiles = split(bibfiles, tmp, ',');
        while(!tmp.empty()) {
-               string fil = findtexfile(ChangeExtension(tmp, "bib", false),
+               string fil = findtexfile(ChangeExtension(tmp, "bib"),
                                         "bib");
                lyxerr[Debug::LATEX] << "Bibfile: " << fil << endl;
                // If we didn't find a matching file name just fail silently
index 1d28e3347b4e8ab3b3389c3a5a03c663182e5127..edba5fac3caa0a4a23365201f27d6794ba811cc7 100644 (file)
@@ -358,7 +358,7 @@ int InsetInclude::Latex(ostream & os,
                }
                
                // write it to a file (so far the complete file)
-               string writefile = ChangeExtension(getFileName(), ".tex", false);
+               string writefile = ChangeExtension(getFileName(), ".tex");
                if (!master->tmppath.empty()
                    && !master->niceFile) {
                        incfile = subst(incfile, '/','@');
@@ -368,7 +368,7 @@ int InsetInclude::Latex(ostream & os,
                        writefile = AddName(master->tmppath, incfile);
                } else
                        writefile = getFileName();
-               writefile = ChangeExtension(writefile, ".tex", false);
+               writefile = ChangeExtension(writefile, ".tex");
                lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
                lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
                
@@ -388,14 +388,14 @@ int InsetInclude::Latex(ostream & os,
                        os << '\\' << command << '{' << incfile << '}';
                } else {
                        os << '\\' << command << '{'
-                          << ChangeExtension(incfile, ".tex", false)
+                          << ChangeExtension(incfile, ".tex")
                           <<  '}';
                }
        } else {
                // \include don't want extension and demands that the
                // file really have .tex
                os << '\\' << command << '{'
-                  << ChangeExtension(incfile, string(), false)
+                  << ChangeExtension(incfile, string())
                   << '}';
        }
 
index 7ba99c9ecdaf0e34906d3ffa559163aac33b6f34..e11d0b9a992437711802aeca478034b89298b5fc 100644 (file)
@@ -431,8 +431,7 @@ bool RunScript(Buffer * buffer, bool wait,
                return false;
        /* get DVI-Filename */
        if (name.empty())
-               name = ChangeExtension(buffer->getLatexName(),
-                                      ".dvi", true);
+               name = ChangeExtension(buffer->getLatexName(), ".dvi");
 
        path = OnlyPath(name);
        if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
@@ -508,8 +507,8 @@ bool CreatePostscript(Buffer * buffer, bool wait = false)
                return false;
         }
        // Generate postscript file
-       string psname = ChangeExtension (buffer->fileName(),
-                                        ".ps_tmp", true);
+       string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
+                                        ".ps_tmp"));
 
        string paper;
 
@@ -596,8 +595,8 @@ bool PreviewPostscript(Buffer * buffer)
 
        // Start postscript viewer
        ProhibitInput(current_view);
-       string ps = ChangeExtension (buffer->fileName(),
-                                    ".ps_tmp", true);
+       string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+                                    ".ps_tmp"));
        // push directorypath, if necessary 
         string path = OnlyPath(buffer->fileName());
         if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
@@ -622,7 +621,8 @@ void MenuFax(Buffer * buffer)
        }
 
        // Send fax
-       string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true);
+       string ps = OnlyFilename(ChangeExtension (buffer->fileName(), 
+                                                 ".ps_tmp"));
        string path = OnlyPath (buffer->fileName());
        if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
                path = buffer->tmppath;
@@ -757,8 +757,7 @@ void MenuMakeLinuxDoc(Buffer * buffer)
        }
        
        // Get LinuxDoc-Filename
-       string s = ChangeExtension(buffer->fileName(), 
-                                  ".sgml", false);
+       string s = ChangeExtension(buffer->fileName(), ".sgml");
 
        if (!AskOverwrite(buffer, s))
                return;
@@ -785,8 +784,7 @@ void MenuMakeDocBook(Buffer * buffer)
        }
        
        // Get DocBook-Filename
-       string s = ChangeExtension(buffer->fileName(), 
-                                  ".sgml", false);
+       string s = ChangeExtension(buffer->fileName(), ".sgml");
 
        if (!AskOverwrite(buffer, s))
                return;
@@ -807,8 +805,7 @@ void MenuMakeAscii(Buffer * buffer)
        //if (!bv->text) return;
        
        /* get LaTeX-Filename */
-       string s = ChangeExtension (buffer->fileName(),
-                                   ".txt", false);
+       string s = ChangeExtension (buffer->fileName(), ".txt");
        
 
        if (!AskOverwrite(buffer, s))
@@ -826,9 +823,8 @@ void MenuPrint(Buffer * buffer)
        //if (!bv->text)
        //      return;
 
-       string input_file = ChangeExtension(buffer->fileName(),
-                                           lyxrc.print_file_extension,
-                                           true);
+       string input_file = OnlyFilename(ChangeExtension(buffer->fileName(),
+                                           lyxrc.print_file_extension));
        fl_set_input(fd_form_print->input_file, input_file.c_str());
        
        if (fd_form_print->form_print->visible) {
@@ -853,7 +849,7 @@ void MenuMakeHTML(Buffer * buffer)
        // the tex file name has to be correct for
        // latex, but the html file name can be
        // anything.
-       string result = ChangeExtension(file, ".html", false);
+       string result = ChangeExtension(file, ".html");
        string infile = buffer->getLatexName(false);
        string tmp = lyxrc.html_command;
        tmp = subst(tmp, "$$FName", infile);
@@ -880,8 +876,8 @@ void MenuMakeHTML_LinuxDoc(Buffer * buffer)
        // And now, run the converter
        string file = buffer->fileName();
 
-       string result = ChangeExtension(file, ".html", false);
-       string infile = ChangeExtension(file, ".sgml", false);
+       string result = ChangeExtension(file, ".html");
+       string infile = ChangeExtension(file, ".sgml");
        string tmp = lyxrc.linuxdoc_to_html_command;
        tmp = subst(tmp, "$$FName", infile);
        tmp = subst(tmp, "$$OutName", result);
@@ -905,8 +901,8 @@ void MenuMakeHTML_DocBook(Buffer * buffer)
 
        // And now, run the converter
        string file = buffer->fileName();
-       string result = ChangeExtension(file, ".html", false);
-       string infile = ChangeExtension(file, ".sgml", false);
+       string result = ChangeExtension(file, ".html");
+       string infile = ChangeExtension(file, ".sgml");
        string tmp = lyxrc.docbook_to_html_command;
        tmp = subst(tmp, "$$FName", infile);
        tmp = subst(tmp, "$$OutName", result);
@@ -1269,7 +1265,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
        int errorcode = 0;
 
        /* generate a path-less extension name */
-       string name = ChangeExtension (filename, ".sgml", true);
+       string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
        string path = OnlyPath (filename);
        if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
                path = bv->buffer()->tmppath;
@@ -1330,7 +1326,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
 int RunDocBook(int flag, string const & filename)
 {
        /* generate a path-less extension name */
-       string name = ChangeExtension (filename, ".sgml", true);
+       string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
        string path = OnlyPath (filename);
        if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
                path = current_view->buffer()->tmppath;
index f287f9b2ace11d30c79434613838f027c288132f..9a67ca8810736512c0e486bb95ad83028fcd8135 100644 (file)
@@ -2108,7 +2108,7 @@ string LyXFunc::Dispatch(int ac,
                sscanf(argument.c_str(), " %s %d", file_name, &row);
 
                // Must replace extension of the file to be .lyx and get full path
-               string s = ChangeExtension(string(file_name), ".lyx", false);
+               string s = ChangeExtension(string(file_name), ".lyx");
 
                // Either change buffer or load the file
                if (bufferlist.exists(s))
@@ -2845,7 +2845,7 @@ void LyXFunc::doImportHelper(
        // get absolute path of file
        filename = MakeAbsPath(filename);
 
-       string lyxfile = ChangeExtension(filename, ".lyx", false);
+       string lyxfile = ChangeExtension(filename, ".lyx");
 
        // Check if the document already is open
        if (bufferlist.exists(lyxfile)) {
@@ -2933,7 +2933,7 @@ bool doImportLinuxDoc(BufferView *, string const & filename)
 
        int result = one.startscript(Systemcalls::System, tmp);
        if (result == 0) {
-               string filename = ChangeExtension(filename, ".lyx", false);
+               string filename = ChangeExtension(filename, ".lyx");
                // File was generated without problems. Load it.
                buf = bufferlist.loadLyXFile(filename);
        }
index 1b2af682fa582bdec9ee10ee3ef773334dff217e..33b0d1a70ce50859b90d76ee7a9cdfa6341649c8 100644 (file)
@@ -892,8 +892,7 @@ string AddPath(string const & path, string const & path_2)
  Strips path off if no_path == true.
  If no extension on oldname, just appends.
  */
-string ChangeExtension(string const & oldname, string const & extension, 
-                       bool no_path) 
+string ChangeExtension(string const & oldname, string const & extension)
 {
        string::size_type last_slash = oldname.rfind('/');
        string::size_type last_dot = oldname.rfind('.');
@@ -906,14 +905,8 @@ string ChangeExtension(string const & oldname, string const & extension,
                ext= '.' + extension;
        else
                ext = extension;
-       string ret_str;
-       if (no_path && last_slash != string::npos) {
-               ++last_slash; // step it
-               ret_str = oldname.substr(last_slash,
-                                        last_dot - last_slash) + ext;
-       } else
-               ret_str = oldname.substr(0, last_dot) + ext;
-       return CleanupPath(ret_str);
+
+       return CleanupPath(oldname.substr(0, last_dot) + ext);
 }
 
 
index ca549b518c27617133589dfd166ab0726b861da4..ade432f04cbc1b974f0c4b6c65026e7504c646e9 100644 (file)
@@ -131,12 +131,10 @@ string AddName(string const & path, string const & fname);
 string AddPath(string const & path, string const & path2);
 
 /** Change extension of oldname to extension.
- If no_path is true, the path is stripped from the filename.
  If oldname does not have an extension, it is appended.
  If the extension is empty, any extension is removed from the name.
  */
-string ChangeExtension(string const & oldname, string const & extension, 
-                      bool no_path);
+string ChangeExtension(string const & oldname, string const & extension);
 
 /// Create absolute path. If impossible, don't do anything
 string ExpandPath(string const & path);