@@ -107,7 +107,7 @@ char *mapFuncs[][2] = {
107107{"DAYNAME" ,"to_char($1, 'Day')" },
108108{"DAYOFMONTH" ,"cast(extract(day from $1) as integer)" },
109109{"DAYOFWEEK" ,"(cast(extract(dow from $1) as integer) + 1)" },
110- {"DAYOFYEAR" ,"cast(extract(doy from $1) as integer)" },
110+ {"DAYOFYEAR" ,"cast(extract(doy from $1) as integer)" },
111111{"HOUR" ,"cast(extract(hour from $1) as integer)" },
112112{"MINUTE" ,"cast(extract(minute from $1) as integer)" },
113113{"MONTH" ,"cast(extract(month from $1) as integer)" },
@@ -161,7 +161,9 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone)
161161* ptr ;
162162int scnt ,
163163i ;
164+ #if defined(WIN32 )|| defined(HAVE_INT_TIMEZONE )
164165long timediff ;
166+ #endif
165167BOOL withZone = * bZone ;
166168
167169* bZone = FALSE;
@@ -402,7 +404,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
402404else
403405{
404406stmt -> errornumber = STMT_RETURN_NULL_WITHOUT_INDICATOR ;
405- stmt -> errormsg = "StrLen_or_IndPtr was a null pointer and NULL data was retrieved" ;
407+ stmt -> errormsg = "StrLen_or_IndPtr was a null pointer and NULL data was retrieved" ;
406408SC_log_error (func ,"" ,stmt );
407409return SQL_ERROR ;
408410}
@@ -757,7 +759,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
757759if (cbValueMax < 2 * (SDWORD )ucount )
758760result = COPY_RESULT_TRUNCATED ;
759761len = ucount * 2 ;
760- free (str );
762+ free (str );
761763}
762764else
763765{
@@ -1431,7 +1433,8 @@ copy_statement_with_parameters(StatementClass *stmt)
14311433 */
14321434else if (oldchar == '{' )
14331435{
1434- char * begin = & old_statement [opos ],* end ;
1436+ char * begin = & old_statement [opos ];
1437+ const char * end ;
14351438
14361439/* procedure calls */
14371440if (stmt -> statement_type == STMT_TYPE_PROCCALL )
@@ -1463,8 +1466,8 @@ copy_statement_with_parameters(StatementClass *stmt)
14631466proc_no_param = FALSE;
14641467continue ;
14651468}
1466- if (convert_escape (begin ,stmt ,& npos ,& new_stsize ,& end
1467- ) != CONVERT_ESCAPE_OK )
1469+ if (convert_escape (begin ,stmt ,& npos ,& new_stsize ,& end ) !=
1470+ CONVERT_ESCAPE_OK )
14681471{
14691472stmt -> errormsg = "ODBC escape convert error" ;
14701473stmt -> errornumber = STMT_EXEC_ERROR ;
@@ -1604,7 +1607,7 @@ copy_statement_with_parameters(StatementClass *stmt)
16041607buffer += (bind_size * current_row );
16051608else if (ctypelen = ctype_length (stmt -> parameters [param_number ].CType ),ctypelen > 0 )
16061609buffer += current_row * ctypelen ;
1607- else
1610+ else
16081611buffer += current_row * stmt -> parameters [param_number ].buflen ;
16091612}
16101613if (stmt -> parameters [param_number ].used )
@@ -2080,7 +2083,7 @@ mapFunction(const char *func, int param_count)
20802083if (mapFuncs [i ][0 ][0 ]== '%' )
20812084{
20822085if (mapFuncs [i ][0 ][1 ]- '0' == param_count &&
2083- !stricmp (mapFuncs [i ][0 ]+ 2 ,func ))
2086+ !stricmp (mapFuncs [i ][0 ]+ 2 ,func ))
20842087return mapFuncs [i ][1 ];
20852088}
20862089else if (!stricmp (mapFuncs [i ][0 ],func ))
@@ -2098,7 +2101,7 @@ static int processParameters(const ConnectionClass *conn, const char *value, cha
20982101 * inner_convert_escape()
20992102 * work with embedded escapes sequences
21002103 */
2101-
2104+
21022105static
21032106int inner_convert_escape (const ConnectionClass * conn ,const char * value ,
21042107char * result ,UInt4 maxLen ,const char * * input_resume ,
@@ -2111,7 +2114,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
21112114const char * valptr ;
21122115UInt4 vlen ,prtlen ,input_consumed ,param_consumed ,extra_len ;
21132116Int4 param_pos [16 ][2 ];
2114-
2117+
21152118valptr = value ;
21162119if (* valptr == '{' )/* skip the first { */
21172120valptr ++ ;
@@ -2123,7 +2126,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
21232126valptr ++ ;
21242127while ((* valptr != '\0' )&& isspace ((unsignedchar )* valptr ))
21252128valptr ++ ;
2126-
2129+
21272130if (end = my_strchr (conn ,valptr ,'}' ),NULL == end )
21282131{
21292132mylog ("%s couldn't find the ending }\n" ,func );
@@ -2135,7 +2138,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
21352138valnts [vlen ]= '\0' ;
21362139* input_resume = valptr + vlen ;/* resume from the last } */
21372140mylog ("%s: key='%s', val='%s'\n" ,func ,key ,valnts );
2138-
2141+
21392142extra_len = 0 ;
21402143if (isalnum (result [-1 ]))/* Avoid the concatenation of the function name with the previous word. Aceto */
21412144{
@@ -2172,7 +2175,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
21722175{
21732176/* Literal; return the escape part as-is */
21742177strncpy (result ,valnts ,maxLen );
2175- prtlen = vlen ;
2178+ prtlen = vlen ;
21762179}
21772180else if (strcmp (key ,"fn" )== 0 )
21782181{
@@ -2183,7 +2186,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
21832186char * funcEnd = valnts ;
21842187char svchar ;
21852188const char * mapExpr ;
2186-
2189+
21872190params [sizeof (params )- 1 ]= '\0' ;
21882191
21892192while ((* funcEnd != '\0' )&& (* funcEnd != '(' )&&
@@ -2197,7 +2200,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
21972200funcEnd ++ ;
21982201
21992202/*
2200- * We expect left parenthesis here, else return fn body as-is
2203+ * We expect left parenthesis here, else return fn body as-is
22012204 * since it is one of those "function constants".
22022205 */
22032206if (* funcEnd != '(' )
@@ -2213,7 +2216,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
22132216 */
22142217
22152218valptr += (UInt4 )(funcEnd - valnts );
2216- if (subret = processParameters (conn ,valptr ,params ,sizeof (params )- 1 ,& input_consumed ,& param_consumed ,param_pos ),CONVERT_ESCAPE_OK != subret )
2219+ if (subret = processParameters (conn ,valptr ,params ,sizeof (params )- 1 ,& input_consumed ,& param_consumed ,param_pos ),CONVERT_ESCAPE_OK != subret )
22172220return CONVERT_ESCAPE_ERROR ;
22182221
22192222for (param_count = 0 ;;param_count ++ )
@@ -2222,9 +2225,9 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
22222225break ;
22232226}
22242227if (param_count == 1 &&
2225- param_pos [0 ][1 ]< param_pos [0 ][0 ])
2228+ param_pos [0 ][1 ]< param_pos [0 ][0 ])
22262229param_count = 0 ;
2227-
2230+
22282231mapExpr = mapFunction (key ,param_count );
22292232if (mapExpr == NULL )
22302233prtlen = snprintf (result ,maxLen ,"%s%s" ,key ,params );
@@ -2256,7 +2259,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
22562259{
22572260pidx = * mapptr - '0' - 1 ;
22582261if (pidx < 0 ||
2259- param_pos [pidx ][0 ]< 0 )
2262+ param_pos [pidx ][0 ]< 0 )
22602263{
22612264qlog ("%s %dth param not found for the expression %s\n" ,pidx + 1 ,mapExpr );
22622265return CONVERT_ESCAPE_ERROR ;
@@ -2291,7 +2294,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
22912294/* Bogus key, leave untranslated */
22922295return CONVERT_ESCAPE_ERROR ;
22932296}
2294-
2297+
22952298if (count )
22962299* count = prtlen + extra_len ;
22972300if (prtlen < 0 || prtlen >=maxLen )/* buffer overflow */
@@ -2301,12 +2304,12 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
23012304}
23022305return CONVERT_ESCAPE_OK ;
23032306}
2304-
2307+
23052308/*
23062309 * processParameters()
23072310 * Process function parameters and work with embedded escapes sequences.
23082311 */
2309-
2312+
23102313static
23112314int processParameters (const ConnectionClass * conn ,const char * value ,
23122315char * result ,UInt4 maxLen ,UInt4 * input_consumed ,
@@ -2321,7 +2324,7 @@ int processParameters(const ConnectionClass *conn, const char *value,
23212324#ifdef MULTIBYTE
23222325encoded_str encstr ;
23232326#endif /* MULTIBYTE */
2324-
2327+
23252328buf [sizeof (buf )- 1 ]= '\0' ;
23262329innerParenthesis = 0 ;
23272330in_quote = in_dquote = in_escape = leadingSpace = FALSE;
@@ -2400,7 +2403,7 @@ int processParameters(const ConnectionClass *conn, const char *value,
24002403}
24012404innerParenthesis ++ ;
24022405break ;
2403-
2406+
24042407case ')' :
24052408innerParenthesis -- ;
24062409if (0 == innerParenthesis )
@@ -2411,18 +2414,18 @@ int processParameters(const ConnectionClass *conn, const char *value,
24112414param_pos [param_count ][1 ]= -1 ;
24122415}
24132416break ;
2414-
2417+
24152418case '}' :
24162419stop = TRUE;
24172420break ;
2418-
2421+
24192422case '{' :
24202423if (subret = inner_convert_escape (conn ,valptr ,buf ,sizeof (buf )- 1 ,& valptr ,& inner_count ),CONVERT_ESCAPE_OK != subret )
24212424return CONVERT_ESCAPE_ERROR ;
2422-
2425+
24232426if (inner_count + count >=maxLen )
24242427return CONVERT_ESCAPE_OVERFLOW ;
2425- memcpy (& result [count ],buf ,inner_count );
2428+ memcpy (& result [count ],buf ,inner_count );
24262429count += inner_count ;
24272430ipos = (UInt4 ) (valptr - value );
24282431continue ;
@@ -2442,14 +2445,15 @@ int processParameters(const ConnectionClass *conn, const char *value,
24422445* output_count = count ;
24432446return CONVERT_ESCAPE_OK ;
24442447}
2445-
2448+
24462449/*
24472450 * convert_escape()
24482451 * This function returns a pointer to static memory!
24492452 */
2450-
2453+
24512454int
2452- convert_escape (const char * value ,StatementClass * stmt ,int * npos ,int * stsize ,const char * * val_resume )
2455+ convert_escape (const char * value ,StatementClass * stmt ,int * npos ,int * stsize ,
2456+ const char * * val_resume )
24532457{
24542458int ret ,pos = * npos ;
24552459UInt4 count ;