Fix compilation with clang

This commit is contained in:
Kovid Goyal 2016-12-12 13:36:11 +05:30
parent 0797f159ad
commit a568f73e77
3 changed files with 18 additions and 16 deletions

View File

@ -129,10 +129,17 @@ typedef unsigned int index_type;
return result; \
}
#ifdef __clang__
#define START_ALLOW_CASE_RANGE _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wpedantic\"")
#define END_ALLOW_CASE_RANGE _Pragma("clang diagnostic pop")
#define ALLOW_UNUSED_RESULT _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunused-result\"")
#define END_ALLOW_UNUSED_RESULT _Pragma("clang diagnostic pop")
#else
#define START_ALLOW_CASE_RANGE _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
#define END_ALLOW_CASE_RANGE _Pragma("GCC diagnostic pop")
#define ALLOW_UNUSED_RESULT _Pragma("GCC diagnostic ignored \"-Wunused-result\"")
#define END_ALLOW_UNUSED_RESULT _Pragma("GCC diagnostic pop")
#endif
typedef struct {
PyObject_HEAD

View File

@ -195,7 +195,6 @@ static PyObject*
as_ansi(Line* self) {
#define as_ansi_doc "Return the line's contents with ANSI (SGR) escape codes for formatting"
static Py_UCS4 t[5120] = {0};
if (t == NULL) return PyErr_NoMemory();
index_type num = line_as_ansi(self, t, 5120);
PyObject *ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, t, num);
return ans;

View File

@ -633,11 +633,8 @@ static inline void
_parse_bytes(Screen *screen, uint8_t *buf, Py_ssize_t len, PyObject DUMP_UNUSED *dump_callback) {
uint32_t prev = screen->utf8_state, codepoint = 0;
for (unsigned int i = 0; i < len; i++) {
switch(screen->use_latin1) {
case true:
dispatch_unicode_char(screen, latin1_charset[buf[i]], dump_callback);
break;
default:
if (screen->use_latin1) dispatch_unicode_char(screen, latin1_charset[buf[i]], dump_callback);
else {
switch (decode_utf8(&screen->utf8_state, &codepoint, buf[i])) {
case UTF8_ACCEPT:
dispatch_unicode_char(screen, codepoint, dump_callback);
@ -647,7 +644,6 @@ _parse_bytes(Screen *screen, uint8_t *buf, Py_ssize_t len, PyObject DUMP_UNUSED
if (prev != UTF8_ACCEPT) i--;
break;
}
break;
}
}
FLUSH_DRAW;