From d8fd645c4c5aff5042da158d2471a2f72c443aad Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 9 Feb 2007 16:02:01 +0000 Subject: [PATCH] * Cleaned up direct pm_fprintf usage (move to MSG/ERR macros for now) * Moved some stderr output to stdout * Remove "RETRIEVE_LOCAL" trans event as libdownload handles local files --- src/pacman/log.c | 4 +++- src/pacman/pacman.c | 7 ++++--- src/pacman/trans.c | 29 +++++------------------------ 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/pacman/log.c b/src/pacman/log.c index 4bed22ae..e33001b3 100644 --- a/src/pacman/log.c +++ b/src/pacman/log.c @@ -173,7 +173,9 @@ int yesno(char *fmt, ...) va_start(args, fmt); vsnprintf(str, LOG_STR_LEN, fmt, args); va_end(args); - pm_fprintf(stderr, NL, str); + + /* Use stderr so questions are always displayed when redirecting output */ + ERR(NL, str); if(fgets(response, 32, stdin)) { /* trim whitespace and newlines */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 48c986a2..99248346 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -184,6 +184,7 @@ static void cleanup(int signum) return; } if(signum != 0 && config->op_d_vertest == 0) { + /* TODO why is this here? */ fprintf(stderr, "\n"); } @@ -295,7 +296,7 @@ static int parseargs(int argc, char *argv[]) case 2: logmask |= PM_LOG_DOWNLOAD; /*fall through */ case 1: logmask |= PM_LOG_DEBUG; break; default: - pm_fprintf(stderr, NL, _("error: '%s' is not a valid debug level"), optarg); + ERR(NL, _("error: '%s' is not a valid debug level"), optarg); return(1); } printf("logmask = %d\n", logmask); @@ -331,7 +332,7 @@ static int parseargs(int argc, char *argv[]) break; case 'b': if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) { - pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg); + ERR(NL, _("error: '%s' is not a valid db path\n"), optarg); return(1); } alpm_option_set_dbpath(optarg); @@ -361,7 +362,7 @@ static int parseargs(int argc, char *argv[]) break; case 'r': if(realpath(optarg, root) == NULL) { - pm_fprintf(stderr, NL, _("error: '%s' is not a valid root path\n"), optarg); + ERR(NL, _("error: '%s' is not a valid root path\n"), optarg); return(1); } alpm_option_set_root(strdup(root)); diff --git a/src/pacman/trans.c b/src/pacman/trans.c index 61c9e005..2a699ada 100644 --- a/src/pacman/trans.c +++ b/src/pacman/trans.c @@ -41,22 +41,6 @@ extern config_t *config; static int prevpercent=0; /* for less progressbar output */ -/* refactored function from cb_trans_evt */ -static void retrieve_local(void *data1, void *data2) -{ - const unsigned int maxcols = getcols(); - char out[PATH_MAX]; - unsigned int i; - - MSG(NL, " %s [", (char*)data1); - STRNCPY(out, (char*)data2, maxcols-42); - MSG(CL, "%s", out); - for(i = strlen(out); i < maxcols-43; i++) { - MSG(CL, " "); - } - fputs(_("] 100% LOCAL "), stdout); -} - /* Callback to handle transaction events */ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) @@ -65,7 +49,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) switch(event) { case PM_TRANS_EVT_CHECKDEPS_START: - pm_fprintf(stderr, NL, _("checking dependencies... ")); + MSG(NL, _("checking dependencies... ")); break; case PM_TRANS_EVT_FILECONFLICTS_START: if(config->noprogressbar) { @@ -73,13 +57,13 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) } break; case PM_TRANS_EVT_CLEANUP_START: - pm_fprintf(stderr, NL, _("cleaning up... ")); + MSG(NL, _("cleaning up... ")); break; case PM_TRANS_EVT_RESOLVEDEPS_START: - pm_fprintf(stderr, NL, _("resolving dependencies... ")); + MSG(NL, _("resolving dependencies... ")); break; case PM_TRANS_EVT_INTERCONFLICTS_START: - pm_fprintf(stderr, NL, _("looking for inter-conflicts... ")); + MSG(NL, _("looking for inter-conflicts... ")); break; case PM_TRANS_EVT_FILECONFLICTS_DONE: if(config->noprogressbar) { @@ -90,7 +74,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) case PM_TRANS_EVT_CLEANUP_DONE: case PM_TRANS_EVT_RESOLVEDEPS_DONE: case PM_TRANS_EVT_INTERCONFLICTS_DONE: - pm_fprintf(stderr, CL, _("done.\n")); + MSG(CL, _("done.\n")); break; case PM_TRANS_EVT_EXTRACT_DONE: if(config->noprogressbar) { @@ -167,9 +151,6 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1); fflush(stdout); break; - case PM_TRANS_EVT_RETRIEVE_LOCAL: - retrieve_local(data1, data2); - break; } }