#include "support/lassert.h"
#include "support/lstrings.h"
-#include <cstring>
-#include <string>
-
using namespace std;
using namespace lyx::support;
"bp", "cc", "cm", "dd", "em", "ex", "in", "mm", "mu",
"pc", "pt", "sp",
"text%", "col%", "page%", "line%",
- "theight%", "pheight%", "" };
+ "theight%", "pheight%", "baselineskip%", "" };
int const num_units = int(sizeof(unit_name) / sizeof(unit_name[0]) - 1);
N_("ex"), N_("in[[unit of measure]]"), N_("mm"), N_("mu[[unit of measure]]"), N_("pc"),
N_("pt"), N_("sp"), N_("Text Width %"),
N_("Column Width %"), N_("Page Width %"), N_("Line Width %"),
- N_("Text Height %"), N_("Page Height %"), "" };
+ N_("Text Height %"), N_("Page Height %"), N_("Line Distance %"), "" };
Length::UNIT unitFromString(string const & data)
};
-} // namespace anon
+} // namespace
const char * stringFromUnit(int unit)
return true;
}
- string buffer = data;
- int pattern_index = 0;
- char pattern[3];
+ string buffer = data;
// To make isValidLength recognize negative values
// this little hack is needed:
int unit_index = 1; // entries at index 0 are sentinels
// construct "pattern" from "data"
+ string pattern;
while (!isEndOfData(buffer)) {
- if (pattern_index > 2)
+ if (pattern.size() > 2)
return false;
- pattern[pattern_index] = nextToken(buffer, number,
+ char const token = nextToken(buffer, number,
number_index, unit, unit_index);
- if (pattern[pattern_index] == 'E')
+ if (token == 'E')
return false;
- ++pattern_index;
+ pattern += token;
}
- pattern[pattern_index] = '\0';
// only the most basic pattern is accepted here
- if (strcmp(pattern, "nu") != 0)
+ if (pattern != "nu")
return false;
// It _was_ a correct length string.