]> git.lyx.org Git - lyx.git/blobdiff - src/tabular_funcs.C
fix typo that put too many include paths for most people
[lyx.git] / src / tabular_funcs.C
index 7601683be53fe2913f10a6ac7edffb84f79c5a61..dd1a2a01c5696dc07158c1b5beb6c860dea684f7 100644 (file)
@@ -1,13 +1,13 @@
 /* This file is part of
- * ====================================================== 
- * 
+ * ======================================================
+ *
  *           LyX, The Document Processor
- *      
+ *
  *           Copyright 2000-2001 The LyX Team.
  *
  *           @author: Jürgen Vigna
  *
- * ====================================================== 
+ * ======================================================
  */
 
 #include <config.h>
@@ -34,8 +34,19 @@ string const write_attribute(string const & name, bool const & b)
        // file format bloat for tabulars.
        if (!b)
                return string();
-       
-       return write_attribute(name, int(b));
+
+       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 <>
@@ -44,7 +55,7 @@ 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());
 }
 
@@ -158,13 +169,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
@@ -181,6 +192,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);
@@ -226,7 +238,7 @@ bool getTokenValue(string const & str, const char * token, bool & flag)
        if (!getTokenValue(str, token, tmp))
                return false;
        return string2type(tmp, flag);
-}    
+}
 
 
 bool getTokenValue(string const & str, const char * token, LyXLength & len)
@@ -238,7 +250,7 @@ bool getTokenValue(string const & str, const char * token, LyXLength & len)
        if (!getTokenValue(str, token, tmp))
                return false;
        return isValidLength(tmp, &len);
-}    
+}
 
 
 void l_getline(istream & is, string & str)