PostgreSQL Source Code  git master
like.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "catalog/pg_collation.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "utils/fmgrprotos.h"
#include "utils/pg_locale.h"
#include "varatt.h"
#include "like_match.c"
Include dependency graph for like.c:

Go to the source code of this file.

Macros

#define LIKE_TRUE   1
 
#define LIKE_FALSE   0
 
#define LIKE_ABORT   (-1)
 
#define NextByte(p, plen)   ((p)++, (plen)--)
 
#define CHAREQ(p1, p2)   wchareq((p1), (p2))
 
#define NextChar(p, plen)    do { int __l = pg_mblen(p); (p) +=__l; (plen) -=__l; } while (0)
 
#define CopyAdvChar(dst, src, srclen)
 
#define MatchText   MB_MatchText
 
#define do_like_escape   MB_do_like_escape
 
#define CHAREQ(p1, p2)   (*(p1) == *(p2))
 
#define NextChar(p, plen)   NextByte((p), (plen))
 
#define CopyAdvChar(dst, src, srclen)   (*(dst)++ = *(src)++, (srclen)--)
 
#define MatchText   SB_MatchText
 
#define do_like_escape   SB_do_like_escape
 
#define MATCH_LOWER(t)   SB_lower_char((unsigned char) (t), locale, locale_is_c)
 
#define NextChar(p, plen)   NextByte((p), (plen))
 
#define MatchText   SB_IMatchText
 
#define NextChar(p, plen)    do { (p)++; (plen)--; } while ((plen) > 0 && (*(p) & 0xC0) == 0x80 )
 
#define MatchText   UTF8_MatchText
 

Functions

static int SB_MatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static textSB_do_like_escape (text *pat, text *esc)
 
static int MB_MatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static textMB_do_like_escape (text *pat, text *esc)
 
static int UTF8_MatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static int SB_IMatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static int GenericMatchText (const char *s, int slen, const char *p, int plen, Oid collation)
 
static int Generic_Text_IC_like (text *str, text *pat, Oid collation)
 
static int wchareq (const char *p1, const char *p2)
 
static char SB_lower_char (unsigned char c, pg_locale_t locale, bool locale_is_c)
 
Datum namelike (PG_FUNCTION_ARGS)
 
Datum namenlike (PG_FUNCTION_ARGS)
 
Datum textlike (PG_FUNCTION_ARGS)
 
Datum textnlike (PG_FUNCTION_ARGS)
 
Datum bytealike (PG_FUNCTION_ARGS)
 
Datum byteanlike (PG_FUNCTION_ARGS)
 
Datum nameiclike (PG_FUNCTION_ARGS)
 
Datum nameicnlike (PG_FUNCTION_ARGS)
 
Datum texticlike (PG_FUNCTION_ARGS)
 
Datum texticnlike (PG_FUNCTION_ARGS)
 
Datum like_escape (PG_FUNCTION_ARGS)
 
Datum like_escape_bytea (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ CHAREQ [1/2]

#define CHAREQ (   p1,
  p2 
)    wchareq((p1), (p2))

Definition at line 124 of file like.c.

◆ CHAREQ [2/2]

#define CHAREQ (   p1,
  p2 
)    (*(p1) == *(p2))

Definition at line 124 of file like.c.

◆ CopyAdvChar [1/2]

#define CopyAdvChar (   dst,
  src,
  srclen 
)
Value:
do { int __l = pg_mblen(src); \
(srclen) -= __l; \
while (__l-- > 0) \
*(dst)++ = *(src)++; \
} while (0)
int pg_mblen(const char *mbstr)
Definition: mbutils.c:1023

Definition at line 126 of file like.c.

◆ CopyAdvChar [2/2]

#define CopyAdvChar (   dst,
  src,
  srclen 
)    (*(dst)++ = *(src)++, (srclen)--)

Definition at line 126 of file like.c.

◆ do_like_escape [1/2]

#define do_like_escape   MB_do_like_escape

Definition at line 129 of file like.c.

◆ do_like_escape [2/2]

#define do_like_escape   SB_do_like_escape

Definition at line 129 of file like.c.

◆ LIKE_ABORT

#define LIKE_ABORT   (-1)

Definition at line 32 of file like.c.

◆ LIKE_FALSE

#define LIKE_FALSE   0

