Remove the optional bool argument to ChangeExtension().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@730 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-05-11 16:12:46 +00:00
parent 0ed7d49cb6
commit 1fc7671591
16 changed files with 316 additions and 83 deletions

View File

@ -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> 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 * src/lyxlookup.C (isDeadEvent): use a switch statement instead of
a chain of "if". Return false when deadkeys are not handled. a chain of "if". Return false when deadkeys are not handled.

View 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 README file for OS/2 version of LyX 1.0.1
by Shigeru Miyata <miyata@kusm.kyoto-u.ac.jp> by Shigeru Miyata <miyata@kusm.kyoto-u.ac.jp>

View File

@ -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> */

View File

@ -47,7 +47,7 @@ Chktex::Chktex(string const & chktex, string const & f, string const & p)
int Chktex::run(TeXErrors &terr) int Chktex::run(TeXErrors &terr)
{ {
// run bibtex // run bibtex
string log = ChangeExtension(file, ".log", true); string log = OnlyFilename(ChangeExtension(file, ".log"));
string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log; string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
Systemcalls one; Systemcalls one;
int result= one.startscript(Systemcalls::System, tmp); int result= one.startscript(Systemcalls::System, tmp);
@ -65,7 +65,7 @@ int Chktex::scanLogFile(TeXErrors & terr)
string token; string token;
int retval = 0; int retval = 0;
string tmp = ChangeExtension(file, ".log", true); string tmp = OnlyFilename(ChangeExtension(file, ".log"));
ifstream ifs(tmp.c_str()); ifstream ifs(tmp.c_str());
while (getline(ifs, token)) { while (getline(ifs, token)) {

View File

@ -43,7 +43,7 @@ Buffer * ImportLaTeX::run()
Buffer * buf = 0; Buffer * buf = 0;
int result = one.startscript(Systemcalls::System, tmp); int result = one.startscript(Systemcalls::System, tmp);
if (result == 0) { if (result == 0) {
string filename = ChangeExtension(file, ".lyx", false); string filename = ChangeExtension(file, ".lyx");
// File was generated without problems. Load it. // File was generated without problems. Load it.
buf = bufferlist.loadLyXFile(filename); buf = bufferlist.loadLyXFile(filename);
} }

View File

@ -110,16 +110,18 @@ void LaTeX::deleteFilesOnError() const
// but the reason for the error might be in a generated file... // but the reason for the error might be in a generated file...
string ofname = OnlyFilename(file);
// bibtex file // bibtex file
string bbl = ChangeExtension(file, ".bbl", true); string bbl = ChangeExtension(ofname, ".bbl");
::unlink(bbl.c_str()); ::unlink(bbl.c_str());
// makeindex file // makeindex file
string ind = ChangeExtension(file, ".ind", true); string ind = ChangeExtension(ofname, ".ind");
::unlink(ind.c_str()); ::unlink(ind.c_str());
// Also remove the aux file // Also remove the aux file
string aux = ChangeExtension(file, ".aux", true); string aux = ChangeExtension(ofname, ".aux");
::unlink(aux.c_str()); ::unlink(aux.c_str());
} }
@ -222,12 +224,12 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
// if needed. // if needed.
// run makeindex // run makeindex
if (head.haschanged(ChangeExtension(file, ".idx", true))) { if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
minib->Set(_("Running MakeIndex.")); minib->Set(_("Running MakeIndex."));
minib->Store(); minib->Store();
rerun = runMakeIndex(ChangeExtension(file, ".idx", true)); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
} }
// run bibtex // run bibtex
@ -241,7 +243,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
lyxerr[Debug::LATEX] << "Running BibTeX." << endl; lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
minib->Set(_("Running BibTeX.")); minib->Set(_("Running BibTeX."));
minib->Store(); minib->Store();
rerun = runBibTeX(ChangeExtension(file, ".aux", true), head); rerun = runBibTeX(OnlyFilename(ChangeExtension(file, ".aux")),
head);
} }
// 1 // 1
@ -288,12 +291,12 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
// more after this. // more after this.
// run makeindex if the <file>.idx has changed or was generated. // 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 // no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
minib->Set(_("Running MakeIndex.")); minib->Set(_("Running MakeIndex."));
minib->Store(); minib->Store();
rerun = runMakeIndex(ChangeExtension(file, ".idx", true)); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
} }
// 2 // 2
@ -370,7 +373,7 @@ bool LaTeX::scanAux(DepTable & dep)
if (dep.extchanged(".bib") if (dep.extchanged(".bib")
|| dep.extchanged(".bst")) return true; || dep.extchanged(".bst")) return true;
string aux = ChangeExtension(file, ".aux", true); string aux = OnlyFilename(ChangeExtension(file, ".aux"));
ifstream ifs(aux.c_str()); ifstream ifs(aux.c_str());
string token; string token;
LRegex reg1("\\\\bibdata\\{([^}]+)\\}"); LRegex reg1("\\\\bibdata\\{([^}]+)\\}");
@ -392,7 +395,7 @@ bool LaTeX::scanAux(DepTable & dep)
} }
string full_l = string full_l =
findtexfile( findtexfile(
ChangeExtension(l, "bib", false), "bib"); ChangeExtension(l, "bib"), "bib");
if (!full_l.empty()) { if (!full_l.empty()) {
if (!dep.exist(full_l)) if (!dep.exist(full_l))
return true; return true;
@ -406,7 +409,7 @@ bool LaTeX::scanAux(DepTable & dep)
// pass it to the helper // pass it to the helper
string full_l = string full_l =
findtexfile( findtexfile(
ChangeExtension(style, "bst", false), ChangeExtension(style, "bst"),
"bst"); "bst");
if (!full_l.empty()) { if (!full_l.empty()) {
if (!dep.exist(full_l)) if (!dep.exist(full_l))
@ -450,7 +453,7 @@ bool LaTeX::runBibTeX(string const & f, DepTable & dep)
} }
string full_l = string full_l =
findtexfile( findtexfile(
ChangeExtension(l, "bib", false), ChangeExtension(l, "bib"),
"bib"); "bib");
lyxerr[Debug::LATEX] << "Bibtex database: `" lyxerr[Debug::LATEX] << "Bibtex database: `"
<< full_l << "'" << endl; << full_l << "'" << endl;
@ -468,7 +471,7 @@ bool LaTeX::runBibTeX(string const & f, DepTable & dep)
// pass it to the helper // pass it to the helper
string full_l = string full_l =
findtexfile( findtexfile(
ChangeExtension(style, "bst", false), ChangeExtension(style, "bst"),
"bst"); "bst");
lyxerr[Debug::LATEX] << "Bibtex style: `" lyxerr[Debug::LATEX] << "Bibtex style: `"
<< full_l << "'" << endl; << full_l << "'" << endl;
@ -481,7 +484,7 @@ bool LaTeX::runBibTeX(string const & f, DepTable & dep)
if (using_bibtex) { if (using_bibtex) {
// run bibtex and // run bibtex and
string tmp = "bibtex "; string tmp = "bibtex ";
tmp += ChangeExtension(file, string(), true); tmp += OnlyFilename(ChangeExtension(file, string()));
Systemcalls one; Systemcalls one;
one.startscript(Systemcalls::System, tmp); one.startscript(Systemcalls::System, tmp);
return true; return true;
@ -496,7 +499,7 @@ int LaTeX::scanLogFile(TeXErrors & terr)
int last_line = -1; int last_line = -1;
int line_count = 1; int line_count = 1;
int retval = NO_ERRORS; int retval = NO_ERRORS;
string tmp = ChangeExtension(file, ".log", true); string tmp = OnlyFilename(ChangeExtension(file, ".log"));
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl; lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
ifstream ifs(tmp.c_str()); 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 // files used by the LaTeX run. The files are then entered into the
// dependency file. // dependency file.
string logfile = ChangeExtension(file, ".log", true); string logfile = OnlyFilename(ChangeExtension(file, ".log"));
ifstream ifs(logfile.c_str()); ifstream ifs(logfile.c_str());
while (ifs) { while (ifs) {
@ -694,9 +697,8 @@ void LaTeX::deptex(DepTable & head)
FileInfo fi; FileInfo fi;
for (int i = 0; i < file_count; ++i) { for (int i = 0; i < file_count; ++i) {
if (!(all_files[i].file & except)) { if (!(all_files[i].file & except)) {
tmp = ChangeExtension(file, tmp = OnlyFilename(ChangeExtension(file,
all_files[i].extension, all_files[i].extension));
true);
lyxerr[Debug::DEPEND] << "deptex: " << tmp << endl; lyxerr[Debug::DEPEND] << "deptex: " << tmp << endl;
if (fi.newFile(tmp).exist()) if (fi.newFile(tmp).exist())
head.insert(tmp); head.insert(tmp);

View File

@ -24,10 +24,9 @@ void ShowLatexLog()
filename = current_view->buffer()->getLatexName(); filename = current_view->buffer()->getLatexName();
if (!filename.empty()) { if (!filename.empty()) {
fname = ChangeExtension(filename, ".log", true); fname = OnlyFilename(ChangeExtension(filename, ".log"));
bname = ChangeExtension(filename, bname = OnlyFilename(ChangeExtension(filename,
lyxrc.literate_extension + ".out", lyxrc.literate_extension + ".out"));
true);
path = OnlyPath(filename); path = OnlyPath(filename);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->buffer()->tmppath; path = current_view->buffer()->tmppath;

View 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")) if (!contains(command, "$$FName"))
command = "( " + command + " ) <$$FName"; command = "( " + command + " ) <$$FName";
command = subst(command, "$$FName", fname); command = subst(command, "$$FName", fname);

View File

@ -157,8 +157,12 @@ Buffer::~Buffer()
string Buffer::getLatexName(bool no_path) const string Buffer::getLatexName(bool no_path) const
{ {
return ChangeExtension(MakeLatexName(filename), if (no_path)
".tex", no_path); return OnlyFilename(ChangeExtension(MakeLatexName(filename),
".tex"));
else
return ChangeExtension(MakeLatexName(filename),
".tex");
} }
@ -3285,8 +3289,8 @@ int Buffer::runLiterate()
// get LaTeX-Filename // get LaTeX-Filename
string name = getLatexName(); string name = getLatexName();
// get Literate-Filename // get Literate-Filename
string lit_name = ChangeExtension (getLatexName(), string lit_name = OnlyFilename(ChangeExtension (getLatexName(),
lyxrc.literate_extension, true); lyxrc.literate_extension));
string path = OnlyPath(filename); string path = OnlyPath(filename);
@ -3356,8 +3360,8 @@ int Buffer::buildProgram()
// get LaTeX-Filename // get LaTeX-Filename
string name = getLatexName(); string name = getLatexName();
// get Literate-Filename // get Literate-Filename
string lit_name = ChangeExtension(getLatexName(), string lit_name = OnlyFilename(ChangeExtension(getLatexName(),
lyxrc.literate_extension, true); lyxrc.literate_extension));
string path = OnlyPath(filename); string path = OnlyPath(filename);
@ -3727,7 +3731,7 @@ string Buffer::getIncludeonlyList(char delim)
&& insetinc->isNoLoad()) { && insetinc->isNoLoad()) {
if (!lst.empty()) if (!lst.empty())
lst += delim; lst += delim;
lst += ChangeExtension(insetinc->getContents(), string(), true); lst += OnlyFilename(ChangeExtension(insetinc->getContents(), string()));
} }
} }
++pos; ++pos;

View File

@ -225,8 +225,7 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
if (!(*it)->isDepClean(mastertmpdir)) { if (!(*it)->isDepClean(mastertmpdir)) {
string writefile = mastertmpdir; string writefile = mastertmpdir;
writefile += '/'; writefile += '/';
writefile += ChangeExtension((*it)->fileName(), writefile += (*it)->getLatexName();
".tex", true);
(*it)->makeLaTeXFile(writefile, mastertmpdir, (*it)->makeLaTeXFile(writefile, mastertmpdir,
false, true); false, true);
(*it)->markDepClean(mastertmpdir); (*it)->markDepClean(mastertmpdir);

View File

@ -339,9 +339,13 @@ int InsetBibtex::Latex(ostream & os,
string db_in = getContents(); string db_in = getContents();
db_in = split(db_in, adb, ','); db_in = split(db_in, adb, ',');
while(!adb.empty()) { while(!adb.empty()) {
if (!owner->niceFile && if (!owner->niceFile) {
IsFileReadable(MakeAbsPath(adb, owner->filepath)+".bib")) string fname
adb = MakeAbsPath(adb, owner->filepath); = findtexfile(ChangeExtension(adb, "bib"),
"bib");
if (!fname.empty())
adb = ChangeExtension(fname, string());
}
db_out += adb; db_out += adb;
db_out += ','; db_out += ',';
db_in= split(db_in, adb,','); db_in= split(db_in, adb,',');
@ -379,7 +383,7 @@ string InsetBibtex::getKeys(char delim)
string bibfiles = getContents(); string bibfiles = getContents();
bibfiles = split(bibfiles, tmp, ','); bibfiles = split(bibfiles, tmp, ',');
while(!tmp.empty()) { while(!tmp.empty()) {
string fil = findtexfile(ChangeExtension(tmp, "bib", false), string fil = findtexfile(ChangeExtension(tmp, "bib"),
"bib"); "bib");
lyxerr[Debug::LATEX] << "Bibfile: " << fil << endl; lyxerr[Debug::LATEX] << "Bibfile: " << fil << endl;
// If we didn't find a matching file name just fail silently // If we didn't find a matching file name just fail silently

View File

@ -358,7 +358,7 @@ int InsetInclude::Latex(ostream & os,
} }
// write it to a file (so far the complete file) // 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() if (!master->tmppath.empty()
&& !master->niceFile) { && !master->niceFile) {
incfile = subst(incfile, '/','@'); incfile = subst(incfile, '/','@');
@ -368,7 +368,7 @@ int InsetInclude::Latex(ostream & os,
writefile = AddName(master->tmppath, incfile); writefile = AddName(master->tmppath, incfile);
} else } else
writefile = getFileName(); writefile = getFileName();
writefile = ChangeExtension(writefile, ".tex", false); writefile = ChangeExtension(writefile, ".tex");
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl; lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
@ -388,14 +388,14 @@ int InsetInclude::Latex(ostream & os,
os << '\\' << command << '{' << incfile << '}'; os << '\\' << command << '{' << incfile << '}';
} else { } else {
os << '\\' << command << '{' os << '\\' << command << '{'
<< ChangeExtension(incfile, ".tex", false) << ChangeExtension(incfile, ".tex")
<< '}'; << '}';
} }
} else { } else {
// \include don't want extension and demands that the // \include don't want extension and demands that the
// file really have .tex // file really have .tex
os << '\\' << command << '{' os << '\\' << command << '{'
<< ChangeExtension(incfile, string(), false) << ChangeExtension(incfile, string())
<< '}'; << '}';
} }

View File

@ -431,8 +431,7 @@ bool RunScript(Buffer * buffer, bool wait,
return false; return false;
/* get DVI-Filename */ /* get DVI-Filename */
if (name.empty()) if (name.empty())
name = ChangeExtension(buffer->getLatexName(), name = ChangeExtension(buffer->getLatexName(), ".dvi");
".dvi", true);
path = OnlyPath(name); path = OnlyPath(name);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
@ -508,8 +507,8 @@ bool CreatePostscript(Buffer * buffer, bool wait = false)
return false; return false;
} }
// Generate postscript file // Generate postscript file
string psname = ChangeExtension (buffer->fileName(), string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
".ps_tmp", true); ".ps_tmp"));
string paper; string paper;
@ -596,8 +595,8 @@ bool PreviewPostscript(Buffer * buffer)
// Start postscript viewer // Start postscript viewer
ProhibitInput(current_view); ProhibitInput(current_view);
string ps = ChangeExtension (buffer->fileName(), string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
".ps_tmp", true); ".ps_tmp"));
// push directorypath, if necessary // push directorypath, if necessary
string path = OnlyPath(buffer->fileName()); string path = OnlyPath(buffer->fileName());
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
@ -622,7 +621,8 @@ void MenuFax(Buffer * buffer)
} }
// Send fax // Send fax
string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true); string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
".ps_tmp"));
string path = OnlyPath (buffer->fileName()); string path = OnlyPath (buffer->fileName());
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath; path = buffer->tmppath;
@ -757,8 +757,7 @@ void MenuMakeLinuxDoc(Buffer * buffer)
} }
// Get LinuxDoc-Filename // Get LinuxDoc-Filename
string s = ChangeExtension(buffer->fileName(), string s = ChangeExtension(buffer->fileName(), ".sgml");
".sgml", false);
if (!AskOverwrite(buffer, s)) if (!AskOverwrite(buffer, s))
return; return;
@ -785,8 +784,7 @@ void MenuMakeDocBook(Buffer * buffer)
} }
// Get DocBook-Filename // Get DocBook-Filename
string s = ChangeExtension(buffer->fileName(), string s = ChangeExtension(buffer->fileName(), ".sgml");
".sgml", false);
if (!AskOverwrite(buffer, s)) if (!AskOverwrite(buffer, s))
return; return;
@ -807,8 +805,7 @@ void MenuMakeAscii(Buffer * buffer)
//if (!bv->text) return; //if (!bv->text) return;
/* get LaTeX-Filename */ /* get LaTeX-Filename */
string s = ChangeExtension (buffer->fileName(), string s = ChangeExtension (buffer->fileName(), ".txt");
".txt", false);
if (!AskOverwrite(buffer, s)) if (!AskOverwrite(buffer, s))
@ -826,9 +823,8 @@ void MenuPrint(Buffer * buffer)
//if (!bv->text) //if (!bv->text)
// return; // return;
string input_file = ChangeExtension(buffer->fileName(), string input_file = OnlyFilename(ChangeExtension(buffer->fileName(),
lyxrc.print_file_extension, lyxrc.print_file_extension));
true);
fl_set_input(fd_form_print->input_file, input_file.c_str()); fl_set_input(fd_form_print->input_file, input_file.c_str());
if (fd_form_print->form_print->visible) { if (fd_form_print->form_print->visible) {
@ -853,7 +849,7 @@ void MenuMakeHTML(Buffer * buffer)
// the tex file name has to be correct for // the tex file name has to be correct for
// latex, but the html file name can be // latex, but the html file name can be
// anything. // anything.
string result = ChangeExtension(file, ".html", false); string result = ChangeExtension(file, ".html");
string infile = buffer->getLatexName(false); string infile = buffer->getLatexName(false);
string tmp = lyxrc.html_command; string tmp = lyxrc.html_command;
tmp = subst(tmp, "$$FName", infile); tmp = subst(tmp, "$$FName", infile);
@ -880,8 +876,8 @@ void MenuMakeHTML_LinuxDoc(Buffer * buffer)
// And now, run the converter // And now, run the converter
string file = buffer->fileName(); string file = buffer->fileName();
string result = ChangeExtension(file, ".html", false); string result = ChangeExtension(file, ".html");
string infile = ChangeExtension(file, ".sgml", false); string infile = ChangeExtension(file, ".sgml");
string tmp = lyxrc.linuxdoc_to_html_command; string tmp = lyxrc.linuxdoc_to_html_command;
tmp = subst(tmp, "$$FName", infile); tmp = subst(tmp, "$$FName", infile);
tmp = subst(tmp, "$$OutName", result); tmp = subst(tmp, "$$OutName", result);
@ -905,8 +901,8 @@ void MenuMakeHTML_DocBook(Buffer * buffer)
// And now, run the converter // And now, run the converter
string file = buffer->fileName(); string file = buffer->fileName();
string result = ChangeExtension(file, ".html", false); string result = ChangeExtension(file, ".html");
string infile = ChangeExtension(file, ".sgml", false); string infile = ChangeExtension(file, ".sgml");
string tmp = lyxrc.docbook_to_html_command; string tmp = lyxrc.docbook_to_html_command;
tmp = subst(tmp, "$$FName", infile); tmp = subst(tmp, "$$FName", infile);
tmp = subst(tmp, "$$OutName", result); tmp = subst(tmp, "$$OutName", result);
@ -1269,7 +1265,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
int errorcode = 0; int errorcode = 0;
/* generate a path-less extension name */ /* generate a path-less extension name */
string name = ChangeExtension (filename, ".sgml", true); string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
string path = OnlyPath (filename); string path = OnlyPath (filename);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = bv->buffer()->tmppath; path = bv->buffer()->tmppath;
@ -1330,7 +1326,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
int RunDocBook(int flag, string const & filename) int RunDocBook(int flag, string const & filename)
{ {
/* generate a path-less extension name */ /* generate a path-less extension name */
string name = ChangeExtension (filename, ".sgml", true); string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
string path = OnlyPath (filename); string path = OnlyPath (filename);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->buffer()->tmppath; path = current_view->buffer()->tmppath;

View File

@ -2108,7 +2108,7 @@ string LyXFunc::Dispatch(int ac,
sscanf(argument.c_str(), " %s %d", file_name, &row); sscanf(argument.c_str(), " %s %d", file_name, &row);
// Must replace extension of the file to be .lyx and get full path // 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 // Either change buffer or load the file
if (bufferlist.exists(s)) if (bufferlist.exists(s))
@ -2845,7 +2845,7 @@ void LyXFunc::doImportHelper(
// get absolute path of file // get absolute path of file
filename = MakeAbsPath(filename); filename = MakeAbsPath(filename);
string lyxfile = ChangeExtension(filename, ".lyx", false); string lyxfile = ChangeExtension(filename, ".lyx");
// Check if the document already is open // Check if the document already is open
if (bufferlist.exists(lyxfile)) { if (bufferlist.exists(lyxfile)) {
@ -2933,7 +2933,7 @@ bool doImportLinuxDoc(BufferView *, string const & filename)
int result = one.startscript(Systemcalls::System, tmp); int result = one.startscript(Systemcalls::System, tmp);
if (result == 0) { if (result == 0) {
string filename = ChangeExtension(filename, ".lyx", false); string filename = ChangeExtension(filename, ".lyx");
// File was generated without problems. Load it. // File was generated without problems. Load it.
buf = bufferlist.loadLyXFile(filename); buf = bufferlist.loadLyXFile(filename);
} }

View File

@ -892,8 +892,7 @@ string AddPath(string const & path, string const & path_2)
Strips path off if no_path == true. Strips path off if no_path == true.
If no extension on oldname, just appends. If no extension on oldname, just appends.
*/ */
string ChangeExtension(string const & oldname, string const & extension, string ChangeExtension(string const & oldname, string const & extension)
bool no_path)
{ {
string::size_type last_slash = oldname.rfind('/'); string::size_type last_slash = oldname.rfind('/');
string::size_type last_dot = oldname.rfind('.'); string::size_type last_dot = oldname.rfind('.');
@ -906,14 +905,8 @@ string ChangeExtension(string const & oldname, string const & extension,
ext= '.' + extension; ext= '.' + extension;
else else
ext = extension; ext = extension;
string ret_str;
if (no_path && last_slash != string::npos) { return CleanupPath(oldname.substr(0, last_dot) + ext);
++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);
} }

View File

@ -131,12 +131,10 @@ string AddName(string const & path, string const & fname);
string AddPath(string const & path, string const & path2); string AddPath(string const & path, string const & path2);
/** Change extension of oldname to extension. /** 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 oldname does not have an extension, it is appended.
If the extension is empty, any extension is removed from the name. If the extension is empty, any extension is removed from the name.
*/ */
string ChangeExtension(string const & oldname, string const & extension, string ChangeExtension(string const & oldname, string const & extension);
bool no_path);
/// Create absolute path. If impossible, don't do anything /// Create absolute path. If impossible, don't do anything
string ExpandPath(string const & path); string ExpandPath(string const & path);