Re: pgsql: Move strtoint() to common
От | Alvaro Herrera |
---|---|
Тема | Re: pgsql: Move strtoint() to common |
Дата | |
Msg-id | 20180315191524.ga2fdjbnuz4y43fg@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: pgsql: Move strtoint() to common (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: pgsql: Move strtoint() to common
(Alvaro Herrera <alvherre@alvh.no-ip.org>)
Re: pgsql: Move strtoint() to common (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-committers |
Tom Lane wrote: > Alvaro Herrera <alvherre@alvh.no-ip.org> writes: > > Michael Paquier wrote: > >> Attached is a patch which fixes the compilation failure on Windows for > >> me. That should put the buildfarm back to green. > > > Pushed, thanks -- let's see how that goes. > > build now works, ecpg tests fail. I stared at the code for a while, didn't notice anything amiss. I'm mystified. Peter? I think the guilty bit is the one below, but 1) I don't see how the new code fails to work exactly like the old code 2) I don't understand why it would only fail on Windows. I thought it may be a port difference in strtol, but I don't see what it'd be. Also: it seems strtol per spec returns LONG_MAX/LONG_MIN on overflow/underflow, and our strtoint doesn't do (an equivalent of) that. But I don't see how that would affect the failing ecpg test. diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index ba1798c77e..405dee73b0 100644 *** a/src/interfaces/ecpg/preproc/pgc.l --- b/src/interfaces/ecpg/preproc/pgc.l *************** *** 723,744 **** cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ return Op; } <SQL>{param} { base_yylval.ival = atol(yytext+1); return PARAM; } <C,SQL>{integer} { ! long val; char* endptr; errno = 0; ! val = strtol((char *)yytext, &endptr,10); ! if (*endptr != '\0' || errno == ERANGE || ! /* check for overflow of int */ ! val != (int) val) { errno = 0; base_yylval.str = mm_strdup(yytext); return FCONST; } base_yylval.ival = val; return ICONST; --- 725,744 ---- return Op; } <SQL>{param} { base_yylval.ival = atol(yytext+1); return PARAM; } <C,SQL>{integer} { ! int val; char* endptr; errno = 0; ! val = strtoint(yytext, &endptr, 10); ! if (*endptr != '\0' || errno == ERANGE) { errno = 0; base_yylval.str = mm_strdup(yytext); return FCONST; } base_yylval.ival = val; return ICONST; -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-committers по дате отправления:
Предыдущее
От: Robert HaasДата:
Сообщение: pgsql: Split create_grouping_paths into degenerate and non-degeneratec