[pacman-dev] [PATCH 02/16] remove :: prefix from all message

Andrew Gregory andrew.gregory.8 at gmail.com
Fri Mar 1 23:31:50 EST 2013


On 03/01/13 at 04:32pm, Simon Gomizelj wrote:
> This will substantially simplify the logic to add colours to messages.
> 
> Signed-off-by: Simon Gomizelj <simongmzlj at gmail.com>
> ---
>  src/pacman/callback.c | 26 +++++++++++++-------------
>  src/pacman/remove.c   |  2 +-
>  src/pacman/sync.c     | 14 +++++++-------
>  src/pacman/util.c     | 15 ++++++++++++++-
>  src/pacman/util.h     |  1 +
>  5 files changed, 36 insertions(+), 22 deletions(-)
> 
> diff --git a/src/pacman/callback.c b/src/pacman/callback.c
> index edd5b39..7014377 100644
> --- a/src/pacman/callback.c
> +++ b/src/pacman/callback.c
> @@ -244,7 +244,7 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
>  			fputs((const char *)data1, stdout);
>  			break;
>  		case ALPM_EVENT_RETRIEVE_START:
> -			printf(_(":: Retrieving packages ...\n"));
> +			colon_printf(_("Retrieving packages ...\n"));
>  			break;
>  		case ALPM_EVENT_DISKSPACE_START:
>  			if(config->noprogressbar) {
> @@ -252,7 +252,7 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
>  			}
>  			break;
>  		case ALPM_EVENT_OPTDEP_REQUIRED:
> -			printf(_(":: %s optionally requires %s\n"), alpm_pkg_get_name(data1),
> +			printf(_("%s optionally requires %s\n"), alpm_pkg_get_name(data1),

Did you intend to remove the colon and not change this to
colon_printf?

>  				alpm_dep_compute_string(data2));
>  			break;
>  		case ALPM_EVENT_DATABASE_MISSING:

<snip>

> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 3270c74..d5fc32c 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -1219,7 +1219,6 @@ static void display_repo_list(const char *dbname, alpm_list_t *list,
>  {
>  	const char *prefix = "  ";
>  
> -	printf(":: ");
>  	printf(_("Repository %s\n"), dbname);

Did you intend to remove the colon and not change this to
colon_printf?

>  	list_display(prefix, list, cols);
>  }
> @@ -1461,6 +1460,7 @@ static int question(short preset, char *fmt, va_list args)
>  	fflush(stdout);
>  	fflush(stderr);
>  
> +	fprintf(stream, ":: ");

You can use fputs here instead of fprintf.

>  	vfprintf(stream, fmt, args);
>  
>  	if(preset) {
> @@ -1522,6 +1522,19 @@ int noyes(char *fmt, ...)
>  	return ret;
>  }
>  
> +int colon_printf(const char *fmt, ...)
> +{
> +	int ret;
> +	va_list args;
> +
> +	printf(":: ");

Any reason not to add a colon_vprintf that could be used here and
consolidate all of the colon prefixing in one place instead of having
it in colon_printf and here?

> +	va_start(args, fmt);
> +	ret = vprintf(fmt, args);
> +	va_end(args);
> +
> +	return ret;
> +}
> +
>  int pm_printf(alpm_loglevel_t level, const char *format, ...)
>  {
>  	int ret;
> diff --git a/src/pacman/util.h b/src/pacman/util.h
> index 2d1e698..f579b7e 100644
> --- a/src/pacman/util.h
> +++ b/src/pacman/util.h
> @@ -72,6 +72,7 @@ void print_packages(const alpm_list_t *packages);
>  void select_display(const alpm_list_t *pkglist);
>  int select_question(int count);
>  int multiselect_question(char *array, int count);
> +int colon_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
>  int yesno(char *fmt, ...) __attribute__((format(printf, 1, 2)));
>  int noyes(char *fmt, ...) __attribute__((format(printf, 1, 2)));
>  
> -- 
> 1.8.1.4
> 
> 

apg


More information about the pacman-dev mailing list