LCOV - code coverage report
Current view: top level - src/include/tsearch - ts_locale.h (source / functions) Hit Total Coverage
Test: PostgreSQL 19devel Lines: 5 5 100.0 %
Date: 2026-02-09 17:18:05 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * ts_locale.h
       4             :  *      locale compatibility layer for tsearch
       5             :  *
       6             :  * Copyright (c) 1998-2026, PostgreSQL Global Development Group
       7             :  *
       8             :  * src/include/tsearch/ts_locale.h
       9             :  *
      10             :  *-------------------------------------------------------------------------
      11             :  */
      12             : #ifndef __TSLOCALE_H__
      13             : #define __TSLOCALE_H__
      14             : 
      15             : #include <ctype.h>
      16             : #include <limits.h>
      17             : #include <wctype.h>
      18             : 
      19             : #include "lib/stringinfo.h"
      20             : #include "mb/pg_wchar.h"
      21             : #include "utils/pg_locale.h"
      22             : 
      23             : /* working state for tsearch_readline (should be a local var in caller) */
      24             : typedef struct
      25             : {
      26             :     FILE       *fp;
      27             :     const char *filename;
      28             :     int         lineno;
      29             :     StringInfoData buf;         /* current input line, in UTF-8 */
      30             :     char       *curline;        /* current input line, in DB's encoding */
      31             :     /* curline may be NULL, or equal to buf.data, or a palloc'd string */
      32             :     ErrorContextCallback cb;
      33             : } tsearch_readline_state;
      34             : 
      35             : #define TOUCHAR(x)  (*((const unsigned char *) (x)))
      36             : 
      37             : /* The second argument of t_iseq() must be a plain ASCII character */
      38             : #define t_iseq(x,c)     (TOUCHAR(x) == (unsigned char) (c))
      39             : 
      40             : /* Copy multibyte character of known byte length, return byte length. */
      41             : static inline int
      42      430282 : ts_copychar_with_len(void *dest, const void *src, int length)
      43             : {
      44      430282 :     memcpy(dest, src, length);
      45      430282 :     return length;
      46             : }
      47             : 
      48             : /* Copy multibyte character from null-terminated string,  return byte length. */
      49             : static inline int
      50      405326 : ts_copychar_cstr(void *dest, const void *src)
      51             : {
      52      405326 :     return ts_copychar_with_len(dest, src, pg_mblen_cstr((const char *) src));
      53             : }
      54             : 
      55             : /* Historical macro for the above. */
      56             : #define COPYCHAR ts_copychar_cstr
      57             : 
      58             : #define GENERATE_T_ISCLASS_DECL(character_class) \
      59             : extern int  t_is##character_class##_with_len(const char *ptr, int len); \
      60             : extern int  t_is##character_class##_cstr(const char *ptr); \
      61             : extern int  t_is##character_class##_unbounded(const char *ptr); \
      62             : \
      63             : /* deprecated */ \
      64             : extern int  t_is##character_class(const char *ptr);
      65             : 
      66             : GENERATE_T_ISCLASS_DECL(alnum);
      67             : GENERATE_T_ISCLASS_DECL(alpha);
      68             : 
      69             : extern bool tsearch_readline_begin(tsearch_readline_state *stp,
      70             :                                    const char *filename);
      71             : extern char *tsearch_readline(tsearch_readline_state *stp);
      72             : extern void tsearch_readline_end(tsearch_readline_state *stp);
      73             : 
      74             : #endif                          /* __TSLOCALE_H__ */

Generated by: LCOV version 1.16