# SRCFILES += $(wildcard ccan/*/*.c)
#CCAN_CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations
-CCAN_CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations
+CCAN_CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -DCCAN_STR_DEBUG=1
CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN) -Werror
#define CCAN_CONFIG_H
#define _GNU_SOURCE /* Always use GNU extensions. */
#define CCAN_COMPILER "cc"
-#define CCAN_CFLAGS "-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations"
+#define CCAN_CFLAGS "-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -DCCAN_STR_DEBUG=1"
#define HAVE_ALIGNOF 1
#define HAVE_ASPRINTF 1
ALL_TOOLS = tools/configurator/configurator tools/ccan_depends tools/doc_extract tools/namespacize tools/ccanlint/ccanlint
-DEP_OBJS = tools/depends.o tools/compile.o tools/tools.o ccan/str_talloc/str_talloc.o ccan/str/str.o ccan/grab_file/grab_file.o ccan/talloc/talloc.o ccan/noerr/noerr.o ccan/read_write_all/read_write_all.o
+DEP_OBJS = tools/depends.o tools/compile.o tools/tools.o ccan/str_talloc/str_talloc.o ccan/str/str.o ccan/str/debug.o ccan/grab_file/grab_file.o ccan/talloc/talloc.o ccan/noerr/noerr.o ccan/read_write_all/read_write_all.o
.PHONY: tools
tools: $(ALL_TOOLS)
tools/tools.o \
tools/compile.o \
ccan/str_talloc/str_talloc.o ccan/grab_file/grab_file.o \
- ccan/str/str.o \
+ ccan/str/str.o ccan/str/debug.o \
ccan/asort/asort.o \
ccan/btree/btree.o \
ccan/talloc/talloc.o ccan/noerr/noerr.o \
if (string[i] == '\\') {
char repl;
unsigned len = 0;
- char *p = strchr(mapfrom, string[i+1]);
+ const char *p = strchr(mapfrom, string[i+1]);
if (p) {
repl = mapto[p - mapfrom];
len = 1;
repl = (string[i+2]-'0')*16
+ string[i+3]-'0';
len = 3;
- } else if (isdigit(string[i+1])) {
+ } else if (cisdigit(string[i+1])) {
repl = (string[i+2]-'0')*8*8
+ (string[i+3]-'0')*8
+ (string[i+4]-'0');
/* We expect the ccan dir to be two levels above module dir. */
if (!ccan_dir) {
- char *p;
- ccan_dir = talloc_strdup(NULL, m->dir);
- p = strrchr(ccan_dir, '/');
+ char *p, *dir;
+ dir = talloc_strdup(NULL, m->dir);
+ p = strrchr(dir, '/');
if (!p)
errx(1, "I expect the ccan root directory in ../..");
*p = '\0';
- p = strrchr(ccan_dir, '/');
+ p = strrchr(dir, '/');
if (!p)
errx(1, "I expect the ccan root directory in ../..");
*p = '\0';
+ ccan_dir = dir;
}
add_files(m, "");
unsigned int toklen;
*line += strspn(*line, " \t");
- if (isalnum(token[0]) || token[0] == '_')
+ if (cisalnum(token[0]) || token[0] == '_')
toklen = strspn(*line, IDENT_CHARS);
else {
/* FIXME: real tokenizer handles ++ and other multi-chars. */
static char *add_func(char *others, const char *line)
{
const char *p, *end = strchr(line, '(') - 1;
- while (isspace(*end)) {
+ while (cisspace(*end)) {
end--;
if (end == line)
return others;
}
- for (p = end; isalnum(*p) || *p == '_'; p--) {
+ for (p = end; cisalnum(*p) || *p == '_'; p--) {
if (p == line)
return others;
}
const char *line = lines[i] + strspn(lines[i], " \t");
unsigned len = strspn(line, IDENT_CHARS);
- if (!line[0] || isspace(line[0]) || strstarts(line, "//"))
+ if (!line[0] || cisspace(line[0]) || strstarts(line, "//"))
continue;
/* The winners. */
/* Single identifier then operator == inside function. */
if (last_ended && len
- && ispunct(line[len+strspn(line+len, " ")])) {
+ && cispunct(line[len+strspn(line+len, " ")])) {
*why = "starts with identifier then punctuation";
return true;
}
} else {
/* Character at start of line, with ( and no ;
* == function start. Ignore comments. */
- if (!isspace(line[0])
+ if (!cisspace(line[0])
&& strchr(line, '(')
&& !strchr(line, ';')
&& !strstr(line, "//")) {
va_copy(ap, *args);
- if (isspace(fmt[0])) {
+ if (cisspace(fmt[0])) {
/* One format space can swallow many input spaces */
ret = false;
- while (isspace(input[0])) {
+ while (cisspace(input[0])) {
if (scan_forv(ctx, ++input, fmt+1, &ap)) {
ret = true;
break;
unsigned int i;
for (i = 0; name[i]; i++) {
- if (isalnum(name[i]))
+ if (cisalnum(name[i]))
name[i] = toupper(name[i]);
else
name[i] = '_';
for (p = contents; *p; p++) {
if (*p == '\n')
state = LINESTART;
- else if (!isspace(*p)) {
+ else if (!cisspace(*p)) {
if (state == LINESTART && *p == '#')
state = HASH;
else if (state==HASH && !strncmp(p, "define", 6)) {
return answer;
}
/* Compress whitespace into a single ' ' */
- if (isspace(c)) {
+ if (cisspace(c)) {
c = ' ';
- while (isspace((*p)[1]))
+ while (cisspace((*p)[1]))
(*p)++;
} else if (c == '{' || c == '(' || c == '[') {
if (c == '(')
while ((p = strstr(p, str)) != NULL) {
/* Check it's not in the middle of a word. */
- if (p > f && (isalnum(p[-1]) || p[-1] == '_')) {
+ if (p > f && (cisalnum(p[-1]) || p[-1] == '_')) {
p++;
continue;
}
- if (isalnum(p[strlen(str)]) || p[strlen(str)] == '_') {
+ if (cisalnum(p[strlen(str)]) || p[strlen(str)] == '_') {
p++;
continue;
}
off = p - file;
memcpy(new, file, off);
- if (isupper(repl->string[0]))
+ if (cisupper(repl->string[0]))
memcpy(new + off, "CCAN_", 5);
else
memcpy(new + off, "ccan_", 5);