Definition at line 31 of file like.c.

◆ LIKE_TRUE

#define LIKE_TRUE   1

Definition at line 30 of file like.c.

◆ MATCH_LOWER

#define MATCH_LOWER (   t)    SB_lower_char((unsigned char) (t), locale, locale_is_c)

Definition at line 134 of file like.c.

◆ MatchText [1/4]

#define MatchText   MB_MatchText

Definition at line 144 of file like.c.

◆ MatchText [2/4]

#define MatchText   SB_MatchText

Definition at line 144 of file like.c.

◆ MatchText [3/4]

#define MatchText   SB_IMatchText

Definition at line 144 of file like.c.

◆ MatchText [4/4]

#define MatchText   UTF8_MatchText

Definition at line 144 of file like.c.

◆ NextByte

#define NextByte (   p,
  plen 
)    ((p)++, (plen)--)

Definition at line 105 of file like.c.

◆ NextChar [1/4]

#define NextChar (   p,
  plen 
)     do { int __l = pg_mblen(p); (p) +=__l; (plen) -=__l; } while (0)

Definition at line 142 of file like.c.

◆ NextChar [2/4]

#define NextChar (   p,
  plen 
)    NextByte((p), (plen))

Definition at line 142 of file like.c.

◆ NextChar [3/4]

#define NextChar (   p,
  plen 
)    NextByte((p), (plen))

Definition at line 142 of file like.c.

◆ NextChar [4/4]

#define NextChar (   p,
  plen 
)     do { (p)++; (plen)--; } while ((plen) > 0 && (*(p) & 0xC0) == 0x80 )

Definition at line 142 of file like.c.

Function Documentation

◆ bytealike()

Datum bytealike ( PG_FUNCTION_ARGS  )

Definition at line 324 of file like.c.

325 {
327  bytea *pat = PG_GETARG_BYTEA_PP(1);
328  bool result;
329  char *s,
330  *p;
331  int slen,
332  plen;
333 
334  s = VARDATA_ANY(str);
335  slen = VARSIZE_ANY_EXHDR(str);
336  p = VARDATA_ANY(pat);
337  plen = VARSIZE_ANY_EXHDR(pat);
338 
339  result = (SB_MatchText(s, slen, p, plen, 0, true) == LIKE_TRUE);
340 
341  PG_RETURN_BOOL(result);
342 }
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
const char * str
static int SB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
#define LIKE_TRUE
Definition: like.c:30
Definition: c.h:687
#define VARDATA_ANY(PTR)
Definition: varatt.h:324
#define VARSIZE_ANY_EXHDR(PTR)
Definition: varatt.h:317

References LIKE_TRUE, PG_GETARG_BYTEA_PP, PG_RETURN_BOOL, SB_MatchText(), str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ byteanlike()

Datum byteanlike ( PG_FUNCTION_ARGS  )

Definition at line 345 of file like.c.

346 {
348  bytea *pat = PG_GETARG_BYTEA_PP(1);
349  bool result;
350  char *s,
351  *p;
352  int slen,
353  plen;
354 
355  s = VARDATA_ANY(str);
356  slen = VARSIZE_ANY_EXHDR(str);
357  p = VARDATA_ANY(pat);
358  plen = VARSIZE_ANY_EXHDR(pat);
359 
360  result = (SB_MatchText(s, slen, p, plen, 0, true) != LIKE_TRUE);
361 
362  PG_RETURN_BOOL(result);
363 }

References LIKE_TRUE, PG_GETARG_BYTEA_PP, PG_RETURN_BOOL, SB_MatchText(), str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ Generic_Text_IC_like()

static int Generic_Text_IC_like ( text str,
text pat,
Oid  collation 
)
inlinestatic

Definition at line 171 of file like.c.

