From 8fa7e67619960554ac4189e8bbcde4a2ac130715 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 7 Dec 2014 14:23:36 +0100 Subject: mds-kbdc: compile-layout: add some test cases + file parsing bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/compile-layout.c | 10 +++++----- test-files/mds-kbdc/compile-layout/README | 4 ++++ .../mds-kbdc/compile-layout/invalid/include_two_variants | 2 ++ test-files/mds-kbdc/compile-layout/invalid/three_variants | 6 ++++++ test-files/mds-kbdc/compile-layout/invalid/two_variants | 5 +++++ test-files/mds-kbdc/compile-layout/valid/assumption | 7 +++++++ test-files/mds-kbdc/compile-layout/valid/information | 8 ++++++++ 7 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 test-files/mds-kbdc/compile-layout/README create mode 100644 test-files/mds-kbdc/compile-layout/invalid/include_two_variants create mode 100644 test-files/mds-kbdc/compile-layout/invalid/three_variants create mode 100644 test-files/mds-kbdc/compile-layout/invalid/two_variants create mode 100644 test-files/mds-kbdc/compile-layout/valid/assumption create mode 100644 test-files/mds-kbdc/compile-layout/valid/information diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c index 01587c2..75b134d 100644 --- a/src/mds-kbdc/compile-layout.c +++ b/src/mds-kbdc/compile-layout.c @@ -727,11 +727,11 @@ static char32_t* parse_quoted_string(mds_kbdc_tree_t* restrict tree, const char* #define GROW_BUF \ if (buf_ptr == buf_size) \ fail_if (xxrealloc(old_buf, buf, buf_size ? (buf_size <<= 1) : 16, char)) -#define COPY \ - n = string_length(subrc); \ - if (rc_ptr + n > rc_size) \ - fail_if (xxrealloc(old_rc, rc, rc_ptr + n, char32_t)); \ - memcpy(rc + rc_ptr, subrc, n * sizeof(char32_t)); \ +#define COPY \ + n = string_length(subrc); \ + if (rc_ptr + n > rc_size) \ + fail_if (xxrealloc(old_rc, rc, rc_size = rc_ptr + n, char32_t)); \ + memcpy(rc + rc_ptr, subrc, n * sizeof(char32_t)), rc_ptr += n; \ free(subrc), subrc = NULL #define STORE \ GROW_BUF; \ diff --git a/test-files/mds-kbdc/compile-layout/README b/test-files/mds-kbdc/compile-layout/README new file mode 100644 index 0000000..4e7c43c --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/README @@ -0,0 +1,4 @@ +When testing these files it is important to +`goto stop;` after `compile_layout` been called +in `mds-kbdc.c`. + diff --git a/test-files/mds-kbdc/compile-layout/invalid/include_two_variants b/test-files/mds-kbdc/compile-layout/invalid/include_two_variants new file mode 100644 index 0000000..c5bd467 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/include_two_variants @@ -0,0 +1,2 @@ +include "two-variants" + diff --git a/test-files/mds-kbdc/compile-layout/invalid/three_variants b/test-files/mds-kbdc/compile-layout/invalid/three_variants new file mode 100644 index 0000000..6cef471 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/three_variants @@ -0,0 +1,6 @@ +information + variant "variant1" + variant "variant2" + variant "variant3" +end information + diff --git a/test-files/mds-kbdc/compile-layout/invalid/two_variants b/test-files/mds-kbdc/compile-layout/invalid/two_variants new file mode 100644 index 0000000..a2b54c0 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/two_variants @@ -0,0 +1,5 @@ +information + variant "variant1" + variant "variant2" +end information + diff --git a/test-files/mds-kbdc/compile-layout/valid/assumption b/test-files/mds-kbdc/compile-layout/valid/assumption new file mode 100644 index 0000000..cf38db9 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/assumption @@ -0,0 +1,7 @@ +assumption + have + have " " + have_chars ",.-" + have_range "a" "z" +end assumption + diff --git a/test-files/mds-kbdc/compile-layout/valid/information b/test-files/mds-kbdc/compile-layout/valid/information new file mode 100644 index 0000000..e470ab9 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/information @@ -0,0 +1,8 @@ +information + language "language1" + language "language2" + country "country1" + country "country2" + variant "variant1" +end information + -- cgit v1.2.3-70-g09d2