X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftabular_funcs.C;h=aa6b634dd359ce34d4f4f8371f8fb9fff4ef7e69;hb=2523638092e2024bac408eee98ad2094bc4e4089;hp=a9d907f51384223003badbba950253a65c9114ea;hpb=7ea7dabed1b72cc25dcbdc482ac006f2b61dacfd;p=lyx.git diff --git a/src/tabular_funcs.C b/src/tabular_funcs.C index a9d907f513..aa6b634dd3 100644 --- a/src/tabular_funcs.C +++ b/src/tabular_funcs.C @@ -1,13 +1,13 @@ /* This file is part of - * ====================================================== - * + * ====================================================== + * * LyX, The Document Processor - * + * * Copyright 2000-2001 The LyX Team. * * @author: Jürgen Vigna * - * ====================================================== + * ====================================================== */ #include @@ -18,9 +18,12 @@ #include "tabular_funcs.h" -#include "support/lstrings.h" #include "support/LIstream.h" +#ifndef CXX_GLOBAL_CSTD +using std::strlen; +#endif + using std::istream; using std::getline; @@ -30,12 +33,32 @@ using std::getline; template <> string const write_attribute(string const & name, bool const & b) { - return write_attribute(name, int(b)); + // we write only true attribute values so we remove a bit of the + // file format bloat for tabulars. + if (!b) + return string(); + + return write_attribute(name, tostr(b)); +} + +template <> +string const write_attribute(string const & name, int const & i) +{ + // we write only true attribute values so we remove a bit of the + // file format bloat for tabulars. + if (!i) + return string(); + + return write_attribute(name, tostr(i)); } template <> string const write_attribute(string const & name, LyXLength const & value) { + // we write only the value if we really have one same reson as above. + if (value.zero()) + return string(); + return write_attribute(name, value.asString()); } @@ -149,13 +172,13 @@ bool string2type(string const str, bool & num) bool getTokenValue(string const & str, const char * token, string & ret) { + ret.erase(); size_t token_length = strlen(token); string::size_type pos = str.find(token); if (pos == string::npos || pos + token_length + 1 >= str.length() || str[pos + token_length] != '=') return false; - ret.erase(); pos += token_length + 1; char ch = str[pos]; if ((ch != '"') && (ch != '\'')) { // only read till next space @@ -172,6 +195,7 @@ bool getTokenValue(string const & str, const char * token, string & ret) bool getTokenValue(string const & str, const char * token, int & num) { string tmp; + num = 0; if (!getTokenValue(str, token, tmp)) return false; num = strToInt(tmp); @@ -210,20 +234,26 @@ bool getTokenValue(string const & str, const char * token, bool getTokenValue(string const & str, const char * token, bool & flag) { + // set the flag always to false as this should be the default for bools + // not in the file-format. + flag = false; string tmp; if (!getTokenValue(str, token, tmp)) return false; return string2type(tmp, flag); -} +} bool getTokenValue(string const & str, const char * token, LyXLength & len) { + // set the lenght to be zero() as default as this it should be if not + // in the file format. + len = LyXLength(); string tmp; if (!getTokenValue(str, token, tmp)) return false; return isValidLength(tmp, &len); -} +} void l_getline(istream & is, string & str)