172 {
173  char *s,
174  *p;
175  int slen,
176  plen;
177  pg_locale_t locale = 0;
178  bool locale_is_c = false;
179 
180  if (!OidIsValid(collation))
181  {
182  /*
183  * This typically means that the parser could not resolve a conflict
184  * of implicit collations, so report it that way.
185  */
186  ereport(ERROR,
187  (errcode(ERRCODE_INDETERMINATE_COLLATION),
188  errmsg("could not determine which collation to use for ILIKE"),
189  errhint("Use the COLLATE clause to set the collation explicitly.")));
190  }
191 
192  if (lc_ctype_is_c(collation))
193  locale_is_c = true;
194  else
195  locale = pg_newlocale_from_collation(collation);
196 
198  ereport(ERROR,
199  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
200  errmsg("nondeterministic collations are not supported for ILIKE")));
201 
202  /*
203  * For efficiency reasons, in the single byte case we don't call lower()
204  * on the pattern and text, but instead call SB_lower_char on each
205  * character. In the multi-byte case we don't have much choice :-(. Also,
206  * ICU does not support single-character case folding, so we go the long
207  * way.
208  */
209 
210  if (pg_database_encoding_max_length() > 1 || (locale && locale->provider == COLLPROVIDER_ICU))
211  {
213  PointerGetDatum(pat)));
214  p = VARDATA_ANY(pat);
215  plen = VARSIZE_ANY_EXHDR(pat);
217  PointerGetDatum(str)));
218  s = VARDATA_ANY(str);
219  slen = VARSIZE_ANY_EXHDR(str);
220  if (GetDatabaseEncoding() == PG_UTF8)
221  return UTF8_MatchText(s, slen, p, plen, 0, true);
222  else
223  return MB_MatchText(s, slen, p, plen, 0, true);
224  }
225  else
226  {
227  p = VARDATA_ANY(pat);
228  plen = VARSIZE_ANY_EXHDR(pat);
229  s = VARDATA_ANY(str);
230  slen = VARSIZE_ANY_EXHDR(str);
231  return SB_IMatchText(s, slen, p, plen, locale, locale_is_c);
232  }
233 }
#define OidIsValid(objectId)
Definition: c.h:775
int errhint(const char *fmt,...)
Definition: elog.c:1315
int errcode(int sqlerrcode)
Definition: elog.c:855
int errmsg(const char *fmt,...)
Definition: elog.c:1068
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
Datum DirectFunctionCall1Coll(PGFunction func, Oid collation, Datum arg1)
Definition: fmgr.c:792
#define DatumGetTextPP(X)
Definition: fmgr.h:292
static char * locale
Definition: initdb.c:140
static int UTF8_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
static int SB_IMatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
static int MB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
int GetDatabaseEncoding(void)
Definition: mbutils.c:1261
int pg_database_encoding_max_length(void)
Definition: mbutils.c:1546
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:49
pg_locale_t pg_newlocale_from_collation(Oid collid)
Definition: pg_locale.c:1552
bool lc_ctype_is_c(Oid collation)
Definition: pg_locale.c:1384
bool pg_locale_deterministic(pg_locale_t locale)
Definition: pg_locale.c:1532
@ PG_UTF8
Definition: pg_wchar.h:232
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322

References DatumGetTextPP, DirectFunctionCall1Coll(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), locale, lower(), MB_MatchText(), OidIsValid, pg_database_encoding_max_length(), pg_locale_deterministic(), pg_newlocale_from_collation(), PG_UTF8, PointerGetDatum(), SB_IMatchText(), str, UTF8_MatchText(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by nameiclike(), nameicnlike(), texticlike(), and texticnlike().

◆ GenericMatchText()

static int GenericMatchText ( const char *  s,
int  slen,
const char *  p,
int  plen,
Oid  collation 
)
inlinestatic

Definition at line 150 of file like.c.

151 {
152  if (collation && !lc_ctype_is_c(collation))
153  {
155 
157  ereport(ERROR,
158  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
159  errmsg("nondeterministic collations are not supported for LIKE")));
160  }
161 
163  return SB_MatchText(s, slen, p, plen, 0, true);
164  else if (GetDatabaseEncoding() == PG_UTF8)
165  return UTF8_MatchText(s, slen, p, plen, 0, true);
166  else
167  return MB_MatchText(s, slen, p, plen, 0, true);
168 }

References ereport, errcode(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), locale, MB_MatchText(), pg_database_encoding_max_length(), pg_locale_deterministic(), pg_newlocale_from_collation(), PG_UTF8, SB_MatchText(), and UTF8_MatchText().

Referenced by namelike(), namenlike(), textlike(), and textnlike().

◆ like_escape()

Datum like_escape ( PG_FUNCTION_ARGS  )

Definition at line 428 of file like.c.

