mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 21:45:24 +00:00
Fix command line parsing and allow unicode arguments for tex2lyx on Windows.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@33755 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
01f95f41e6
commit
0a7616e65c
@ -1108,6 +1108,7 @@ void LyX::easyParse(int & argc, char * argv[])
|
||||
// Now, remove used arguments by shifting
|
||||
// the following ones remove places down.
|
||||
if (remove > 0) {
|
||||
os::remove_internal_args(i, remove);
|
||||
argc -= remove;
|
||||
for (int j = i; j < argc; ++j)
|
||||
argv[j] = argv[j + remove];
|
||||
|
@ -43,6 +43,9 @@ void init(int argc, char * argv[]);
|
||||
/// Returns the i-th program argument in utf8 encoding.
|
||||
std::string utf8_argv(int i);
|
||||
|
||||
/// Removes from the internal copy \p num program arguments starting from \p i.
|
||||
void remove_internal_args(int i, int num);
|
||||
|
||||
/// Returns the name of the NULL device (/dev/null, null).
|
||||
std::string const & nulldev();
|
||||
|
||||
|
@ -227,6 +227,10 @@ string utf8_argv(int i)
|
||||
}
|
||||
|
||||
|
||||
void remove_internal_args(int, int)
|
||||
{}
|
||||
|
||||
|
||||
string current_root()
|
||||
{
|
||||
return string("/");
|
||||
|
@ -52,6 +52,10 @@ string utf8_argv(int i)
|
||||
}
|
||||
|
||||
|
||||
void remove_internal_args(int, int)
|
||||
{}
|
||||
|
||||
|
||||
string current_root()
|
||||
{
|
||||
return "/";
|
||||
|
@ -209,6 +209,14 @@ string utf8_argv(int i)
|
||||
}
|
||||
|
||||
|
||||
void remove_internal_args(int i, int num)
|
||||
{
|
||||
argc_ -= num;
|
||||
for (int j = i; j < argc_; ++j)
|
||||
argv_[j] = argv_[j + num];
|
||||
}
|
||||
|
||||
|
||||
string current_root()
|
||||
{
|
||||
// _getdrive returns the current drive (1=A, 2=B, and so on).
|
||||
|
@ -366,13 +366,14 @@ void easyParse(int & argc, char * argv[])
|
||||
continue;
|
||||
}
|
||||
|
||||
string arg(to_utf8(from_local8bit((i + 1 < argc) ? argv[i + 1] : "")));
|
||||
string arg2(to_utf8(from_local8bit((i + 2 < argc) ? argv[i + 2] : "")));
|
||||
string arg = (i + 1 < argc) ? os::utf8_argv(i + 1) : string();
|
||||
string arg2 = (i + 2 < argc) ? os::utf8_argv(i + 2) : string();
|
||||
|
||||
int const remove = 1 + it->second(arg, arg2);
|
||||
|
||||
// Now, remove used arguments by shifting
|
||||
// the following ones remove places down.
|
||||
os::remove_internal_args(i, remove);
|
||||
argc -= remove;
|
||||
for (int j = i; j < argc; ++j)
|
||||
argv[j] = argv[j + remove];
|
||||
@ -502,13 +503,15 @@ int main(int argc, char * argv[])
|
||||
|
||||
lyxerr.setStream(cerr);
|
||||
|
||||
os::init(argc, argv);
|
||||
|
||||
easyParse(argc, argv);
|
||||
|
||||
if (argc <= 1)
|
||||
error_message("Not enough arguments.");
|
||||
os::init(argc, argv);
|
||||
|
||||
try { init_package(internal_path(to_utf8(from_local8bit(argv[0]))),
|
||||
try {
|
||||
init_package(internal_path(os::utf8_argv(0)),
|
||||
cl_system_support, cl_user_support,
|
||||
top_build_dir_is_two_levels_up);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
@ -520,12 +523,12 @@ int main(int argc, char * argv[])
|
||||
|
||||
// Now every known option is parsed. Look for input and output
|
||||
// file name (the latter is optional).
|
||||
string infilename = internal_path(to_utf8(from_local8bit(argv[1])));
|
||||
string infilename = internal_path(os::utf8_argv(1));
|
||||
infilename = makeAbsPath(infilename).absFilename();
|
||||
|
||||
string outfilename;
|
||||
if (argc > 2) {
|
||||
outfilename = internal_path(to_utf8(from_local8bit(argv[2])));
|
||||
outfilename = internal_path(os::utf8_argv(2));
|
||||
if (outfilename != "-")
|
||||
outfilename = makeAbsPath(outfilename).absFilename();
|
||||
} else
|
||||
|
@ -25,7 +25,7 @@ What's new
|
||||
* DOCUMENT INPUT/OUTPUT
|
||||
|
||||
- LyX now supports SVG images when either the librsvg library or
|
||||
or Inkscape (version 0.47 recommended) is installed (bug 3349).
|
||||
Inkscape (version 0.47 recommended) is installed (bug 3349).
|
||||
|
||||
- LaTeX import (tex2lyx) now recognizes the types of quotes dependent
|
||||
on the document language. (When importing e.g. a Spanish document,
|
||||
@ -154,6 +154,9 @@ What's new
|
||||
- On Windows, allow loading and saving files whose path and/or name contains
|
||||
characters not encodable in the current code page (bug 5238).
|
||||
|
||||
- On Windows, allow using unicode characters in the command line arguments
|
||||
for lyx and tex2lyx.
|
||||
|
||||
- Do not try to move the autosave file if it does not yet exist (bug 6525.)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user