1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-29 12:45:20 +02:00

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

This commit is contained in:
Werner Almesberger 2016-08-22 05:06:05 -03:00
parent 1a5c8a564c
commit b5a29b85da
5 changed files with 24 additions and 23 deletions

View File

@ -89,7 +89,7 @@ static bool try_related(struct file *file)
return 0; return 0;
} }
progress(1, "reading %s\n", tmp); progress(1, "reading %s", tmp);
free((char *) file->name); free((char *) file->name);
file->name = tmp; file->name = tmp;
@ -138,14 +138,14 @@ static void *open_vcs(struct file *file)
free(tmp); free(tmp);
return file->vcs; return file->vcs;
} }
progress(2, "could not open %s:%s\n", tmp, colon + 1); progress(2, "could not open %s:%s", tmp, colon + 1);
return NULL; return NULL;
} else { } else {
file->vcs = vcs_git_open(NULL, file->name, file->vcs = vcs_git_open(NULL, file->name,
file->related ? file->related->vcs : NULL); file->related ? file->related->vcs : NULL);
if (file->vcs) if (file->vcs)
return file->vcs; return file->vcs;
progress(2, "could not open %s\n", file->name); progress(2, "could not open %s", file->name);
return NULL; return NULL;
} }
} }
@ -174,7 +174,7 @@ bool file_open(struct file *file, const char *name, const struct file *related)
file->file = fopen(name, "r"); file->file = fopen(name, "r");
if (file->file) { if (file->file) {
progress(1, "reading %s\n", name); progress(1, "reading %s", name);
return 1; return 1;
} }
@ -211,7 +211,7 @@ bool file_open_revision(struct file *file, const char *rev, const char *name,
file->vcs = vcs_git_open(rev, name, related ? related->vcs : NULL); file->vcs = vcs_git_open(rev, name, related ? related->vcs : NULL);
if (file->vcs) if (file->vcs)
return 1; return 1;
progress(2, "could not open %s at %s\n", name, rev); progress(2, "could not open %s at %s", name, rev);
return 0; return 0;
} }

View File

