YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/build/debugcov-clang-dynamic-arm64-ninja/postgres_build/src/interfaces/ecpg/pgtypeslib/string.c
Line
Count
Source (jump to first uncovered line)
1
/*-------------------------------------------------------------------------
2
 *
3
 * string.c
4
 *    string handling helpers
5
 *
6
 *
7
 * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
8
 * Portions Copyright (c) 1994, Regents of the University of California
9
 *
10
 *
11
 * IDENTIFICATION
12
 *    src/common/string.c
13
 *
14
 *-------------------------------------------------------------------------
15
 */
16
17
18
#ifndef FRONTEND
19
#include "postgres.h"
20
#else
21
#include "postgres_fe.h"
22
#endif
23
24
#include "common/string.h"
25
26
27
/*
28
 * Returns whether the string `str' has the postfix `end'.
29
 */
30
bool
31
pg_str_endswith(const char *str, const char *end)
32
0
{
33
0
  size_t    slen = strlen(str);
34
0
  size_t    elen = strlen(end);
35
36
  /* can't be a postfix if longer */
37
0
  if (elen > slen)
38
0
    return false;
39
40
  /* compare the end of the strings */
41
0
  str += slen - elen;
42
0
  return strcmp(str, end) == 0;
43
0
}
44
45
46
/*
47
 * strtoint --- just like strtol, but returns int not long
48
 */
49
int
50
strtoint(const char *pg_restrict str, char **pg_restrict endptr, int base)
51
1.67M
{
52
1.67M
  long    val;
53
54
1.67M
  val = strtol(str, endptr, base);
55
1.67M
  if (val != (int) val)
56
702
    errno = ERANGE;
57
1.67M
  return (int) val;
58
1.67M
}