Remove ranges from switch statements.
Though very nice and readable, the "case 'a'...'z':" construct is not ANSI C99 compliant. This patch unfolds the range in `quote.c' and substitutes the switch-statement with an if-statement in `http-fetch.c' and `http-push.c'. Signed-off-by: Florian Forster <octo@verplant.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
64e86c5786
commit
cfd432e63d
13
http-fetch.c
13
http-fetch.c
@ -1136,13 +1136,14 @@ int fetch(unsigned char *sha1)
|
|||||||
|
|
||||||
static inline int needs_quote(int ch)
|
static inline int needs_quote(int ch)
|
||||||
{
|
{
|
||||||
switch (ch) {
|
if (((ch >= 'A') && (ch <= 'Z'))
|
||||||
case '/': case '-': case '.':
|
|| ((ch >= 'a') && (ch <= 'z'))
|
||||||
case 'A'...'Z': case 'a'...'z': case '0'...'9':
|
|| ((ch >= '0') && (ch <= '9'))
|
||||||
|
|| (ch == '/')
|
||||||
|
|| (ch == '-')
|
||||||
|
|| (ch == '.'))
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int hex(int v)
|
static inline int hex(int v)
|
||||||
|
13
http-push.c
13
http-push.c
@ -1077,13 +1077,14 @@ static int fetch_indices(void)
|
|||||||
|
|
||||||
static inline int needs_quote(int ch)
|
static inline int needs_quote(int ch)
|
||||||
{
|
{
|
||||||
switch (ch) {
|
if (((ch >= 'A') && (ch <= 'Z'))
|
||||||
case '/': case '-': case '.':
|
|| ((ch >= 'a') && (ch <= 'z'))
|
||||||
case 'A'...'Z': case 'a'...'z': case '0'...'9':
|
|| ((ch >= '0') && (ch <= '9'))
|
||||||
|
|| (ch == '/')
|
||||||
|
|| (ch == '-')
|
||||||
|
|| (ch == '.'))
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int hex(int v)
|
static inline int hex(int v)
|
||||||
|
9
quote.c
9
quote.c
@ -206,7 +206,14 @@ char *unquote_c_style(const char *quoted, const char **endp)
|
|||||||
case '\\': case '"':
|
case '\\': case '"':
|
||||||
break; /* verbatim */
|
break; /* verbatim */
|
||||||
|
|
||||||
case '0'...'7':
|
case '0':
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
/* octal */
|
/* octal */
|
||||||
ac = ((ch - '0') << 6);
|
ac = ((ch - '0') << 6);
|
||||||
if ((ch = *sp++) < '0' || '7' < ch)
|
if ((ch = *sp++) < '0' || '7' < ch)
|
||||||
|
Loading…
Reference in New Issue
Block a user