@ -76,7 +76,7 @@ static git_repository *select_repo(const char *path)
* So we trim off elements until we find a repository. * So we trim off elements until we find a repository.
*/ */
while (1) { while (1) {
progress(3, "trying \"%s\"\n", tmp); progress(3, "trying \"%s\"", tmp);
if (!git_repository_open_ext(&repo, *tmp ? tmp : "/", if (!git_repository_open_ext(&repo, *tmp ? tmp : "/",
GIT_REPOSITORY_OPEN_CROSS_FS, NULL)) GIT_REPOSITORY_OPEN_CROSS_FS, NULL))
break; break;
@ -155,7 +155,7 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
end = tail = strchr(tmp, 0); end = tail = strchr(tmp, 0);
while (1) { while (1) {
progress(3, "probing \"%s\" tail \"%s\"\n", tmp, tail); progress(3, "probing \"%s\" tail \"%s\"", tmp, tail);
if (stat(tmp, &path_st) == 0) if (stat(tmp, &path_st) == 0)
break; break;
if (!tmp[1]) if (!tmp[1])
@ -169,7 +169,7 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
/* remove . and .. from tail */ /* remove . and .. from tail */
progress(3, "input tail \"%s\"\n", tail); progress(3, "input tail \"%s\"", tail);
from = to = tail; from = to = tail;
while (1) { while (1) {
if (!strncmp(from, "./", 2)) { if (!strncmp(from, "./", 2)) {
@ -207,12 +207,12 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
to--; to--;
} }
*to = 0; *to = 0;
progress(3, "output tail \"%s\"\n", tail); progress(3, "output tail \"%s\"", tail);
/* resolve all symlinks */ /* resolve all symlinks */
real = realpath(tmp, NULL); real = realpath(tmp, NULL);
progress(3, "realpath(\"%s\") = \"%s\"\n", tmp, real); progress(3, "realpath(\"%s\") = \"%s\"", tmp, real);
/* append tail */ /* append tail */
@ -226,13 +226,13 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
free(tmp); free(tmp);
tmp = tmp2; tmp = tmp2;
progress(2, "full object path \"%s\"\n", tmp); progress(2, "full object path \"%s\"", tmp);
/* find which part of our path is inside the repo */ /* find which part of our path is inside the repo */
end = tail = strchr(tmp, 0); end = tail = strchr(tmp, 0);
while (1) { while (1) {
progress(3, "trying \"%s\" tail \"%s\"\n", tmp, tail); progress(3, "trying \"%s\" tail \"%s\"", tmp, tail);
if (stat(tmp, &path_st) == 0 && if (stat(tmp, &path_st) == 0 &&
path_st.st_dev == repo_st.st_dev && path_st.st_dev == repo_st.st_dev &&
@ -252,7 +252,7 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
*slash = 0; *slash = 0;
} }
progress(2, "path in repo \"%s\"\n", tail); progress(2, "path in repo \"%s\"", tail);
tmp2 = stralloc(tail); tmp2 = stralloc(tail);
free(tmp); free(tmp);
@ -278,7 +278,7 @@ static git_tree_entry *find_file(git_repository *repo, git_tree *tree,
if (len >= 5 && !strcmp(repo_path + len - 5, "/.git")) if (len >= 5 && !strcmp(repo_path + len - 5, "/.git"))
repo_path[len == 5 ? 1 : len - 5] = 0; repo_path[len == 5 ? 1 : len - 5] = 0;
progress(2, "repo dir \"%s\"\n", repo_path); progress(2, "repo dir \"%s\"", repo_path);
canon_path = canonical_path_into_repo(repo_path, path); canon_path = canonical_path_into_repo(repo_path, path);
free(repo_path); free(repo_path);
@ -320,7 +320,7 @@ static const void *get_data(struct vcs_git *vcs_git, git_tree_entry *entry,
fatal("%s\n", e->message); fatal("%s\n", e->message);
} }
progress(3, "object %s\n", buf.ptr); progress(3, "object %s", buf.ptr);
git_buf_free(&buf); git_buf_free(&buf);
} }
blob = (git_blob *) obj; blob = (git_blob *) obj;
@ -351,7 +351,7 @@ static bool access_file_data(struct vcs_git *vcs_git, const char *name)
entry = find_file(vcs_git->repo, vcs_git->tree, name); entry = find_file(vcs_git->repo, vcs_git->tree, name);
if (!entry) if (!entry)
return 0; return 0;
progress(1, "reading %s\n", name); progress(1, "reading %s", name);
vcs_git->data = get_data(vcs_git, entry, &vcs_git->size); vcs_git->data = get_data(vcs_git, entry, &vcs_git->size);
return 1; return 1;
@ -386,7 +386,7 @@ static bool related_only_repo(struct vcs_git *vcs_git)
const struct vcs_git *related = vcs_git->related; const struct vcs_git *related = vcs_git->related;
char *tmp; char *tmp;
progress(2, "trying graft \"%s\" \"%s\"\n", progress(2, "trying graft \"%s\" \"%s\"",
related->name, vcs_git->name); related->name, vcs_git->name);
tmp = file_graft_relative(related->name, vcs_git->name); tmp = file_graft_relative(related->name, vcs_git->name);
if (!tmp) if (!tmp)
@ -446,7 +446,7 @@ struct vcs_git *vcs_git_open(const char *revision, const char *name,
error("%s: not found", name); error("%s: not found", name);
goto fail; goto fail;
} }
progress(2, "using repository %s\n", progress(2, "using repository %s",
git_repository_path(vcs_git->repo)); git_repository_path(vcs_git->repo));
if (!revision) if (!revision)

View File

@ -85,7 +85,7 @@ static void recurse(struct hist *h,
n = git_commit_parentcount(h->commit); n = git_commit_parentcount(h->commit);
if (verbose > 2) if (verbose > 2)
progress(3, "commit %p: %u + %u\n", h->commit, n_branches, n); progress(3, "commit %p: %u + %u", h->commit, n_branches, n);
b = alloca(sizeof(struct hist) * (n_branches - 1 + n)); b = alloca(sizeof(struct hist) * (n_branches - 1 + n));
n_branches--; n_branches--;

View File

@ -118,7 +118,7 @@ static void hover_update(int x, int y)
if (sp != old_sp) if (sp != old_sp)
return; return;
progress(3, "hover_update %s\n", state()); progress(3, "hover_update %s", state());
switch (sp->state) { switch (sp->state) {
case input_idle: case input_idle:
@ -180,7 +180,7 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
if (!sp) if (!sp)
return TRUE; return TRUE;
progress(3, "motion %s\n", state()); progress(3, "motion %s", state());
switch (sp->state) { switch (sp->state) {
case input_idle: case input_idle:
@ -221,7 +221,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
if (event->button != 1) if (event->button != 1)
return TRUE; return TRUE;
progress(3, "press %s\n", state()); progress(3, "press %s", state());
switch (sp->state) { switch (sp->state) {
case input_idle: case input_idle:
@ -256,7 +256,7 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
if (event->button != 1) if (event->button != 1)
return TRUE; return TRUE;
progress(3, "release %s\n", state()); progress(3, "release %s", state());
switch (sp->state) { switch (sp->state) {
case input_idle: case input_idle:

View File

@ -85,4 +85,5 @@ void progress(unsigned level, const char *fmt, ...)
fprintf(stderr, "%*s", level * 2, ""); fprintf(stderr, "%*s", level * 2, "");
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
va_end(ap); va_end(ap);
fprintf(stderr, "\n");
} }