Re: [PATCH 08/10] i18n: refactor "unrecognized %(foo) argument" strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 03 2021, Jean-Noël Avila via GitGitGadget wrote:

> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@xxxxxxx>
>
> Signed-off-by: Jean-Noël Avila <jn.avila@xxxxxxx>
> ---
>  ref-filter.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/ref-filter.c b/ref-filter.c
> index 08a3f839c97..554c2ba1b17 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -341,7 +341,7 @@ static int objectsize_atom_parser(struct ref_format *format, struct used_atom *a
>  		else
>  			oi.info.disk_sizep = &oi.disk_size;
>  	} else
> -		return strbuf_addf_ret(err, -1, _("unrecognized %%(objectsize) argument: %s"), arg);
> +		return strbuf_addf_ret(err, -1, _("unrecognized %%(%s) argument: %s"), "objectsize", arg);
>  	return 0;
>  }
>  
> @@ -374,7 +374,7 @@ static int subject_atom_parser(struct ref_format *format, struct used_atom *atom
>  	else if (!strcmp(arg, "sanitize"))
>  		atom->u.contents.option = C_SUB_SANITIZE;
>  	else
> -		return strbuf_addf_ret(err, -1, _("unrecognized %%(subject) argument: %s"), arg);
> +		return strbuf_addf_ret(err, -1, _("unrecognized %%(%s) argument: %s"), "subject", arg);
>  	return 0;
>  }
>  
> @@ -428,7 +428,7 @@ static int contents_atom_parser(struct ref_format *format, struct used_atom *ato
>  		if (strtoul_ui(arg, 10, &atom->u.contents.nlines))
>  			return strbuf_addf_ret(err, -1, _("positive value expected contents:lines=%s"), arg);
>  	} else
> -		return strbuf_addf_ret(err, -1, _("unrecognized %%(contents) argument: %s"), arg);
> +		return strbuf_addf_ret(err, -1, _("unrecognized %%(%s) argument: %s"), "contents", arg);
>  	return 0;
>  }
>  
> @@ -440,7 +440,7 @@ static int raw_atom_parser(struct ref_format *format, struct used_atom *atom,
>  	else if (!strcmp(arg, "size"))
>  		atom->u.raw_data.option = RAW_LENGTH;
>  	else
> -		return strbuf_addf_ret(err, -1, _("unrecognized %%(raw) argument: %s"), arg);
> +		return strbuf_addf_ret(err, -1, _("unrecognized %%(%s) argument: %s"), "raw", arg);
>  	return 0;
>  }
>  
> @@ -531,7 +531,7 @@ static int align_atom_parser(struct ref_format *format, struct used_atom *atom,
>  		else if ((position = parse_align_position(s)) >= 0)
>  			align->position = position;
>  		else {
> -			strbuf_addf(err, _("unrecognized %%(align) argument: %s"), s);
> +			strbuf_addf(err, _("unrecognized %%(%s) argument: %s"), "align", s);
>  			string_list_clear(&params, 0);
>  			return -1;
>  		}
> @@ -557,7 +557,7 @@ static int if_atom_parser(struct ref_format *format, struct used_atom *atom,
>  	} else if (skip_prefix(arg, "notequals=", &atom->u.if_then_else.str)) {
>  		atom->u.if_then_else.cmp_status = COMPARE_UNEQUAL;
>  	} else
> -		return strbuf_addf_ret(err, -1, _("unrecognized %%(if) argument: %s"), arg);
> +		return strbuf_addf_ret(err, -1, _("unrecognized %%(%s) argument: %s"), "if", arg);
>  	return 0;
>  }

Maybe too big a refactoring, but doesn't the parent function here know
the "name" and could just pass it along?

Or actually not pass it at all and just have all of these be say:

    return -2;

And we'd do the error one caller above this if we get a return code of
-2.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux