]> Pileus Git - ~andy/sunrise/blob - dev-python/pyicu/files/parseArgsConstChar.patch
net-mail/notmuch: bump and add vim support. Thanks to floppym, hwoarang
[~andy/sunrise] / dev-python / pyicu / files / parseArgsConstChar.patch
1 Treat string literals as const char* instead of char*.
2
3 PyICU had a lot of implicit conversions from string constant to char*,
4 which could cause huge lists of compiler messages like this:
5
6 warning: deprecated conversion from string constant to ‘char*’
7
8 This patch attempts to fix as many of these as possible inside the
9 PyICU codebase. Some cannot be fixed, because the cooresponding
10 problem is in Python headers. This is known as Python issue #6952.
11
12 2011-02-11 Martin von Gagern
13
14 References:
15 http://bugs.gentoo.org/237888
16 http://bugs.python.org/issue6952
17
18 Index: PyICU-1.1/common.cpp
19 ===================================================================
20 --- PyICU-1.1.orig/common.cpp
21 +++ PyICU-1.1/common.cpp
22 @@ -178,7 +178,8 @@ EXPORT PyObject *PyUnicode_FromUnicodeSt
23  }
24  
25  EXPORT UnicodeString &PyString_AsUnicodeString(PyObject *object,
26 -                                               char *encoding, char *mode,
27 +                                               const char *encoding,
28 +                                               const char *mode,
29                                                 UnicodeString &string)
30  {
31      UErrorCode status = U_ZERO_ERROR;
32 @@ -206,7 +207,7 @@ EXPORT UnicodeString &PyString_AsUnicode
33  
34      if (U_FAILURE(status))
35      {
36 -        char *reasonName;
37 +        const char *reasonName;
38  
39          switch (stop.reason) {
40            case UCNV_UNASSIGNED:
41 @@ -241,7 +242,8 @@ EXPORT UnicodeString &PyString_AsUnicode
42  }
43  
44  EXPORT UnicodeString &PyObject_AsUnicodeString(PyObject *object,
45 -                                               char *encoding, char *mode,
46 +                                               const char *encoding,
47 +                                               const char *mode,
48                                                 UnicodeString &string)
49  {
50      if (PyUnicode_Check(object))
51 @@ -672,7 +674,7 @@ static UBool *toUBoolArray(PyObject *arg
52  
53  #ifdef _MSC_VER
54  
55 -int __parseArgs(PyObject *args, char *types, ...)
56 +int __parseArgs(PyObject *args, const char *types, ...)
57  {
58      int count = ((PyTupleObject *)(args))->ob_size;
59      va_list list;
60 @@ -682,7 +684,7 @@ int __parseArgs(PyObject *args, char *ty
61      return _parseArgs(((PyTupleObject *)(args))->ob_item, count, types, list);
62  }
63  
64 -int __parseArg(PyObject *arg, char *types, ...)
65 +int __parseArg(PyObject *arg, const char *types, ...)
66  {
67      va_list list;
68  
69 @@ -692,14 +694,14 @@ int __parseArg(PyObject *arg, char *type
70  }
71  
72  
73 -int _parseArgs(PyObject **args, int count, char *types, va_list list)
74 +int _parseArgs(PyObject **args, int count, const char *types, va_list list)
75  {
76      if (count != strlen(types))
77          return -1;
78  
79  #else
80  
81 -int _parseArgs(PyObject **args, int count, char *types, ...)
82 +int _parseArgs(PyObject **args, int count, const char *types, ...)
83  {
84      va_list list;
85  
86 @@ -1121,7 +1123,7 @@ int _parseArgs(PyObject **args, int coun
87      return 0;
88  }
89  
90 -PyObject *PyErr_SetArgsError(PyObject *self, char *name, PyObject *args)
91 +PyObject *PyErr_SetArgsError(PyObject *self, const char *name, PyObject *args)
92  {
93      if (!PyErr_Occurred())
94      {
95 @@ -1135,7 +1137,7 @@ PyObject *PyErr_SetArgsError(PyObject *s
96      return NULL;
97  }
98  
99 -PyObject *PyErr_SetArgsError(PyTypeObject *type, char *name, PyObject *args)
100 +PyObject *PyErr_SetArgsError(PyTypeObject *type, const char *name, PyObject *args)
101  {
102      if (!PyErr_Occurred())
103      {
104 Index: PyICU-1.1/common.h
105 ===================================================================
106 --- PyICU-1.1.orig/common.h
107 +++ PyICU-1.1/common.h
108 @@ -191,10 +191,12 @@ EXPORT PyObject *PyUnicode_FromUnicodeSt
109  EXPORT PyObject *PyUnicode_FromUnicodeString(const UChar *chars, int size);
110  
111  EXPORT UnicodeString &PyString_AsUnicodeString(PyObject *object,
112 -                                               char *encoding, char *mode,
113 +                                               const char *encoding,
114 +                                               const char *mode,
115                                                 UnicodeString &string);
116  EXPORT UnicodeString &PyObject_AsUnicodeString(PyObject *object,
117 -                                               char *encoding, char *mode,
118 +                                               const char *encoding,
119 +                                               const char *mode,
120                                                 UnicodeString &string);
121  EXPORT UnicodeString &PyObject_AsUnicodeString(PyObject *object,
122                                                 UnicodeString &string);
123 @@ -208,10 +210,10 @@ int abstract_init(PyObject *self, PyObje
124  #define parseArgs __parseArgs
125  #define parseArg __parseArg
126  
127 -int __parseArgs(PyObject *args, char *types, ...);
128 -int __parseArg(PyObject *arg, char *types, ...);
129 +int __parseArgs(PyObject *args, const char *types, ...);
130 +int __parseArg(PyObject *arg, const char *types, ...);
131  
132 -int _parseArgs(PyObject **args, int count, char *types, va_list list);
133 +int _parseArgs(PyObject **args, int count, const char *types, va_list list);
134  
135  #else
136  
137 @@ -222,7 +224,7 @@ int _parseArgs(PyObject **args, int coun
138  #define parseArg(arg, types, rest...) \
139      _parseArgs(&(arg), 1, types, ##rest)
140  
141 -int _parseArgs(PyObject **args, int count, char *types, ...);
142 +int _parseArgs(PyObject **args, int count, const char *types, ...);
143  
144  #endif
145  
146 @@ -240,7 +242,7 @@ Formattable *toFormattableArray(PyObject
147  UObject **pl2cpa(PyObject *arg, int *len, classid id, PyTypeObject *type);
148  PyObject *cpa2pl(UObject **array, int len, PyObject *(*wrap)(UObject *, int));
149  
150 -PyObject *PyErr_SetArgsError(PyObject *self, char *name, PyObject *args);
151 -PyObject *PyErr_SetArgsError(PyTypeObject *type, char *name, PyObject *args);
152 +PyObject *PyErr_SetArgsError(PyObject *self, const char *name, PyObject *args);
153 +PyObject *PyErr_SetArgsError(PyTypeObject *type, const char *name, PyObject *args);
154  
155  #endif /* _common_h */
156 Index: PyICU-1.1/errors.cpp
157 ===================================================================
158 --- PyICU-1.1.orig/errors.cpp
159 +++ PyICU-1.1/errors.cpp
160 @@ -26,7 +26,7 @@
161  
162  #include "errors.h"
163  
164 -static void _setMsg(PyObject *messages, UErrorCode code, char *msg)
165 +static void _setMsg(PyObject *messages, UErrorCode code, const char *msg)
166  {
167      PyObject *pycode = PyInt_FromLong((long) code);
168      PyObject *pymsg = PyString_FromString(msg);
169 Index: PyICU-1.1/bases.cpp
170 ===================================================================
171 --- PyICU-1.1.orig/bases.cpp
172 +++ PyICU-1.1/bases.cpp
173 @@ -532,7 +532,7 @@ static int t_unicodestring_init(t_unicod
174  {
175      UnicodeString *u, _u;
176      PyObject *obj;
177 -    char *encoding, *mode;
178 +    const char *encoding, *mode;
179      int32_t start, length;
180      int i;
181