LCOV - differential code coverage report
Current view: top level - src/backend/regex - regc_pg_locale.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DUB DCB
Current: d36b728949bf4e37ada1cd23e0f2aaa94f609a70 vs 52e118fe2f7e3381bdaa479816a7f72eda2ae517 Lines: 76.1 % 159 121 16 22 54 67 71 137
Current Date: 2026-06-29 16:15:13 +0200 Functions: 100.0 % 15 15 14 1 13
Baseline: lcov-20260630-baseline Branches: 55.6 % 124 69 37 18 33 36
Baseline Date: 2026-06-29 13:01:57 +0200 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 90.5 % 21 19 2 19
(360..) days: 73.9 % 138 102 14 22 35 67
Function coverage date bins:
(30,360] days: 100.0 % 13 13 13
(360..) days: 100.0 % 2 2 1 1
Branch coverage date bins:
(30,360] days: 66.7 % 6 4 2 4
(360..) days: 55.1 % 118 65 35 18 29 36

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * regc_pg_locale.c
                                  4                 :                :  *    ctype functions adapted to work on pg_wchar (a/k/a chr),
                                  5                 :                :  *    and functions to cache the results of wholesale ctype probing.
                                  6                 :                :  *
                                  7                 :                :  * This file is #included by regcomp.c; it's not meant to compile standalone.
                                  8                 :                :  *
                                  9                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                 10                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 11                 :                :  *
                                 12                 :                :  * IDENTIFICATION
                                 13                 :                :  *    src/backend/regex/regc_pg_locale.c
                                 14                 :                :  *
                                 15                 :                :  *-------------------------------------------------------------------------
                                 16                 :                :  */
                                 17                 :                : 
                                 18                 :                : #include "catalog/pg_collation.h"
                                 19                 :                : #include "common/unicode_case.h"
                                 20                 :                : #include "common/unicode_category.h"
                                 21                 :                : #include "utils/pg_locale.h"
                                 22                 :                : #include "utils/pg_locale_c.h"
                                 23                 :                : 
                                 24                 :                : static pg_locale_t pg_regex_locale;
                                 25                 :                : 
                                 26                 :                : 
                                 27                 :                : /*
                                 28                 :                :  * pg_set_regex_collation: set collation for these functions to obey
                                 29                 :                :  *
                                 30                 :                :  * This is called when beginning compilation or execution of a regexp.
                                 31                 :                :  * Since there's no need for reentrancy of regexp operations, it's okay
                                 32                 :                :  * to store the results in static variables.
                                 33                 :                :  */
                                 34                 :                : void
 5560 tgl@sss.pgh.pa.us          35                 :CBC     5782065 : pg_set_regex_collation(Oid collation)
                                 36                 :                : {
  663 jdavis@postgresql.or       37                 :        5782065 :     pg_locale_t locale = 0;
                                 38                 :                : 
 1622 peter@eisentraut.org       39         [ -  + ]:        5782065 :     if (!OidIsValid(collation))
                                 40                 :                :     {
                                 41                 :                :         /*
                                 42                 :                :          * This typically means that the parser could not resolve a conflict
                                 43                 :                :          * of implicit collations, so report it that way.
                                 44                 :                :          */
 1622 peter@eisentraut.org       45         [ #  # ]:UBC           0 :         ereport(ERROR,
                                 46                 :                :                 (errcode(ERRCODE_INDETERMINATE_COLLATION),
                                 47                 :                :                  errmsg("could not determine which collation to use for regular expression"),
                                 48                 :                :                  errhint("Use the COLLATE clause to set the collation explicitly.")));
                                 49                 :                :     }
                                 50                 :                : 
  238 jdavis@postgresql.or       51                 :GNC     5782065 :     locale = pg_newlocale_from_collation(collation);
                                 52                 :                : 
                                 53         [ +  + ]:        5782065 :     if (!locale->deterministic)
                                 54         [ +  - ]:             16 :         ereport(ERROR,
                                 55                 :                :                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                 56                 :                :                  errmsg("nondeterministic collations are not supported for regular expressions")));
                                 57                 :                : 
  663 jdavis@postgresql.or       58                 :CBC     5782049 :     pg_regex_locale = locale;
 5560 tgl@sss.pgh.pa.us          59                 :        5782049 : }
                                 60                 :                : 
                                 61                 :                : /*
                                 62                 :                :  * The following functions overlap with those defined in pg_locale.c. XXX:
                                 63                 :                :  * consider refactor.
                                 64                 :                :  */
                                 65                 :                : 
                                 66                 :                : static int
  259 jdavis@postgresql.or       67                 :GNC      122435 : regc_wc_isdigit(pg_wchar c)
                                 68                 :                : {
  364                            69         [ +  + ]:         122435 :     if (pg_regex_locale->ctype_is_c)
                                 70         [ +  - ]:           2642 :         return (c <= (pg_wchar) 127 &&
                                 71         [ +  + ]:           1321 :                 (pg_char_properties[c] & PG_ISDIGIT));
                                 72                 :                :     else
                                 73                 :         121114 :         return pg_regex_locale->ctype->wc_isdigit(c, pg_regex_locale);
                                 74                 :                : }
                                 75                 :                : 
                                 76                 :                : static int
  259                            77                 :          19094 : regc_wc_isalpha(pg_wchar c)
                                 78                 :                : {
  364                            79         [ +  + ]:          19094 :     if (pg_regex_locale->ctype_is_c)
                                 80         [ +  - ]:           1024 :         return (c <= (pg_wchar) 127 &&
                                 81         [ +  + ]:            512 :                 (pg_char_properties[c] & PG_ISALPHA));
                                 82                 :                :     else
                                 83                 :          18582 :         return pg_regex_locale->ctype->wc_isalpha(c, pg_regex_locale);
                                 84                 :                : }
                                 85                 :                : 
                                 86                 :                : static int
  259                            87                 :          59906 : regc_wc_isalnum(pg_wchar c)
                                 88                 :                : {
  364                            89         [ +  + ]:          59906 :     if (pg_regex_locale->ctype_is_c)
                                 90         [ +  - ]:           1016 :         return (c <= (pg_wchar) 127 &&
                                 91         [ +  + ]:            508 :                 (pg_char_properties[c] & PG_ISALNUM));
                                 92                 :                :     else
                                 93                 :          59398 :         return pg_regex_locale->ctype->wc_isalnum(c, pg_regex_locale);
                                 94                 :                : }
                                 95                 :                : 
                                 96                 :                : static int
  259                            97                 :          23041 : regc_wc_isword(pg_wchar c)
                                 98                 :                : {
                                 99                 :                :     /* We define word characters as alnum class plus underscore */
 1951 tgl@sss.pgh.pa.us         100         [ +  + ]:CBC       23041 :     if (c == CHR('_'))
                                101                 :             15 :         return 1;
  259 jdavis@postgresql.or      102                 :GNC       23026 :     return regc_wc_isalnum(c);
                                103                 :                : }
                                104                 :                : 
                                105                 :                : static int
                                106                 :          26632 : regc_wc_isupper(pg_wchar c)
                                107                 :                : {
  364                           108         [ -  + ]:          26632 :     if (pg_regex_locale->ctype_is_c)
  364 jdavis@postgresql.or      109         [ #  # ]:UNC           0 :         return (c <= (pg_wchar) 127 &&
                                110         [ #  # ]:              0 :                 (pg_char_properties[c] & PG_ISUPPER));
                                111                 :                :     else
  364 jdavis@postgresql.or      112                 :GNC       26632 :         return pg_regex_locale->ctype->wc_isupper(c, pg_regex_locale);
                                113                 :                : }
                                114                 :                : 
                                115                 :                : static int
  259                           116                 :          10243 : regc_wc_islower(pg_wchar c)
                                117                 :                : {
  364                           118         [ -  + ]:          10243 :     if (pg_regex_locale->ctype_is_c)
  364 jdavis@postgresql.or      119         [ #  # ]:UNC           0 :         return (c <= (pg_wchar) 127 &&
                                120         [ #  # ]:              0 :                 (pg_char_properties[c] & PG_ISLOWER));
                                121                 :                :     else
  364 jdavis@postgresql.or      122                 :GNC       10243 :         return pg_regex_locale->ctype->wc_islower(c, pg_regex_locale);
                                123                 :                : }
                                124                 :                : 
                                125                 :                : static int
  259                           126                 :          10243 : regc_wc_isgraph(pg_wchar c)
                                127                 :                : {
  364                           128         [ -  + ]:          10243 :     if (pg_regex_locale->ctype_is_c)
  364 jdavis@postgresql.or      129         [ #  # ]:UNC           0 :         return (c <= (pg_wchar) 127 &&
                                130         [ #  # ]:              0 :                 (pg_char_properties[c] & PG_ISGRAPH));
                                131                 :                :     else
  364 jdavis@postgresql.or      132                 :GNC       10243 :         return pg_regex_locale->ctype->wc_isgraph(c, pg_regex_locale);
                                133                 :                : }
                                134                 :                : 
                                135                 :                : static int
  259                           136                 :          10243 : regc_wc_isprint(pg_wchar c)
                                137                 :                : {
  364                           138         [ -  + ]:          10243 :     if (pg_regex_locale->ctype_is_c)
  364 jdavis@postgresql.or      139         [ #  # ]:UNC           0 :         return (c <= (pg_wchar) 127 &&
                                140         [ #  # ]:              0 :                 (pg_char_properties[c] & PG_ISPRINT));
                                141                 :                :     else
  364 jdavis@postgresql.or      142                 :GNC       10243 :         return pg_regex_locale->ctype->wc_isprint(c, pg_regex_locale);
                                143                 :                : }
                                144                 :                : 
                                145                 :                : static int
  259                           146                 :          26627 : regc_wc_ispunct(pg_wchar c)
                                147                 :                : {
  364                           148         [ -  + ]:          26627 :     if (pg_regex_locale->ctype_is_c)
  364 jdavis@postgresql.or      149         [ #  # ]:UNC           0 :         return (c <= (pg_wchar) 127 &&
                                150         [ #  # ]:              0 :                 (pg_char_properties[c] & PG_ISPUNCT));
                                151                 :                :     else
  364 jdavis@postgresql.or      152                 :GNC       26627 :         return pg_regex_locale->ctype->wc_ispunct(c, pg_regex_locale);
                                153                 :                : }
                                154                 :                : 
                                155                 :                : static int
  259                           156                 :          50488 : regc_wc_isspace(pg_wchar c)
                                157                 :                : {
  364                           158         [ -  + ]:          50488 :     if (pg_regex_locale->ctype_is_c)
  364 jdavis@postgresql.or      159         [ #  # ]:UNC           0 :         return (c <= (pg_wchar) 127 &&
                                160         [ #  # ]:              0 :                 (pg_char_properties[c] & PG_ISSPACE));
                                161                 :                :     else
  364 jdavis@postgresql.or      162                 :GNC       50488 :         return pg_regex_locale->ctype->wc_isspace(c, pg_regex_locale);
                                163                 :                : }
                                164                 :                : 
                                165                 :                : static pg_wchar
  259                           166                 :           5572 : regc_wc_toupper(pg_wchar c)
                                167                 :                : {
  364                           168         [ +  + ]:           5572 :     if (pg_regex_locale->ctype_is_c)
                                169                 :                :     {
                                170         [ +  - ]:            496 :         if (c <= (pg_wchar) 127)
                                171                 :            496 :             return pg_ascii_toupper((unsigned char) c);
  364 jdavis@postgresql.or      172                 :UNC           0 :         return c;
                                173                 :                :     }
                                174                 :                :     else
  364 jdavis@postgresql.or      175                 :GNC        5076 :         return pg_regex_locale->ctype->wc_toupper(c, pg_regex_locale);
                                176                 :                : }
                                177                 :                : 
                                178                 :                : static pg_wchar
  259                           179                 :           5574 : regc_wc_tolower(pg_wchar c)
                                180                 :                : {
  364                           181         [ +  + ]:           5574 :     if (pg_regex_locale->ctype_is_c)
                                182                 :                :     {
                                183         [ +  - ]:            496 :         if (c <= (pg_wchar) 127)
                                184                 :            496 :             return pg_ascii_tolower((unsigned char) c);
  364 jdavis@postgresql.or      185                 :UNC           0 :         return c;
                                186                 :                :     }
                                187                 :                :     else
  364 jdavis@postgresql.or      188                 :GNC        5078 :         return pg_regex_locale->ctype->wc_tolower(c, pg_regex_locale);
                                189                 :                : }
                                190                 :                : 
                                191                 :                : 
                                192                 :                : /*
                                193                 :                :  * These functions cache the results of probing libc's ctype behavior for
                                194                 :                :  * all character codes of interest in a given encoding/collation.  The
                                195                 :                :  * result is provided as a "struct cvec", but notice that the representation
                                196                 :                :  * is a touch different from a cvec created by regc_cvec.c: we allocate the
                                197                 :                :  * chrs[] and ranges[] arrays separately from the struct so that we can
                                198                 :                :  * realloc them larger at need.  This is okay since the cvecs made here
                                199                 :                :  * should never be freed by freecvec().
                                200                 :                :  *
                                201                 :                :  * We use malloc not palloc since we mustn't lose control on out-of-memory;
                                202                 :                :  * the main regex code expects us to return a failure indication instead.
                                203                 :                :  */
                                204                 :                : 
                                205                 :                : typedef int (*regc_wc_probefunc) (pg_wchar c);
                                206                 :                : 
                                207                 :                : typedef struct pg_ctype_cache
                                208                 :                : {
                                209                 :                :     regc_wc_probefunc probefunc;    /* regc_wc_isalpha or a sibling */
                                210                 :                :     pg_locale_t locale;         /* locale this entry is for */
                                211                 :                :     struct cvec cv;             /* cache entry contents */
                                212                 :                :     struct pg_ctype_cache *next;    /* chain link */
                                213                 :                : } pg_ctype_cache;
                                214                 :                : 
                                215                 :                : static pg_ctype_cache *pg_ctype_cache_list = NULL;
                                216                 :                : 
                                217                 :                : /*
                                218                 :                :  * Add a chr or range to pcc->cv; return false if run out of memory
                                219                 :                :  */
                                220                 :                : static bool
 5245 tgl@sss.pgh.pa.us         221                 :CBC        7551 : store_match(pg_ctype_cache *pcc, pg_wchar chr1, int nchrs)
                                222                 :                : {
                                223                 :                :     chr        *newchrs;
                                224                 :                : 
                                225         [ +  + ]:           7551 :     if (nchrs > 1)
                                226                 :                :     {
                                227         [ -  + ]:           2366 :         if (pcc->cv.nranges >= pcc->cv.rangespace)
                                228                 :                :         {
 5245 tgl@sss.pgh.pa.us         229                 :UBC           0 :             pcc->cv.rangespace *= 2;
                                230                 :              0 :             newchrs = (chr *) realloc(pcc->cv.ranges,
                                231                 :              0 :                                       pcc->cv.rangespace * sizeof(chr) * 2);
                                232         [ #  # ]:              0 :             if (newchrs == NULL)
                                233                 :              0 :                 return false;
                                234                 :              0 :             pcc->cv.ranges = newchrs;
                                235                 :                :         }
 5245 tgl@sss.pgh.pa.us         236                 :CBC        2366 :         pcc->cv.ranges[pcc->cv.nranges * 2] = chr1;
                                237                 :           2366 :         pcc->cv.ranges[pcc->cv.nranges * 2 + 1] = chr1 + nchrs - 1;
                                238                 :           2366 :         pcc->cv.nranges++;
                                239                 :                :     }
                                240                 :                :     else
                                241                 :                :     {
                                242         [ -  + ]:           5185 :         assert(nchrs == 1);
                                243         [ +  + ]:           5185 :         if (pcc->cv.nchrs >= pcc->cv.chrspace)
                                244                 :                :         {
                                245                 :             18 :             pcc->cv.chrspace *= 2;
                                246                 :             18 :             newchrs = (chr *) realloc(pcc->cv.chrs,
                                247                 :             18 :                                       pcc->cv.chrspace * sizeof(chr));
                                248         [ -  + ]:             18 :             if (newchrs == NULL)
 5245 tgl@sss.pgh.pa.us         249                 :UBC           0 :                 return false;
 5245 tgl@sss.pgh.pa.us         250                 :CBC          18 :             pcc->cv.chrs = newchrs;
                                251                 :                :         }
                                252                 :           5185 :         pcc->cv.chrs[pcc->cv.nchrs++] = chr1;
                                253                 :                :     }
                                254                 :           7551 :     return true;
                                255                 :                : }
                                256                 :                : 
                                257                 :                : /*
                                258                 :                :  * Given a probe function (e.g., regc_wc_isalpha) get a struct cvec for all
                                259                 :                :  * chrs satisfying the probe function.  The active collation is the one
                                260                 :                :  * previously set by pg_set_regex_collation.  Return NULL if out of memory.
                                261                 :                :  *
                                262                 :                :  * Note that the result must not be freed or modified by caller.
                                263                 :                :  */
                                264                 :                : static struct cvec *
  259 jdavis@postgresql.or      265                 :GNC         524 : regc_ctype_get_cache(regc_wc_probefunc probefunc, int cclasscode)
                                266                 :                : {
                                267                 :                :     pg_ctype_cache *pcc;
                                268                 :                :     pg_wchar    max_chr;
                                269                 :                :     pg_wchar    cur_chr;
                                270                 :                :     int         nmatches;
                                271                 :                :     chr        *newchrs;
                                272                 :                : 
                                273                 :                :     /*
                                274                 :                :      * Do we already have the answer cached?
                                275                 :                :      */
 5245 tgl@sss.pgh.pa.us         276         [ +  + ]:CBC        1195 :     for (pcc = pg_ctype_cache_list; pcc != NULL; pcc = pcc->next)
                                277                 :                :     {
                                278         [ +  + ]:           1015 :         if (pcc->probefunc == probefunc &&
  572 peter@eisentraut.org      279         [ +  + ]:            392 :             pcc->locale == pg_regex_locale)
 5245 tgl@sss.pgh.pa.us         280                 :            344 :             return &pcc->cv;
                                281                 :                :     }
                                282                 :                : 
                                283                 :                :     /*
                                284                 :                :      * Nope, so initialize some workspace ...
                                285                 :                :      */
                                286                 :            180 :     pcc = (pg_ctype_cache *) malloc(sizeof(pg_ctype_cache));
                                287         [ -  + ]:            180 :     if (pcc == NULL)
 5245 tgl@sss.pgh.pa.us         288                 :UBC           0 :         return NULL;
 5245 tgl@sss.pgh.pa.us         289                 :CBC         180 :     pcc->probefunc = probefunc;
  572 peter@eisentraut.org      290                 :            180 :     pcc->locale = pg_regex_locale;
 5245 tgl@sss.pgh.pa.us         291                 :            180 :     pcc->cv.nchrs = 0;
                                292                 :            180 :     pcc->cv.chrspace = 128;
                                293                 :            180 :     pcc->cv.chrs = (chr *) malloc(pcc->cv.chrspace * sizeof(chr));
                                294                 :            180 :     pcc->cv.nranges = 0;
                                295                 :            180 :     pcc->cv.rangespace = 64;
                                296                 :            180 :     pcc->cv.ranges = (chr *) malloc(pcc->cv.rangespace * sizeof(chr) * 2);
                                297   [ +  -  -  + ]:            180 :     if (pcc->cv.chrs == NULL || pcc->cv.ranges == NULL)
 5245 tgl@sss.pgh.pa.us         298                 :UBC           0 :         goto out_of_memory;
 3585 tgl@sss.pgh.pa.us         299                 :CBC         180 :     pcc->cv.cclasscode = cclasscode;
                                300                 :                : 
                                301                 :                :     /*
                                302                 :                :      * Decide how many character codes we ought to look through.  In general
                                303                 :                :      * we don't go past MAX_SIMPLE_CHR; chr codes above that are handled at
                                304                 :                :      * runtime using the "high colormap" mechanism.  However, in C locale
                                305                 :                :      * there's no need to go further than 127, and if we only have a 1-byte
                                306                 :                :      * <ctype.h> API there's no need to go further than that can handle.
                                307                 :                :      *
                                308                 :                :      * If it's not MAX_SIMPLE_CHR that's constraining the search, mark the
                                309                 :                :      * output cvec as not having any locale-dependent behavior, since there
                                310                 :                :      * will be no need to do any run-time locale checks.  (The #if's here
                                311                 :                :      * would always be true for production values of MAX_SIMPLE_CHR, but it's
                                312                 :                :      * useful to allow it to be small for testing purposes.)
                                313                 :                :      */
  364 jdavis@postgresql.or      314         [ +  + ]:GNC         180 :     if (pg_regex_locale->ctype_is_c)
                                315                 :                :     {
                                316                 :                : #if MAX_SIMPLE_CHR >= 127
                                317                 :             18 :         max_chr = (pg_wchar) 127;
                                318                 :             18 :         pcc->cv.cclasscode = -1;
                                319                 :                : #else
                                320                 :                :         max_chr = (pg_wchar) MAX_SIMPLE_CHR;
                                321                 :                : #endif
                                322                 :                :     }
  211                           323         [ +  - ]:            162 :     else if (GetDatabaseEncoding() == PG_UTF8)
                                324                 :                :     {
                                325                 :            162 :         max_chr = (pg_wchar) MAX_SIMPLE_CHR;
                                326                 :                :     }
                                327                 :                :     else
                                328                 :                :     {
                                329                 :                : #if MAX_SIMPLE_CHR >= UCHAR_MAX
  211 jdavis@postgresql.or      330                 :UNC           0 :         max_chr = (pg_wchar) UCHAR_MAX;
                                331                 :              0 :         pcc->cv.cclasscode = -1;
                                332                 :                : #else
                                333                 :                :         max_chr = (pg_wchar) MAX_SIMPLE_CHR;
                                334                 :                : #endif
                                335                 :                :     }
                                336                 :                : 
                                337                 :                :     /*
                                338                 :                :      * And scan 'em ...
                                339                 :                :      */
 5245 tgl@sss.pgh.pa.us         340                 :CBC         180 :     nmatches = 0;               /* number of consecutive matches */
                                341                 :                : 
                                342         [ +  + ]:         334260 :     for (cur_chr = 0; cur_chr <= max_chr; cur_chr++)
                                343                 :                :     {
                                344         [ +  + ]:         334080 :         if ((*probefunc) (cur_chr))
                                345                 :          90054 :             nmatches++;
                                346         [ +  + ]:         244026 :         else if (nmatches > 0)
                                347                 :                :         {
                                348         [ -  + ]:           7536 :             if (!store_match(pcc, cur_chr - nmatches, nmatches))
 5245 tgl@sss.pgh.pa.us         349                 :UBC           0 :                 goto out_of_memory;
 5245 tgl@sss.pgh.pa.us         350                 :CBC        7536 :             nmatches = 0;
                                351                 :                :         }
                                352                 :                :     }
                                353                 :                : 
                                354         [ +  + ]:            180 :     if (nmatches > 0)
                                355         [ -  + ]:             15 :         if (!store_match(pcc, cur_chr - nmatches, nmatches))
 5245 tgl@sss.pgh.pa.us         356                 :UBC           0 :             goto out_of_memory;
                                357                 :                : 
                                358                 :                :     /*
                                359                 :                :      * We might have allocated more memory than needed, if so free it
                                360                 :                :      */
 5245 tgl@sss.pgh.pa.us         361         [ +  + ]:CBC         180 :     if (pcc->cv.nchrs == 0)
                                362                 :                :     {
                                363                 :             73 :         free(pcc->cv.chrs);
                                364                 :             73 :         pcc->cv.chrs = NULL;
                                365                 :             73 :         pcc->cv.chrspace = 0;
                                366                 :                :     }
                                367         [ +  - ]:            107 :     else if (pcc->cv.nchrs < pcc->cv.chrspace)
                                368                 :                :     {
                                369                 :            107 :         newchrs = (chr *) realloc(pcc->cv.chrs,
                                370                 :            107 :                                   pcc->cv.nchrs * sizeof(chr));
                                371         [ -  + ]:            107 :         if (newchrs == NULL)
 5245 tgl@sss.pgh.pa.us         372                 :UBC           0 :             goto out_of_memory;
 5245 tgl@sss.pgh.pa.us         373                 :CBC         107 :         pcc->cv.chrs = newchrs;
                                374                 :            107 :         pcc->cv.chrspace = pcc->cv.nchrs;
                                375                 :                :     }
                                376         [ -  + ]:            180 :     if (pcc->cv.nranges == 0)
                                377                 :                :     {
 5245 tgl@sss.pgh.pa.us         378                 :UBC           0 :         free(pcc->cv.ranges);
                                379                 :              0 :         pcc->cv.ranges = NULL;
                                380                 :              0 :         pcc->cv.rangespace = 0;
                                381                 :                :     }
 5245 tgl@sss.pgh.pa.us         382         [ +  - ]:CBC         180 :     else if (pcc->cv.nranges < pcc->cv.rangespace)
                                383                 :                :     {
                                384                 :            180 :         newchrs = (chr *) realloc(pcc->cv.ranges,
                                385                 :            180 :                                   pcc->cv.nranges * sizeof(chr) * 2);
                                386         [ -  + ]:            180 :         if (newchrs == NULL)
 5245 tgl@sss.pgh.pa.us         387                 :UBC           0 :             goto out_of_memory;
 5245 tgl@sss.pgh.pa.us         388                 :CBC         180 :         pcc->cv.ranges = newchrs;
                                389                 :            180 :         pcc->cv.rangespace = pcc->cv.nranges;
                                390                 :                :     }
                                391                 :                : 
                                392                 :                :     /*
                                393                 :                :      * Success, link it into cache chain
                                394                 :                :      */
                                395                 :            180 :     pcc->next = pg_ctype_cache_list;
                                396                 :            180 :     pg_ctype_cache_list = pcc;
                                397                 :                : 
                                398                 :            180 :     return &pcc->cv;
                                399                 :                : 
                                400                 :                :     /*
                                401                 :                :      * Failure, clean up
                                402                 :                :      */
 5245 tgl@sss.pgh.pa.us         403                 :UBC           0 : out_of_memory:
 1475 peter@eisentraut.org      404                 :              0 :     free(pcc->cv.chrs);
                                405                 :              0 :     free(pcc->cv.ranges);
 5245 tgl@sss.pgh.pa.us         406                 :              0 :     free(pcc);
                                407                 :                : 
                                408                 :              0 :     return NULL;
                                409                 :                : }
                                410                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                411                 :                : /* (content generated from coverage data) */
                                412                 :                : /* ... */
                                413                 :                : /* ... */
                                414                 :                : /* ... */
                                415                 :                : /* ... */
                                416                 :                : /* BEGIN: function "pg_wc_islower" */
                                417                 :                : /* ... */
                                418                 :                : /* ... */
                                419                 :                : /* ... */
                                420                 :                : /* ... */
                                421                 :                : /* ... */
                                422                 :                : /* ... */
                                423                 :                : /* ... */
                                424                 :                : /* ... */
                                425                 :                : /* ... */
                                426                 :                : /* ... */
                                427                 :                : /* ... */
                                428                 :                : /* ... */
                                429                 :                : /* ... */
                                430                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                431                 :                : /* (content generated from coverage data) */
                                432                 :                : /* ... */
                                433                 :                : /* ... */
                                434                 :                : /* ... */
                                435                 :                : /* ... */
                                436                 :                : /* ... */
                                437                 :                : /* ... */
                                438                 :                : /* ... */
                                439                 :                : /* ... */
                                440                 :                : /* ... */
                                441                 :                : /* ... */
                                442                 :                : /* ... */
                                443                 :                : /* BEGIN: function "pg_wc_isgraph" */
                                444                 :                : /* ... */
                                445                 :                : /* ... */
                                446                 :                : /* ... */
                                447                 :                : /* ... */
                                448                 :                : /* ... */
                                449                 :                : /* ... */
                                450                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                451                 :                : /* (content generated from coverage data) */
                                452                 :                : /* ... */
                                453                 :                : /* ... */
                                454                 :                : /* ... */
                                455                 :                : /* ... */
                                456                 :                : /* ... */
                                457                 :                : /* ... */
                                458                 :                : /* ... */
                                459                 :                : /* ... */
                                460                 :                : /* ... */
                                461                 :                : /* ... */
                                462                 :                : /* ... */
                                463                 :                : /* ... */
                                464                 :                : /* ... */
                                465                 :                : /* ... */
                                466                 :                : /* ... */
                                467                 :                : /* ... */
                                468                 :                : /* ... */
                                469                 :                : /* ... */
                                470                 :                : /* BEGIN: function "pg_wc_isprint" */
                                471                 :                : /* (content generated from coverage data) */
                                472                 :                : /* ... */
                                473                 :                : /* ... */
                                474                 :                : /* ... */
                                475                 :                : /* ... */
                                476                 :                : /* ... */
                                477                 :                : /* ... */
                                478                 :                : /* ... */
                                479                 :                : /* ... */
                                480                 :                : /* ... */
                                481                 :                : /* ... */
                                482                 :                : /* ... */
                                483                 :                : /* ... */
                                484                 :                : /* ... */
                                485                 :                : /* ... */
                                486                 :                : /* ... */
                                487                 :                : /* ... */
                                488                 :                : /* ... */
                                489                 :                : /* ... */
                                490                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                491                 :                : /* (content generated from coverage data) */
                                492                 :                : /* ... */
                                493                 :                : /* ... */
                                494                 :                : /* ... */
                                495                 :                : /* ... */
                                496                 :                : /* ... */
                                497                 :                : /* BEGIN: function "pg_wc_ispunct" */
                                498                 :                : /* ... */
                                499                 :                : /* ... */
                                500                 :                : /* ... */
                                501                 :                : /* ... */
                                502                 :                : /* ... */
                                503                 :                : /* ... */
                                504                 :                : /* ... */
                                505                 :                : /* ... */
                                506                 :                : /* ... */
                                507                 :                : /* ... */
                                508                 :                : /* ... */
                                509                 :                : /* ... */
                                510                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                511                 :                : /* (content generated from coverage data) */
                                512                 :                : /* ... */
                                513                 :                : /* ... */
                                514                 :                : /* ... */
                                515                 :                : /* ... */
                                516                 :                : /* ... */
                                517                 :                : /* ... */
                                518                 :                : /* ... */
                                519                 :                : /* ... */
                                520                 :                : /* ... */
                                521                 :                : /* ... */
                                522                 :                : /* ... */
                                523                 :                : /* ... */
                                524                 :                : /* BEGIN: function "pg_wc_isspace" */
                                525                 :                : /* ... */
                                526                 :                : /* ... */
                                527                 :                : /* ... */
                                528                 :                : /* ... */
                                529                 :                : /* ... */
                                530                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                531                 :                : /* (content generated from coverage data) */
                                532                 :                : /* ... */
                                533                 :                : /* ... */
                                534                 :                : /* ... */
                                535                 :                : /* ... */
                                536                 :                : /* ... */
                                537                 :                : /* ... */
                                538                 :                : /* ... */
                                539                 :                : /* ... */
                                540                 :                : /* ... */
                                541                 :                : /* ... */
                                542                 :                : /* ... */
                                543                 :                : /* ... */
                                544                 :                : /* ... */
                                545                 :                : /* ... */
                                546                 :                : /* ... */
                                547                 :                : /* ... */
                                548                 :                : /* ... */
                                549                 :                : /* ... */
                                550                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                551                 :                : /* BEGIN: function "pg_wc_toupper" */
                                552                 :                : /* ... */
                                553                 :                : /* ... */
                                554                 :                : /* ... */
                                555                 :                : /* ... */
                                556                 :                : /* ... */
                                557                 :                : /* ... */
                                558                 :                : /* ... */
                                559                 :                : /* ... */
                                560                 :                : /* ... */
                                561                 :                : /* ... */
                                562                 :                : /* ... */
                                563                 :                : /* ... */
                                564                 :                : /* ... */
                                565                 :                : /* ... */
                                566                 :                : /* ... */
                                567                 :                : /* ... */
                                568                 :                : /* ... */
                                569                 :                : /* ... */
                                570                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                571                 :                : /* (content generated from coverage data) */
                                572                 :                : /* ... */
                                573                 :                : /* ... */
                                574                 :                : /* ... */
                                575                 :                : /* ... */
                                576                 :                : /* ... */
                                577                 :                : /* ... */
                                578                 :                : /* ... */
                                579                 :                : /* ... */
                                580                 :                : /* ... */
                                581                 :                : /* ... */
                                582                 :                : /* ... */
                                583                 :                : /* ... */
                                584                 :                : /* ... */
                                585                 :                : /* BEGIN: function "pg_wc_tolower" */
                                586                 :                : /* ... */
                                587                 :                : /* ... */
                                588                 :                : /* ... */
                                589                 :                : /* ... */
                                590                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                591                 :                : /* (content generated from coverage data) */
                                592                 :                : /* ... */
                                593                 :                : /* ... */
                                594                 :                : /* ... */
                                595                 :                : /* ... */
                                596                 :                : /* ... */
                                597                 :                : /* ... */
                                598                 :                : /* ... */
                                599                 :                : /* ... */
                                600                 :                : /* ... */
                                601                 :                : /* ... */
                                602                 :                : /* ... */
                                603                 :                : /* ... */
                                604                 :                : /* ... */
                                605                 :                : /* ... */
                                606                 :                : /* ... */
                                607                 :                : /* ... */
                                608                 :                : /* ... */
                                609                 :                : /* ... */
                                610                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                611                 :                : /* (content generated from coverage data) */
                                612                 :                : /* ... */
                                613                 :                : /* ... */
                                614                 :                : /* ... */
                                615                 :                : /* ... */
                                616                 :                : /* ... */
                                617                 :                : /* ... */
                                618                 :                : /* ... */
                                619                 :                : /* ... */
                                620                 :                : /* ... */
                                621                 :                : /* ... */
                                622                 :                : /* ... */
                                623                 :                : /* ... */
                                624                 :                : /* ... */
                                625                 :                : /* ... */
                                626                 :                : /* ... */
                                627                 :                : /* ... */
                                628                 :                : /* ... */
                                629                 :                : /* ... */
                                630                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                631                 :                : /* (content generated from coverage data) */
                                632                 :                : /* ... */
                                633                 :                : /* ... */
                                634                 :                : /* ... */
                                635                 :                : /* ... */
                                636                 :                : /* ... */
                                637                 :                : /* ... */
                                638                 :                : /* ... */
                                639                 :                : /* ... */
                                640                 :                : /* ... */
                                641                 :                : /* ... */
                                642                 :                : /* ... */
                                643                 :                : /* ... */
                                644                 :                : /* ... */
                                645                 :                : /* ... */
                                646                 :                : /* ... */
                                647                 :                : /* ... */
                                648                 :                : /* ... */
                                649                 :                : /* ... */
                                650                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                651                 :                : /* (content generated from coverage data) */
                                652                 :                : /* ... */
                                653                 :                : /* ... */
                                654                 :                : /* ... */
                                655                 :                : /* ... */
                                656                 :                : /* ... */
                                657                 :                : /* ... */
                                658                 :                : /* ... */
                                659                 :                : /* ... */
                                660                 :                : /* ... */
                                661                 :                : /* ... */
                                662                 :                : /* ... */
                                663                 :                : /* ... */
                                664                 :                : /* ... */
                                665                 :                : /* ... */
                                666                 :                : /* ... */
                                667                 :                : /* ... */
                                668                 :                : /* ... */
                                669                 :                : /* ... */
                                670                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                671                 :                : /* (content generated from coverage data) */
                                672                 :                : /* ... */
                                673                 :                : /* ... */
                                674                 :                : /* ... */
                                675                 :                : /* ... */
                                676                 :                : /* ... */
                                677                 :                : /* ... */
                                678                 :                : /* ... */
                                679                 :                : /* ... */
                                680                 :                : /* ... */
                                681                 :                : /* ... */
                                682                 :                : /* ... */
                                683                 :                : /* ... */
                                684                 :                : /* ... */
                                685                 :                : /* ... */
                                686                 :                : /* ... */
                                687                 :                : /* ... */
                                688                 :                : /* ... */
                                689                 :                : /* ... */
                                690                 :                : /* /home/coverage/diff-cov-workdir/pg-current/src/backend/regex/regc_pg_locale.c not long enough */
                                691                 :                : /* (content generated from coverage data) */
                                692                 :                : /* BEGIN: function "pg_ctype_get_cache" */
        

Generated by: LCOV version 2.0-1