3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
14 #include "support/filetools.h"
15 #include "support/lyxlib.h"
16 #include "support/os.h"
17 #include "support/FileInfo.h"
18 #include "support/path.h"
23 #include "graphics/GraphicsTypes.h"
25 #include "bufferlist.h"
27 #include "lyxserver.h"
30 #include "ToolbarDefaults.h"
31 #include "MenuBackend.h"
33 #include "lastfiles.h"
35 #include "converter.h"
37 #include "lyxtextclasslist.h"
39 #include "frontends/Alert.h"
40 #include "frontends/lyx_gui.h"
42 #include "BoostFormat.h"
43 #include <boost/function.hpp>
51 #ifndef CXX_GLOBAL_CSTD
57 extern void LoadLyXFile(string const &);
58 extern void QuitLyX();
60 extern LyXServer * lyxserver;
64 string system_tempdir;
69 boost::scoped_ptr<LastFiles> lastfiles;
71 // This is the global bufferlist object
72 BufferList bufferlist;
74 // convenient to have it here.
75 boost::scoped_ptr<kb_keymap> toplevel_keymap;
78 LyX::LyX(int & argc, char * argv[])
80 // Here we need to parse the command line. At least
81 // we need to parse for "-dbg" and "-help"
82 bool const want_gui = easyParse(argc, argv);
84 // Global bindings (this must be done as early as possible.) (Lgb)
85 toplevel_keymap.reset(new kb_keymap);
86 defaultKeyBindings(toplevel_keymap.get());
88 // set the DisplayTranslator only once; should that be done here??
89 // if this should not be in this file, please also remove
90 // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
91 grfx::setDisplayTranslator();
94 lyx_gui::parse_init(argc, argv);
97 // check for any spurious extra arguments
98 // other than documents
99 for (int argi = 1; argi < argc ; ++argi) {
100 if (argv[argi][0] == '-') {
102 lyxerr << boost::format(_("Wrong command line option `%1$s'. Exiting."))
106 lyxerr << _("Wrong command line option `")
107 << argv[argi] << _("'. Exiting.")
114 // Initialization of LyX (reads lyxrc and more)
115 lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
117 lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
120 lyx_gui::parse_lyxrc();
123 vector<string> files;
125 for (int argi = argc - 1; argi >= 1; --argi) {
126 files.push_back(argv[argi]);
130 files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
133 // Execute batch commands if available
134 if (!batch_command.empty()) {
135 lyxerr[Debug::INIT] << "About to handle -x '"
136 << batch_command << '\'' << endl;
138 Buffer * last_loaded = 0;
140 vector<string>::iterator it = files.begin();
141 vector<string>::iterator end = files.end();
142 for (; it != end; ++it) {
143 last_loaded = bufferlist.loadLyXFile(*it);
148 // no buffer loaded, create one
150 last_loaded = bufferlist.newFile("tmpfile", string());
152 bool success = false;
154 // try to dispatch to last loaded buffer first
155 bool const dispatched = last_loaded->dispatch(batch_command, &success);
163 lyx_gui::start(batch_command, files);
169 static void error_handler(int err_sig)
173 lyxerr << "\nlyx: SIGHUP signal caught" << endl;
179 lyxerr << "\nlyx: SIGFPE signal caught" << endl;
182 lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
184 "Sorry, you have found a bug in LyX. "
185 "Please read the bug-reporting instructions "
186 "in Help->Introduction and send us a bug report, "
187 "if necessary. Thanks !" << endl;
194 // Deinstall the signal handlers
195 signal(SIGHUP, SIG_DFL);
196 signal(SIGINT, SIG_DFL);
197 signal(SIGFPE, SIG_DFL);
198 signal(SIGSEGV, SIG_DFL);
199 signal(SIGTERM, SIG_DFL);
201 LyX::emergencyCleanup();
203 lyxerr << "Bye." << endl;
204 if (err_sig!= SIGHUP &&
205 (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
213 void LyX::init(bool gui)
215 signal(SIGHUP, error_handler);
216 signal(SIGFPE, error_handler);
217 signal(SIGSEGV, error_handler);
218 signal(SIGINT, error_handler);
219 signal(SIGTERM, error_handler);
222 // Determine path of binary
225 string binpath = os::binpath();
226 string binname = os::binname();
227 string fullbinname = MakeAbsPath(binname, binpath);
229 if (binpath.empty()) {
230 lyxerr << _("Warning: could not determine path of binary.")
232 << _("If you have problems, try starting LyX with an absolute path.")
235 lyxerr[Debug::INIT] << "Name of binary: " << binname << endl;
236 lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
239 // Determine system directory.
242 // Directories are searched in this order:
243 // 1) -sysdir command line parameter
244 // 2) LYX_DIR_13x environment variable
245 // 3) Maybe <path of binary>/TOP_SRCDIR/lib
246 // 4) <path of binary>/../share/<name of binary>/
247 // 4a) repeat 4 after following the Symlink if <path of
248 // binary> is a symbolic link.
249 // 5) hardcoded lyx_dir
250 // The directory is checked for the presence of the file
251 // "chkconfig.ltx", and if that is present, the directory
252 // is accepted as the system directory.
253 // If no chkconfig.ltx file is found, a warning is given,
254 // and the hardcoded lyx_dir is used.
256 // If we had a command line switch, system_lyxdir is already set
258 if (!system_lyxdir.empty())
259 searchpath = MakeAbsPath(system_lyxdir) + ';';
261 string const lyxdir = GetEnvPath("LYX_DIR_13x");
263 if (!lyxdir.empty()) {
264 lyxerr[Debug::INIT] << "LYX_DIR_13x: " << lyxdir << endl;
265 searchpath += lyxdir + ';';
268 string fullbinpath = binpath;
269 FileInfo file(fullbinname, true);
271 lyxerr[Debug::INIT] << "binary is a link" << endl;
273 if (LyXReadLink(fullbinname, link, true)) {
274 // Path of binary/../share/name of binary/
275 searchpath += NormalizePath(AddPath(binpath,
277 + OnlyFilename(binname));
280 binpath = MakeAbsPath(OnlyPath(fullbinpath));
286 // Path of binary/../share/name of binary/
287 searchpath += NormalizePath(AddPath(binpath, "../share/") +
288 OnlyFilename(binname)) + ';';
291 FileInfo file(fullbinpath, true);
292 followlink = file.isLink();
294 lyxerr[Debug::INIT] << " directory " << fullbinpath
295 << " is a link" << endl;
297 if (LyXReadLink(fullbinpath, link, true)) {
299 binpath = MakeAbsPath(OnlyPath(fullbinpath));
305 } while (followlink);
307 // <path of binary>/TOP_SRCDIR/lib
308 build_lyxdir = MakeAbsPath("../lib", binpath);
309 if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
310 searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
312 lyxerr[Debug::INIT] << "Checking whether LyX is run in "
313 "place... yes" << endl;
316 << "Checking whether LyX is run in place... no"
318 build_lyxdir.erase();
322 searchpath += LYX_DIR;
324 lyxerr[Debug::INIT] << "System directory search path: "
325 << searchpath << endl;
327 string const filename = "chkconfig.ltx";
328 string const temp = FileOpenSearch(searchpath, filename, string());
329 system_lyxdir = OnlyPath(temp);
331 // Reduce "path/../path" stuff out of system directory
332 system_lyxdir = NormalizePath(system_lyxdir);
334 bool path_shown = false;
336 // Warn if environment variable is set, but unusable
337 if (!lyxdir.empty()) {
338 if (system_lyxdir != NormalizePath(lyxdir)) {
339 lyxerr <<_("LYX_DIR_13x environment variable no good.")
341 << _("System directory set to: ")
342 << system_lyxdir << endl;
347 // Warn the user if we couldn't find "chkconfig.ltx"
348 if (system_lyxdir == "./") {
349 lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
350 <<_("Try the '-sysdir' command line parameter or ")
351 <<_("set the environment variable LYX_DIR_13x to the "
352 "LyX system directory ")
353 << _("containing the file `chkconfig.ltx'.") << endl;
355 FileInfo fi(LYX_DIR);
357 lyxerr << "Couldn't even find the default LYX_DIR." << endl
358 << "Giving up." << endl;
362 lyxerr << boost::format(_("Using built-in default %1$s"
363 " but expect problems."))
364 % static_cast<char *>(LYX_DIR)
367 lyxerr << _("Using built-in default ") << LYX_DIR
368 << _(" but expect problems.")
372 lyxerr << _("Expect problems.") << endl;
374 system_lyxdir = LYX_DIR;
379 lyxerr[Debug::INIT] << "System directory: '"
380 << system_lyxdir << '\'' << endl;
383 // Determine user lyx-dir
386 // Directories are searched in this order:
387 // 1) -userdir command line parameter
388 // 2) LYX_USERDIR_13x environment variable
389 // 3) $HOME/.<name of binary>
391 // If we had a command line switch, user_lyxdir is already set
392 bool explicit_userdir = true;
393 if (user_lyxdir.empty()) {
395 // LYX_USERDIR_13x environment variable
396 user_lyxdir = GetEnvPath("LYX_USERDIR_13x");
399 if (user_lyxdir.empty())
400 user_lyxdir = AddPath(GetEnvPath("HOME"),
401 string(".") + PACKAGE);
402 explicit_userdir = false;
405 lyxerr[Debug::INIT] << "User LyX directory: '"
406 << user_lyxdir << '\'' << endl;
408 // Check that user LyX directory is ok. We don't do that if
409 // running in batch mode.
411 queryUserLyXDir(explicit_userdir);
417 // Shine up lyxrc defaults
420 // Default template path: system_dir/templates
421 if (lyxrc.template_path.empty()) {
422 lyxrc.template_path = AddPath(system_lyxdir, "templates");
425 // Default lastfiles file: $HOME/.lyx/lastfiles
426 if (lyxrc.lastfiles.empty()) {
427 lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
430 // Disable gui when either lyxrc or easyparse says so
432 lyxrc.use_gui = false;
435 // Read configuration files
438 readRcFile("lyxrc.defaults");
439 system_lyxrc = lyxrc;
440 system_formats = formats;
441 system_converters = converters;
442 system_lcolor = lcolor;
444 // If there is a preferences file we read that instead
445 // of the old lyxrc file.
446 if (!readRcFile("preferences"))
449 readEncodingsFile("encodings");
450 readLanguagesFile("languages");
453 lyxerr[Debug::INIT] << "Reading layouts..." << endl;
456 // Ensure that we have really read a bind file, so that LyX is
458 lyxrc.readBindFileIfNeeded();
461 readUIFile(lyxrc.ui_file);
463 if (lyxerr.debugging(Debug::LYXRC)) {
467 os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
468 system_tempdir = os::getTmpDir();
469 if (lyxerr.debugging(Debug::INIT)) {
470 lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
473 lyxerr[Debug::INIT] << "Reading lastfiles `"
474 << lyxrc.lastfiles << "'..." << endl;
475 lastfiles.reset(new LastFiles(lyxrc.lastfiles,
476 lyxrc.check_lastfiles,
477 lyxrc.num_lastfiles));
481 void LyX::defaultKeyBindings(kb_keymap * kbmap)
483 kbmap->bind("Right", LFUN_RIGHT);
484 kbmap->bind("Left", LFUN_LEFT);
485 kbmap->bind("Up", LFUN_UP);
486 kbmap->bind("Down", LFUN_DOWN);
488 kbmap->bind("Tab", LFUN_TAB);
489 kbmap->bind("ISO_Left_Tab", LFUN_TAB); // jbl 2001-23-02
491 kbmap->bind("Home", LFUN_HOME);
492 kbmap->bind("End", LFUN_END);
493 kbmap->bind("Prior", LFUN_PRIOR);
494 kbmap->bind("Next", LFUN_NEXT);
496 kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
497 //kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
499 kbmap->bind("Delete", LFUN_DELETE);
500 kbmap->bind("BackSpace", LFUN_BACKSPACE);
502 // sub- and superscript -MV
503 kbmap->bind("~S-underscore", LFUN_SUBSCRIPT);
504 kbmap->bind("~S-asciicircum", LFUN_SUPERSCRIPT);
506 // kbmap->bindings to enable the use of the numeric keypad
508 //kbmap->bind("KP_0", LFUN_SELFINSERT);
509 //kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
510 kbmap->bind("KP_Enter", LFUN_BREAKPARAGRAPH);
511 //kbmap->bind("KP_1", LFUN_SELFINSERT);
512 //kbmap->bind("KP_2", LFUN_SELFINSERT);
513 //kbmap->bind("KP_3", LFUN_SELFINSERT);
514 //kbmap->bind("KP_4", LFUN_SELFINSERT);
515 //kbmap->bind("KP_5", LFUN_SELFINSERT);
516 //kbmap->bind("KP_6", LFUN_SELFINSERT);
517 //kbmap->bind("KP_Add", LFUN_SELFINSERT);
518 //kbmap->bind("KP_7", LFUN_SELFINSERT);
519 //kbmap->bind("KP_8", LFUN_SELFINSERT);
520 //kbmap->bind("KP_9", LFUN_SELFINSERT);
521 //kbmap->bind("KP_Divide", LFUN_SELFINSERT);
522 //kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
523 //kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
524 kbmap->bind("KP_Right", LFUN_RIGHT);
525 kbmap->bind("KP_Left", LFUN_LEFT);
526 kbmap->bind("KP_Up", LFUN_UP);
527 kbmap->bind("KP_Down", LFUN_DOWN);
528 kbmap->bind("KP_Home", LFUN_HOME);
529 kbmap->bind("KP_End", LFUN_END);
530 kbmap->bind("KP_Prior", LFUN_PRIOR);
531 kbmap->bind("KP_Next", LFUN_NEXT);
533 kbmap->bind("C-Tab", LFUN_TABINSERT); // ale970515
534 kbmap->bind("S-Tab", LFUN_SHIFT_TAB); // jug20000522
535 kbmap->bind("S-ISO_Left_Tab", LFUN_SHIFT_TAB); // jbl 2001-23-02
539 void LyX::emergencyCleanup()
541 // what to do about tmpfiles is non-obvious. we would
542 // like to delete any we find, but our lyxdir might
543 // contain documents etc. which might be helpful on
546 bufferlist.emergencyWriteAll();
548 lyxserver->emergencyCleanup();
552 void LyX::deadKeyBindings(kb_keymap * kbmap)
554 // bindKeyings for transparent handling of deadkeys
555 // The keysyms are gotten from XFree86 X11R6
556 kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
557 kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
558 kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
559 kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
560 kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
561 kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
562 kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
563 kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
564 kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
565 kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
566 // nothing with this name
567 // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
568 kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
569 kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
570 // nothing with this name either...
571 //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
572 kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
573 kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
574 kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
578 void LyX::queryUserLyXDir(bool explicit_userdir)
580 string const configure_script = AddName(system_lyxdir, "configure");
582 // Does user directory exist?
583 FileInfo fileInfo(user_lyxdir);
584 if (fileInfo.isOK() && fileInfo.isDir()) {
586 FileInfo script(configure_script);
587 FileInfo defaults(AddName(user_lyxdir, "lyxrc.defaults"));
588 if (defaults.isOK() && script.isOK()
589 && defaults.getModificationTime() < script.getModificationTime()) {
590 lyxerr << _("LyX: reconfiguring user directory")
593 ::system(configure_script.c_str());
594 lyxerr << "LyX: " << _("Done!") << endl;
599 first_start = !explicit_userdir;
602 lyxerr << boost::format(_("LyX: Creating directory %1$s"
603 " and running configure..."))
607 lyxerr << _("LyX: Creating directory ") << user_lyxdir
608 << _(" and running configure...")
612 if (!createDirectory(user_lyxdir, 0755)) {
613 // Failed, let's use $HOME instead.
614 user_lyxdir = GetEnvPath("HOME");
616 lyxerr << boost::format(_("Failed. Will use %1$s instead."))
620 lyxerr << _("Failed. Will use ") << user_lyxdir <<
627 // Run configure in user lyx directory
629 ::system(configure_script.c_str());
630 lyxerr << "LyX: " << _("Done!") << endl;
634 bool LyX::readRcFile(string const & name)
636 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
638 string const lyxrc_path = LibFileSearch(string(), name);
639 if (!lyxrc_path.empty()) {
640 lyxerr[Debug::INIT] << "Found " << name
641 << " in " << lyxrc_path << endl;
642 if (lyxrc.read(lyxrc_path) < 0) {
644 Alert::alert(_("LyX Warning!"),
645 boost::io::str(boost::format(_("Error while reading %1$s.")) % lyxrc_path),
646 _("Using built-in defaults."));
648 Alert::alert(_("LyX Warning!"),
649 _("Error while reading ") + lyxrc_path,
650 _("Using built-in defaults."));
656 lyxerr[Debug::INIT] << "Could not find " << name << endl;
663 // Read the ui file `name'
664 void LyX::readUIFile(string const & name)
672 struct keyword_item uitags[ui_last - 1] = {
673 { "menuset", ui_menuset },
674 { "toolbar", ui_toolbar }
677 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
679 string const ui_path = LibFileSearch("ui", name, "ui");
681 if (ui_path.empty()) {
682 lyxerr[Debug::INIT] << "Could not find " << name << endl;
683 menubackend.defaults();
687 lyxerr[Debug::INIT] << "Found " << name
688 << " in " << ui_path << endl;
689 LyXLex lex(uitags, ui_last - 1);
690 lex.setFile(ui_path);
692 lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
696 if (lyxerr.debugging(Debug::PARSER))
697 lex.printTable(lyxerr);
702 menubackend.read(lex);
706 toolbardefaults.read(lex);
710 if (!rtrim(lex.getString()).empty())
711 lex.printError("LyX::ReadUIFile: "
712 "Unknown menu tag: `$$Token'");
719 // Read the languages file `name'
720 void LyX::readLanguagesFile(string const & name)
722 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
724 string const lang_path = LibFileSearch(string(), name);
725 if (lang_path.empty()) {
726 lyxerr[Debug::INIT] << "Could not find " << name << endl;
727 languages.setDefaults();
730 languages.read(lang_path);
734 // Read the encodings file `name'
735 void LyX::readEncodingsFile(string const & name)
737 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
739 string const enc_path = LibFileSearch(string(), name);
740 if (enc_path.empty()) {
741 lyxerr[Debug::INIT] << "Could not find " << name << endl;
744 encodings.read(enc_path);
753 /// return the the number of arguments consumed
754 typedef boost::function<int(string const &, string const &)> cmd_helper;
756 int parse_dbg(string const & arg, string const &)
759 lyxerr << _("List of supported debug flags:") << endl;
760 Debug::showTags(lyxerr);
764 lyxerr << boost::format(_("Setting debug level to %1$s"))
768 lyxerr << _("Setting debug level to ") << arg << endl;
771 lyxerr.level(Debug::value(arg));
772 Debug::showLevel(lyxerr, lyxerr.level());
776 int parse_help(string const &, string const &)
779 _("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
780 "Command line switches (case sensitive):\n"
781 "\t-help summarize LyX usage\n"
782 "\t-userdir dir try to set user directory to dir\n"
783 "\t-sysdir dir try to set system directory to dir\n"
784 "\t-geometry WxH+X+Y set geometry of the main window\n"
785 "\t-dbg feature[,feature]...\n"
786 " select the features to debug.\n"
787 " Type `lyx -dbg' to see the list of features\n"
788 "\t-x [--execute] command\n"
789 " where command is a lyx command.\n"
790 "\t-e [--export] fmt\n"
791 " where fmt is the export format of choice.\n"
792 "\t-i [--import] fmt file.xxx\n"
793 " where fmt is the import format of choice\n"
794 " and file.xxx is the file to be imported.\n"
795 "\t-version summarize version and build info\n"
796 "Check the LyX man page for more details.") << endl;
801 int parse_version(string const &, string const &)
803 lyxerr << "LyX " << lyx_version
804 << " of " << lyx_release_date << endl;
805 lyxerr << "Built on " << __DATE__ << ", " << __TIME__ << endl;
807 lyxerr << lyx_version_info << endl;
812 int parse_sysdir(string const & arg, string const &)
815 lyxerr << _("Missing directory for -sysdir switch") << endl;
822 int parse_userdir(string const & arg, string const &)
825 lyxerr << _("Missing directory for -userdir switch") << endl;
832 int parse_execute(string const & arg, string const &)
835 lyxerr << _("Missing command string after --execute switch") << endl;
839 // Argh. Setting gui to false segfaults..
840 // FIXME: when ? how ?
845 int parse_export(string const & type, string const &)
848 lyxerr << _("Missing file type [eg latex, ps...] after "
849 "--export switch") << endl;
852 batch = "buffer-export " + type;
857 int parse_import(string const & type, string const & file)
860 lyxerr << _("Missing file type [eg latex, ps...] after "
861 "--import switch") << endl;
865 lyxerr << _("Missing filename for --import") << endl;
869 batch = "buffer-import " + type + ' ' + file;
876 bool LyX::easyParse(int & argc, char * argv[])
878 std::map<string, cmd_helper> cmdmap;
880 cmdmap["-dbg"] = parse_dbg;
881 cmdmap["-help"] = parse_help;
882 cmdmap["--help"] = parse_help;
883 cmdmap["-version"] = parse_version;
884 cmdmap["--version"] = parse_version;
885 cmdmap["-sysdir"] = parse_sysdir;
886 cmdmap["-userdir"] = parse_userdir;
887 cmdmap["-x"] = parse_execute;
888 cmdmap["--execute"] = parse_execute;
889 cmdmap["-e"] = parse_export;
890 cmdmap["--export"] = parse_export;
891 cmdmap["-i"] = parse_import;
892 cmdmap["--import"] = parse_import;
894 for (int i = 1; i < argc; ++i) {
895 std::map<string, cmd_helper>::const_iterator it
896 = cmdmap.find(argv[i]);
898 // don't complain if not found - may be parsed later
899 if (it == cmdmap.end())
902 string arg((i + 1 < argc) ? argv[i + 1] : "");
903 string arg2((i + 2 < argc) ? argv[i + 2] : "");
905 int const remove = 1 + it->second(arg, arg2);
907 // Now, remove used arguments by shifting
908 // the following ones remove places down.
910 for (int j = i; j < argc; ++j)
911 argv[j] = argv[j + remove];
915 batch_command = batch;