/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 | 13.3M | { |
52 | 13.3M | long val; |
53 | | |
54 | 13.3M | val = strtol(str, endptr, base); |
55 | 13.3M | if (val != (int) val) |
56 | 11.0k | errno = ERANGE; |
57 | 13.3M | return (int) val; |
58 | 13.3M | } |