This is an simple patch for remove prefix "::" from messages, all magic chars are in function `info_msg' like "warning: : and "error: " prefixes in `pm_*printf'. It will be better for translators to, and it's first step prepare for colorize output support for pacman. --- src/pacman/callback.c | 32 +++++++++++++++++--------------- src/pacman/remove.c | 4 ++-- src/pacman/sync.c | 18 +++++++++--------- src/pacman/upgrade.c | 10 +++++----- src/pacman/util.c | 16 ++++++++++++++++ src/pacman/util.h | 1 + 6 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/pacman/callback.c b/src/pacman/callback.c index e3feea1..263a8cd 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -227,7 +227,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) printf("%s", (char*)data1); break; case PM_TRANS_EVT_RETRIEVE_START: - printf(_(":: Retrieving packages from %s...\n"), (char*)data1); + info_msg(_("Retrieving packages from %s...\n"), (char*)data1); break; case PM_TRANS_EVT_DISKSPACE_START: if(config->noprogressbar) { @@ -256,29 +256,30 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, { switch(event) { case PM_TRANS_CONV_INSTALL_IGNOREPKG: - *response = yesno(_(":: %s is in IgnorePkg/IgnoreGroup. Install anyway?"), - alpm_pkg_get_name(data1)); + info_msg(_("%s is in IgnorePkg/IgnoreGroup\n"), alpm_pkg_get_name(data1)); + *response = yesno(_("Install %s anyway?"), alpm_pkg_get_name(data1)); break; case PM_TRANS_CONV_REPLACE_PKG: - *response = yesno(_(":: Replace %s with %s/%s?"), + info_msg(_("%s replace %s/%s\n"), alpm_pkg_get_name(data1), (char *)data3, alpm_pkg_get_name(data2)); + *response = yesno(_("Replace %s?"), alpm_pkg_get_name(data1)); break; case PM_TRANS_CONV_CONFLICT_PKG: /* data parameters: target package, local package, conflict (strings) */ /* print conflict only if it contains new information */ if(strcmp(data1, data3) == 0 || strcmp(data2, data3) == 0) { - *response = noyes(_(":: %s and %s are in conflict. Remove %s?"), + info_msg(_("%s and %s are in conflict\n"), (char *)data1, - (char *)data2, (char *)data2); + *response = noyes(_("Remove %s?"), (char *)data2); } else { - *response = noyes(_(":: %s and %s are in conflict (%s). Remove %s?"), + info_msg(_("%s and %s are in conflict (%s)\n"), (char *)data1, (char *)data2, - (char *)data3, - (char *)data2); + (char *)data3); + *response = noyes(_("Remove %s?"), (char *)data2); } break; case PM_TRANS_CONV_REMOVE_PKGS: @@ -289,9 +290,9 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, namelist = alpm_list_add(namelist, (char *)alpm_pkg_get_name(i->data)); } - printf(_n( - ":: The following package cannot be upgraded due to unresolvable dependencies:\n", - ":: The following packages cannot be upgraded due to unresolvable dependencies:\n", + info_msg(_n( + "The following package cannot be upgraded due to unresolvable dependencies:\n", + "The following packages cannot be upgraded due to unresolvable dependencies:\n", alpm_list_count(namelist))); list_display(" ", namelist); printf("\n"); @@ -304,16 +305,17 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, break; case PM_TRANS_CONV_LOCAL_NEWER: if(!config->op_s_downloadonly) { - *response = yesno(_(":: %s-%s: local version is newer. Upgrade anyway?"), + info_msg(_("%s-%s: local version is newer\n"), alpm_pkg_get_name(data1), alpm_pkg_get_version(data1)); + *response = yesno(_("Upgrade %s anyway?"), alpm_pkg_get_name(data1)); } else { *response = 1; } break; case PM_TRANS_CONV_CORRUPTED_PKG: - *response = yesno(_(":: File %s is corrupted. Do you want to delete it?"), - (char *)data1); + info_msg(_("File %s is corrupted\n"), (char *)data1); + *response = yesno(_("Delete corrupted file?")); break; } if(config->noask) { diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 52f92ec..07a5aec 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -79,7 +79,7 @@ int pacman_remove(alpm_list_t *targets) case PM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { char *pkg = alpm_list_getdata(i); - printf(_(":: package %s does not have a valid architecture\n"), pkg); + info_msg(_("package %s does not have a valid architecture\n"), pkg); } break; case PM_ERR_UNSATISFIED_DEPS: @@ -87,7 +87,7 @@ int pacman_remove(alpm_list_t *targets) pmdepmissing_t *miss = alpm_list_getdata(i); pmdepend_t *dep = alpm_miss_get_dep(miss); char *depstring = alpm_dep_compute_string(dep); - printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), + info_msg(_("%s: requires %s\n"), alpm_miss_get_target(miss), depstring); free(depstring); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 278f15e..579f6b4 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -644,7 +644,7 @@ static int sync_trans(alpm_list_t *targets) } if(config->op_s_upgrade) { - printf(_(":: Starting full system upgrade...\n")); + info_msg(_("Starting full system upgrade...\n")); alpm_logaction("starting full system upgrade\n"); if(alpm_sync_sysupgrade(config->op_s_upgrade >= 2) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, "%s\n", alpm_strerrorlast()); @@ -662,7 +662,7 @@ static int sync_trans(alpm_list_t *targets) case PM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { char *pkg = alpm_list_getdata(i); - printf(_(":: package %s does not have a valid architecture\n"), pkg); + info_msg(_("package %s does not have a valid architecture\n"), pkg); } break; case PM_ERR_UNSATISFIED_DEPS: @@ -670,7 +670,7 @@ static int sync_trans(alpm_list_t *targets) pmdepmissing_t *miss = alpm_list_getdata(i); pmdepend_t *dep = alpm_miss_get_dep(miss); char *depstring = alpm_dep_compute_string(dep); - printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), + info_msg(_("%s: requires %s\n"), alpm_miss_get_target(miss), depstring); free(depstring); } @@ -683,9 +683,9 @@ static int sync_trans(alpm_list_t *targets) const char *reason = alpm_conflict_get_reason(conflict); /* only print reason if it contains new information */ if(strcmp(package1, reason) == 0 || strcmp(package2, reason) == 0) { - printf(_(":: %s and %s are in conflict\n"), package1, package2); + info_msg(_("%s and %s are in conflict\n"), package1, package2); } else { - printf(_(":: %s and %s are in conflict (%s)\n"), package1, package2, reason); + info_msg(_("%s and %s are in conflict (%s)\n"), package1, package2, reason); } } break; @@ -806,7 +806,7 @@ int pacman_sync(alpm_list_t *targets) if(config->op_s_sync) { /* grab a fresh package list */ - printf(_(":: Synchronizing package databases...\n")); + info_msg(_("Synchronizing package databases...\n")); alpm_logaction("synchronizing package lists\n"); if(!sync_synctree(config->op_s_sync, sync_dbs)) { return(1); @@ -855,10 +855,10 @@ int pacman_sync(alpm_list_t *targets) alpm_list_t *tmp = NULL; if(config->op_s_upgrade || (tmp = alpm_list_diff(targets, packages, (alpm_list_fn_cmp)strcmp))) { alpm_list_free(tmp); - printf(_(":: The following packages should be upgraded first :\n")); + info_msg(_("The following packages should be upgraded first :\n")); list_display(" ", packages); - if(yesno(_(":: Do you want to cancel the current operation\n" - ":: and upgrade these packages now?"))) { + if(yesno(_("Do you want to cancel the current operation\n" + "and upgrade these packages now?"))) { FREELIST(targs); targs = packages; config->flags = 0; diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 92a477e..e3c9629 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -88,7 +88,7 @@ int pacman_upgrade(alpm_list_t *targets) case PM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { char *pkg = alpm_list_getdata(i); - printf(_(":: package %s does not have a valid architecture\n"), pkg); + info_msg(_("package %s does not have a valid architecture\n"), pkg); } break; case PM_ERR_UNSATISFIED_DEPS: @@ -98,9 +98,9 @@ int pacman_upgrade(alpm_list_t *targets) char *depstring = alpm_dep_compute_string(dep); /* TODO indicate if the error was a virtual package or not: - * :: %s: requires %s, provided by %s + * %s: requires %s, provided by %s */ - printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), + info_msg(_("%s: requires %s\n"), alpm_miss_get_target(miss), depstring); free(depstring); } @@ -113,9 +113,9 @@ int pacman_upgrade(alpm_list_t *targets) const char *reason = alpm_conflict_get_reason(conflict); /* only print reason if it contains new information */ if(strcmp(package1, reason) == 0 || strcmp(package2, reason) == 0) { - printf(_(":: %s and %s are in conflict\n"), package1, package2); + info_msg(_("%s and %s are in conflict\n"), package1, package2); } else { - printf(_(":: %s and %s are in conflict (%s)\n"), package1, package2, reason); + info_msg(_("%s and %s are in conflict (%s)\n"), package1, package2, reason); } } break; diff --git a/src/pacman/util.c b/src/pacman/util.c index d91d1d4..e4974b0 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -750,6 +750,22 @@ int noyes(char *fmt, ...) return(ret); } +int info_msg(char *fmt, ...) +{ + int ret; + va_list args; + + /* print a prefix to the message */ + printf(":: "); + + /* print the message using va_arg list */ + va_start(args, fmt); + ret = printf(fmt, args); + va_end(args); + + return(ret); +} + int pm_printf(pmloglevel_t level, const char *format, ...) { int ret; diff --git a/src/pacman/util.h b/src/pacman/util.h index a5c382d..0a5e10e 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -61,6 +61,7 @@ void display_optdepends(pmpkg_t *pkg); void print_packages(const alpm_list_t *packages); int yesno(char *fmt, ...); int noyes(char *fmt, ...); +int info_msg(char *fmt, ...); int pm_printf(pmloglevel_t level, const char *format, ...) __attribute__((format(printf,2,3))); int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...) __attribute__((format(printf,3,4))); int pm_asprintf(char **string, const char *format, ...); -- 1.7.3.5