Skip to content

Commit

Permalink
Merge pull request #140 from 9999years/fix-139
Browse files Browse the repository at this point in the history
Fix `iscntrl` on macOS
  • Loading branch information
kristapsdz authored Sep 15, 2024
2 parents a555325 + 5a02866 commit 4d35503
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ rndr_escape(struct lowdown_buf *out, const char *buf, size_t sz)
if (!hbuf_putc(out, ' '))
return 0;
start = i + 1;
} else if (iscntrl((unsigned char)buf[i])) {
} else if ((unsigned char) buf[i] < 0x80 && iscntrl((unsigned char)buf[i])) {
fprintf(stderr, "this is a control character: %x %x\n", (unsigned char)buf[i], buf[i]);
if (!hbuf_put(out, buf + start, i - start))
return 0;
start = i + 1;
Expand Down
2 changes: 1 addition & 1 deletion term.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ rndr_escape(struct term *term, struct lowdown_buf *out,
/* Don't allow control characters through. */

for (i = 0; i < sz; i++)
if (iscntrl((unsigned char)buf[i])) {
if ((unsigned char)buf[i] < 0x80 && iscntrl((unsigned char)buf[i])) {
ret = rndr_mbswidth
(term, buf + start, i - start);
if (ret < 0)
Expand Down
2 changes: 1 addition & 1 deletion tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ rndr_short(struct lowdown_buf *ob, const struct lowdown_buf *b)
} else if (b->data[i] == '\t') {
if (!HBUF_PUTSL(ob, "\\t"))
return 0;
} else if (iscntrl((unsigned char)b->data[i])) {
} else if ((unsigned char)b->data[i] < 0x80 && iscntrl((unsigned char)b->data[i])) {
if (!hbuf_putc(ob, '?'))
return 0;
} else {
Expand Down

0 comments on commit 4d35503

Please sign in to comment.