Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extern
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-11-22 18:26:54 +0300
committermano-wii <germano.costa@ig.com.br>2019-11-22 18:27:34 +0300
commit177dfc6384b926dd19e3b7e98a995ccb4da9167c (patch)
tree865abe9f707bee039a506bfc17cb4cff218bd6c6 /extern
parent1304cee920c5f01fd9f0474ea782db61ac031403 (diff)
Fix T71273: Bad encoding of utf-8 for Text objects
`BLI_strncpy_wchar_from_utf8` internally assumes `wchar_t` is 32 bits which is not the case on windows. The solution is to replace `wchar_t` with `char32_t`. Thanks to @robbott for compatibility on macOS. Differential Revision: https://developer.blender.org/D6198
Diffstat (limited to 'extern')
-rw-r--r--extern/wcwidth/README.blender4
-rw-r--r--extern/wcwidth/wcwidth.c12
-rw-r--r--extern/wcwidth/wcwidth.h18
3 files changed, 21 insertions, 13 deletions
diff --git a/extern/wcwidth/README.blender b/extern/wcwidth/README.blender
index 27c8574d1d7..3b32ddc5bc9 100644
--- a/extern/wcwidth/README.blender
+++ b/extern/wcwidth/README.blender
@@ -2,4 +2,6 @@ Project: WC Width
URL: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
License: ICS
Upstream version: 2007-05-26
-Local modifications: None
+Local modifications:
+* Fix T33192
+ Bad encoding of utf-8 on windows systems.
diff --git a/extern/wcwidth/wcwidth.c b/extern/wcwidth/wcwidth.c
index 8cab81e32cd..8922ffe0842 100644
--- a/extern/wcwidth/wcwidth.c
+++ b/extern/wcwidth/wcwidth.c
@@ -59,8 +59,6 @@
* Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
*/
-#include <wchar.h>
-
#include "wcwidth.h"
struct interval {
@@ -69,7 +67,7 @@ struct interval {
};
/* auxiliary function for binary search in interval table */
-static int bisearch(wchar_t ucs, const struct interval *table, int max) {
+static int bisearch(char32_t ucs, const struct interval *table, int max) {
int min = 0;
int mid;
@@ -121,7 +119,7 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) {
* in ISO 10646.
*/
-int mk_wcwidth(wchar_t ucs)
+int mk_wcwidth(char32_t ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
@@ -206,7 +204,7 @@ int mk_wcwidth(wchar_t ucs)
}
-int mk_wcswidth(const wchar_t *pwcs, size_t n)
+int mk_wcswidth(const char32_t *pwcs, size_t n)
{
int w, width = 0;
@@ -229,7 +227,7 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n)
* the traditional terminal character-width behaviour. It is not
* otherwise recommended for general use.
*/
-int mk_wcwidth_cjk(wchar_t ucs)
+int mk_wcwidth_cjk(char32_t ucs)
{
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
@@ -297,7 +295,7 @@ int mk_wcwidth_cjk(wchar_t ucs)
}
-int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
+int mk_wcswidth_cjk(const char32_t *pwcs, size_t n)
{
int w, width = 0;
diff --git a/extern/wcwidth/wcwidth.h b/extern/wcwidth/wcwidth.h
index 9ae6ec9ef14..d87eaf20695 100644
--- a/extern/wcwidth/wcwidth.h
+++ b/extern/wcwidth/wcwidth.h
@@ -20,11 +20,19 @@
#ifndef __WCWIDTH_H__
#define __WCWIDTH_H__
-#include <wchar.h>
+#ifndef __cplusplus
+# if defined(__APPLE__)
+/* The <uchar.h> standard header is missing on macOS. */
+#include <stddef.h>
+typedef unsigned int char32_t;
+# else
+# include <uchar.h>
+# endif
+#endif
-int mk_wcwidth(wchar_t ucs);
-int mk_wcswidth(const wchar_t *pwcs, size_t n);
-int mk_wcwidth_cjk(wchar_t ucs);
-int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n);
+int mk_wcwidth(char32_t ucs);
+int mk_wcswidth(const char32_t *pwcs, size_t n);
+int mk_wcwidth_cjk(char32_t ucs);
+int mk_wcswidth_cjk(const char32_t *pwcs, size_t n);
#endif