Skip to content

Commit

Permalink
Merge pull request #60 from thpatch/master
Browse files Browse the repository at this point in the history
Couple bug/format fixes
  • Loading branch information
ManDude authored Sep 5, 2019
2 parents 11cc3e4 + fda9b4e commit 0995ae9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
build
*~
.vs
2 changes: 1 addition & 1 deletion thecl/ecsparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ instr_set_types(

if (new_type != param->type &&
!(param->type == 'z' && (new_type == 'm' || new_type == 'x')) &&
!(param->type == 'S' && new_type == 's')) {
!(param->type == 'S' && (new_type == 's' || new_type == 'U'))) {

char errbuf[256];
snprintf(errbuf, 256, "instr_set_types: in sub %s: wrong argument "
Expand Down
4 changes: 2 additions & 2 deletions thecl/thecl10.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static const id_format_pair_t th12_fmts[] = {
{ 424, "S" },
{ 425, "" },
{ 426, "f" },
{ 427, "SfC" },
{ 427, "SfU" },
{ 428, "SSSx" },
{ 429, "ffff" },
{ 430, "ffffff" },
Expand Down Expand Up @@ -583,7 +583,7 @@ static const id_format_pair_t th12_fmts[] = {
{ 523, "Sff" },
{ 524, "Sf" },
{ 525, "Sff" },
{ 526, "fC" },
{ 526, "fU" },
{ 527, "" },
{ 528, "" },
{ 529, "S" },
Expand Down
13 changes: 12 additions & 1 deletion util/value.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ value_from_data(
case 'S':
READ(S, sizeof(int32_t));
case 'C':
READ(C, sizeof(int32_t));
READ(C, sizeof(uint32_t));
break;
case 'z':
value->val.z = malloc(data_length);
Expand Down Expand Up @@ -196,6 +196,13 @@ value_from_text(
case 'S':
READ(d, value->val.S);
break;
case 'C':
if (sscanf(text, "#%02hhx%02hhx%02hhx%02hhx", &value->val.C[0], &value->val.C[1], &value->val.C[2], &value->val.C[3]) != 4) {
fprintf(stderr, "%s:value_from_text: couldn't parse '%c' from \"%s\"\n", argv0, value->type, text);
return 0;
}
READ(u, value->val.C);
break;
case 'z':
value->val.z = strdup(text);
break;
Expand Down Expand Up @@ -299,6 +306,8 @@ value_to_data(
WRITE(U, sizeof(uint32_t));
case 'S':
WRITE(S, sizeof(int32_t));
case 'C':
WRITE(C, sizeof(uint32_t));
case 'z': {
size_t zlen = strlen(value->val.z);
if (data_length < zlen) {
Expand Down Expand Up @@ -344,6 +353,8 @@ value_size(
return sizeof(uint32_t);
case 'S':
return sizeof(int32_t);
case 'C':
return sizeof(uint32_t);
case 'z':
return strlen(value->val.z);
case 'm':
Expand Down

0 comments on commit 0995ae9

Please sign in to comment.