~mcf/cproc

4e9690b6cb07de9f5a1927ec0b1a8d0c99ddbbe8 — Michael Forney a month ago 32df872
Make string literal data unsigned char
5 files changed, 11 insertions(+), 10 deletions(-)

M cc.h
M expr.c
M map.c
M qbe.c
M util.h
M cc.h => cc.h +1 -1
@@ 331,7 331,7 @@ struct expr {
			double f;
		} constant;
		struct {
			char *data;
			unsigned char *data;
			size_t size;
		} string;
		struct {

M expr.c => expr.c +5 -4
@@ 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) {

M map.c => map.c +1 -1
@@ 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;

M qbe.c => qbe.c +2 -2
@@ 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)

M util.h => util.h +2 -2
@@ 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 *);