Commit Graph

31 Commits

Author SHA1 Message Date
Abdelrazak Younes
4d5ae916ad Fix bug 3293 by Bernhard Roider:
This changes the semantics of isOK() and operator(), comments from Bernhard below:

With the old version of lyxlex it was _impossible_ to check whether reading an integer, float, ... succeeded or not. The current solution to check for is.bad() in some cases and in other cases use is.good() does not give the desired information. Moreover the result of is.bad() depends on the stl implementation and behaves different for linux and windows.

the bug was introduced by the patch that fixed the bug that crashed lyx when "inset-insert ert" was executed from the command buffer.
The lexer has the method isOK() which reflects the status of the stream is.
The operators void* and ! are not really well defined (they depend on the value of is.bad()). What is missing is a test if the last reading operation was successful and thus the returned value is valid.
That's what i implemented in this patch.

The new rule for using the lexer:

if you want to know if the lexer still has data to read (either from the stream or from the pushed token) then use "lex.isOK()".
If you want to test if the last reading operation was successful then use eg. "if (lex) {...}" or unsuccessful then use eg. "if (!lex) {...}"

an example:

int readParam(LyxLex &lex) {

    int param = 1; // default value
    if (lex.isOK()) { // the lexer has data to read
        int p;    // temporary variable
        lex >> p;
        if (lex) param = p; // only use the input if the reading operation was successful
    }
    return param;
}




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17569 a592a061-630c-0410-9148-cb99ea01b6c8
2007-03-26 13:43:49 +00:00
Georg Baum
cdfed1ce7d remove unused stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16109 a592a061-630c-0410-9148-cb99ea01b6c8
2006-11-29 21:34:24 +00:00
Georg Baum
8e6e970d7b Next step of true unicode filenames: Use support::FileName instead of
std::string at many places (not all yet).


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16069 a592a061-630c-0410-9148-cb99ea01b6c8
2006-11-26 21:30:39 +00:00
Abdelrazak Younes
451b12d00d * LyXLex::Pimpl::buff is now a string.
* unicode.[Ch]:
 - new non template iconv_convert()
 - iconv_convert() template use above function.

* docstring.C:
 - utf8_to_ucs4(): new function, use the new iconv_convert() function above.
 - from_utf8(): use utf8_to_ucs4() function above.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15592 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-28 15:16:30 +00:00
André Pönitz
6c300f72a2 move everything into namespace lyx
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15422 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-21 00:16:43 +00:00
Lars Gullik Bjønnes
c46b7d8955 Merge the unicode branch into trunk.
- src/support/unicode.[Ch]: new files with functions for converting
  to and fro ucs4, ucs2 and utf8.
- src/support/docstring.h: specialization of basic_string that
  holds a uint32_t internally.
- Several functions changed to use char_type instead of char or unsigned char.
- Qt3 and Qt4 sends ucs2 on to core
- Gtk sends ucs4 on to core
- Read and write utf-8 .lyx files.
- font_metrics and painter updated to handle ucs4 chars as input.
- Quite a bit of ugly compability code, conversion string->docstring, etc.
- Have fun...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14661 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-13 22:54:59 +00:00
Bo Peng
a19e4ae888 Remove USE_COMPRESSION and force the use of zlib, by Bo Peng (ben.bob@gmail.com)
* src/lyxlex_pimpl.[hC], src/buffer.C, src/tex2lyx/Makefile.am: remove USE_COMPRESSION
	* configure.ac: check for zlib.h and libz.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13765 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-27 18:14:36 +00:00
