@@ -56,7 +56,7 @@ static const int NumKeywords = lengthof(psqlplus_keywords);
5656
5757static const PsqlScanKeyword *PsqlplusKeywordLookup (const char *text);
5858static int process_integer_literal (const char *token, YYSTYPE *lval);
59- static char *psqlplus_downcase_identifier (const char *str, int len, int encoding );
59+ static char *psqlplus_downcase_identifier (const char *str, int len);
6060static void startlit (yyscan_t yyscanner);
6161static void addlitchar (unsigned char ychar, yyscan_t yyscanner);
6262static void addlit (char *ytext, int yleng, yyscan_t yyscanner);
@@ -358,8 +358,7 @@ xlinside [^ ]+
358358 return keyword->value ;
359359 }
360360
361- ident = psqlplus_downcase_identifier (yytext, yyleng,
362- cur_state->encoding );
361+ ident = psqlplus_downcase_identifier (yytext, yyleng);
363362 yylval->str = ident;
364363 cur_state->token_count ++;
365364 return IDENT;
@@ -455,42 +454,18 @@ psqlplus_scanner_finish(yyscan_t yyscanner)
455454 * Do downcasing and returns a palloc'd string.
456455 */
457456static char *
458- psqlplus_downcase_identifier (const char *str, int len, int encoding )
457+ psqlplus_downcase_identifier (const char *str, int len)
459458{
460459 char *result;
461- int i = 0 ;
462- int out = 0 ;
463- bool enc_is_single_byte = (pg_encoding_max_length (encoding) == 1 );
460+ int i;
464461
465462 result = (char *) pg_malloc (len + 1 );
466-
467- while (i < len)
463+ for (i = 0 ; i < len; i++)
468464 {
469- unsigned char ch = (unsigned char ) str[i];
470-
471- if (!enc_is_single_byte && IS_HIGHBIT_SET (ch))
472- {
473- int mblen = pg_encoding_mblen (encoding, str + i);
474-
475- if (mblen <= 0 || i + mblen > len)
476- mblen = 1 ;
477- memcpy (result + out, str + i, mblen);
478- out += mblen;
479- i += mblen;
480- }
481- else
482- {
483- if (ch >= ' A' && ch <= ' Z' )
484- ch += ' a' - ' A' ;
485- else if (enc_is_single_byte && IS_HIGHBIT_SET (ch) && isupper (ch))
486- ch = tolower (ch);
487-
488- result[out++] = (char ) ch;
489- i++;
490- }
465+ result[i] = (char ) pg_tolower ((unsigned char ) str[i]);
491466 }
492467
493- result[out ] = ' \0 ' ;
468+ result[i ] = ' \0 ' ;
494469
495470 return result;
496471}
0 commit comments