PostgreSQL Source Code  git master
string.c File Reference
#include "postgres.h"
#include "common/string.h"
Include dependency graph for string.c:

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)
 
void pg_clean_ascii (char *str)
 
bool pg_is_ascii (const char *str)
 
int pg_strip_crlf (char *str)
 

Function Documentation

◆ pg_clean_ascii()

void pg_clean_ascii ( char *  str)

Definition at line 82 of file string.c.

83 {
84  /* Only allow clean ASCII chars in the string */
85  char *p;
86 
87  for (p = str; *p != '\0'; p++)
88  {
89  if (*p < 32 || *p > 126)
90  *p = '?';
91  }
92 }

References generate_unaccent_rules::str.

Referenced by check_application_name(), check_cluster_name(), and ProcessStartupPacket().

◆ pg_is_ascii()

bool pg_is_ascii ( const char *  str)

Definition at line 99 of file string.c.

100 {
101  while (*str)
102  {
103  if (IS_HIGHBIT_SET(*str))
104  return false;
105  str++;
106  }
107  return true;
108 }
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1153

References IS_HIGHBIT_SET, and generate_unaccent_rules::str.

Referenced by parse_key_value_arrays(), pg_import_system_collations(), and pg_saslprep().

◆ pg_str_endswith()

bool pg_str_endswith ( const char *  str,
const char *  end 
)

Definition at line 31 of file string.c.

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 }

References generate_unaccent_rules::str.

Referenced by decide_file_action(), extract_directory(), and StartupReplicationSlots().

◆ pg_strip_crlf()

int pg_strip_crlf ( char *  str)

Definition at line 121 of file string.c.

122 {
123  int len = strlen(str);
124 
125  while (len > 0 && (str[len - 1] == '\n' ||
126  str[len - 1] == '\r'))
127  str[--len] = '\0';
128 
129  return len;
130 }
const void size_t len

References len, and generate_unaccent_rules::str.

Referenced by adjust_data_dir(), check_exec(), CheckDataVersion(), get_prompt(), get_sock_dir(), get_su_pwd(), getRestoreCommand(), passwordFromFile(), run_ssl_passphrase_command(), simple_prompt_extended(), and tokenize_file().

◆ strtoint()

int strtoint ( const char *pg_restrict  str,
char **pg_restrict  endptr,
int  base 
)

Definition at line 50 of file string.c.

51 {
52  long val;
53 
54  val = strtol(str, endptr, base);
55  if (val != (int) val)
56  errno = ERANGE;
57  return (int) val;
58 }
long val
Definition: informix.c:664

References generate_unaccent_rules::str, and val.

Referenced by buildDefItem(), DecodeDateTime(), DecodeInterval(), DecodeNumber(), DecodeNumberField(), DecodeTime(), DecodeTimeOnly(), DecodeTimezone(), get_path_all(), jsonb_get_element(), nodeTokenType(), option_parse_int(), push_path(), and setPathArray().