PostgreSQL Source Code: src/common/string.c File Reference (original) (raw)
Go to the source code of this file.
Functions | |
---|---|
bool | pg_str_endswith (const char *str, const char *end) |
int | strtoint (const char *pg_restrict str, char **pg_restrict endptr, int base) |
char * | pg_clean_ascii (const char *str, int alloc_flags) |
bool | pg_is_ascii (const char *str) |
int | pg_strip_crlf (char *str) |
◆ pg_clean_ascii()
char * pg_clean_ascii | ( | const char * | str, |
---|---|---|---|
int | alloc_flags | ||
) |
Definition at line 85 of file string.c.
86{
87 size_t dstlen;
88 char *dst;
89 const char *p;
90 size_t i = 0;
91
92
93 dstlen = strlen(str) * 4 + 1;
94
95#ifdef FRONTEND
97#else
99#endif
100
101 if (!dst)
102 return NULL;
103
104 for (p = str; *p != '\0'; p++)
105 {
106
107
108 if (*p < 32 || *p > 126)
109 {
111 snprintf(&dst[i], dstlen - i, "\\x%02x", (unsigned char) *p);
112 i += 4;
113 }
114 else
115 {
117 dst[i] = *p;
118 i++;
119 }
120 }
121
123 dst[i] = '\0';
124 return dst;
125}
Assert(PointerIsAligned(start, uint64))
void * palloc_extended(Size size, int flags)
References Assert(), i, malloc, palloc_extended(), snprintf, and str.
Referenced by check_application_name(), check_cluster_name(), prepare_cert_name(), and ProcessStartupPacket().
◆ pg_is_ascii()
bool pg_is_ascii | ( | const char * | str | ) |
---|
◆ pg_str_endswith()
bool pg_str_endswith | ( | const char * | str, |
---|---|---|---|
const char * | end | ||
) |
◆ pg_strip_crlf()
int pg_strip_crlf | ( | char * | str | ) |
---|
Definition at line 154 of file string.c.
155{
157
158 while (len > 0 && (str[len - 1] == '\n' ||
161
162 return len;
163}
Referenced by adjust_data_dir(), check_exec(), CheckDataVersion(), get_control_data(), get_prompt(), get_sock_dir(), get_su_pwd(), getRestoreCommand(), passwordFromFile(), run_ssl_passphrase_command(), simple_prompt_extended(), and tokenize_auth_file().
◆ strtoint()
int strtoint | ( | const char *pg_restrict | str, |
---|---|---|---|
char **pg_restrict | endptr, | ||
int | base | ||
) |
Definition at line 50 of file string.c.
51{
53
54 val = strtol(str, endptr, base);
56 errno = ERANGE;
57 return (int) val;
58}
Referenced by buildDefItem(), DecodeDateTime(), DecodeInterval(), DecodeNumber(), DecodeNumberField(), DecodeTime(), DecodeTimeCommon(), DecodeTimeOnly(), DecodeTimezone(), exec_command_watch(), get_path_all(), jsonb_get_element(), nodeTokenType(), option_parse_int(), process_integer_literal(), push_path(), px_crypt_shacrypt(), and setPathArray().