3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
13 #pragma implementation
18 #include "support/filetools.h"
19 #include "support/lyxlib.h"
20 #include "support/os.h"
21 #include "support/FileInfo.h"
22 #include "support/path.h"
27 #include "bufferlist.h"
28 #include "lyxtextclasslist.h"
29 #include "lyxserver.h"
32 #include "ToolbarDefaults.h"
33 #include "MenuBackend.h"
35 #include "lastfiles.h"
37 #include "converter.h"
39 #include "frontends/Alert.h"
40 #include "frontends/lyx_gui.h"
48 #ifndef CXX_GLOBAL_CSTD
54 extern void LoadLyXFile(string const &);
55 extern void QuitLyX();
57 extern LyXServer * lyxserver;
61 string system_tempdir;
66 boost::scoped_ptr<LastFiles> lastfiles;
68 // This is the global bufferlist object
69 BufferList bufferlist;
71 // this should be static, but I need it in buffer.C
72 bool finished = false; // flag, that we are quitting the program
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());
89 lyx_gui::parse_init(argc, argv);
92 // check for any spurious extra arguments
93 // other than documents
94 for (int argi = 1; argi < argc ; ++argi) {
95 if (argv[argi][0] == '-') {
96 lyxerr << _("Wrong command line option `")
98 << _("'. Exiting.") << endl;
103 // Initialization of LyX (reads lyxrc and more)
104 lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
106 lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
109 lyx_gui::parse_lyxrc();
112 vector<string> files;
114 for (int argi = argc - 1; argi >= 1; --argi) {
115 files.push_back(argv[argi]);
119 files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
123 // Execute batch commands if available
124 if (!batch_command.empty()) {
125 lyxerr[Debug::INIT] << "About to handle -x '"
126 << batch_command << "'" << endl;
128 // no buffer loaded, create one
130 last_loaded = bufferlist.newFile("tmpfile", string());
132 bool success = false;
134 // try to dispatch to last loaded buffer first
135 bool const dispatched = last_loaded->dispatch(batch_command, &success);
137 // if this was successful, finish
145 lyx_gui::start(batch_command, files);
152 void error_handler(int err_sig)
156 lyxerr << "\nlyx: SIGHUP signal caught" << endl;
162 lyxerr << "\nlyx: SIGFPE signal caught" << endl;
165 lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
167 "Sorry, you have found a bug in LyX. "
168 "Please read the bug-reporting instructions "
169 "in Help->Introduction and send us a bug report, "
170 "if necessary. Thanks !" << endl;
177 // Deinstall the signal handlers
178 signal(SIGHUP, SIG_DFL);
179 signal(SIGINT, SIG_DFL);
180 signal(SIGFPE, SIG_DFL);
181 signal(SIGSEGV, SIG_DFL);
182 signal(SIGTERM, SIG_DFL);
184 LyX::emergencyCleanup();
186 lyxerr << "Bye." << endl;
187 if (err_sig!= SIGHUP &&
188 (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
196 void LyX::init(bool gui)
198 // Install the signal handlers
199 signal(SIGHUP, error_handler);
200 signal(SIGFPE, error_handler);
201 signal(SIGSEGV, error_handler);
202 signal(SIGINT, error_handler);
203 signal(SIGTERM, error_handler);
206 // Determine path of binary
209 string binpath = os::binpath();
210 string binname = os::binname();
211 string fullbinname = MakeAbsPath(binname, binpath);
213 if (binpath.empty()) {
214 lyxerr << _("Warning: could not determine path of binary.")
216 << _("If you have problems, try starting LyX with an absolute path.")
219 lyxerr[Debug::INIT] << "Name of binary: " << binname << endl;
220 lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
223 // Determine system directory.
226 // Directories are searched in this order:
227 // 1) -sysdir command line parameter
228 // 2) LYX_DIR_13x environment variable
229 // 3) Maybe <path of binary>/TOP_SRCDIR/lib
230 // 4) <path of binary>/../share/<name of binary>/
231 // 4a) repeat 4 after following the Symlink if <path of
232 // binary> is a symbolic link.
233 // 5) hardcoded lyx_dir
234 // The directory is checked for the presence of the file
235 // "chkconfig.ltx", and if that is present, the directory
236 // is accepted as the system directory.
237 // If no chkconfig.ltx file is found, a warning is given,
238 // and the hardcoded lyx_dir is used.
240 // If we had a command line switch, system_lyxdir is already set
242 if (!system_lyxdir.empty())
243 searchpath = MakeAbsPath(system_lyxdir) + ';';
245 // LYX_DIR_13x environment variable
246 string const lyxdir = GetEnvPath("LYX_DIR_13x");
248 if (!lyxdir.empty()) {
249 lyxerr[Debug::INIT] << "LYX_DIR_13x: " << lyxdir << endl;
250 searchpath += lyxdir + ';';
253 string fullbinpath = binpath;
254 FileInfo file(fullbinname, true);
256 lyxerr[Debug::INIT] << "binary is a link" << endl;
258 if (LyXReadLink(fullbinname, link, true)) {
259 // Path of binary/../share/name of binary/
260 searchpath += NormalizePath(AddPath(binpath,
262 + OnlyFilename(binname));
265 binpath = MakeAbsPath(OnlyPath(fullbinpath));
271 // Path of binary/../share/name of binary/
272 searchpath += NormalizePath(AddPath(binpath, "../share/") +
273 OnlyFilename(binname)) + ';';
276 FileInfo file(fullbinpath, true);
277 followlink = file.isLink();
279 lyxerr << " directory " << fullbinpath
280 << " is a link" << endl;
282 if (LyXReadLink(fullbinpath, link, true)) {
284 binpath = MakeAbsPath(OnlyPath(fullbinpath));
290 } while (followlink);
292 // <path of binary>/TOP_SRCDIR/lib
293 build_lyxdir = MakeAbsPath("../lib", binpath);
294 if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
295 searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
297 lyxerr[Debug::INIT] << "Checking whether LyX is run in "
298 "place... yes" << endl;
301 << "Checking whether LyX is run in place... no"
303 build_lyxdir.erase();
307 searchpath += LYX_DIR;
309 // If debugging, show complete search path
310 lyxerr[Debug::INIT] << "System directory search path: "
311 << searchpath << endl;
313 string const filename = "chkconfig.ltx";
314 string const temp = FileOpenSearch(searchpath, filename, string());
315 system_lyxdir = OnlyPath(temp);
317 // Reduce "path/../path" stuff out of system directory
318 system_lyxdir = NormalizePath(system_lyxdir);
320 bool path_shown = false;
322 // Warn if environment variable is set, but unusable
323 if (!lyxdir.empty()) {
324 if (system_lyxdir != NormalizePath(lyxdir)) {
325 lyxerr <<_("LYX_DIR_13x environment variable no good.")
327 << _("System directory set to: ")
328 << system_lyxdir << endl;
333 // Warn the user if we couldn't find "chkconfig.ltx"
334 if (system_lyxdir == "./") {
335 lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
336 <<_("Try the '-sysdir' command line parameter or ")
337 <<_("set the environment variable LYX_DIR_13x to the "
338 "LyX system directory ")
339 << _("containing the file `chkconfig.ltx'.") << endl;
341 FileInfo fi(LYX_DIR);
343 lyxerr << "Couldn't even find the default LYX_DIR." << endl
344 << "Giving up." << endl;
347 lyxerr << _("Using built-in default ")
348 << LYX_DIR << _(" but expect problems.")
351 lyxerr << _("Expect problems.") << endl;
353 system_lyxdir = LYX_DIR;
356 // Report the system directory if debugging is on
358 lyxerr[Debug::INIT] << "System directory: '"
359 << system_lyxdir << '\'' << endl;
362 // Determine user lyx-dir
365 // Directories are searched in this order:
366 // 1) -userdir command line parameter
367 // 2) LYX_USERDIR_13x environment variable
368 // 3) $HOME/.<name of binary>
370 // If we had a command line switch, user_lyxdir is already set
371 bool explicit_userdir = true;
372 if (user_lyxdir.empty()) {
374 // LYX_USERDIR_13x environment variable
375 user_lyxdir = GetEnvPath("LYX_USERDIR_13x");
378 if (user_lyxdir.empty())
379 user_lyxdir = AddPath(GetEnvPath("HOME"),
380 string(".") + PACKAGE);
381 explicit_userdir = false;
384 lyxerr[Debug::INIT] << "User LyX directory: '"
385 << user_lyxdir << '\'' << endl;
387 // Check that user LyX directory is ok. We don't do that if
388 // running in batch mode.
390 queryUserLyXDir(explicit_userdir);
396 // Shine up lyxrc defaults
399 // Default template path: system_dir/templates
400 if (lyxrc.template_path.empty()) {
401 lyxrc.template_path = AddPath(system_lyxdir, "templates");
404 // Default lastfiles file: $HOME/.lyx/lastfiles
405 if (lyxrc.lastfiles.empty()) {
406 lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
409 // Disable gui when either lyxrc or easyparse says so
411 lyxrc.use_gui = false;
414 // Read configuration files
417 readRcFile("lyxrc.defaults");
418 system_lyxrc = lyxrc;
419 system_formats = formats;
420 system_converters = converters;
421 system_lcolor = lcolor;
423 // If there is a preferences file we read that instead
424 // of the old lyxrc file.
425 if (!readRcFile("preferences"))
429 readEncodingsFile("encodings");
431 readLanguagesFile("languages");
434 lyxerr[Debug::INIT] << "Reading layouts..." << endl;
437 // Ensure that we have really read a bind file, so that LyX is
439 lyxrc.readBindFileIfNeeded();
442 readUIFile(lyxrc.ui_file);
444 // Bind the X dead keys to the corresponding LyX functions if
446 if (lyxrc.override_x_deadkeys)
447 deadKeyBindings(toplevel_keymap.get());
449 if (lyxerr.debugging(Debug::LYXRC)) {
453 // Create temp directory
454 os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
455 system_tempdir = os::getTmpDir();
456 if (lyxerr.debugging(Debug::INIT)) {
457 lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
460 // load the lastfiles mini-database
461 lyxerr[Debug::INIT] << "Reading lastfiles `"
462 << lyxrc.lastfiles << "'..." << endl;
463 lastfiles.reset(new LastFiles(lyxrc.lastfiles,
464 lyxrc.check_lastfiles,
465 lyxrc.num_lastfiles));
469 // These are the default bindings known to LyX
470 void LyX::defaultKeyBindings(kb_keymap * kbmap)
472 kbmap->bind("Right", LFUN_RIGHT);
473 kbmap->bind("Left", LFUN_LEFT);
474 kbmap->bind("Up", LFUN_UP);
475 kbmap->bind("Down", LFUN_DOWN);
477 kbmap->bind("Tab", LFUN_TAB);
478 kbmap->bind("ISO_Left_Tab", LFUN_TAB); // jbl 2001-23-02
480 kbmap->bind("Home", LFUN_HOME);
481 kbmap->bind("End", LFUN_END);
482 kbmap->bind("Prior", LFUN_PRIOR);
483 kbmap->bind("Next", LFUN_NEXT);
485 kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
486 //kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
488 kbmap->bind("Delete", LFUN_DELETE);
489 kbmap->bind("BackSpace", LFUN_BACKSPACE);
491 // sub- and superscript -MV
492 kbmap->bind("~S-underscore", LFUN_SUBSCRIPT);
493 kbmap->bind("~S-asciicircum", LFUN_SUPERSCRIPT);
495 // kbmap->bindings to enable the use of the numeric keypad
497 //kbmap->bind("KP_0", LFUN_SELFINSERT);
498 //kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
499 kbmap->bind("KP_Enter", LFUN_BREAKPARAGRAPH);
500 //kbmap->bind("KP_1", LFUN_SELFINSERT);
501 //kbmap->bind("KP_2", LFUN_SELFINSERT);
502 //kbmap->bind("KP_3", LFUN_SELFINSERT);
503 //kbmap->bind("KP_4", LFUN_SELFINSERT);
504 //kbmap->bind("KP_5", LFUN_SELFINSERT);
505 //kbmap->bind("KP_6", LFUN_SELFINSERT);
506 //kbmap->bind("KP_Add", LFUN_SELFINSERT);
507 //kbmap->bind("KP_7", LFUN_SELFINSERT);
508 //kbmap->bind("KP_8", LFUN_SELFINSERT);
509 //kbmap->bind("KP_9", LFUN_SELFINSERT);
510 //kbmap->bind("KP_Divide", LFUN_SELFINSERT);
511 //kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
512 //kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
513 kbmap->bind("KP_Right", LFUN_RIGHT);
514 kbmap->bind("KP_Left", LFUN_LEFT);
515 kbmap->bind("KP_Up", LFUN_UP);
516 kbmap->bind("KP_Down", LFUN_DOWN);
517 kbmap->bind("KP_Home", LFUN_HOME);
518 kbmap->bind("KP_End", LFUN_END);
519 kbmap->bind("KP_Prior", LFUN_PRIOR);
520 kbmap->bind("KP_Next", LFUN_NEXT);
522 kbmap->bind("C-Tab", LFUN_TABINSERT); // ale970515
523 kbmap->bind("S-Tab", LFUN_SHIFT_TAB); // jug20000522
524 kbmap->bind("S-ISO_Left_Tab", LFUN_SHIFT_TAB); // jbl 2001-23-02
528 void LyX::emergencyCleanup()
530 // what to do about tmpfiles is non-obvious. we would
531 // like to delete any we find, but our lyxdir might
532 // contain documents etc. which might be helpful on
535 bufferlist.emergencyWriteAll();
537 lyxserver->emergencyCleanup();
541 // LyX can optionally take over the handling of deadkeys
542 void LyX::deadKeyBindings(kb_keymap * kbmap)
544 // bindKeyings for transparent handling of deadkeys
545 // The keysyms are gotten from XFree86 X11R6
546 kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
547 kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
548 kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
549 kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
550 kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
551 kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
552 kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
553 kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
554 kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
555 kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
556 // nothing with this name
557 // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
558 kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
559 kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
560 // nothing with this name either...
561 //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
562 kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
563 kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
564 kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
568 // This one is not allowed to use anything on the main form, since that
569 // one does not exist yet. (Asger)
570 void LyX::queryUserLyXDir(bool explicit_userdir)
572 // Does user directory exist?
573 FileInfo fileInfo(user_lyxdir);
574 if (fileInfo.isOK() && fileInfo.isDir()) {
578 first_start = !explicit_userdir;
581 // If the user specified explicitely a directory, ask whether
582 // to create it (otherwise, always create it)
583 if (explicit_userdir &&
584 !Alert::askQuestion(_("You have specified an invalid LyX directory."),
585 _("It is needed to keep your own configuration."),
586 _("Should I try to set it up for you (recommended)?"))) {
587 lyxerr << _("Running without personal LyX directory.") << endl;
588 // No, let's use $HOME instead.
589 user_lyxdir = GetEnvPath("HOME");
593 // Tell the user what is going on
594 lyxerr << _("LyX: Creating directory ") << user_lyxdir
595 << _(" and running configure...") << endl;
597 // Create directory structure
598 if (!createDirectory(user_lyxdir, 0755)) {
599 // Failed, let's use $HOME instead.
600 user_lyxdir = GetEnvPath("HOME");
601 lyxerr << _("Failed. Will use ") << user_lyxdir
602 << _(" instead.") << endl;
606 // Run configure in user lyx directory
608 ::system(AddName(system_lyxdir, "configure").c_str());
609 lyxerr << "LyX: " << _("Done!") << endl;
613 // Read the rc file `name'
614 bool LyX::readRcFile(string const & name)
616 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
618 string const lyxrc_path = LibFileSearch(string(), name);
619 if (!lyxrc_path.empty()) {
620 lyxerr[Debug::INIT] << "Found " << name
621 << " in " << lyxrc_path << endl;
622 if (lyxrc.read(lyxrc_path) < 0) {
623 Alert::alert(_("LyX Warning!"),
624 _("Error while reading ") + lyxrc_path + ".",
625 _("Using built-in defaults."));
630 lyxerr[Debug::INIT] << "Could not find " << name << endl;
637 // Read the ui file `name'
638 void LyX::readUIFile(string const & name)
646 struct keyword_item uitags[ui_last-1] = {
647 { "menuset", ui_menuset },
648 { "toolbar", ui_toolbar }
651 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
653 string const ui_path = LibFileSearch("ui", name, "ui");
655 if (ui_path.empty()) {
656 lyxerr[Debug::INIT] << "Could not find " << name << endl;
657 menubackend.defaults();
661 lyxerr[Debug::INIT] << "Found " << name
662 << " in " << ui_path << endl;
663 LyXLex lex(uitags, ui_last - 1);
664 lex.setFile(ui_path);
666 lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
670 if (lyxerr.debugging(Debug::PARSER))
671 lex.printTable(lyxerr);
676 menubackend.read(lex);
680 toolbardefaults.read(lex);
684 if (!strip(lex.getString()).empty())
685 lex.printError("LyX::ReadUIFile: "
686 "Unknown menu tag: `$$Token'");
693 // Read the languages file `name'
694 void LyX::readLanguagesFile(string const & name)
696 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
698 string const lang_path = LibFileSearch(string(), name);
699 if (lang_path.empty()) {
700 lyxerr[Debug::INIT] << "Could not find " << name << endl;
701 languages.setDefaults();
704 languages.read(lang_path);
708 // Read the encodings file `name'
709 void LyX::readEncodingsFile(string const & name)
711 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
713 string const enc_path = LibFileSearch(string(), name);
714 if (enc_path.empty()) {
715 lyxerr[Debug::INIT] << "Could not find " << name << endl;
718 encodings.read(enc_path);
724 // Set debugging level and report result to user
725 void setDebuggingLevel(string const & dbgLevel)
727 lyxerr << _("Setting debug level to ") << dbgLevel << endl;
728 lyxerr.level(Debug::value(dbgLevel));
729 Debug::showLevel(lyxerr, lyxerr.level());
733 // Give command line help
734 void commandLineHelp()
737 _("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
738 "Command line switches (case sensitive):\n"
739 "\t-help summarize LyX usage\n"
740 "\t-userdir dir try to set user directory to dir\n"
741 "\t-sysdir dir try to set system directory to dir\n"
742 "\t-geometry WxH+X+Y set geometry of the main window\n"
743 "\t-dbg feature[,feature]...\n"
744 " select the features to debug.\n"
745 " Type `lyx -dbg' to see the list of features\n"
746 "\t-x [--execute] command\n"
747 " where command is a lyx command.\n"
748 "\t-e [--export] fmt\n"
749 " where fmt is the export format of choice.\n"
750 "\t-i [--import] fmt file.xxx\n"
751 " where fmt is the import format of choice\n"
752 " and file.xxx is the file to be imported.\n"
753 "\t-version summarize version and build info\n"
754 "Check the LyX man page for more details.") << endl;
757 // Give command line version information
758 void commandLineVersionInfo()
760 lyxerr << "LyX " << lyx_version
761 << " of " << lyx_release_date << endl;
762 lyxerr << "Built on " << __DATE__ << ", " << __TIME__ << endl;
764 lyxerr << lyx_version_info << endl;
771 bool LyX::easyParse(int & argc, char * argv[])
774 int removeargs = 0; // used when options are read
775 for (int i = 1; i < argc; ++i) {
776 string arg = argv[i];
778 // Check for -dbg int
781 setDebuggingLevel(argv[i + 1]);
784 lyxerr << _("List of supported debug flags:")
786 Debug::showTags(lyxerr);
790 // Check for "-sysdir"
791 else if (arg == "-sysdir") {
793 system_lyxdir = argv[i + 1];
796 lyxerr << _("Missing directory for -sysdir switch!")
801 // Check for "-userdir"
802 else if (arg == "-userdir") {
804 user_lyxdir = argv[i + 1];
807 lyxerr << _("Missing directory for -userdir switch!")
812 // Check for --help or -help
813 else if (arg == "--help" || arg == "-help") {
817 // Check for --version or -version
818 else if (arg == "--version" || arg == "-version") {
819 commandLineVersionInfo();
822 // FIXME: why is this commented out ?
823 // Check for "-nw": No XWindows as for emacs this should
824 // give a LyX that could be used in a terminal window.
825 //else if (arg == "-nw") {
829 // Check for "-x": Execute commands
830 else if (arg == "-x" || arg == "--execute") {
832 batch_command = string(argv[i + 1]);
836 lyxerr << _("Missing command string after -x switch!") << endl;
838 // Argh. Setting gui to false segfaults..
839 // FIXME: when ? how ?
843 else if (arg == "-e" || arg == "--export") {
845 string type(argv[i+1]);
847 batch_command = "buffer-export " + type;
850 lyxerr << _("Missing file type [eg latex, "
852 << arg << _(" switch!") << endl;
856 else if (arg == "-i" || arg == "--import") {
859 lyxerr << _("Missing filename for --import") << endl;
863 string const file(argv[i+2]);
864 string const type(argv[i+1]);
867 batch_command = "buffer-import " + type + " " + file;
868 lyxerr << "batch_command: "
869 << batch_command << endl;
872 lyxerr << _("Missing type [eg latex, "
874 << arg << _(" switch!") << endl;
879 if (removeargs > 0) {
880 // Now, remove used arguments by shifting
881 // the following ones removeargs places down.
883 for (int j = i; j < argc; ++j)
884 argv[j] = argv[j + removeargs];
885 --i; // After shift, check this number again.