PostgreSQL Source Code git master
pgstrcasecmp.c File Reference
#include "c.h"
#include <ctype.h>
Include dependency graph for pgstrcasecmp.c:

Go to the source code of this file.

Functions

int pg_strcasecmp (const char *s1, const char *s2)
 
int pg_strncasecmp (const char *s1, const char *s2, size_t n)
 
unsigned char pg_toupper (unsigned char ch)
 
unsigned char pg_tolower (unsigned char ch)
 

Function Documentation

◆ pg_strcasecmp()

int pg_strcasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 32 of file pgstrcasecmp.c.

33{
34 for (;;)
35 {
36 unsigned char ch1 = (unsigned char) *s1++;
37 unsigned char ch2 = (unsigned char) *s2++;
38
39 if (ch1 != ch2)
40 {
41 if (ch1 >= 'A' && ch1 <= 'Z')
42 ch1 += 'a' - 'A';
43 else if (IS_HIGHBIT_SET(ch1) && isupper(ch1))
44 ch1 = tolower(ch1);
45
46 if (ch2 >= 'A' && ch2 <= 'Z')
47 ch2 += 'a' - 'A';
48 else if (IS_HIGHBIT_SET(ch2) && isupper(ch2))
49 ch2 = tolower(ch2);
50
51 if (ch1 != ch2)
52 return (int) ch1 - (int) ch2;
53 }
54 if (ch1 == 0)
55 break;
56 }
57 return 0;
58}
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1143
char * s1
char * s2

References IS_HIGHBIT_SET, s1, and s2.

Referenced by AlterSubscription(), AlterType(), appendPGArray(), array_out(), build_startup_packet(), check_createrole_self_grant(), check_datestyle(), check_debug_io_direct(), check_log_destination(), check_publications_origin_sequences(), check_publications_origin_tables(), check_restrict_nonsystem_relation_kind(), check_usermap(), check_wal_consistency_checking(), comp_keyword_case_hook(), config_enum_lookup_by_name(), convert_any_priv_string(), createdb(), defGetBoolean(), defGetCopyHeaderOption(), defGetCopyLogVerbosityChoice(), defGetCopyOnErrorChoice(), defGetGeneratedColsOption(), defGetStreamingMode(), defGetTypeLength(), DefineAggregate(), DefineCollation(), DefineType(), do_pset(), dumpSubscription(), echo_hidden_hook(), echo_hook(), evaluateSleep(), exec_command(), ExecVacuum(), expect_boolean_value(), find_matching_ts_config(), get_arg_by_name(), get_collation_actual_version_libc(), get_progname(), GetAttributeStorage(), GetCommandTagEnum(), getMetaCommand(), helpSQL(), histcontrol_hook(), hostname_match(), IsReservedOriginName(), locate_stem_module(), lookup_prop_name(), main(), makeVariableValue(), map_typename_pattern(), on_error_rollback_hook(), parse_basebackup_options(), parse_hstore(), parse_one_reloption(), parse_output_parameters(), parse_slash_copy(), parse_subscription_options(), parseArchiveFormat(), parseCommandLine(), parseNameAndArgTypes(), ParseVariableBool(), pg_checksum_parse_type(), pg_fe_sendauth(), pg_find_encoding(), pg_get_encoding_from_locale(), pg_size_bytes(), pg_stat_get_progress_info(), pgp_get_cipher_code(), pgp_get_digest_code(), pgstat_get_kind_from_str(), pgstat_register_kind(), PGTYPEStimestamp_defmt_scan(), plperl_trigger_handler(), plpgsql_extra_checks_check_hook(), PLy_exec_trigger(), pq_verify_peer_name_matches_certificate_name(), process_backslash_command(), prsd_headline(), px_gen_salt(), px_resolve_alias(), ReadArrayToken(), RegisterCustomRmgr(), show_context_hook(), splitTzLine(), ssl_protocol_version_to_openssl(), sslVerifyProtocolRange(), sslVerifyProtocolVersion(), stats_fill_fcinfo_from_arg_pairs(), SyncRepGetStandbyPriority(), unicode_norm_form_from_string(), validate_exec(), validate_log_connections_options(), variable_is_guc_list_quote(), verbosity_hook(), verify_heapam(), wildcard_certificate_match(), and xmlpi().

◆ pg_strncasecmp()

int pg_strncasecmp ( const char *  s1,
const char *  s2,
size_t  n 
)

Definition at line 65 of file pgstrcasecmp.c.

66{
67 while (n-- > 0)
68 {
69 unsigned char ch1 = (unsigned char) *s1++;
70 unsigned char ch2 = (unsigned char) *s2++;
71
72 if (ch1 != ch2)
73 {
74 if (ch1 >= 'A' && ch1 <= 'Z')
75 ch1 += 'a' - 'A';
76 else if (IS_HIGHBIT_SET(ch1) && isupper(ch1))
77 ch1 = tolower(ch1);
78
79 if (ch2 >= 'A' && ch2 <= 'Z')
80 ch2 += 'a' - 'A';
81 else if (IS_HIGHBIT_SET(ch2) && isupper(ch2))
82 ch2 = tolower(ch2);
83
84 if (ch1 != ch2)
85 return (int) ch1 - (int) ch2;
86 }
87 if (ch1 == 0)
88 break;
89 }
90 return 0;
91}

References IS_HIGHBIT_SET, s1, and s2.

Referenced by check_content_type(), check_datestyle(), check_for_device_flow(), check_special_value(), check_timezone(), checkKeyword(), command_no_begin(), do_pset(), float4in_internal(), float8in_internal(), get_collation_actual_version_libc(), helpSQL(), issuer_from_well_known_uri(), MainLoop(), makeVariableValue(), map_sql_identifier_to_xml_name(), multirange_in(), numeric_in(), parse_bool_with_len(), parse_jsonb_index_flags(), parse_or_operator(), ParseTzFile(), ParseVariableBool(), range_parse(), replace_guc_value(), scan_directory_ci(), set_unicode_line_style(), set_var_from_str(), SpecialTags(), and validate_token_format().

◆ pg_tolower()

unsigned char pg_tolower ( unsigned char  ch)

Definition at line 118 of file pgstrcasecmp.c.

119{
120 if (ch >= 'A' && ch <= 'Z')
121 ch += 'a' - 'A';
122 else if (IS_HIGHBIT_SET(ch) && isupper(ch))
123 ch = tolower(ch);
124 return ch;
125}

References IS_HIGHBIT_SET.

Referenced by DecodeTimezoneAbbrevPrefix(), dequote_downcase_identifier(), dir_strcmp(), ParseDateTime(), patternToSQLRegex(), PGTYPESdate_defmt_asc(), PQfnumber(), SB_lower_char(), and validateTzEntry().

◆ pg_toupper()

unsigned char pg_toupper ( unsigned char  ch)

Definition at line 101 of file pgstrcasecmp.c.

102{
103 if (ch >= 'a' && ch <= 'z')
104 ch += 'A' - 'a';
105 else if (IS_HIGHBIT_SET(ch) && islower(ch))
106 ch = toupper(ch);
107 return ch;
108}

References IS_HIGHBIT_SET.

Referenced by DetermineTimeZoneAbbrevOffsetInternal(), pg_timezone_abbrevs_abbrevs(), pg_tzset(), and TimeZoneAbbrevIsKnown().