1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 01:41:53 +02:00

eeshow/diag.c (error): don't require user to supply newline

This commit is contained in:
Werner Almesberger 2016-08-22 05:04:23 -03:00
parent 1812d1af86
commit 1a5c8a564c
6 changed files with 20 additions and 19 deletions

View File

@ -194,7 +194,7 @@ bool file_open(struct file *file, const char *name, const struct file *related)
if (file->vcs) if (file->vcs)
return 1; return 1;
error("could not open %s\n", name); error("could not open %s", name);
fail: fail:
free((char *) file->name); free((char *) file->name);
return 0; return 0;

View File

@ -286,7 +286,7 @@ static git_tree_entry *find_file(git_repository *repo, git_tree *tree,
if (git_tree_entry_bypath(&entry, tree, canon_path)) { if (git_tree_entry_bypath(&entry, tree, canon_path)) {
const git_error *e = giterr_last(); const git_error *e = giterr_last();
error("%s: %s\n", path, e->message); error("%s: %s", path, e->message);
free(canon_path); free(canon_path);
return NULL; return NULL;
} }
@ -443,7 +443,7 @@ struct vcs_git *vcs_git_open(const char *revision, const char *name,
vcs_git->repo = select_repo(name); vcs_git->repo = select_repo(name);
if (!vcs_git->repo) { if (!vcs_git->repo) {
error("%s: not found\n", name); error("%s: not found", name);
goto fail; goto fail;
} }
progress(2, "using repository %s\n", progress(2, "using repository %s\n",

View File

@ -398,7 +398,7 @@ const struct comp *lib_find(const struct lib *lib, const char *name)
if (!strcmp(alias->name, name)) if (!strcmp(alias->name, name))
return comp; return comp;
} }
error("\"%s\" not found\n", name); error("\"%s\" not found", name);
return NULL; return NULL;
} }

View File

@ -49,7 +49,7 @@ static bool get_coord(const struct expr *e,
float f = strtof(e->s, &end); float f = strtof(e->s, &end);
if (*end) { if (*end) {
error("no a number \"%s\"\n", e->s); error("no a number \"%s\"", e->s);
return 0; return 0;
} }
if (n++) if (n++)
@ -62,12 +62,12 @@ static bool get_coord(const struct expr *e,
switch (n) { switch (n) {
case 0: case 0:
case 1: case 1:
error("no enough coordinates\n"); error("no enough coordinates");
return 0; return 0;
case 2: case 2:
return 1; return 1;
default: default:
error("too many coordinates\n"); error("too many coordinates");
return 0; return 0;
} }
} }
@ -86,7 +86,7 @@ static bool get_size(const struct expr *e, float *x, float *y)
f = strtof(e->s, &end); f = strtof(e->s, &end);
if (*end) { if (*end) {
error("no a number \"%s\"\n", e->s); error("no a number \"%s\"", e->s);
return 0; return 0;
} }
if (n++) if (n++)
@ -98,12 +98,12 @@ static bool get_size(const struct expr *e, float *x, float *y)
switch (n) { switch (n) {
case 0: case 0:
case 1: case 1:
error("no enough coordinates\n"); error("no enough coordinates");
return 0; return 0;
case 2: case 2:
return 1; return 1;
default: default:
error("too many coordinates\n"); error("too many coordinates");
return 0; return 0;
} }
} }
@ -116,7 +116,7 @@ static bool get_float(const struct expr *e, float *f)
*f = atof(e->s); // @@@ error checking *f = atof(e->s); // @@@ error checking
return 1; return 1;
} }
error("no number found\n"); error("no number found");
return 0; return 0;
} }
@ -129,7 +129,7 @@ static bool get_int(const struct expr *e, int *n)
*n = atoi(e->s); // @@@ error checking *n = atoi(e->s); // @@@ error checking
return 1; return 1;
} }
error("no number found\n"); error("no number foundn");
return 0; return 0;
} }
@ -263,7 +263,7 @@ static bool process_obj(struct pl_ctx *pl, const struct expr *e,
for (; e; e = e->next) { for (; e; e = e->next) {
if (e->s) { if (e->s) {
if (obj->s) { if (obj->s) {
error("multiple strings\n"); error("multiple strings");
return 0; return 0;
} }
obj->s = stralloc(e->s); obj->s = stralloc(e->s);
@ -365,7 +365,7 @@ static bool process(struct pl_ctx *p, const struct expr *e)
return process_layout(p, e->e->next); return process_layout(p, e->e->next);
e = e->next; e = e->next;
} }
error("no layout information found\n"); error("no layout information found");
return 0; return 0;
} }

View File

@ -138,7 +138,7 @@ bool sexpr_parse(struct sexpr_ctx *ctx, const char *s)
case ')': case ')':
if (!ctx->sp->prev) { if (!ctx->sp->prev) {
ctx->state = failed; ctx->state = failed;
error("too many\n )"); error("too many )");
break; break;
} }
ctx->sp = ctx->sp->prev; ctx->sp = ctx->sp->prev;
@ -177,7 +177,7 @@ bool sexpr_parse(struct sexpr_ctx *ctx, const char *s)
case '\r': case '\r':
case '\n': case '\n':
ctx->state = failed; ctx->state = failed;
error("newline in string\n"); error("newline in string");
break; break;
case '"': case '"':
ctx->state = idle; ctx->state = idle;
@ -195,7 +195,7 @@ bool sexpr_parse(struct sexpr_ctx *ctx, const char *s)
case '\r': case '\r':
case '\n': case '\n':
ctx->state = failed; ctx->state = failed;
error("newline in string\n"); error("newline in string");
break; break;
default: default:
ctx->state = string; ctx->state = string;
@ -323,11 +323,11 @@ void sexpr_abort(struct sexpr_ctx *ctx)
bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res) bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res)
{ {
if (ctx->sp != &ctx->stack) { if (ctx->sp != &ctx->stack) {
error("not enough )\n"); error("not enough )");
ctx->state = failed; ctx->state = failed;
} }
if (ctx->state != idle && ctx->state != failed) if (ctx->state != idle && ctx->state != failed)
error("invalid end state %d\n", ctx->state); error("invalid end state %d", ctx->state);
if (ctx->state != idle) { if (ctx->state != idle) {
sexpr_abort(ctx); sexpr_abort(ctx);
return 0; return 0;

View File

@ -59,6 +59,7 @@ void error(const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
va_end(ap); va_end(ap);
fprintf(stderr, "\n");
} }