mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
os:: patch from Ruurd + bindings display fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2005 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
97c5ea56cf
commit
cdcb9b2cc0
@ -1,3 +1,7 @@
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* Added README.Win32
|
||||
|
||||
2001-04-15 Allan Rae <rae@lyx.org>
|
||||
|
||||
* Makefile.am (sourcedoc/Doxyfile): ensure modifications to doxygen
|
||||
|
39
README.Win32
Normal file
39
README.Win32
Normal file
@ -0,0 +1,39 @@
|
||||
================================================================
|
||||
README for Win32 by Ruurd Reitsma (R.A.Reitsma@wbmt.tudelft.nl)
|
||||
================================================================
|
||||
|
||||
Lyx has been ported to Win32 using the Cygwin environement. The port
|
||||
consists of a few small tweaks to deal with DOS-style pathnames, so
|
||||
LyX can use Win32 TeX distros like fptex and MiKTeX. There's also a
|
||||
cygwin TeTeX port, but the native Win32 ports have a definite speed
|
||||
advantage. Besides that, nothing fancy.
|
||||
|
||||
The prerequisites are (obviously?):
|
||||
|
||||
* cygwin installation (http://www.cygwin.com/).
|
||||
* decent X server; eXceed, X-Win32, or maybe even Cygwin/XFree86.
|
||||
* working TeX installation; fpTex, MikTex.
|
||||
|
||||
It should compile out of the box, but there might be some libraries
|
||||
missing in the final link step. You'll have to add them to the Makefile
|
||||
by hand. Be sure to include -lregex, because cygwin's builtin regex is
|
||||
sortof weird (filedialogs will turn up empty...)
|
||||
|
||||
If you want to run lyx with no console windows open, there's a small
|
||||
program in development/Win32 that will set the proper environment vars
|
||||
and start lyx.
|
||||
|
||||
Compile with:
|
||||
|
||||
gcc lyxwin32.C -O2 -o lyxwin32 -static -Wall -Wno-format \
|
||||
-Wstrict-prototypes -Wmissing-prototypes -mwindows -e _mainCRTStartup
|
||||
|
||||
Also make sure the latex binaries are in your Windows path. Windvi and
|
||||
Yap are auto detected, and you might want to make a symlink to Adobe
|
||||
Acrobat so it's detected too:
|
||||
|
||||
ln -s //c/Program\ Files/adobe/Acrobat\ 4.0/Reader/AcroRd32.exe \
|
||||
/usr/bin/acroread
|
||||
|
||||
Many thanks to Steven van Dijk, Claus Hentschel and Miyata Shigeru for
|
||||
starting the porting business.
|
@ -1,3 +1,7 @@
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* progtest.m4: added OS2 detection
|
||||
|
||||
2001-04-04 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* lyxinclude.m4: remove support for gcc 2.97 simplify calling for
|
||||
|
@ -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_CACHE_VAL(ac_cv_path_$1,
|
||||
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
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* Win32/lyxwin32.C added.
|
||||
|
||||
2001-04-17 Allan Rae <rae@lyx.org>
|
||||
|
||||
* tools/makeLyXsigc.sh: put the important local changes into sed
|
||||
|
27
development/Win32/lyxprofile
Normal file
27
development/Win32/lyxprofile
Normal file
@ -0,0 +1,27 @@
|
||||
PATH="/usr/local/lyx/bin:/usr/local/bin:/usr/X11R6/bin:/usr/bin:/bin:$PATH"
|
||||
unset DOSDRIVE
|
||||
unset DOSDIR
|
||||
unset TMPDIR
|
||||
unset TMP
|
||||
|
||||
USER="`id -un`"
|
||||
|
||||
# Set up USER's home directory; no spaces allowed in the path!
|
||||
export HOME=//c/Docs/Lyx
|
||||
|
||||
export USER PATH
|
||||
|
||||
for i in /etc/profile.d/*.sh ; do
|
||||
if [ -f $i ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
|
||||
export DISPLAY=localhost:0
|
||||
|
||||
export MAKE_MODE=unix
|
||||
|
||||
|
||||
cd "$HOME"
|
||||
|
||||
test -f ./.bashrc && . ./.bashrc
|
32
development/Win32/lyxwin32.C
Normal file
32
development/Win32/lyxwin32.C
Normal file
@ -0,0 +1,32 @@
|
||||
#include <stdio.h> /* standard io library */
|
||||
#include <stdlib.h> /* standard library */
|
||||
#include <unistd.h> /* sleep , fork & exec */
|
||||
#include <string.h> /* standard string library */
|
||||
#include <errno.h>
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
/*char cmd [32000] = "lyx " ; */ /* user command */
|
||||
char cmd [32000] = "lyx " ;
|
||||
char *nargs [4 ] = { "/bin/bash", "-c" , cmd , NULL } ; /* execute with login /bin/bash */
|
||||
int i=1;
|
||||
|
||||
putenv ( "BASH_ENV=/etc/lyxprofile" ) ; /* ensure bash reads my global env changes */
|
||||
|
||||
while ( i < argc ) /* do for all "real" args */
|
||||
{
|
||||
strcat ( cmd , "\"" ) ; /* add quote before */
|
||||
strcat ( cmd , argv [ i ] ) ; /* add the argument */
|
||||
strcat ( cmd , "\" " ) ; /* add closing quote */
|
||||
i ++ ;
|
||||
}
|
||||
|
||||
strcat ( cmd, "</dev/null 2>/dev/null");
|
||||
|
||||
fprintf ( stderr , "Command is: |%s|\n" , cmd );
|
||||
execv ( "/bin/bash" , nargs ) ; /* exec sub command */
|
||||
|
||||
/* we should never reach here */
|
||||
fprintf ( stderr , "Execute failed, error = %d\n" , errno ) ;
|
||||
return ( 0 ) ; /* exit with no error */
|
||||
}
|
@ -1,3 +1,10 @@
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* configure.m4: detect cygwin, windvi and yap
|
||||
|
||||
* reLyX/acinclude.m4 :
|
||||
* reLyX/configure.in : OS/2 fixes
|
||||
|
||||
2001-05-17 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* bind/latinkeys.bind: fixup more bindings.
|
||||
|
10
lib/configure
vendored
10
lib/configure
vendored
@ -72,6 +72,12 @@ if test ! -r ${srcdir}/chkconfig.ltx ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#### Adjust PATH for Win32 (Cygwin)
|
||||
if test "x$OSTYPE" = xcygwin; then
|
||||
echo "configure: cygwin detected; path correction"
|
||||
srcdir=`cygpath -w "${srcdir}" | tr '\\\\' /`
|
||||
echo "srcdir=${srcdir}"
|
||||
fi
|
||||
|
||||
#### Create the build directories if necessary
|
||||
for dir in bind clipart doc examples images kbd layouts reLyX \
|
||||
@ -522,9 +528,9 @@ fi
|
||||
|
||||
# Search something to preview dvi
|
||||
echo $ac_n "checking for a DVI previewer""... $ac_c"
|
||||
echo "$ac_t""(xdvi)"
|
||||
echo "$ac_t""(xdvi windvi yap)"
|
||||
DVI_VIEWER=
|
||||
for ac_prog in xdvi
|
||||
for ac_prog in xdvi windvi yap
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
|
@ -148,6 +148,12 @@ if test ! -r ${srcdir}/chkconfig.ltx ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#### Adjust PATH for Win32 (Cygwin)
|
||||
if test "x$OSTYPE" = xcygwin; then
|
||||
echo "configure: cygwin detected; path correction"
|
||||
srcdir=`cygpath -w "${srcdir}" | tr '\\\\' /`
|
||||
echo "srcdir=${srcdir}"
|
||||
fi
|
||||
|
||||
#### Create the build directories if necessary
|
||||
for dir in bind clipart doc examples images kbd layouts reLyX \
|
||||
@ -219,7 +225,7 @@ SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
|
||||
SEARCH_PROG([for a PDF preview],PDF_VIEWER,acroread gv ghostview xpdf)
|
||||
|
||||
# Search something to preview dvi
|
||||
SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi)
|
||||
SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi windvi yap)
|
||||
|
||||
# Search something to preview html
|
||||
SEARCH_PROG([for a HTML previewer],HTML_VIEWER, netscape)
|
||||
|
@ -10,15 +10,24 @@ relyx_warning=yes])
|
||||
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
|
||||
|
@ -2,6 +2,7 @@ dnl Process with autoconf to generate configure script -*- sh -*-
|
||||
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
|
||||
|
@ -10,8 +10,8 @@ src/CutAndPaste.C
|
||||
src/debug.C
|
||||
src/exporter.C
|
||||
src/ext_l10n.h
|
||||
src/figure_form.C
|
||||
src/figureForm.C
|
||||
src/figure_form.C
|
||||
src/FontLoader.C
|
||||
src/frontends/controllers/ButtonController.h
|
||||
src/frontends/controllers/character.C
|
||||
@ -90,67 +90,67 @@ src/frontends/qt2/paragraphdlgimpl.C
|
||||
src/frontends/qt2/tabularcreatedlgimpl.C
|
||||
src/frontends/xforms/combox.C
|
||||
src/frontends/xforms/FileDialog.C
|
||||
src/frontends/xforms/form_bibitem.C
|
||||
src/frontends/xforms/FormBibitem.C
|
||||
src/frontends/xforms/form_bibtex.C
|
||||
src/frontends/xforms/form_bibitem.C
|
||||
src/frontends/xforms/FormBibtex.C
|
||||
src/frontends/xforms/form_bibtex.C
|
||||
src/frontends/xforms/form_browser.C
|
||||
src/frontends/xforms/form_character.C
|
||||
src/frontends/xforms/FormCharacter.C
|
||||
src/frontends/xforms/form_citation.C
|
||||
src/frontends/xforms/form_character.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/form_copyright.C
|
||||
src/frontends/xforms/form_citation.C
|
||||
src/frontends/xforms/FormCopyright.C
|
||||
src/frontends/xforms/form_credits.C
|
||||
src/frontends/xforms/form_copyright.C
|
||||
src/frontends/xforms/FormCredits.C
|
||||
src/frontends/xforms/form_document.C
|
||||
src/frontends/xforms/form_credits.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/form_error.C
|
||||
src/frontends/xforms/form_document.C
|
||||
src/frontends/xforms/FormError.C
|
||||
src/frontends/xforms/form_external.C
|
||||
src/frontends/xforms/form_error.C
|
||||
src/frontends/xforms/FormExternal.C
|
||||
src/frontends/xforms/form_filedialog.C
|
||||
src/frontends/xforms/form_external.C
|
||||
src/frontends/xforms/FormFiledialog.C
|
||||
src/frontends/xforms/form_graphics.C
|
||||
src/frontends/xforms/form_filedialog.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/form_include.C
|
||||
src/frontends/xforms/form_graphics.C
|
||||
src/frontends/xforms/FormInclude.C
|
||||
src/frontends/xforms/form_index.C
|
||||
src/frontends/xforms/form_include.C
|
||||
src/frontends/xforms/FormIndex.C
|
||||
src/frontends/xforms/form_index.C
|
||||
src/frontends/xforms/FormLog.C
|
||||
src/frontends/xforms/FormMathsBitmap.C
|
||||
src/frontends/xforms/form_maths_deco.C
|
||||
src/frontends/xforms/FormMathsDeco.C
|
||||
src/frontends/xforms/form_maths_delim.C
|
||||
src/frontends/xforms/form_maths_deco.C
|
||||
src/frontends/xforms/FormMathsDelim.C
|
||||
src/frontends/xforms/form_maths_matrix.C
|
||||
src/frontends/xforms/form_maths_delim.C
|
||||
src/frontends/xforms/FormMathsMatrix.C
|
||||
src/frontends/xforms/form_maths_panel.C
|
||||
src/frontends/xforms/form_maths_matrix.C
|
||||
src/frontends/xforms/FormMathsPanel.C
|
||||
src/frontends/xforms/form_maths_space.C
|
||||
src/frontends/xforms/form_maths_panel.C
|
||||
src/frontends/xforms/FormMathsSpace.C
|
||||
src/frontends/xforms/form_minipage.C
|
||||
src/frontends/xforms/form_maths_space.C
|
||||
src/frontends/xforms/FormMinipage.C
|
||||
src/frontends/xforms/form_paragraph.C
|
||||
src/frontends/xforms/form_minipage.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/form_preamble.C
|
||||
src/frontends/xforms/form_paragraph.C
|
||||
src/frontends/xforms/FormPreamble.C
|
||||
src/frontends/xforms/form_preferences.C
|
||||
src/frontends/xforms/form_preamble.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/form_print.C
|
||||
src/frontends/xforms/form_preferences.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/form_ref.C
|
||||
src/frontends/xforms/form_print.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/form_search.C
|
||||
src/frontends/xforms/form_ref.C
|
||||
src/frontends/xforms/FormSearch.C
|
||||
src/frontends/xforms/form_tabular.C
|
||||
src/frontends/xforms/form_search.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/form_tabular_create.C
|
||||
src/frontends/xforms/form_tabular.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/form_toc.C
|
||||
src/frontends/xforms/form_tabular_create.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/form_toc.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/FormVCLog.C
|
||||
src/frontends/xforms/input_validators.C
|
||||
src/frontends/xforms/Menubar_pimpl.C
|
||||
|
@ -1,3 +1,19 @@
|
||||
2001-05-16 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* kbmap.C (findbinding): clean it up and make it work correctly.
|
||||
|
||||
* lyx_main.C (init): do not pass argc and argv as parameters
|
||||
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* buffer.C: fix path for OS/2 & Win32
|
||||
|
||||
* lyx_gui.C
|
||||
* lyx_main
|
||||
* lyx_main.C: Added os:: class.
|
||||
|
||||
* os2_defines.h: update
|
||||
|
||||
2001-05-17 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* lyxfunc.[Ch] (processKeySym): return void. Handle unknown actions
|
||||
|
@ -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.
|
||||
@ -1769,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();
|
||||
|
@ -1,3 +1,8 @@
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* figinset.C
|
||||
* insetbib.C: fix path for OS/2 & Win32
|
||||
|
||||
2001-05-10 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* insetfoot.C (Latex): don't use % after footnote.
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "lyx_gui_misc.h" // CancelCloseBoxCB
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/os.h"
|
||||
#include "Painter.h"
|
||||
#include "font.h"
|
||||
#include "bufferview_funcs.h"
|
||||
@ -1919,7 +1920,7 @@ void InsetFig::Preview(string const & p)
|
||||
if (GetExtension(tfname).empty())
|
||||
tfname += ".eps";
|
||||
string buf1 = OnlyPath(owner->fileName());
|
||||
string buf2 = MakeAbsPath(tfname, buf1);
|
||||
string buf2 = os::external_path(MakeAbsPath(tfname, buf1));
|
||||
if (!formats.View(owner, buf2, "eps"))
|
||||
lyxerr << "Can't view " << buf2 << endl;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "lyxtext.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path.h"
|
||||
#include "support/os.h"
|
||||
#include "lyxrc.h"
|
||||
#include "font.h"
|
||||
#include "LyXView.h"
|
||||
@ -141,7 +142,7 @@ int InsetBibtex::Latex(Buffer const * buffer, ostream & os,
|
||||
while(!adb.empty()) {
|
||||
if (!buffer->niceFile &&
|
||||
IsFileReadable(MakeAbsPath(adb, buffer->filepath)+".bib"))
|
||||
adb = MakeAbsPath(adb, buffer->filepath);
|
||||
adb = os::external_path(MakeAbsPath(adb, buffer->filepath));
|
||||
|
||||
db_out += adb;
|
||||
db_out += ',';
|
||||
|
16
src/kbmap.C
16
src/kbmap.C
@ -234,7 +234,7 @@ string const kb_keymap::keyname(kb_key const & k)
|
||||
|
||||
|
||||
// Finds a key for a keyaction, if possible
|
||||
string const kb_keymap::findbinding(int act) const
|
||||
string const kb_keymap::findbinding(int act, string const & prefix) const
|
||||
{
|
||||
string res;
|
||||
if (table.empty()) return res;
|
||||
@ -243,17 +243,13 @@ string const kb_keymap::findbinding(int act) const
|
||||
for (Table::const_iterator cit = table.begin();
|
||||
cit != end; ++cit) {
|
||||
if ((*cit).table.get()) {
|
||||
string suffix = (*cit).table->findbinding(act);
|
||||
suffix = strip(suffix, ' ');
|
||||
suffix = strip(suffix, ']');
|
||||
suffix = frontStrip(suffix, '[');
|
||||
if (!suffix.empty()) {
|
||||
res += "[" + keyname((*cit)) + " "
|
||||
+ suffix + "] ";
|
||||
}
|
||||
res += (*cit).table->findbinding(act,
|
||||
prefix
|
||||
+ keyname((*cit))
|
||||
+ " ");
|
||||
} else if ((*cit).action == act) {
|
||||
res += "[";
|
||||
res += keyname((*cit));
|
||||
res += prefix + keyname((*cit));
|
||||
res += "] ";
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ public:
|
||||
unsigned int mod, kb_sequence * seq) const;
|
||||
|
||||
/// Given an action, find all keybindings.
|
||||
string const findbinding(int action) const;
|
||||
string const findbinding(int action,
|
||||
string const & prefix = string()) const;
|
||||
private:
|
||||
///
|
||||
struct kb_key {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "lyx_gui.h"
|
||||
#include FORMS_H_LOCATION
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
#include "figure_form.h"
|
||||
#include "print_form.h"
|
||||
#include "tex-strings.h"
|
||||
@ -117,6 +118,7 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
|
||||
Display * display = fl_get_display();
|
||||
if (!display) {
|
||||
lyxerr << "LyX: unable to access X display, exiting" << endl;
|
||||
os::warn("Unable to access X display, exiting");
|
||||
exit(1);
|
||||
}
|
||||
fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC);
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "encoding.h"
|
||||
#include "converter.h"
|
||||
#include "language.h"
|
||||
#include "support/os.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
@ -106,7 +107,7 @@ LyX::LyX(int * argc, char * argv[])
|
||||
|
||||
// Initialization of LyX (reads lyxrc and more)
|
||||
lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
|
||||
init(argc, argv, gui);
|
||||
init(gui);
|
||||
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
|
||||
|
||||
lyxGUI->init();
|
||||
@ -184,7 +185,7 @@ LyX::~LyX()
|
||||
|
||||
extern "C" void error_handler(int err_sig);
|
||||
|
||||
void LyX::init(int */*argc*/, char **argv, bool gui)
|
||||
void LyX::init(bool gui)
|
||||
{
|
||||
// Install the signal handlers
|
||||
signal(SIGHUP, error_handler);
|
||||
@ -198,27 +199,9 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
|
||||
//
|
||||
|
||||
string fullbinpath;
|
||||
string binpath = subst(argv[0], '\\', '/');
|
||||
string binname = OnlyFilename(argv[0]);
|
||||
// Sorry for system specific code. (SMiyata)
|
||||
if (suffixIs(binname, ".exe"))
|
||||
binname.erase(binname.length()-4, string::npos);
|
||||
|
||||
binpath = ExpandPath(binpath); // This expands ./ and ~/
|
||||
|
||||
if (!AbsolutePath(binpath)) {
|
||||
string binsearchpath = GetEnvPath("PATH");
|
||||
// This will make "src/lyx" work always :-)
|
||||
binsearchpath += ";.";
|
||||
binpath = FileOpenSearch(binsearchpath, argv[0]);
|
||||
}
|
||||
|
||||
string binpath = os::binpath();
|
||||
string binname = os::binname();
|
||||
fullbinpath = binpath;
|
||||
binpath = MakeAbsPath(OnlyPath(binpath));
|
||||
|
||||
// In case we are running in place and compiled with shared libraries
|
||||
if (suffixIs(binpath, "/.libs/"))
|
||||
binpath.erase(binpath.length()-6, string::npos);
|
||||
|
||||
if (binpath.empty()) {
|
||||
lyxerr << _("Warning: could not determine path of binary.")
|
||||
@ -444,7 +427,8 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
|
||||
}
|
||||
|
||||
// Create temp directory
|
||||
system_tempdir = CreateLyXTmpDir(lyxrc.tempdir_path);
|
||||
os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
|
||||
system_tempdir = os::getTmpDir();
|
||||
if (lyxerr.debugging(Debug::INIT)) {
|
||||
lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ private:
|
||||
///
|
||||
void runtime();
|
||||
///
|
||||
void init(int * argc, char * argv[], bool);
|
||||
void init(bool);
|
||||
///
|
||||
void defaultKeyBindings(kb_keymap * kbmap);
|
||||
///
|
||||
|
@ -14,11 +14,13 @@
|
||||
#include "gettext.h"
|
||||
#include "LString.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
os::init(&argc, &argv);
|
||||
int const val = GUIRunTime::initApplication(argc, argv);
|
||||
if (val)
|
||||
return val;
|
||||
@ -33,10 +35,6 @@ int main(int argc, char * argv[])
|
||||
locale_init();
|
||||
gettext_init(lyx_localedir);
|
||||
|
||||
#ifdef __EMX__
|
||||
_wildcard(&argc, &argv);
|
||||
#endif
|
||||
|
||||
LyX lyx(&argc, argv);
|
||||
return 0; // SUCCESS
|
||||
}
|
||||
|
@ -13,16 +13,22 @@
|
||||
#ifndef OS2_DEFINES_H
|
||||
#define OS2_DEFINES_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
#include <cctype>
|
||||
#include <process.h>
|
||||
#include <cstdlib>
|
||||
extern "C" inline int readlink(const char *, char *, size_t) {return -1;}
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#define readlink(s, t, l) (-1)
|
||||
#endif
|
||||
#include <process.h>
|
||||
#include <unistd.h>
|
||||
#include <X11/Xlocale.h>
|
||||
/* #include <malloc.h> */
|
||||
#define lstat stat
|
||||
#define S_ISLNK(x) false
|
||||
#define S_ISBLK(x) false
|
||||
#define readlink(s, t, l) (strcpy(t, s), strlen(t))
|
||||
/*#define mkfifo(p, m) (0) *//* LyXserver is temporary disabled. */
|
||||
#define chdir _chdir2
|
||||
#define strcasecmp stricmp
|
||||
|
@ -1,3 +1,20 @@
|
||||
2001-05-16 Ruurd Reitsma <r.a.reitsma@wbmt.tudelft.nl>
|
||||
|
||||
* FileInfo.h: X_OK workaround for cygwin
|
||||
|
||||
* Makefile.am:
|
||||
* os.C:
|
||||
* os.h:
|
||||
* os_os2.C:
|
||||
* os_unix.C:
|
||||
* os_win32.C:
|
||||
* filetools.C:
|
||||
* filetools.h: Added os:: class.
|
||||
|
||||
* rename.C:
|
||||
* syscall.C:
|
||||
* tempname.C: OS/2 fixes
|
||||
|
||||
2001-05-03 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* textutils.h: remvoe !NEW_INSETS cruft
|
||||
|
@ -24,6 +24,11 @@
|
||||
#include <boost/utility.hpp>
|
||||
#include "LString.h"
|
||||
|
||||
#if defined(__CYGWIN__) //Cygwin has it's own concept of X_OK ???
|
||||
#undef X_OK
|
||||
#define X_OK 1
|
||||
#endif
|
||||
|
||||
/** Use objects of this class to get information about files.
|
||||
*/
|
||||
class FileInfo : boost::noncopyable {
|
||||
|
@ -29,6 +29,8 @@ libsupport_la_SOURCES = \
|
||||
LRegex.h \
|
||||
LSubstring.C \
|
||||
LSubstring.h \
|
||||
os.C \
|
||||
os.h \
|
||||
StrPool.C \
|
||||
StrPool.h \
|
||||
abort.C \
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "support/path.h" // I know it's OS/2 specific (SMiyata)
|
||||
#include "gettext.h"
|
||||
#include "lyxlib.h"
|
||||
#include "os.h"
|
||||
|
||||
// Which part of this is still necessary? (JMarc).
|
||||
#if HAVE_DIRENT_H
|
||||
@ -103,12 +104,9 @@ string const MakeLatexName(string const & file)
|
||||
// Substitutes spaces with underscores in filename (and path)
|
||||
string const QuoteName(string const & name)
|
||||
{
|
||||
// CHECK Add proper emx support here!
|
||||
#ifndef __EMX__
|
||||
return "\'" + name + "\'";
|
||||
#else
|
||||
return name;
|
||||
#endif
|
||||
return (os::shell() == os::UNIX) ?
|
||||
"\'" + name + "\'":
|
||||
"\"" + name + "\"";
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +170,7 @@ string const FileOpenSearch (string const & path, string const & name,
|
||||
string tmppath = split(path, path_element, ';');
|
||||
|
||||
while (notfound && !path_element.empty()) {
|
||||
path_element = CleanupPath(path_element);
|
||||
path_element = os::slashify_path(path_element);
|
||||
if (!suffixIs(path_element, '/'))
|
||||
path_element+= '/';
|
||||
path_element = subst(path_element, "$$LyX", system_lyxdir);
|
||||
@ -249,7 +247,6 @@ string const FileSearch(string const & path, string const & name,
|
||||
// Expand Environmentvariables in 'name'
|
||||
string const tmpname = ReplaceEnvironmentPath(name);
|
||||
string fullname = MakeAbsPath(tmpname, path);
|
||||
|
||||
// search first without extension, then with it.
|
||||
if (IsFileReadable(fullname))
|
||||
return fullname;
|
||||
@ -321,7 +318,7 @@ string const GetEnvPath(string const & name)
|
||||
#ifndef __EMX__
|
||||
string const pathlist = subst(GetEnv(name), ':', ';');
|
||||
#else
|
||||
string const pathlist = subst(GetEnv(name), '\\', '/');
|
||||
string const pathlist = os::slashify_path(GetEnv(name));
|
||||
#endif
|
||||
return strip(pathlist, ';');
|
||||
}
|
||||
@ -469,7 +466,18 @@ int DestroyTmpDir(string const & tmpdir, bool Allfiles)
|
||||
|
||||
string const CreateBufferTmpDir(string const & pathfor)
|
||||
{
|
||||
return CreateTmpDir(pathfor, "lyx_tmpbuf");
|
||||
static int count = 0;
|
||||
static string const tmpdir(pathfor.empty() ? os::getTmpDir() : pathfor);
|
||||
// We are in our own directory. Why bother to mangle name?
|
||||
// In fact I wrote this code to circumvent a problematic behaviour (bug?)
|
||||
// of EMX mkstemp().
|
||||
string tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++);
|
||||
if (lyx::mkdir(tmpfl, 0777)) {
|
||||
WriteFSAlert(_("Error! Couldn't create temporary directory:"),
|
||||
tmpdir);
|
||||
return string();
|
||||
}
|
||||
return tmpfl;
|
||||
}
|
||||
|
||||
|
||||
@ -509,7 +517,7 @@ int DestroyLyXTmpDir(string const & tmpdir)
|
||||
// Creates directory. Returns true if succesfull
|
||||
bool createDirectory(string const & path, int permission)
|
||||
{
|
||||
string temp(strip(CleanupPath(path), '/'));
|
||||
string temp(strip(os::slashify_path(path), '/'));
|
||||
|
||||
if (temp.empty()) {
|
||||
WriteAlert(_("Internal error!"),
|
||||
@ -546,31 +554,20 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
{
|
||||
// checks for already absolute path
|
||||
if (AbsolutePath(RelPath))
|
||||
#ifdef __EMX__
|
||||
if (RelPath[0]!= '/' && RelPath[0]!= '\\')
|
||||
#endif
|
||||
return RelPath;
|
||||
|
||||
// Copies given paths
|
||||
string TempRel(CleanupPath(RelPath));
|
||||
string TempRel(os::slashify_path(RelPath));
|
||||
lyxerr << "TempRel=" << TempRel <<endl;
|
||||
// Since TempRel is NOT absolute, we can safely replace "//" with "/"
|
||||
TempRel = subst(TempRel, "//", "/");
|
||||
|
||||
string TempBase;
|
||||
|
||||
if (!BasePath.empty()) {
|
||||
#ifndef __EMX__
|
||||
if (AbsolutePath(BasePath))
|
||||
TempBase = BasePath;
|
||||
#else
|
||||
char * with_drive = new char[_MAX_PATH];
|
||||
_abspath(with_drive, BasePath.c_str(), _MAX_PATH);
|
||||
TempBase = with_drive;
|
||||
delete[] with_drive;
|
||||
#endif
|
||||
} else
|
||||
TempBase = lyx::getcwd(); //GetCWD();
|
||||
#ifdef __EMX__
|
||||
if (AbsolutePath(TempRel))
|
||||
return TempBase.substr(0, 2) + TempRel;
|
||||
#endif
|
||||
else
|
||||
TempBase = AddPath(lyx::getcwd(), BasePath);
|
||||
|
||||
// Handle /./ at the end of the path
|
||||
while(suffixIs(TempBase, "/./"))
|
||||
@ -600,6 +597,9 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
TempBase.erase(i, string::npos);
|
||||
else
|
||||
TempBase += '/';
|
||||
} else if (Temp.empty() && !RTemp.empty()) {
|
||||
TempBase = os::current_root() + RTemp;
|
||||
RTemp.erase();
|
||||
} else {
|
||||
// Add this piece to TempBase
|
||||
if (!suffixIs(TempBase, '/'))
|
||||
@ -609,7 +609,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
}
|
||||
|
||||
// returns absolute path
|
||||
return TempBase;
|
||||
return os::slashify_path(TempBase);
|
||||
}
|
||||
|
||||
|
||||
@ -624,7 +624,7 @@ string const AddName(string const & path, string const & fname)
|
||||
string buf;
|
||||
|
||||
if (path != "." && path != "./" && !path.empty()) {
|
||||
buf = CleanupPath(path);
|
||||
buf = os::slashify_path(path);
|
||||
if (!suffixIs(path, '/'))
|
||||
buf += '/';
|
||||
}
|
||||
@ -654,7 +654,7 @@ bool AbsolutePath(string const & path)
|
||||
#ifndef __EMX__
|
||||
return (!path.empty() && path[0] == '/');
|
||||
#else
|
||||
return (!path.empty() && (path[0] == '/' || (isalpha(static_cast<unsigned char>(path[0])) && path.length()>1 && path[1] == ':')));
|
||||
return (!path.empty() && isalpha(static_cast<unsigned char>(path[0])) && path.length() > 1 && path[1] == ':');
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -726,18 +726,6 @@ string const NormalizePath(string const & path)
|
||||
}
|
||||
|
||||
|
||||
string const CleanupPath(string const & path)
|
||||
{
|
||||
#ifdef __EMX__ /* SMiyata: This should fix searchpath bug. */
|
||||
string temppath = subst(path, '\\', '/');
|
||||
temppath = subst(temppath, "//", "/");
|
||||
return lowercase(temppath);
|
||||
#else // On unix, nothing to do
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
string const GetFileContents(string const & fname)
|
||||
{
|
||||
FileInfo finfo(fname);
|
||||
@ -849,33 +837,16 @@ string const ReplaceEnvironmentPath(string const & path)
|
||||
|
||||
|
||||
// Make relative path out of two absolute paths
|
||||
string const MakeRelPath(string const & abspath0, string const & basepath0)
|
||||
string const MakeRelPath(string const & abspath, string const & basepath)
|
||||
// Makes relative path out of absolute path. If it is deeper than basepath,
|
||||
// it's easy. If basepath and abspath share something (they are all deeper
|
||||
// than some directory), it'll be rendered using ..'s. If they are completely
|
||||
// different, then the absolute path will be used as relative path.
|
||||
{
|
||||
// This is a hack. It should probaly be done in another way. Lgb.
|
||||
string const abspath = CleanupPath(abspath0);
|
||||
string const basepath = CleanupPath(basepath0);
|
||||
if (abspath.empty())
|
||||
return "<unknown_path>";
|
||||
|
||||
string::size_type const abslen = abspath.length();
|
||||
string::size_type const baselen = basepath.length();
|
||||
|
||||
// Find first different character
|
||||
string::size_type i = 0;
|
||||
while (i < abslen && i < baselen && abspath[i] == basepath[i]) ++i;
|
||||
|
||||
// Go back to last /
|
||||
if (i < abslen && i < baselen
|
||||
|| (i < abslen && abspath[i] != '/' && i == baselen)
|
||||
|| (i < baselen && basepath[i] != '/' && i == abslen))
|
||||
{
|
||||
if (i) --i; // here was the last match
|
||||
while (i && abspath[i] != '/') --i;
|
||||
}
|
||||
string::size_type i = os::common_path(abspath, basepath);
|
||||
|
||||
if (i == 0) {
|
||||
// actually no match - cannot make it relative
|
||||
@ -912,17 +883,20 @@ string const MakeRelPath(string const & abspath0, string const & basepath0)
|
||||
string const AddPath(string const & path, string const & path_2)
|
||||
{
|
||||
string buf;
|
||||
string const path2 = CleanupPath(path_2);
|
||||
string const path2 = os::slashify_path(path_2);
|
||||
|
||||
if (!path.empty() && path != "." && path != "./") {
|
||||
buf = CleanupPath(path);
|
||||
buf = os::slashify_path(path);
|
||||
if (path[path.length() - 1] != '/')
|
||||
buf += '/';
|
||||
}
|
||||
|
||||
if (!path2.empty())
|
||||
buf += frontStrip(strip(path2, '/'), '/') + '/';
|
||||
|
||||
if (!path2.empty()) {
|
||||
string::size_type const p2start = path2.find_first_not_of('/');
|
||||
string::size_type const p2end = path2.find_last_not_of('/');
|
||||
string const tmp = path2.substr(p2start, p2end - p2start + 1);
|
||||
buf += tmp + '/';
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -947,7 +921,7 @@ ChangeExtension(string const & oldname, string const & extension)
|
||||
else
|
||||
ext = extension;
|
||||
|
||||
return CleanupPath(oldname.substr(0, last_dot) + ext);
|
||||
return os::slashify_path(oldname.substr(0, last_dot) + ext);
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,9 +182,6 @@ string const OnlyFilename(string const & fname);
|
||||
/// Get the contents of a file as a huge string
|
||||
string const GetFileContents(string const & fname);
|
||||
|
||||
/// Cleanup a path if necessary. Currently only useful with OS/2
|
||||
string const CleanupPath(string const & path);
|
||||
|
||||
/** Check and Replace Environmentvariables ${NAME} in Path.
|
||||
Replaces all occurences of these, if they are found in the
|
||||
environment.
|
||||
|
11
src/support/os.C
Normal file
11
src/support/os.C
Normal file
@ -0,0 +1,11 @@
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#ifdef __EMX__
|
||||
#include "os_os2.C"
|
||||
#elif defined(__CYGWIN__) || defined( __CYGWIN32__)
|
||||
#include "os_win32.C"
|
||||
#else
|
||||
#include "os_unix.C"
|
||||
#endif
|
66
src/support/os.h
Normal file
66
src/support/os.h
Normal file
@ -0,0 +1,66 @@
|
||||
// os.h copyright "Ruurd A. Reitsma" <R.A.Reitsma@wbmt.tudelft.nl>
|
||||
|
||||
#ifndef OS_H
|
||||
#define OS_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
/// Do we need a base class for this?
|
||||
class os {
|
||||
public:
|
||||
//
|
||||
enum shell_type {
|
||||
UNIX, // Do we have to distinguish sh and csh?
|
||||
CMD_EXE
|
||||
};
|
||||
|
||||
//
|
||||
static void init(int * argc, char ** argv[]);
|
||||
|
||||
//
|
||||
static string binpath() {return binpath_;};
|
||||
|
||||
//
|
||||
static string binname() {return binname_;};
|
||||
|
||||
// system_tempdir actually doesn't belong here.
|
||||
// I put it here only to avoid a global variable.
|
||||
static void setTmpDir(string p) {tmpdir_ = p;};
|
||||
|
||||
//
|
||||
static string getTmpDir() {return tmpdir_;};
|
||||
|
||||
//
|
||||
static string current_root();
|
||||
|
||||
//
|
||||
static os::shell_type shell() {return _shell;};
|
||||
|
||||
// DBCS aware!
|
||||
static string::size_type common_path(string const &p1, string const &p2);
|
||||
|
||||
// no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc.
|
||||
static string slashify_path(string p);
|
||||
static string external_path(string p);
|
||||
static void warn(string mesg);
|
||||
private:
|
||||
static string binpath_;
|
||||
static string binname_;
|
||||
static string tmpdir_;
|
||||
static os::shell_type _shell;
|
||||
static unsigned long cp_; // Used only on OS/2 to determine file system encoding.
|
||||
|
||||
// Never initialize static variables in the header!
|
||||
// Anyway I bet this class will never be constructed.
|
||||
os() {};
|
||||
|
||||
// Ignore warning!
|
||||
~os() {};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
160
src/support/os_os2.C
Normal file
160
src/support/os_os2.C
Normal file
@ -0,0 +1,160 @@
|
||||
// os_os2.C
|
||||
|
||||
// Various OS specific functions
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "os.h"
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "support/filetools.h"
|
||||
#define INCL_DOSFILEMGR
|
||||
#define INCL_DOSMODULEMGR
|
||||
#define INCL_DOSPROCESS
|
||||
#define INCL_DOSNLS
|
||||
#define INCL_DOSERRORS
|
||||
#include <os2.h>
|
||||
|
||||
string os::binpath_ = string();
|
||||
string os::binname_ = string();
|
||||
string os::tmpdir_ = string();
|
||||
os::shell_type os::_shell = os::UNIX;
|
||||
unsigned long os::cp_ = 0;
|
||||
|
||||
void os::init(int * argc, char ** argv[]) {
|
||||
if (argc != 0 /* This is a hack! */) {
|
||||
_wildcard(argc, argv);
|
||||
PTIB ptib = new TIB[1];
|
||||
PPIB ppib = new PIB[1];
|
||||
APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
|
||||
if (rc != NO_ERROR)
|
||||
exit(rc);
|
||||
char* tmp = new char[256];
|
||||
// This is the only reliable way to retrieve the executable name.
|
||||
rc = DosQueryModuleName(ppib->pib_hmte, 256L, tmp);
|
||||
if (rc != NO_ERROR)
|
||||
exit(rc);
|
||||
string p(tmp);
|
||||
p = slashify_path(p);
|
||||
binname_ = OnlyFilename(p);
|
||||
binname_.erase(binname_.length()-4, string::npos);
|
||||
binpath_ = OnlyPath(p);
|
||||
|
||||
// OS/2 cmd.exe has another use for '&'
|
||||
string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
|
||||
if (sh.empty()) {
|
||||
// COMSPEC is set, unless user unsets
|
||||
sh = OnlyFilename(GetEnvPath("COMSPEC"));
|
||||
if (sh.empty())
|
||||
sh = "cmd.exe";
|
||||
}
|
||||
sh = lowercase(sh); // DosMapCase() is an overkill here
|
||||
if (contains(sh, "cmd.exe")
|
||||
|| contains(sh, "4os2.exe"))
|
||||
_shell = os::CMD_EXE;
|
||||
else
|
||||
_shell = os::UNIX;
|
||||
}
|
||||
static bool initialized = false;
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
ULONG CPList[3] = {0}, CPList_size;
|
||||
APIRET rc = DosQueryCp(3 * sizeof(ULONG), CPList, &CPList_size);
|
||||
if (rc != NO_ERROR)
|
||||
exit(rc);
|
||||
// CPList[0] == process current codepage,
|
||||
// CPList[1] == system default codepage, the rest are auxilary.
|
||||
// Once cp_ is correctly set, you can call other routines.
|
||||
cp_ = CPList[1];
|
||||
}
|
||||
|
||||
void os::warn(string /*mesg*/) {
|
||||
return;
|
||||
}
|
||||
|
||||
string os::current_root() {
|
||||
APIRET rc;
|
||||
ULONG drv_num, drv_map;
|
||||
rc = DosQueryCurrentDisk(&drv_num, &drv_map);
|
||||
if (rc != NO_ERROR)
|
||||
exit(rc);
|
||||
char drive = 'A' + drv_num -1;
|
||||
string tmp(1, drive);
|
||||
tmp += ":/";
|
||||
return tmp;
|
||||
}
|
||||
|
||||
string::size_type os::common_path(string const &p1, string const &p2) {
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
init(0, 0);
|
||||
initialized = true;
|
||||
}
|
||||
COUNTRYCODE cntry;
|
||||
cntry.country = 0;
|
||||
cntry.codepage = cp_;
|
||||
string temp1 = slashify_path(p1);
|
||||
string temp2 = slashify_path(p2);
|
||||
char * tmp1 = const_cast<char*> (temp1.c_str());
|
||||
char * tmp2 = const_cast<char*> (temp2.c_str());
|
||||
/* rc = */ DosMapCase(p1.length(), &cntry, tmp1);
|
||||
// if (rc != NO_ERROR)
|
||||
// exit(rc);
|
||||
/* rc = */ DosMapCase(p2.length(), &cntry, tmp2);
|
||||
// if (rc != NO_ERROR)
|
||||
// exit(rc);
|
||||
// This algorithm works only if paths are slashified on DBCS systems.
|
||||
string::size_type i = 0,
|
||||
p1_len = p1.length(),
|
||||
p2_len = p2.length();
|
||||
while (i < p1_len && i < p2_len && tmp1[i] == tmp2[i]) ++i;
|
||||
if ((i < p1_len && i < p2_len)
|
||||
|| (i < p1_len && tmp1[i] != '/' && i == p2_len)
|
||||
|| (i < p2_len && tmp2[i] != '/' && i == p1_len)) {
|
||||
if (i) --i; // here was the last match
|
||||
while (i && tmp1[i] != '/') --i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
string os::slashify_path(string p) {
|
||||
static bool initialized = false;
|
||||
static bool leadbyte[256] = {false};
|
||||
if (!initialized) {
|
||||
init(0, 0);
|
||||
COUNTRYCODE cntry;
|
||||
cntry.country = 0;
|
||||
cntry.codepage = cp_;
|
||||
unsigned char *DBCSinfo = new unsigned char[12];
|
||||
/* rc = */ DosQueryDBCSEnv(12, &cntry, (char*) DBCSinfo);
|
||||
// if (rc != NO_ERROR)
|
||||
// exit(rc);
|
||||
for (int j = 1; j < 12; j += 2)
|
||||
DBCSinfo[j]++;
|
||||
unsigned char i = 0;
|
||||
bool isLeadByte = false;
|
||||
while (*DBCSinfo != 0) {
|
||||
if (i == *DBCSinfo) {
|
||||
isLeadByte = !isLeadByte;
|
||||
DBCSinfo++;
|
||||
}
|
||||
leadbyte[i++] = isLeadByte;
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
string::iterator lit = p.begin();
|
||||
string::iterator end = p.end();
|
||||
for (; lit < end; ++lit) {
|
||||
if (leadbyte[(*lit)])
|
||||
lit += 2;
|
||||
if ((*lit) == '\\')
|
||||
(*lit) = '/';
|
||||
}
|
||||
p = subst(p, "//", "/");
|
||||
return p;
|
||||
}
|
||||
|
||||
string os::external_path(string p) {
|
||||
return p;
|
||||
}
|
69
src/support/os_unix.C
Normal file
69
src/support/os_unix.C
Normal file
@ -0,0 +1,69 @@
|
||||
// os_unix.C
|
||||
|
||||
// Various OS specific functions
|
||||
#include <config.h>
|
||||
|
||||
#include "os.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
string os::binpath_ = string();
|
||||
string os::binname_ = string();
|
||||
string os::tmpdir_ = string();
|
||||
os::shell_type os::_shell = os::UNIX;
|
||||
unsigned long os::cp_ = 0;
|
||||
|
||||
void os::init(int * /*argc*/, char ** argv[]) /* :cp_(0), _shell(os::UNIX) */ {
|
||||
static bool initialized = false;
|
||||
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
initialized = true;
|
||||
string tmp = *argv[0];
|
||||
binname_ = OnlyFilename(tmp);
|
||||
tmp = ExpandPath(tmp); // This expands ./ and ~/
|
||||
if (!AbsolutePath(tmp)) {
|
||||
string binsearchpath = GetEnvPath("PATH");
|
||||
// This will make "src/lyx" work always :-)
|
||||
binsearchpath += ";.";
|
||||
tmp = FileOpenSearch(binsearchpath, tmp);
|
||||
}
|
||||
|
||||
tmp = MakeAbsPath(OnlyPath(tmp));
|
||||
|
||||
// In case we are running in place and compiled with shared libraries
|
||||
if (suffixIs(tmp, "/.libs/"))
|
||||
tmp.erase(tmp.length()-6, string::npos);
|
||||
binpath_ = tmp;
|
||||
}
|
||||
|
||||
void os::warn(string /*mesg*/) {
|
||||
return;
|
||||
}
|
||||
|
||||
string os::current_root() {
|
||||
return string("/");
|
||||
}
|
||||
|
||||
string::size_type os::common_path(string const &p1, string const &p2) {
|
||||
string::size_type i = 0,
|
||||
p1_len = p1.length(),
|
||||
p2_len = p2.length();
|
||||
while (i < p1_len && i < p2_len && p1[i] == p2[i]) ++i;
|
||||
if ((i < p1_len && i < p2_len)
|
||||
|| (i < p1_len && p1[i] != '/' && i == p2_len)
|
||||
|| (i < p2_len && p2[i] != '/' && i == p1_len)) {
|
||||
if (i) --i; // here was the last match
|
||||
while (i && p1[i] != '/') --i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
string os::slashify_path(string p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
string os::external_path(string p) {
|
||||
return p;
|
||||
}
|
||||
|
83
src/support/os_win32.C
Normal file
83
src/support/os_win32.C
Normal file
@ -0,0 +1,83 @@
|
||||
// os_win32.C copyright "Ruurd A. Reitsma" <R.A.Reitsma@wbmt.tudelft.nl>
|
||||
|
||||
// Various OS specific functions
|
||||
#include <config.h>
|
||||
|
||||
#include "os.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <sys/cygwin.h>
|
||||
|
||||
|
||||
string os::binpath_ = string();
|
||||
string os::binname_ = string();
|
||||
string os::tmpdir_ = string();
|
||||
os::shell_type os::_shell = os::UNIX;
|
||||
unsigned long os::cp_ = 0;
|
||||
|
||||
void os::init(int * argc, char ** argv[]) {
|
||||
static bool initialized = false;
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
string tmp = *argv[0];
|
||||
binname_ = OnlyFilename(tmp);
|
||||
tmp = ExpandPath(tmp); // This expands ./ and ~/
|
||||
|
||||
if (!AbsolutePath(tmp)) {
|
||||
string binsearchpath = GetEnvPath("PATH");
|
||||
// This will make "src/lyx" work always :-)
|
||||
binsearchpath += ";.";
|
||||
tmp = *argv[0];
|
||||
tmp = FileOpenSearch(binsearchpath, tmp);
|
||||
}
|
||||
|
||||
tmp = MakeAbsPath(OnlyPath(tmp));
|
||||
|
||||
// In case we are running in place and compiled with shared libraries
|
||||
if (suffixIs(tmp, "/.libs/"))
|
||||
tmp.erase(tmp.length()-6, string::npos);
|
||||
binpath_ = tmp;
|
||||
}
|
||||
|
||||
void os::warn(string mesg) {
|
||||
MessageBox(0, mesg.c_str(), "LyX error",
|
||||
MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL);
|
||||
}
|
||||
|
||||
string os::current_root() {
|
||||
return string("/");
|
||||
}
|
||||
|
||||
string::size_type os::common_path(string const &p1, string const &p2) {
|
||||
string::size_type i = 0,
|
||||
p1_len = p1.length(),
|
||||
p2_len = p2.length();
|
||||
while (i < p1_len && i < p2_len && uppercase(p1[i]) == uppercase(p2[i])) ++i;
|
||||
if ((i < p1_len && i < p2_len)
|
||||
|| (i < p1_len && p1[i] != '/' && i == p2_len)
|
||||
|| (i < p2_len && p2[i] != '/' && i == p1_len)) {
|
||||
if (i) --i; // here was the last match
|
||||
while (i && p1[i] != '/') --i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
string os::slashify_path(string p) {
|
||||
return subst(p, '\\', '/');
|
||||
}
|
||||
|
||||
string os::external_path(string p) {
|
||||
string dos_path=p;
|
||||
if (AbsolutePath(p)) {
|
||||
char dp[255];
|
||||
cygwin_conv_to_full_win32_path(p.c_str(), dp);
|
||||
dos_path=subst(dp,'\\','/');
|
||||
}
|
||||
lyxerr[Debug::LATEX]
|
||||
<< "<Win32 path correction> ["
|
||||
<< p << "]->>["
|
||||
<< dos_path << "]" << endl;
|
||||
return dos_path;
|
||||
}
|
@ -6,6 +6,9 @@
|
||||
|
||||
bool lyx::rename(string const & from, string const & to)
|
||||
{
|
||||
#ifdef __EMX__
|
||||
lyx::unlink(to.c_str());
|
||||
#endif
|
||||
if (::rename(from.c_str(), to.c_str()) == -1)
|
||||
if (lyx::copy(from, to)) {
|
||||
lyx::unlink(from);
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "syscontr.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
@ -137,8 +139,10 @@ void Systemcalls::waitForChild() {
|
||||
|
||||
pid_t Systemcalls::fork()
|
||||
{
|
||||
#ifndef __EMX__
|
||||
pid_t cpid= ::fork();
|
||||
if (cpid == 0) { // child
|
||||
#endif
|
||||
// TODO: Consider doing all of this before the fork, otherwise me
|
||||
// might have troubles with multi-threaded access. (Baruch 20010228)
|
||||
string childcommand(command); // copy
|
||||
@ -169,10 +173,15 @@ pid_t Systemcalls::fork()
|
||||
}
|
||||
argv[index] = 0;
|
||||
// replace by command. Expand using PATH-environment-var.
|
||||
#ifndef __EMX__
|
||||
execvp(syscmd, argv);
|
||||
// If something goes wrong, we end up here:
|
||||
lyxerr << "LyX: execvp failed: " << strerror(errno) << endl;
|
||||
} else if (cpid < 0) { // error
|
||||
#else
|
||||
pid_t cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND, syscmd, argv);
|
||||
if (cpid < 0) { // error
|
||||
#endif
|
||||
lyxerr << "LyX: Could not fork: " << strerror(errno) << endl;
|
||||
} else { // parent
|
||||
return cpid;
|
||||
@ -193,25 +202,8 @@ int Systemcalls::startscript(Starttype how, string const & what,
|
||||
retval = 0;
|
||||
|
||||
if (how == SystemDontWait) {
|
||||
#ifndef __EMX__
|
||||
command += " &";
|
||||
#else
|
||||
// OS/2 cmd.exe has another use for '&'
|
||||
// This is not NLS safe, but it's OK, I think.
|
||||
string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
|
||||
if (sh.empty()) {
|
||||
// COMSPEC is set, unless user unsets
|
||||
sh = OnlyFilename(GetEnvPath("COMSPEC"));
|
||||
if (sh.empty())
|
||||
sh = "cmd.exe";
|
||||
}
|
||||
sh = lowercase(sh);
|
||||
if (contains(sh, "cmd.exe")
|
||||
|| contains(sh, "4os2.exe"))
|
||||
command = "start /min/n " + command;
|
||||
else
|
||||
command += " &";
|
||||
#endif
|
||||
(os::shell() == os::UNIX) ? command += " &"
|
||||
: command = "start /min/n " + command;
|
||||
}
|
||||
|
||||
return startscript();
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/filetools.h"
|
||||
#include "debug.h"
|
||||
#include "os.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
extern string system_tempdir;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -23,7 +23,7 @@ int make_tempfile(char * templ)
|
||||
#ifdef HAVE_MKTEMP
|
||||
// This probably just barely works...
|
||||
::mktemp(templ);
|
||||
return ::open(templ, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
return ::open(templ, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
#else
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning FIX FIX FIX
|
||||
@ -37,7 +37,7 @@ int make_tempfile(char * templ)
|
||||
|
||||
string const lyx::tempName(string const & dir, string const & mask)
|
||||
{
|
||||
string const tmpdir(dir.empty() ? system_tempdir : dir);
|
||||
string const tmpdir(dir.empty() ? os::getTmpDir() : dir);
|
||||
string tmpfl(AddName(tmpdir, mask));
|
||||
tmpfl += tostr(getpid());
|
||||
tmpfl += "XXXXXX";
|
||||
|
Loading…
Reference in New Issue
Block a user