changeset 856:c4e75447a4df

sexpr: dump only 7-bit chars as #\foo isprint(3) on Linux can return true for codepoints >= 256 (not necessarily wrong), which don't interact well with the %c printf format. So, at least for now, let's force any character >= 128 to get printed in hex (#\uXXXX). Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Tue, 04 Oct 2022 22:14:36 -0400
parents 49c810f9f92d
children 2c1345a06ba1
files sexpr_dump.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sexpr_dump.c	Mon Sep 05 09:38:03 2022 -0400
+++ b/sexpr_dump.c	Tue Oct 04 22:14:36 2022 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2015-2018,2022 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -127,7 +127,7 @@
 				return STATIC_STR("#\\nul");
 			else if (lv->i == ' ')
 				return STATIC_STR("#\\space");
-			else if (isprint(lv->i))
+			else if ((lv->i < 128) && isprint(lv->i))
 				return str_printf("#\\%c", (char) lv->i);
 			else
 				return str_printf("#\\u%04"PRIX64, lv->i);