| 1 |
From: =?utf-8?b?IllhbyBXZWkgKOmtj+mKmOW7tyki?= <[email protected]> |
| 2 |
Date: Tue, 15 Feb 2022 09:56:27 +0800 |
| 3 |
Subject: Use ucd_3_2_0 from python standard library |
| 4 |
|
| 5 |
--- |
| 6 |
makeunicodedata.py | 2 +- |
| 7 |
unicodedata2/unicodedata.c | 15 ++++++++++----- |
| 8 |
2 files changed, 11 insertions(+), 6 deletions(-) |
| 9 |
|
| 10 |
diff --git a/makeunicodedata.py b/makeunicodedata.py |
| 11 |
index 75c899e..9d93a0e 100644 |
| 12 |
--- a/makeunicodedata.py |
| 13 |
+++ b/makeunicodedata.py |
| 14 |
@@ -65,7 +65,7 @@ PUA_16 = range(0x100000, 0x10FFFE) |
| 15 |
NAME_ALIASES_START = 0xF0000 |
| 16 |
NAMED_SEQUENCES_START = 0xF0200 |
| 17 |
|
| 18 |
|
| 19 |
+old_versions = [] |
| 20 |
|
| 21 |
CATEGORY_NAMES = [ "Cn", "Lu", "Ll", "Lt", "Mn", "Mc", "Me", "Nd", |
| 22 |
"Nl", "No", "Zs", "Zl", "Zp", "Cc", "Cf", "Cs", "Co", "Cn", "Lm", |
| 23 |
diff --git a/unicodedata2/unicodedata.c b/unicodedata2/unicodedata.c |
| 24 |
index 2c2ca05..cbff807 100644 |
| 25 |
--- a/unicodedata2/unicodedata.c |
| 26 |
+++ b/unicodedata2/unicodedata.c |
| 27 |
@@ -105,6 +105,7 @@ static PyMemberDef DB_members[] = { |
| 28 |
static PyTypeObject UCD_Type; |
| 29 |
#define UCD_Check(o) (Py_TYPE(o)==&UCD_Type) |
| 30 |
|
| 31 |
+#if 0 |
| 32 |
static PyObject* |
| 33 |
new_previous_version(const char*name, const change_record* (*getrecord)(Py_UCS4), |
| 34 |
Py_UCS4 (*normalization)(Py_UCS4)) |
| 35 |
@@ -118,6 +119,7 @@ new_previous_version(const char*name, const change_record* (*getrecord)(Py_UCS4) |
| 36 |
self->normalization = normalization; |
| 37 |
return (PyObject*)self; |
| 38 |
} |
| 39 |
+#endif |
| 40 |
|
| 41 |
|
| 42 |
/* --- Module API --------------------------------------------------------- */ |
| 43 |
@@ -1368,7 +1370,7 @@ static struct PyModuleDef unicodedatamodule = { |
| 44 |
PyMODINIT_FUNC |
| 45 |
PyInit_unicodedata2(void) |
| 46 |
{ |
| 47 |
|
| 48 |
+ PyObject *m, *u, *v; |
| 49 |
|
| 50 |
Py_SET_TYPE(&UCD_Type, &PyType_Type); |
| 51 |
|
| 52 |
@@ -1380,10 +1382,13 @@ PyInit_unicodedata2(void) |
| 53 |
Py_INCREF(&UCD_Type); |
| 54 |
PyModule_AddObject(m, "UCD", (PyObject*)&UCD_Type); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
+ /* Import ucd_3_2_0 from unicodedata */ |
| 61 |
+ u = PyImport_ImportModule("unicodedata"); |
| 62 |
+ if (u != NULL) { |
| 63 |
+ v = PyObject_GetAttrString(u, "ucd_3_2_0"); |
| 64 |
+ if (v != NULL) |
| 65 |
+ PyModule_AddObject(m, "ucd_3_2_0", v); |
| 66 |
+ } |
| 67 |
|
| 68 |
/* Export C API */ |
| 69 |
// v = PyCapsule_New((void *)&hashAPI, PyUnicodeData_CAPSULE_NAME, NULL); |