Skip to content

Commit 01af46c

Browse files
Improve the representations of string literals (#93)
1 parent dc59ab4 commit 01af46c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cobj/codegen.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,16 @@ static void joutput_string(const unsigned char *s, int size) {
422422
int c;
423423
int printable = 1;
424424

425-
for (i = 0; i < size; i++) {
426-
if (!isprint(s[i])) {
425+
for (i = 0; i < size;) {
426+
c = s[i];
427+
if ((0x00 <= c && c <= 0x1F) || (c == 0x7F) || (c == 0x80) || (0xf0 <= c)) {
427428
printable = 0;
429+
break;
430+
} else if (i < size - 1 &&
431+
((0x81 <= c && c <= 0x9f) || (0xE0 <= c && c <= 0xEF))) {
432+
i += 2;
433+
} else {
434+
i += 1;
428435
}
429436
}
430437

@@ -437,6 +444,8 @@ static void joutput_string(const unsigned char *s, int size) {
437444
c = s[i];
438445
if (c == '\"' || c == '\\') {
439446
joutput("\\%c", c);
447+
} else if (c == '\n') {
448+
joutput("\\n");
440449
} else {
441450
joutput("%c", c);
442451
}

tests/cobol85/report.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
$skip{OBNC2M} = 1;
5757
#$skip{IX106A} = 1;
5858
$skip{NC127A} = 1;
59+
$skip{NC219A} = 1;
5960
$skip{IC222A} = 1;
6061
$skip{IC223A} = 1;
6162
$skip{IC224A} = 1;

0 commit comments

Comments
 (0)