git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] unicode_width.h: fix the double_width[] table

From
Beat Bolli <dev+git@drbeat.li>
Date
Dec 3, 2016, 10:35 UTC
Message-ID
<1480761320-27967-1-git-send-email-dev+git@drbeat.li>
In-Reply-To
<1480713995-16157-1-git-send-email-dev+git@drbeat.li>

The function bisearch() in utf8.c does a pure binary search in double_width. It does not care about the 17 plane offsets which unicode/uniset/uniset prepends. Leaving the plane offsets in the table may cause wrong results.

Filter out the plane offsets in the update-unicode.sh and regenerate the table.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 unicode_width.h   | 17 -----------------
 update_unicode.sh |  2 +-
 2 files changed, 1 insertion(+), 18 deletions(-)
diff --git a/unicode_width.h b/unicode_width.h
index 73b5fd6..02207be 100644
--- a/unicode_width.h
+++ b/unicode_width.h
@@ -297,23 +297,6 @@ static const struct interval zero_width[] = {
 { 0xE0100, 0xE01EF }
 };
 static const struct interval double_width[] = {
-{ /* plane */ 0x0, 0x3D },
-{ /* plane */ 0x3D, 0x68 },
-{ /* plane */ 0x68, 0x69 },
-{ /* plane */ 0x69, 0x6A },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
 { 0x1100, 0x115F },
 { 0x231A, 0x231B },
 { 0x2329, 0x232A },
diff --git a/update_unicode.sh b/update_unicode.sh
index 3c84270..4c1ec8d 100755
--- a/update_unicode.sh
+++ b/update_unicode.sh
@@ -30,7 +30,7 @@ fi &&
 		  grep -v plane)
 	};
 	static const struct interval double_width[] = {
-		$(uniset/uniset --32 eaw:F,W)
+		$(uniset/uniset --32 eaw:F,W | grep -v plane)
 	};
 	EOF
 )
-- 
2.7.2
Previous: Beat BolliNext: Beat Bolli
Message 3 of 18 in “update-unicode.sh: automatically download newer definition files”
  1. 1/2 update-unicode.sh: automatically download newer definition filesBeat Bolli, Dec 2, 2016
  2. 2/2 unicode: update the tables to Unicode 9.0Beat Bolli, Dec 2, 2016
  3. 3/3 unicode_width.h: fix the double_width[] tableBeat Bolli, Dec 3, 2016
  4. 1/3 update-unicode.sh: automatically download newer definition filesBeat Bolli, Dec 3, 2016
  5. 3/3 unicode_width.h: fix the double_width[] tableBeat Bolli, Dec 3, 2016
  6. 1/3 update-unicode.sh: automatically download newer definition filesBeat Bolli, Dec 3, 2016
  7. 2/3 update-unicode.sh: strip the plane offsets from the double_width[] tableBeat Bolli, Dec 3, 2016
  8. 3/3 unicode_width.h: update the tables to Unicode 9.0Beat Bolli, Dec 3, 2016
  9. Torsten B��gershausenDec 3, 2016
  10. Beat BolliDec 3, 2016
  11. 1/3 update-unicode.sh: automatically download newer definition filesBeat Bolli, Dec 3, 2016
  12. 2/3 update-unicode.sh: strip the plane offsets from the double_width[] tableBeat Bolli, Dec 3, 2016
  13. 3/3 unicode_width.h: update the tables to Unicode 9.0Beat Bolli, Dec 3, 2016
  14. Torsten BögershausenDec 4, 2016
  15. Junio C HamanoDec 5, 2016
  16. Beat BolliDec 7, 2016
  17. jbh, Dec 7, 2016
  18. 2/3 unicode_width.h: update the tables to Unicode 9.0Beat Bolli, Dec 3, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.