aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc.h2
-rw-r--r--expr.c9
-rw-r--r--map.c2
-rw-r--r--qbe.c4
-rw-r--r--util.h4
5 files changed, 11 insertions, 10 deletions
diff --git a/cc.h b/cc.h
index 396a4ae..beb448e 100644
--- a/cc.h
+++ b/cc.h
@@ -331,7 +331,7 @@ struct expr {
double f;
} constant;
struct {
- char *data;
+ unsigned char *data;
size_t size;
} string;
struct {
diff --git a/expr.c b/expr.c
index d1458a4..986f438 100644
--- a/expr.c
+++ b/expr.c
@@ -363,10 +363,10 @@ isodigit(int c)
return '0' <= c && c <= '8';
}
-static int
+static unsigned
unescape(char **p)
{
- int c;
+ unsigned c;
char *s = *p;
if (*s == '\\') {
@@ -397,7 +397,7 @@ unescape(char **p)
while (isodigit(*++s));
}
} else {
- c = *s++;
+ c = (unsigned char)*s++;
}
*p = s;
return c;
@@ -456,7 +456,8 @@ primaryexpr(struct scope *s)
struct expr *e;
struct decl *d;
struct type *t;
- char *src, *dst, *end;
+ char *src, *end;
+ unsigned char *dst;
int base;
switch (tok.kind) {
diff --git a/map.c b/map.c
index 06be327..f01efc1 100644
--- a/map.c
+++ b/map.c
@@ -24,7 +24,7 @@ hash(const void *ptr, size_t len)
}
void
-mapkey(struct mapkey *k, const char *s, size_t n)
+mapkey(struct mapkey *k, const void *s, size_t n)
{
k->str = s;
k->len = n;
diff --git a/qbe.c b/qbe.c
index e3c7148..e814fee 100644
--- a/qbe.c
+++ b/qbe.c
@@ -1275,7 +1275,7 @@ dataitem(struct expr *expr, uint64_t size)
{
struct decl *decl;
size_t i;
- char c;
+ unsigned c;
switch (expr->kind) {
case EXPRUNARY:
@@ -1309,7 +1309,7 @@ dataitem(struct expr *expr, uint64_t size)
if (isprint(c) && c != '"' && c != '\\')
putchar(c);
else
- printf("\\%03hho", c);
+ printf("\\%03o", c);
}
fputc('"', stdout);
if (i < size)
diff --git a/util.h b/util.h
index 0081667..3a06874 100644
--- a/util.h
+++ b/util.h
@@ -9,7 +9,7 @@ struct array {
struct mapkey {
uint64_t hash;
- const char *str;
+ const void *str;
size_t len;
};
@@ -47,7 +47,7 @@ void *arraylast(struct array *, size_t);
/* map */
-void mapkey(struct mapkey *, const char *, size_t);
+void mapkey(struct mapkey *, const void *, size_t);
struct map *mkmap(size_t);
void delmap(struct map *, void(void *));
void **mapput(struct map *, struct mapkey *);