X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flengthcommon.cpp;h=c4fe515e093275a80996f10d4f6c2f2c55f3bb5d;hb=0430132aa049f2a97280bcbcff69f71d42ed7d98;hp=72f5bbf88faf4274800b11edd344152b9ae79e4b;hpb=25ff2f8e2bd4b8567d8a921e478204759e0e942c;p=lyx.git diff --git a/src/lengthcommon.cpp b/src/lengthcommon.cpp index 72f5bbf88f..c4fe515e09 100644 --- a/src/lengthcommon.cpp +++ b/src/lengthcommon.cpp @@ -19,9 +19,6 @@ #include "support/lassert.h" #include "support/lstrings.h" -#include -#include - using namespace std; using namespace lyx::support; @@ -315,9 +312,7 @@ bool isValidLength(string const & data, Length * result) 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: @@ -345,19 +340,19 @@ bool isValidLength(string const & data, Length * result) 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.