Hi all,

there 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.

--
Vojtěch "vogo" Gondžala
diff -Naur a/src/pacman/callback.c b/src/pacman/callback.c
--- a/src/pacman/callback.c	2011-01-15 08:47:40.882931914 +0100
+++ b/src/pacman/callback.c	2011-01-15 09:29:22.039598581 +0100
@@ -227,7 +227,7 @@
 			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 @@
 {
 	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 @@
 					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 @@
 			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 -Naur a/src/pacman/remove.c b/src/pacman/remove.c
--- a/src/pacman/remove.c	2011-01-09 13:33:08.923333337 +0100
+++ b/src/pacman/remove.c	2011-01-15 09:12:19.000000000 +0100
@@ -79,7 +79,7 @@
 			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 @@
 					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 -Naur a/src/pacman/sync.c b/src/pacman/sync.c
--- a/src/pacman/sync.c	2011-01-09 13:33:08.923333337 +0100
+++ b/src/pacman/sync.c	2011-01-15 09:14:30.000000000 +0100
@@ -644,7 +644,7 @@
 	}
 
 	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 @@
 			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 @@
 					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 @@
 					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 @@
 
 	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 @@
 			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 -Naur a/src/pacman/upgrade.c b/src/pacman/upgrade.c
--- a/src/pacman/upgrade.c	2011-01-09 13:33:08.923333337 +0100
+++ b/src/pacman/upgrade.c	2011-01-15 09:15:21.000000000 +0100
@@ -88,7 +88,7 @@
 			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 @@
 					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 @@
 					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 -Naur a/src/pacman/util.c b/src/pacman/util.c
--- a/src/pacman/util.c	2011-01-15 08:47:40.882931914 +0100
+++ b/src/pacman/util.c	2011-01-15 09:22:08.000000000 +0100
@@ -750,6 +750,22 @@
 	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 -Naur a/src/pacman/util.h b/src/pacman/util.h
--- a/src/pacman/util.h	2011-01-09 13:33:08.923333337 +0100
+++ b/src/pacman/util.h	2011-01-15 08:54:40.000000000 +0100
@@ -61,6 +61,7 @@
 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, ...);


Reply via email to