Skip to content

Commit 057519f

Browse files
committed
thecl10: elide sigils for type 'H'
1 parent 1d2120f commit 057519f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

thecl/ecsparse.y

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,24 @@ instr_set_types(
15081508
else
15091509
new_type = *format;
15101510

1511+
// automatically add sigils to S and f for format H
1512+
if (new_type == 'H' && (param->type == 'S' || param->type == 'f')) {
1513+
value_t new_value;
1514+
new_value.type = 'm';
1515+
new_value.val.m.length = sizeof(thecl_sub_param_t);
1516+
new_value.val.m.data = malloc(sizeof(thecl_sub_param_t));
1517+
thecl_sub_param_t* D = (thecl_sub_param_t*)new_value.val.m.data;
1518+
D->zero = 0;
1519+
D->from = D->to = param->type == 'f' ? 'f' : 'i';
1520+
if (param->type == 'f') {
1521+
D->val.f = param->value.val.f;
1522+
} else {
1523+
D->val.S = param->value.val.S;
1524+
}
1525+
param->type = new_type;
1526+
param->value = new_value;
1527+
}
1528+
15111529
if (new_type != param->type &&
15121530
!(param->type == 'D' && new_type == 'H') &&
15131531
!(param->type == 'z' && (new_type == 'm' || new_type == 'x' || new_type == 'N' || new_type == 'n')) &&

thecl/thecl10.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,19 +1623,19 @@ th10_stringify_param(
16231623

16241624
if (D->from == 'f' && D->to == 'f') {
16251625
new_value.val.f = D->val.f;
1626-
sprintf(temp, "_ff");
1626+
sprintf(temp, "_ff ");
16271627
new_value.type = 'f';
16281628
} else if (D->from == 'i' && D->to == 'f') {
16291629
new_value.val.f = D->val.f;
1630-
sprintf(temp, "_fS");
1630+
sprintf(temp, "_fS ");
16311631
new_value.type = 'S';
16321632
} else if (D->from == 'f' && D->to == 'i') {
16331633
new_value.val.S = D->val.S;
1634-
sprintf(temp, "_Sf");
1634+
sprintf(temp, "_Sf ");
16351635
new_value.type = 'f';
16361636
} else if (D->from == 'i' && D->to == 'i') {
16371637
new_value.val.S = D->val.S;
1638-
sprintf(temp, "_SS");
1638+
sprintf(temp, "_SS ");
16391639
new_value.type = 'S';
16401640
} else {
16411641
fprintf(stderr, "%s: bad ECL file - invalid types in 'D' param\n", argv0);
@@ -1645,8 +1645,9 @@ th10_stringify_param(
16451645
thecl_param_t temp_param = *param;
16461646
temp_param.type = new_value.type;
16471647
temp_param.value = new_value;
1648-
strcat(temp, " ");
16491648
char* str_temp = th10_stringify_param(version, sub, node, 0, &temp_param, removed, 0);
1649+
if (param->type == 'H') /* no sigil for H */
1650+
return str_temp;
16501651
strcat(temp, str_temp);
16511652
free(str_temp);
16521653

0 commit comments

Comments
 (0)