From 27657b3b754b50f4648e073b31c3038c64c4d32d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 8 Mar 2010 13:33:47 +0000 Subject: [PATCH] isValidGlueLength(): fix gcc warning and cleanup. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33671 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/VSpace.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/VSpace.cpp b/src/VSpace.cpp index 06799263f4..46f39bfeae 100644 --- a/src/VSpace.cpp +++ b/src/VSpace.cpp @@ -244,27 +244,21 @@ bool isValidGlueLength(string const & data, GlueLength * result) } // end of hack - int pattern_index = 0; - int table_index = 0; - char pattern[22]; // 20 + 1 for pattern[20], + 1 for '\0' - - number_index = 1; - unit_index = 1; // entries at index 0 are sentinels - // construct "pattern" from "data" + size_t const pattern_max_size = 20; + string pattern; while (!isEndOfData(buffer)) { - if (pattern_index > (sizeof(pattern) - 2)) + if (pattern.size() > pattern_max_size) return false; - pattern[pattern_index] = nextToken(buffer); - if (pattern[pattern_index] == 'E') + char const c = nextToken(buffer); + if (c == 'E') return false; - ++pattern_index; + pattern.push_back(c); } - pattern[pattern_index] = '\0'; // search "pattern" in "table" - table_index = 0; - while (strcmp(pattern, table[table_index].pattern)) { + size_t table_index = 0; + while (pattern != table[table_index].pattern) { ++table_index; if (!*table[table_index].pattern) return false; -- 2.39.5