PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
string.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * string.c
4  * string handling helpers
5  *
6  *
7  * Portions Copyright (c) 1996-2017, 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 {
33  size_t slen = strlen(str);
34  size_t elen = strlen(end);
35 
36  /* can't be a postfix if longer */
37  if (elen > slen)
38  return false;
39 
40  /* compare the end of the strings */
41  str += slen - elen;
42  return strcmp(str, end) == 0;
43 }
bool pg_str_endswith(const char *str, const char *end)
Definition: string.c:31