credential-store: move related functions to credential-store file
is_rfc3986_unreserved() and is_rfc3986_reserved_or_unreserved() are only called from builtin/credential-store.c and they are only relevant to that file so move those functions and make them static. Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Calvin Wan committed
Jun 6, 2023 at 19:48 UTC
f89854362cbe60371605dac3ae542109218ef1f3
3 files changed
+19
-22
builtin/credential-store.c
+19
@@ -74,6 +74,25 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
74
die_errno("unable to write credential store");
75
}
76
77
+static int is_rfc3986_unreserved(char ch)
78
+{
79
+ return isalnum(ch) ||
80
+ ch == '-' || ch == '_' || ch == '.' || ch == '~';
81
+}
82
+
83
+static int is_rfc3986_reserved_or_unreserved(char ch)
84
+{
85
+ if (is_rfc3986_unreserved(ch))
86
+ return 1;
87
+ switch (ch) {
88
+ case '!': case '*': case '\'': case '(': case ')': case ';':
89
+ case ':': case '@': case '&': case '=': case '+': case '$':
90
+ case ',': case '/': case '?': case '#': case '[': case ']':
91
+ return 1;
92
+ }
93
+ return 0;
94
+}
95
+
96
static void store_credential_file(const char *fn, struct credential *c)
97
{
98
struct strbuf buf = STRBUF_INIT;
strbuf.c
-19
@@ -810,25 +810,6 @@ void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
810
}
811
}
812
813
-int is_rfc3986_reserved_or_unreserved(char ch)
814
-{
815
- if (is_rfc3986_unreserved(ch))
816
- return 1;
817
- switch (ch) {
818
- case '!': case '*': case '\'': case '(': case ')': case ';':
819
- case ':': case '@': case '&': case '=': case '+': case '$':
820
- case ',': case '/': case '?': case '#': case '[': case ']':
821
- return 1;
822
- }
823
- return 0;
824
-}
825
-
826
-int is_rfc3986_unreserved(char ch)
827
-{
828
- return isalnum(ch) ||
829
- ch == '-' || ch == '_' || ch == '.' || ch == '~';
830
-}
831
-
813
static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
814
char_predicate allow_unencoded_fn)
815
{
strbuf.h
-3
@@ -690,9 +690,6 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
690
691
typedef int (*char_predicate)(char ch);
692
693
-int is_rfc3986_unreserved(char ch);
694
-int is_rfc3986_reserved_or_unreserved(char ch);
695
-
693
void strbuf_addstr_urlencode(struct strbuf *sb, const char *name,
694
char_predicate allow_unencoded_fn);
695