429 {
430  text *pat = PG_GETARG_TEXT_PP(0);
431  text *esc = PG_GETARG_TEXT_PP(1);
432  text *result;
433 
435  result = SB_do_like_escape(pat, esc);
436  else
437  result = MB_do_like_escape(pat, esc);
438 
439  PG_RETURN_TEXT_P(result);
440 }
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
static text * SB_do_like_escape(text *pat, text *esc)
static text * MB_do_like_escape(text *pat, text *esc)

References MB_do_like_escape(), pg_database_encoding_max_length(), PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, and SB_do_like_escape().

◆ like_escape_bytea()

Datum like_escape_bytea ( PG_FUNCTION_ARGS  )

Definition at line 447 of file like.c.

448 {
449  bytea *pat = PG_GETARG_BYTEA_PP(0);
450  bytea *esc = PG_GETARG_BYTEA_PP(1);
451  bytea *result = SB_do_like_escape((text *) pat, (text *) esc);
452 
453  PG_RETURN_BYTEA_P((bytea *) result);
454 }
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:371

References PG_GETARG_BYTEA_PP, PG_RETURN_BYTEA_P, and SB_do_like_escape().

◆ MB_do_like_escape()

static text* MB_do_like_escape ( text pat,
text esc 
)
static

Referenced by like_escape().

◆ MB_MatchText()

static int MB_MatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

◆ nameiclike()

Datum nameiclike ( PG_FUNCTION_ARGS  )

Definition at line 370 of file like.c.

371 {
372  Name str = PG_GETARG_NAME(0);
373  text *pat = PG_GETARG_TEXT_PP(1);
374  bool result;
375  text *strtext;
376 
378  NameGetDatum(str)));
379  result = (Generic_Text_IC_like(strtext, pat, PG_GET_COLLATION()) == LIKE_TRUE);
380 
381  PG_RETURN_BOOL(result);
382 }
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:642
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278
#define PG_GET_COLLATION()
Definition: fmgr.h:198
static int Generic_Text_IC_like(text *str, text *pat, Oid collation)
Definition: like.c:171
static Datum NameGetDatum(const NameData *X)
Definition: postgres.h:373
Definition: c.h:741
Datum name_text(PG_FUNCTION_ARGS)
Definition: varlena.c:3382

References DatumGetTextPP, DirectFunctionCall1, Generic_Text_IC_like(), LIKE_TRUE, name_text(), NameGetDatum(), PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and str.

◆ nameicnlike()

Datum nameicnlike ( PG_FUNCTION_ARGS  )

Definition at line 385 of file like.c.

386 {
387  Name str = PG_GETARG_NAME(0);
388  text *pat = PG_GETARG_TEXT_PP(1);
389  bool result;
390  text *strtext;
391 
393  NameGetDatum(str)));
394  result = (Generic_Text_IC_like(strtext, pat, PG_GET_COLLATION()) != LIKE_TRUE);
395 
396  PG_RETURN_BOOL(result);
397 }

References DatumGetTextPP, DirectFunctionCall1, Generic_Text_IC_like(), LIKE_TRUE, name_text(), NameGetDatum(), PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and str.

◆ namelike()

Datum namelike ( PG_FUNCTION_ARGS  )

Definition at line 240 of file like.c.

241 {
242  Name str = PG_GETARG_NAME(0);
243  text *pat = PG_GETARG_TEXT_PP(1);
244  bool result;
245  char *s,
246  *p;
247  int slen,
248  plen;
249 
250  s = NameStr(*str);
251  slen = strlen(s);
252  p = VARDATA_ANY(pat);
253  plen = VARSIZE_ANY_EXHDR(pat);
254 
255  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) == LIKE_TRUE);
256 
257  PG_RETURN_BOOL(result);
258 }
#define NameStr(name)
Definition: c.h:746
static int GenericMatchText(const char *s, int slen, const char *p, int plen, Oid collation)
Definition: like.c:150

References GenericMatchText(), LIKE_TRUE, NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ namenlike()

Datum namenlike ( PG_FUNCTION_ARGS  )

Definition at line 261 of file like.c.

262 {
263  Name str = PG_GETARG_NAME(0);
264  text *pat = PG_GETARG_TEXT_PP(1);
265  bool result;
266  char *s,
267  *p;
268  int slen,
269  plen;
270 
271  s = NameStr(*str);
272  slen = strlen(s);
273  p = VARDATA_ANY(pat);
274  plen = VARSIZE_ANY_EXHDR(pat);
275 
276  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) != LIKE_TRUE);
277 
278  PG_RETURN_BOOL(result);
279 }