Bo Peng
5cf8376ef7 Replace gzstream by boost::iostreams::gzip_(de)compressor: by Bo Peng (ben.bob@gmail.com)
* src/buffer.C, use filtering_ostream
	* src/lyxlex_pimpl.h, .C, use filtering_istreambuf
	* src/Makefile.am,  src/support/Makefile.am, src/tex2lyx/Makefile.am, use BOOST_IOSTREAMS
	* remove src/support/gzstream.h, .C
	* add needed boost files boost/boost/iostreams/device/file_descriptor.hpp,
     device/mapped_file.hpp, detail/system_failure.hpp, 
		 detail/config/windows_posix.hpp


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13706 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-21 06:42:17 +00:00
Angus Leeming
984a123af3 Asger's obviously-correct Win32 changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9556 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-31 15:26:40 +00:00
Angus Leeming
c38c00230c Fix typo. HAVE_COMPRESSION -> USE_COMPRESSION.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9519 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-21 08:39:13 +00:00
Angus Leeming
0de22c86f8 use USE_COMPRESSION to guard code.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9516 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-20 21:34:23 +00:00
Angus Leeming
c9f9ba315c Asger's exchanging of the class and struct keywords.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9502 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-19 15:03:31 +00:00
André Pönitz
7c12de7d3d * lyxlex_pimpl.[Ch]: don't use '__' in identifiers
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8181 a592a061-630c-0410-9148-cb99ea01b6c8
2003-12-02 12:02:39 +00:00
Lars Gullik Bjønnes
44cd0fc9a1 The std::string mammoth path.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7862 a592a061-630c-0410-9148-cb99ea01b6c8
2003-10-06 15:43:21 +00:00
Angus Leeming
0705dae8a3 Finish the task of removing all cruft from the header files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7703 a592a061-630c-0410-9148-cb99ea01b6c8
2003-09-07 21:25:37 +00:00
Angus Leeming
0be0fcfd59 If I ever see another licence blurb again, it'll be too soon...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7598 a592a061-630c-0410-9148-cb99ea01b6c8
2003-08-23 00:17:00 +00:00
Lars Gullik Bjønnes
a16c8a8759 zlib stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7405 a592a061-630c-0410-9148-cb99ea01b6c8
2003-07-27 23:40:08 +00:00
Lars Gullik Bjønnes
7b41119463 lyxlex-1-a with some modifications
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6794 a592a061-630c-0410-9148-cb99ea01b6c8
2003-04-14 12:44:36 +00:00
Lars Gullik Bjønnes
99d1627a47 dont use pragma impementation and interface anymore
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6138 a592a061-630c-0410-9148-cb99ea01b6c8
2003-02-13 16:53:15 +00:00
Lars Gullik Bjønnes
8283e978f8 ws cleanup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3803 a592a061-630c-0410-9148-cb99ea01b6c8
2002-03-21 17:27:08 +00:00
Jean-Marc Lasgouttes
e266fd847f more warnings go to /dev/null
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2831 a592a061-630c-0410-9148-cb99ea01b6c8
2001-10-01 15:31:59 +00:00
Lars Gullik Bjønnes
a0bf0835e5 more funcs to lowerchar, adjust
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2428 a592a061-630c-0410-9148-cb99ea01b6c8
2001-08-06 19:12:46 +00:00
Lars Gullik Bjønnes
0b98ee5f2e inherit privately from noncopyable
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1926 a592a061-630c-0410-9148-cb99ea01b6c8
2001-04-17 14:00:20 +00:00
Angus Leeming
524a23ba3a Compile fixes for DEC cxx, John's maths and keymap patches.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1783 a592a061-630c-0410-9148-cb99ea01b6c8
2001-03-16 12:08:14 +00:00
Lars Gullik Bjønnes
1499443f39 add boost
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1782 a592a061-630c-0410-9148-cb99ea01b6c8
2001-03-16 11:54:34 +00:00
Jean-Marc Lasgouttes
1a3ed565d9 Use lyxlex to parse rgb.txt + small compilation fixes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1206 a592a061-630c-0410-9148-cb99ea01b6c8
2000-11-08 15:19:55 +00:00
Lars Gullik Bjønnes
eeaae9c355 more changes read the ChangeLog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@954 a592a061-630c-0410-9148-cb99ea01b6c8
2000-08-05 05:17:18 +00:00
Lars Gullik Bjønnes
7110b8eda4 small changes read ChangeLog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@941 a592a061-630c-0410-9148-cb99ea01b6c8
2000-07-31 16:39:50 +00:00
Lars Gullik Bjønnes
e5f1824f33 trying to track down a bug in lyxlex with gcc 2.96, new insetmarginal, mini fix to insetfoot and testing the new lyx-cvs mailing list
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@838 a592a061-630c-0410-9148-cb99ea01b6c8
2000-06-26 18:34:31 +00:00
Jürgen Vigna
fa6aa115e7 Various warnings fixed, added preliminary read of old table format and
fixed a bug when removing error-insets with AutoDeleteInsets().


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@736 a592a061-630c-0410-9148-cb99ea01b6c8
2000-05-17 14:43:09 +00:00
Lars Gullik Bjønnes
76938908d7 use more explicit on constructors use the pimpl idom to reduce size with about 500k
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@641 a592a061-630c-0410-9148-cb99ea01b6c8
2000-04-08 17:02:02 +00:00