rid of digittoint() (which is pointless since ISO C guarantees that digits
are consecutive in the execution character set); get rid of __unused.
Also fix a buglet in argv.c's BackSlash() (parsing of octal numbers), and
constify the array passed around by ParseArgv() and FreeArgv().
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@103
d4fa192b-c00b-0410-8231-
f00ffab90ce4
}
static void
-accept_f(int fd, short event, void *arg __unused)
+accept_f(int fd, short event, void *arg)
{
socklen_t l;
struct sessmem *sm;
struct sess *sp;
char port[10];
+ (void)arg;
sm = calloc(sizeof *sm, 1);
assert(sm != NULL); /*
* XXX: this is probably one we should handle
struct cli; /* NB: struct cli is opaque at this level. */
-typedef void cli_func_t(struct cli*, char **av, void *priv);
+typedef void cli_func_t(struct cli*, const char **av, void *priv);
struct cli_proto {
/* These must match the CLI_* macros in cli.h */
*/
/* from libvarnish/argv.c */
-void FreeArgv(char **argv);
-char **ParseArgv(const char *s, int comment);
+void FreeArgv(const char **argv);
+const char **ParseArgv(const char *s, int comment);
/* Assert zero return value */
#define AZ(foo) do { assert((foo) == 0); } while (0)
-
/*
* $Id$
*
- * char **ParseArgv(const char *s, int comment)
+ * const char **ParseArgv(const char *s, int comment)
* Parse a command like line into an argv[]
* Index zero contains NULL or an error message
* "double quotes" and backslash substitution is handled.
*
- * void FreeArgv(char **argv)
+ * void FreeArgv(const char **argv)
* Free the result of ParseArgv()
*
*/
i = '\\';
r = 2;
break;
- case '0': case '1': case '2': case 3:
- case '4': case '5': case '6': case 7:
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
for (r = 1; r < 4; r++) {
if (!isdigit(s[r]))
break;
- if (digittoint(s[r]) > 7)
+ if (s[r] - '0' > 7)
break;
i <<= 3;
- i |= digittoint(s[r]);
+ i |= s[r] - '0';
}
break;
case 'x':
return (p);
}
-char **
+const char **
ParseArgv(const char *s, int comment)
{
- char **argv;
+ const char **argv;
const char *p;
int nargv, largv;
int i, quote;
if (*s == '\\') {
i = BackSlash(s, NULL);
if (i == 0) {
- argv[0] = __DECONST(void *,
- "Illegal backslash sequence");
+ argv[0] = "Illegal backslash sequence";
return (argv);
}
s += i;
if (*s == '"')
break;
if (*s == '\0') {
- argv[0] = __DECONST(void *,
- "Missing '\"'");
+ argv[0] = "Missing '\"'";
return (argv);
}
s++;
}
void
-FreeArgv(char **argv)
+FreeArgv(const char **argv)
{
int i;
for (i = 1; argv[i] != NULL; i++)
- free(argv[i]);
+ free((void *)(uintptr_t)argv[i]);
free(argv);
}
*/
void
-cli_func_help(struct cli *cli, char **av, void *priv)
+cli_func_help(struct cli *cli, const char **av, void *priv)
{
struct cli_proto *cp;
void
cli_dispatch(struct cli *cli, struct cli_proto *clp, const char *line)
{
- char **av;
+ const char **av;
unsigned u;
struct cli_proto *cp;
* and all the rest...
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
#include <assert.h>
-#include <string.h>
#include <ctype.h>
-#include <unistd.h>
-#include <fcntl.h>
#include <errno.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <sbuf.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/sbuf.h>
-#include <sys/stat.h>
-#include <sys/queue.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
+#include <string.h>
+#include <queue.h>
+#include <unistd.h>
#include "vcl_priv.h"
case 'b': *q++ = '\b'; r += 2; break;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
- u = digittoint(r[1]);
+ u = r[1] - '0';
r += 2;
- if (isdigit(r[0]) && digittoint(r[0]) < 8) {
+ if (isdigit(r[0]) && (r[0] - '0') < 8) {
u <<= 3;
- u |= digittoint(r[0]);
+ u |= r[0] - '0';
r++;
- if (isdigit(r[0]) && digittoint(r[0]) < 8) {
+ if (isdigit(r[0]) && (r[0] - '0') < 8) {
u <<= 3;
- u |= digittoint(r[0]);
+ u |= r[0] - '0';
r++;
}
}
Expect(tl, CNUM);
for (p = tl->t->b; p < tl->t->e; p++) {
d *= 10;
- d += digittoint(*p);
+ d += *p - '0';
}
NextToken(tl);
return (d);
Expect(tl, CNUM);
for (p = tl->t->b; p < tl->t->e; p++) {
d *= 10;
- d += digittoint(*p);
+ d += *p - '0';
}
NextToken(tl);
if (tl->t->tok != '.')
if (tl->t->tok != CNUM)
return (d);
for (p = tl->t->b; p < tl->t->e; p++) {
- d += digittoint(*p) * e;
+ d += (*p - '0') * e;
e *= 0.1;
}
NextToken(tl);
}
static void
-Cond_String(struct var *vp __unused, struct tokenlist *tl)
+Cond_String(struct var *vp, struct tokenlist *tl)
{
+ (void)vp;
switch (tl->t->tok) {
case '~':
I(tl); sbuf_printf(tl->fc, "string_match(%s, ", vp->cname);