Fix graphics id not going upto UINT32_MAX

This commit is contained in:
Kovid Goyal 2017-09-28 08:20:53 +05:30
parent 204bd97198
commit 7736629bc4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 5 deletions

View File

@ -11,13 +11,13 @@
#include <time.h>
// utils {{{
static unsigned int pow10[10] = {
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
static unsigned long pow10[] = {
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000
};
static inline unsigned int
static inline uint32_t
utoi(uint32_t *buf, unsigned int sz) {
unsigned int ans = 0;
unsigned long ans = 0;
uint32_t *p = buf;
// Ignore leading zeros
while(sz > 0) {
@ -602,7 +602,7 @@ parse_graphics_code(Screen *screen, PyObject UNUSED *dump_callback) {
#undef F
#define READ_UINT \
for (i = pos; i < MIN(screen->parser_buf_pos, pos + 7); i++) { \
for (i = pos; i < MIN(screen->parser_buf_pos, pos + 10); i++) { \
if (screen->parser_buf[i] < '0' || screen->parser_buf[i] > '9') break; \
} \
if (i == pos) { REPORT_ERROR("Malformed graphics control block, expecting an integer value"); return; } \

View File

@ -218,6 +218,9 @@ class TestParser(BaseTest):
s = self.create_screen()
pb = partial(self.parse_bytes_dump, s)
uint32_max = 2**32 - 1
t('i=%d' % uint32_max, id=uint32_max)
t('i=%d' % (uint32_max + 1), id=0)
pb('\033_Gi=12\033\\', c(id=12))
t('a=t,t=d,s=100,z=-9', payload='X', action='t', transmission_type='d', data_width=100, z_index=-9, payload_sz=1)
t('a=t,t=d,s=100,z=9', payload='payload', action='t', transmission_type='d', data_width=100, z_index=9, payload_sz=7)