References GenericMatchText(), LIKE_TRUE, NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ SB_do_like_escape()

static text* SB_do_like_escape ( text pat,
text esc 
)
static

Referenced by like_escape(), and like_escape_bytea().

◆ SB_IMatchText()

static int SB_IMatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

Referenced by Generic_Text_IC_like().

◆ SB_lower_char()

static char SB_lower_char ( unsigned char  c,
pg_locale_t  locale,
bool  locale_is_c 
)
static

Definition at line 94 of file like.c.

95 {
96  if (locale_is_c)
97  return pg_ascii_tolower(c);
98  else if (locale)
99  return tolower_l(c, locale->info.lt);
100  else
101  return pg_tolower(c);
102 }
unsigned char pg_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:122
unsigned char pg_ascii_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:146
char * c
#define tolower_l
Definition: win32_port.h:425

References locale, pg_ascii_tolower(), pg_tolower(), and tolower_l.

◆ SB_MatchText()

static int SB_MatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

◆ texticlike()

Datum texticlike ( PG_FUNCTION_ARGS  )

Definition at line 400 of file like.c.

401 {
402  text *str = PG_GETARG_TEXT_PP(0);
403  text *pat = PG_GETARG_TEXT_PP(1);
404  bool result;
405 
406  result = (Generic_Text_IC_like(str, pat, PG_GET_COLLATION()) == LIKE_TRUE);
407 
408  PG_RETURN_BOOL(result);
409 }

References Generic_Text_IC_like(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and str.

◆ texticnlike()

Datum texticnlike ( PG_FUNCTION_ARGS  )

Definition at line 412 of file like.c.

413 {
414  text *str = PG_GETARG_TEXT_PP(0);
415  text *pat = PG_GETARG_TEXT_PP(1);
416  bool result;
417 
418  result = (Generic_Text_IC_like(str, pat, PG_GET_COLLATION()) != LIKE_TRUE);
419 
420  PG_RETURN_BOOL(result);
421 }

References Generic_Text_IC_like(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and str.

◆ textlike()

Datum textlike ( PG_FUNCTION_ARGS  )

Definition at line 282 of file like.c.

283 {
284  text *str = PG_GETARG_TEXT_PP(0);
285  text *pat = PG_GETARG_TEXT_PP(1);
286  bool result;
287  char *s,
288  *p;
289  int slen,
290  plen;
291 
292  s = VARDATA_ANY(str);
293  slen = VARSIZE_ANY_EXHDR(str);
294  p = VARDATA_ANY(pat);
295  plen = VARSIZE_ANY_EXHDR(pat);
296 
297  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) == LIKE_TRUE);
298 
299  PG_RETURN_BOOL(result);
300 }

References GenericMatchText(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ textnlike()

Datum textnlike ( PG_FUNCTION_ARGS  )

Definition at line 303 of file like.c.

304 {
305  text *str = PG_GETARG_TEXT_PP(0);
306  text *pat = PG_GETARG_TEXT_PP(1);
307  bool result;
308  char *s,
309  *p;
310  int slen,
311  plen;
312 
313  s = VARDATA_ANY(str);
314  slen = VARSIZE_ANY_EXHDR(str);
315  p = VARDATA_ANY(pat);
316  plen = VARSIZE_ANY_EXHDR(pat);
317 
318  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) != LIKE_TRUE);
319 
320  PG_RETURN_BOOL(result);
321 }

References GenericMatchText(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ UTF8_MatchText()

static int UTF8_MatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

◆ wchareq()

static int wchareq ( const char *  p1,
const char *  p2 
)
inlinestatic

Definition at line 58 of file like.c.

59 {
60  int p1_len;
61 
62  /* Optimization: quickly compare the first byte. */
63  if (*p1 != *p2)
64  return 0;
65 
66  p1_len = pg_mblen(p1);
67  if (pg_mblen(p2) != p1_len)
68  return 0;
69 
70  /* They are the same length */
71  while (p1_len--)
72  {
73  if (*p1++ != *p2++)
74  return 0;
75  }
76  return 1;
77 }

References p2, and pg_mblen().