Ticket #26217: patch-isspace-utf8-fix.diff
File patch-isspace-utf8-fix.diff, 2.5 KB (added by stevenschlansker@…, 14 years ago) |
---|
-
src/backend/utils/adt/arrayfuncs.c
old new 50 50 ARRAY_LEVEL_DELIMITED 51 51 } ArrayParseState; 52 52 53 static bool array_isspace(char ch); 53 54 static int ArrayCount(const char *str, int *dim, char typdelim); 54 55 static void ReadArrayStr(char *arrayStr, const char *origStr, 55 56 int nitems, int ndim, int *dim, … … 192 193 * Note: we currently allow whitespace between, but not within, 193 194 * dimension items. 194 195 */ 195 while ( isspace((unsigned char)*p))196 while (array_isspace(*p)) 196 197 p++; 197 198 if (*p != '[') 198 199 break; /* no more dimension items */ … … 265 266 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), 266 267 errmsg("missing assignment operator"))); 267 268 p += strlen(ASSGN); 268 while ( isspace((unsigned char)*p))269 while (array_isspace(*p)) 269 270 p++; 270 271 271 272 /* … … 345 346 } 346 347 347 348 /* 349 * array_isspace() --- a non-locale-dependent isspace() 350 * 351 * We used to use isspace() for parsing array values, but that has 352 * undesirable results: an array value might be silently interpreted 353 * differently depending on the locale setting. Now we just hard-wire 354 * the traditional ASCII definition of isspace(). 355 */ 356 static bool 357 array_isspace(char ch) 358 { 359 if (ch == ' ' || 360 ch == '\t' || 361 ch == '\n' || 362 ch == '\r' || 363 ch == '\v' || 364 ch == '\f') 365 return true; 366 return false; 367 } 368 369 /* 348 370 * ArrayCount 349 371 * Determines the dimensions for an array string. 350 372 * … … 528 550 itemdone = true; 529 551 nelems[nest_level - 1]++; 530 552 } 531 else if (! isspace((unsigned char)*ptr))553 else if (!array_isspace(*ptr)) 532 554 { 533 555 /* 534 556 * Other non-space characters must be after a … … 557 579 /* only whitespace is allowed after the closing brace */ 558 580 while (*ptr) 559 581 { 560 if (! isspace((unsigned char)*ptr++))582 if (!array_isspace(*ptr++)) 561 583 ereport(ERROR, 562 584 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), 563 585 errmsg("malformed array literal: \"%s\"", str))); … … 750 772 indx[ndim - 1]++; 751 773 srcptr++; 752 774 } 753 else if ( isspace((unsigned char)*srcptr))775 else if (array_isspace(*srcptr)) 754 776 { 755 777 /* 756 778 * If leading space, drop it immediately. Else, copy … … 1038 1060 overall_length += 1; 1039 1061 } 1040 1062 else if (ch == '{' || ch == '}' || ch == typdelim || 1041 isspace((unsigned char)ch))1063 array_isspace(ch)) 1042 1064 needquote = true; 1043 1065 } 1044 1066 }