From: Ulya Trofimovich Date: Fri, 14 Aug 2015 13:29:19 +0000 (+0100) Subject: Some more explicit casts in lexer fill procedure (found with [-Wsign-conversion]). X-Git-Tag: 0.15~122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=286f8990e8a8fccc83defa2324405be97735ee2f;p=re2c Some more explicit casts in lexer fill procedure (found with [-Wsign-conversion]). Lexer tries to maintain certain layout of pointers to buffer. Buffer refilling procedure relies on that layout. --- diff --git a/re2c/src/parse/scanner.cc b/re2c/src/parse/scanner.cc index b7c9e823..7073db73 100644 --- a/re2c/src/parse/scanner.cc +++ b/re2c/src/parse/scanner.cc @@ -332,7 +332,8 @@ void Scanner::fill (uint32_t need) const ptrdiff_t diff = tok - bot; if (diff > 0) { - memmove(bot, tok, top - tok); + const size_t move = static_cast (top - tok); + memmove (bot, tok, move); tok -= diff; ptr -= diff; cur -= diff; @@ -348,12 +349,13 @@ void Scanner::fill (uint32_t need) } if (top - lim < need) { - char *buf = new char[(lim - bot) + need]; + const size_t copy = static_cast (lim - bot); + char * buf = new char[copy + need]; if (!buf) { fatal("Out of memory"); } - memcpy(buf, bot, lim - bot); + memcpy (buf, bot, copy); tok = &buf[tok - bot]; ptr = &buf[ptr - bot]; cur = &buf[cur - bot];