Add first test case for a UTF-8 config file

This commit is contained in:
Thomas Jensen 2023-05-04 21:32:49 +02:00
parent 4cce7ae461
commit d36380268d
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
4 changed files with 90 additions and 6 deletions

View File

@ -208,7 +208,7 @@ static char *locate_config_common(int *error_printed)
} }
#ifdef DISCOVERY_DEBUG #ifdef DISCOVERY_DEBUG
fprintf(stderr, "locate_config_common() - exit -> [%s]\n", result); fprintf(stderr, "locate_config_common() - exit -> [%s]\n", result != NULL ? result : "(null)");
#endif #endif
return result; return result;
} }

View File

@ -166,15 +166,17 @@ static void print_tags(tagstats_t *tagstats, size_t num_tags)
static bxstr_t *escape(const bxstr_t *org, const int pLength) static bxstr_t *escape(bxstr_t *org)
{ {
const ucs4_t char_backslash = to_utf32('\\'); const ucs4_t char_backslash = to_utf32('\\');
const ucs4_t char_quote = to_utf32('"'); const ucs4_t char_quote = to_utf32('"');
uint32_t *temp = (uint32_t *) calloc(2 * org->num_chars + 1, sizeof(uint32_t)); uint32_t *temp = (uint32_t *) calloc(2 * org->num_chars + 1, sizeof(uint32_t));
int orgIdx, resultIdx; size_t orgIdx, resultIdx;
for (orgIdx = 0, resultIdx = 0; orgIdx < pLength; ++orgIdx, ++resultIdx) { for (orgIdx = 0, resultIdx = 0; orgIdx < org->num_chars; ++orgIdx, ++resultIdx) {
if (is_char_at(org->memory, orgIdx, char_backslash) || is_char_at(org->memory, orgIdx, char_quote)) { if ((is_char_at(org->memory, orgIdx, char_backslash) || is_char_at(org->memory, orgIdx, char_quote))
&& bxs_is_visible_char(org, orgIdx))
{
set_char_at(temp, resultIdx++, char_backslash); set_char_at(temp, resultIdx++, char_backslash);
} }
set_char_at(temp, resultIdx, org->memory[orgIdx]); set_char_at(temp, resultIdx, org->memory[orgIdx]);
@ -336,7 +338,7 @@ static void print_design_details(design_t *d)
continue; continue;
} }
for (size_t w = 0; w < d->shape[i].height; ++w) { for (size_t w = 0; w < d->shape[i].height; ++w) {
bxstr_t *escaped_line = escape(d->shape[i].mbcs[w], d->shape[i].width); bxstr_t *escaped_line = escape(d->shape[i].mbcs[w]);
fprintf(opt.outfile, "%-24s%3s%c \"%s\"%c%s", fprintf(opt.outfile, "%-24s%3s%c \"%s\"%c%s",
(first_shape == 1 && w == 0 ? "Defined Shapes:" : ""), (first_shape == 1 && w == 0 ? "Defined Shapes:" : ""),
(w == 0 ? shape_name[i] : ""), (w == 0 ? ':' : ' '), (w == 0 ? shape_name[i] : ""), (w == 0 ? ':' : ' '),

View File

@ -0,0 +1,49 @@
# This config contains UTF-8-encoded elements used correctly, and a simple colored box design.
BOX designA
author "沐宸" # in a value
designer "John Doe"
𝕂𝕖𝕪𝕨𝕠𝕣𝕕 "value" # in a keyword
Mix𝕖𝕕 "value"
sample
┏━ 沐宸 若汐 ━┓
┗━━━━━━━━━━━━━┛
ends
# Monochrome sample (with UTF-8):
# ┏━ 沐宸 若汐 ━┓
# ┃
# ┃
# ┗━━━━━━━━━━━━━┛
shapes {
n (" 沐宸 若汐 ")
nw ("┏")
nnw ("━")
nne ("━")
ne ("┓")
e ("┃")
w ("", "")
se ("┗")
s ("━")
sw ("┛")
}
elastic (
nnw, nne, e, w, s
)
padding {
horiz 1
}
replace "ä" with "ö"
reverse "ö" to "ä"
END designA

View File

@ -0,0 +1,33 @@
:ARGS
-f 175_utf8_happy_design_info.cfg -d designA -l
:INPUT
:OUTPUT-FILTER
:EXPECTED
Complete Design Information for "designA":
------------------------------------------
Alias Names: none
Author: 沐宸
Original Designer: John Doe
Creation Date: (unknown)
Current Revision: (unknown)
Configuration File: 175_utf8_happy_design_info.cfg
Indentation Mode: box (indent box)
Replacement Rules: 1. (glob) "ä" WITH "ö"
Reversion Rules: 1. (glob) "ö" TO "ä"
Minimum Box Dimensions: 15 x 4 (width x height)
Default Padding: left 1, right 1
Default Killblank: yes
Tags: none
Elastic Shapes: NNW, NNE, E, S, W
Defined Shapes: NW: "┏"
NNW: "━"
N: " 沐宸 若汐 "
NNE: "━"
NE: "┓"
E: "┃"
SE: "┗"
S: "━"
SW: "┛"
W: "",
""
:EOF