LCOV - differential code coverage report
Current view: top level - src/backend/utils/mb/conversion_procs/utf8_and_big5 - utf8_and_big5.c (source / functions) Coverage Total Hit CBC
Current: bed3ffbf9d952be6c7d739d068cdce44c046dfb7 vs 574581b50ac9c63dd9e4abebb731a3b67e5b50f6 Lines: 100.0 % 19 19 19
Current Date: 2026-05-05 10:23:31 +0900 Functions: 100.0 % 5 5 5
Baseline: lcov-20260505-025707-baseline Line coverage date bins:
Baseline Date: 2026-05-05 10:27:06 +0900 (360..) days: 100.0 % 19 19 19
Legend: Lines:     hit not hit Function coverage date bins:
(360..) days: 100.0 % 5 5 5

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  *
                                  3                 :  *    BIG5 <--> UTF8
                                  4                 :  *
                                  5                 :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  6                 :  * Portions Copyright (c) 1994, Regents of the University of California
                                  7                 :  *
                                  8                 :  * IDENTIFICATION
                                  9                 :  *    src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c
                                 10                 :  *
                                 11                 :  *-------------------------------------------------------------------------
                                 12                 :  */
                                 13                 : 
                                 14                 : #include "postgres.h"
                                 15                 : #include "fmgr.h"
                                 16                 : #include "mb/pg_wchar.h"
                                 17                 : #include "../../Unicode/big5_to_utf8.map"
                                 18                 : #include "../../Unicode/utf8_to_big5.map"
                                 19                 : 
  405 tgl@sss.pgh.pa.us          20 CBC           8 : PG_MODULE_MAGIC_EXT(
                                 21                 :                     .name = "utf8_and_big5",
                                 22                 :                     .version = PG_VERSION
                                 23                 : );
                                 24                 : 
 8592                            25               8 : PG_FUNCTION_INFO_V1(big5_to_utf8);
                                 26               4 : PG_FUNCTION_INFO_V1(utf8_to_big5);
                                 27                 : 
                                 28                 : /* ----------
                                 29                 :  * conv_proc(
                                 30                 :  *      INTEGER,    -- source encoding id
                                 31                 :  *      INTEGER,    -- destination encoding id
                                 32                 :  *      CSTRING,    -- source string (null terminated C string)
                                 33                 :  *      CSTRING,    -- destination string (null terminated C string)
                                 34                 :  *      INTEGER,    -- source string length
                                 35                 :  *      BOOL        -- if true, don't throw an error if conversion fails
                                 36                 :  * ) returns INTEGER;
                                 37                 :  *
                                 38                 :  * Returns the number of bytes successfully converted.
                                 39                 :  * ----------
                                 40                 :  */
                                 41                 : Datum
 8694 ishii@postgresql.org       42             100 : big5_to_utf8(PG_FUNCTION_ARGS)
                                 43                 : {
 7528 tgl@sss.pgh.pa.us          44             100 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                 45             100 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8644 bruce@momjian.us           46             100 :     int         len = PG_GETARG_INT32(4);
 1860 heikki.linnakangas@i       47             100 :     bool        noError = PG_GETARG_BOOL(5);
                                 48                 :     int         converted;
                                 49                 : 
 6305 tgl@sss.pgh.pa.us          50             100 :     CHECK_ENCODING_CONVERSION_ARGS(PG_BIG5, PG_UTF8);
                                 51                 : 
 1860 heikki.linnakangas@i       52             100 :     converted = LocalToUtf(src, len, dest,
                                 53                 :                            &big5_to_unicode_tree,
                                 54                 :                            NULL, 0,
                                 55                 :                            NULL,
                                 56                 :                            PG_BIG5,
                                 57                 :                            noError);
                                 58                 : 
                                 59              64 :     PG_RETURN_INT32(converted);
                                 60                 : }
                                 61                 : 
                                 62                 : Datum
 8694 ishii@postgresql.org       63               4 : utf8_to_big5(PG_FUNCTION_ARGS)
                                 64                 : {
 7528 tgl@sss.pgh.pa.us          65               4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                 66               4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8644 bruce@momjian.us           67               4 :     int         len = PG_GETARG_INT32(4);
 1860 heikki.linnakangas@i       68               4 :     bool        noError = PG_GETARG_BOOL(5);
                                 69                 :     int         converted;
                                 70                 : 
 6305 tgl@sss.pgh.pa.us          71               4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_BIG5);
                                 72                 : 
 1860 heikki.linnakangas@i       73               4 :     converted = UtfToLocal(src, len, dest,
                                 74                 :                            &big5_from_unicode_tree,
                                 75                 :                            NULL, 0,
                                 76                 :                            NULL,
                                 77                 :                            PG_BIG5,
                                 78                 :                            noError);
                                 79                 : 
                                 80               4 :     PG_RETURN_INT32(converted);
                                 81                 : }
        

Generated by: LCOV version 2.5.0-beta