]> granicus.if.org Git - re2c/commit
Use custom function instead of 'atoi' to read 32-bit integers.
authorUlya Trofimovich <skvadrik@gmail.com>
Sun, 16 Aug 2015 11:08:21 +0000 (12:08 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Sun, 16 Aug 2015 11:08:21 +0000 (12:08 +0100)
commit819c85733a785084c6e710c47d579260b1c586a1
treed3bc3bd598136afa110d67a666bf89d8f89d82e1
parent06e850501455ed0dd816a86ca7ce0a14163ba870
Use custom function instead of 'atoi' to read 32-bit integers.

Using 'atoi' displeased me for several reasons:
    - 'atoi' doesn't check for overflow
    - by the time 'atoi' was called, re2c has already parsed input
      string and knows that it is well-formed, no need to do it twice
    - atoi returns 'int', custom function allows to refine types and
      avoid casts between signed/unsigned values or [-Wsign-conversion]
      warnings

Added test for new conversion functions.
re2c/Makefile.am
re2c/bootstrap/src/parse/scanner_lex.cc
re2c/src/parse/extop.h
re2c/src/parse/parser.ypp
re2c/src/parse/scanner_lex.re
re2c/src/test/s_to_n32_unsafe/test.cc [new file with mode: 0644]
re2c/src/util/s_to_n32_unsafe.cc [new file with mode: 0644]
re2c/src/util/s_to_n32_unsafe.h [new file with mode: 0644]