This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository e16.

View the commit online.

commit 051a41826104b28b872aba7ec1871a32f6d61d19
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Mon Sep 18 20:24:21 2023 +0200

    text: Fix calculating long multibyte string length (codepoints)
    
    Fixes very long window titles sometimes spilling over into border
    buttons.
    
    Reported by Milan Maljković.
    
    This fix causes slow rendering of very long window titles, this will be
    dealt with shortly.
---
 src/lang.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/lang.c b/src/lang.c
index 2b9f5d27..96701141 100644
--- a/src/lang.c
+++ b/src/lang.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2004-2021 Kim Woelders
+ * Copyright (C) 2004-2023 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -43,6 +43,7 @@
 
 #if HAVE_ICONV
 
+#include <errno.h>
 #include <iconv.h>
 #define BAD_CD ((iconv_t)-1)
 
@@ -229,12 +230,17 @@ EwcStrToWcs(const char *str, int len, wchar_t *wcs, int wcl)
 
    if (!wcs)
      {
-	no = 4096;
-	po = buf;
-	rc = iconv(iconv_cd_str2wcs, &pi, &ni, &po, &no);
-	if (rc == (size_t)(-1) || no == 0)
-	   return -1;
-	wcl = (4096 - no) / sizeof(wchar_t);
+	for (wcl = 0;;)
+	  {
+	     no = sizeof(buf);
+	     po = buf;
+	     rc = iconv(iconv_cd_str2wcs, &pi, &ni, &po, &no);
+	     if (rc == (size_t)(-1) && errno != E2BIG)
+		return -1;
+	     wcl += (sizeof(buf) - no) / sizeof(wchar_t);
+	     if (ni == 0)
+		break;
+	  }
 	return wcl;
      }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to