Re: [pacman-dev] [PATCH] pacman/pacman-conf: -i/--is-set switch, returns 0 if option set

2019-09-10 Thread Eli Schwartz
On 9/10/19 2:32 PM, Matthew Sexton wrote:
> Returns 1 if option not set. Returns 1 with error to stderr if
> flag does not exist. Case insensitive.

As discussed on IRC, it seems like this may be easier and more reliable
to achieve by using exit statuses. Instead of exiting 1 on a missing
flag, and returning 0 otherwise while printing out the key (or not)...

Maybe emulate e.g. grep. Return 2 if an error occurred, i.e. missing
option, and then even without -i, we can return 1 if the option is not set.

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH] pacman/pacman-conf: -i/--is-set switch, returns 0 if option set

2019-09-10 Thread Matthew Sexton
On Tuesday, September 10, 2019 2:32:03 PM EDT you wrote:
> Returns 1 if option not set. Returns 1 with error to stderr if
> flag does not exist. Case insensitive.
> 
> Signed-off-by: Matthew Sexton 
> ---
>  src/pacman/pacman-conf.c | 44 ++--
>  1 file changed, 42 insertions(+), 2 deletions(-)

Note: This patch is based off of my previous patch adding gettext localisation 
to pacman-conf. If attempting to apply this patch without that one first, the 
patch will most likely not apply. 

signature.asc
Description: This is a digitally signed message part.


[pacman-dev] [PATCH] pacman/pacman-conf: -i/--is-set switch, returns 0 if option set

2019-09-10 Thread Matthew Sexton
Returns 1 if option not set. Returns 1 with error to stderr if
flag does not exist. Case insensitive.

Signed-off-by: Matthew Sexton 
---
 src/pacman/pacman-conf.c | 44 ++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index efc62cdd..ada4bd9f 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -25,7 +25,7 @@
 const char *myname = "pacman-conf", *myver = "1.0.0";
 
 alpm_list_t *directives = NULL;
-char sep = '\n', *repo_name = NULL;
+char sep = '\n', *repo_name = NULL, *check_name = NULL;
 const char *config_file = NULL;
 int repo_list = 0, verbose = 0;
 
@@ -47,6 +47,7 @@ static void usage(int ret)
fputs(_("  -r, --repo=  query options for a specific repo\n"), 
stream);
fputs(_("  -v, --verbosealways show directive names\n"), 
stream);
fputs(_("  -l, --repo-list  list configured repositories\n"), 
stream);
+   fputs(_("  -i, --is-set returns 0 (successful) if config flag 
is set\n"), stream);
fputs(_("  -h, --help   display this help information\n"), 
stream);
fputs(_("  -V, --versiondisplay version information\n"), 
stream);
cleanup();
@@ -58,7 +59,7 @@ static void parse_opts(int argc, char **argv)
int c;
config_file = CONFFILE;
 
-   const char *short_opts = "c:hlR:r:Vv";
+   const char *short_opts = "c:h:i:lR:r:Vv";
struct option long_opts[] = {
{ "config", required_argument , NULL , 'c' },
{ "rootdir"   , required_argument , NULL , 'R' },
@@ -67,6 +68,7 @@ static void parse_opts(int argc, char **argv)
{ "verbose"   , no_argument   , NULL , 'v' },
{ "help"  , no_argument   , NULL , 'h' },
{ "version"   , no_argument   , NULL , 'V' },
+   { "is-set", required_argument , NULL , 'i' },
{ 0, 0, 0, 0 },
};
 
@@ -99,6 +101,9 @@ static void parse_opts(int argc, char **argv)
cleanup();
exit(0);
break;
+   case 'i':
+   check_name = optarg;
+   break;
case '?':
default:
usage(1);
@@ -391,6 +396,39 @@ static int list_directives(void)
return ret;
 }
 
+static int check_config_flags( void )
+{
+   /* 1 = flag-not-set. Regardless of whether flag exists or not */
+   int ret = 1;
+   short value;
+
+   if (strcasecmp(check_name, "Color") == 0) {
+   value = config->color;
+   } else if (strcasecmp(check_name, "UseSyslog") == 0) {
+   value = config->usesyslog;
+   } else if (strcasecmp(check_name, "TotalDownload") == 0) {
+   value = config->totaldownload;
+   } else if (strcasecmp(check_name, "CheckSpace") == 0) {
+   value = config->checkspace;
+   } else if (strcasecmp(check_name, "VerbosePkgLists") == 0) {
+   value = config->verbosepkglists;
+   } else if (strcasecmp(check_name, "DisableDownloadTimeout") == 0) {
+   value = config->disable_dl_timeout;
+   } else if (strcasecmp(check_name, "ILoveCandy") == 0) {
+   value = config->chomp;
+   } else {
+   value = -1;
+   }
+
+   if (value == -1) {
+   fprintf(stderr, _("error: unknown config option '%s'\n"), 
check_name);
+   ret = 1;
+   } else {
+   ret = !value;
+   }
+   return ret;
+}
+
 int main(int argc, char **argv)
 {
int ret = 0;
@@ -427,6 +465,8 @@ int main(int argc, char **argv)
list_repos();
} else if(repo_name) {
ret = list_repo_directives();
+   } else if (check_name) {
+   ret = check_config_flags();
} else {
ret = list_directives();
}
-- 
2.23.0


Re: [pacman-dev] [PATCH 2/4] libalpm: resolvedep(): don't compare names twice

2019-09-10 Thread Andrew Gregory
On 09/08/19 at 10:45pm, morganamilo wrote:
> If we failed to get the pkg from pkgcache then we know no satisfying
> package exists by name. So only compare provides.
> ---
>  lib/libalpm/deps.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
> index ce7869c3..322c4e7e 100644
> --- a/lib/libalpm/deps.c
> +++ b/lib/libalpm/deps.c
> @@ -698,7 +698,8 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, 
> alpm_depend_t *dep,
>   for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
>   alpm_pkg_t *pkg = j->data;
>   if((pkg->name_hash != dep->name_hash || 
> strcmp(pkg->name, dep->name) != 0)

Unrelated to this patch, but we probably shouldn't be filtering out
name matches here.  A package could provide a different version of
itself.

> - && _alpm_depcmp(pkg, dep) && 
> !alpm_pkg_find(excluding, pkg->name)) {
> + && _alpm_depcmp_provides(dep, 
> alpm_pkg_get_provides(pkg))
> + && !alpm_pkg_find(excluding, 
> pkg->name)) {
>   if(alpm_pkg_should_ignore(handle, pkg)) {
>   alpm_question_install_ignorepkg_t 
> question = {
>   .type = 
> ALPM_QUESTION_INSTALL_IGNOREPKG,
> -- 
> 2.23.0


Re: [pacman-dev] [PATCH] pacman: better handle -F when file is not found

2019-09-10 Thread Andrew Gregory
On 09/09/19 at 05:49pm, morganamilo wrote:
> Error messages are now printed.
> Pacman now returns 1 if any of the files queried are not found.
> ---
>  src/pacman/files.c | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/src/pacman/files.c b/src/pacman/files.c
> index 8e518486..c4351114 100644
> --- a/src/pacman/files.c
> +++ b/src/pacman/files.c
> @@ -115,7 +115,6 @@ static int files_search(alpm_list_t *syncs, alpm_list_t 
> *targets, int regex) {
>  
>   if(regex) {
>   if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | 
> REG_ICASE | REG_NEWLINE) != 0) {
> - /* TODO: error message */
>   goto notfound;

...

>  notfound:
> - if(!found) {
> - ret++;
> + ret = 1;
> + if(regex) {
> + pm_printf(ALPM_LOG_ERROR, _("no files match '%s'\n"), 
> targ);

"no files match" isn't really a great error message if the real
problem is that the regex failed to even compile.


Re: [pacman-dev] [PATCH v2 1/2] pacman/pacman-conf: removed hputs macro for usage display

2019-09-10 Thread Matthew Sexton
On Tuesday, September 10, 2019 7:32:46 AM EDT you wrote:
> On 10/9/19 7:33 pm, Matthew Sexton wrote:
> > Signed-off-by: Matthew Sexton 
> > ---
> 
> What changed in v2 apart from the disappearing commit message?
> 
Nothing. My apologies. I wasn't thinking and just re-sent both patches when I 
changed the second one. 

PATCH v2 1/2 can be ignored, it's identical to the original.

signature.asc
Description: This is a digitally signed message part.


Re: [pacman-dev] [PATCH v2 1/2] pacman/pacman-conf: removed hputs macro for usage display

2019-09-10 Thread Allan McRae
On 10/9/19 7:33 pm, Matthew Sexton wrote:
> Signed-off-by: Matthew Sexton 
> ---

What changed in v2 apart from the disappearing commit message?

>  src/pacman/pacman-conf.c | 24 +++-
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index df874029..d9e596b8 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -37,19 +37,17 @@ static void cleanup(void)
>  static void usage(int ret)
>  {
>   FILE *stream = (ret ? stderr : stdout);
> -#define hputs(x) fputs(x"\n", stream)
> - hputs("pacman-conf - query pacman's configuration file");
> - hputs("usage:  pacman-conf [options] [...]");
> - hputs("pacman-conf (--repo-list|--help|--version)");
> - hputs("options:");
> - hputs("  -c, --config=  set an alternate configuration file");
> - hputs("  -R, --rootdir= set an alternate installation root");
> - hputs("  -r, --repo=  query options for a specific repo");
> - hputs("  -v, --verbosealways show directive names");
> - hputs("  -l, --repo-list  list configured repositories");
> - hputs("  -h, --help   display this help information");
> - hputs("  -V, --versiondisplay version information");
> -#undef hputs
> + fputs("pacman-conf - query pacman's configuration file\n", stream);
> + fputs("usage:  pacman-conf [options] [...]\n", stream);
> + fputs("pacman-conf (--repo-list|--help|--version)\n", stream);
> + fputs("options:\n", stream);
> + fputs("  -c, --config=  set an alternate configuration file\n", 
> stream);
> + fputs("  -R, --rootdir= set an alternate installation root\n", 
> stream);
> + fputs("  -r, --repo=  query options for a specific repo\n", 
> stream);
> + fputs("  -v, --verbosealways show directive names\n", stream);
> + fputs("  -l, --repo-list  list configured repositories\n", stream);
> + fputs("  -h, --help   display this help information\n", stream);
> + fputs("  -V, --versiondisplay version information\n", stream);
>   cleanup();
>   exit(ret);
>  }
> 


Re: [pacman-dev] [PATCH] pacman: new config to highlight testing packages

2019-09-10 Thread Matthew Sexton
On Tuesday, September 10, 2019 6:42:01 AM EDT Jan Alexander Steffens wrote:
> On Tue, Sep 10, 2019, 12:17 Morten Linderud  wrote:
> > If you turn it around and add a list instead?
> > 
> > HilightRepositories = testing community-testing
> 
> You could give each [repo] a Color= setting.

That seems like it would be a little bit more straightforward to implement. 
Making a list of repos to highlight in the config would involve a bunch of alpm 
back-end stuff. (Basically modelling after an existing list, like IgnorePkg)


signature.asc
Description: This is a digitally signed message part.


Re: [pacman-dev] [PATCH] pacman: new config to highlight testing packages

2019-09-10 Thread Jan Alexander Steffens
On Tue, Sep 10, 2019, 12:17 Morten Linderud  wrote:

> If you turn it around and add a list instead?
>
> HilightRepositories = testing community-testing
>

You could give each [repo] a Color= setting.

>


Re: [pacman-dev] [PATCH] pacman: new config to highlight testing packages

2019-09-10 Thread Morten Linderud
On Tue, Sep 10, 2019 at 06:04:54AM -0400, Matthew Sexton wrote:
> On Tuesday, September 10, 2019 5:57:19 AM EDT Morgan Adamiec wrote:
> > Pacman is a general Linux package manager and not specific to Arch
> > Linux. testing and community-testing are specific to Arch Linux.
> 
> I struggled with whether to share this patch or not, because my motivation 
> was 
> pure laziness. I didn't know whether anyone else would find it useful/usable. 
> Without maintaining a list of every 'testing' repo name for every distro, it 
> would only be useful for Arch. Thank you for the big-picture perspective I 
> was 
> clearly missing. =D

If you turn it around and add a list instead?

HilightRepositories = testing community-testing

-- 
Morten Linderud
PGP: 9C02FF419FECBE16


signature.asc
Description: PGP signature


Re: [pacman-dev] [PATCH] pacman: new config to highlight testing packages

2019-09-10 Thread Matthew Sexton
On Tuesday, September 10, 2019 5:57:19 AM EDT Morgan Adamiec wrote:
> Pacman is a general Linux package manager and not specific to Arch
> Linux. testing and community-testing are specific to Arch Linux.

I struggled with whether to share this patch or not, because my motivation was 
pure laziness. I didn't know whether anyone else would find it useful/usable. 
Without maintaining a list of every 'testing' repo name for every distro, it 
would only be useful for Arch. Thank you for the big-picture perspective I was 
clearly missing. =D

signature.asc
Description: This is a digitally signed message part.


Re: [pacman-dev] [PATCH] pacman: new config to highlight testing packages

2019-09-10 Thread Morgan Adamiec
On Tue, 10 Sep 2019 at 10:54, Matthew Sexton  wrote:
>
> Only during Install/Upgrade, and not to verbosepkglist
>
> Signed-off-by: Matthew Sexton 
> ---
>  src/pacman/conf.c|  2 ++
>  src/pacman/conf.h|  2 ++
>  src/pacman/pacman-conf.c |  1 +
>  src/pacman/util.c| 20 
>  4 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/src/pacman/conf.c b/src/pacman/conf.c
> index 2d8518c4..70c8a4f4 100644
> --- a/src/pacman/conf.c
> +++ b/src/pacman/conf.c
> @@ -494,6 +494,8 @@ static int _parse_options(const char *key, char *value,
> config->color = isatty(fileno(stdout)) ? 
> PM_COLOR_ON : PM_COLOR_OFF;
> enable_colors(config->color);
> }
> +   } else if(strcmp(key, "HighlightTesting") == 0) {
> +   config->highlighttesting = 1;
> } else if(strcmp(key, "DisableDownloadTimeout") == 0) {
> config->disable_dl_timeout = 1;
> } else {
> diff --git a/src/pacman/conf.h b/src/pacman/conf.h
> index f45ed436..51fa5764 100644
> --- a/src/pacman/conf.h
> +++ b/src/pacman/conf.h
> @@ -117,6 +117,8 @@ typedef struct __config_t {
> unsigned short totaldownload;
> /* select -Sc behavior */
> unsigned short cleanmethod;
> +   /* Highlight packages from testing repositories */
> +   unsigned short highlighttesting;
> alpm_list_t *holdpkg;
> alpm_list_t *ignorepkg;
> alpm_list_t *ignoregrp;
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index df874029..1e40c138 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -260,6 +260,7 @@ static void dump_config(void)
> show_bool("VerbosePkgLists", config->verbosepkglists);
> show_bool("DisableDownloadTimeout", config->disable_dl_timeout);
> show_bool("ILoveCandy", config->chomp);
> +  show_bool("HighlightTesting", config->highlighttesting);
>
> show_cleanmethod("CleanMethod", config->cleanmethod);
>
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 8f6290db..13ac0f25 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -898,15 +898,27 @@ static void _display_targets(alpm_list_t *targets, int 
> verbose)
>
> /* form data for both verbose and non-verbose display */
> for(i = targets; i; i = alpm_list_next(i)) {
> +   unsigned short testing = 0;
> +   const char *repo;
> pm_target_t *target = i->data;
> -
> +   alpm_db_t *db = alpm_pkg_get_db(target->install);
> +   if(db) {
> +   repo = alpm_db_get_name(db);
> +   if (strcmp(repo, "testing") == 0 || 
> strcmp(repo,"community-testing") == 0) {
> +   testing = 1;
> +   }
> +   }
> if(verbose) {
> rows = alpm_list_add(rows, 
> create_verbose_row(target));
> }
> -
> if(target->install) {
> -   pm_asprintf(&str, "%s-%s", 
> alpm_pkg_get_name(target->install),
> -   
> alpm_pkg_get_version(target->install));
> +   if (testing && config->highlighttesting) {
> +   pm_asprintf(&str, "%s%s-%s%s", config->color 
> == PM_COLOR_ON ? config->colstr.warn : "**",
> +   
> alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install),
> +   config->color == 
> PM_COLOR_ON ? config->colstr.nocolor : "**");
> +   } else {
> +   pm_asprintf(&str, "%s-%s", 
> alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install));
> +   }
> } else if(isize == 0) {
> pm_asprintf(&str, "%s-%s", 
> alpm_pkg_get_name(target->remove),
> alpm_pkg_get_version(target->remove));
> --
> 2.23.0

Pacman is a general Linux package manager and not specific to Arch
Linux. testing and community-testing are specific to Arch Linux.


[pacman-dev] [PATCH] pacman: new config to highlight testing packages

2019-09-10 Thread Matthew Sexton
Only during Install/Upgrade, and not to verbosepkglist

Signed-off-by: Matthew Sexton 
---
 src/pacman/conf.c|  2 ++
 src/pacman/conf.h|  2 ++
 src/pacman/pacman-conf.c |  1 +
 src/pacman/util.c| 20 
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 2d8518c4..70c8a4f4 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -494,6 +494,8 @@ static int _parse_options(const char *key, char *value,
config->color = isatty(fileno(stdout)) ? 
PM_COLOR_ON : PM_COLOR_OFF;
enable_colors(config->color);
}
+   } else if(strcmp(key, "HighlightTesting") == 0) {
+   config->highlighttesting = 1;
} else if(strcmp(key, "DisableDownloadTimeout") == 0) {
config->disable_dl_timeout = 1;
} else {
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index f45ed436..51fa5764 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -117,6 +117,8 @@ typedef struct __config_t {
unsigned short totaldownload;
/* select -Sc behavior */
unsigned short cleanmethod;
+   /* Highlight packages from testing repositories */
+   unsigned short highlighttesting;
alpm_list_t *holdpkg;
alpm_list_t *ignorepkg;
alpm_list_t *ignoregrp;
diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index df874029..1e40c138 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -260,6 +260,7 @@ static void dump_config(void)
show_bool("VerbosePkgLists", config->verbosepkglists);
show_bool("DisableDownloadTimeout", config->disable_dl_timeout);
show_bool("ILoveCandy", config->chomp);
+  show_bool("HighlightTesting", config->highlighttesting);
 
show_cleanmethod("CleanMethod", config->cleanmethod);
 
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 8f6290db..13ac0f25 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -898,15 +898,27 @@ static void _display_targets(alpm_list_t *targets, int 
verbose)
 
/* form data for both verbose and non-verbose display */
for(i = targets; i; i = alpm_list_next(i)) {
+   unsigned short testing = 0;
+   const char *repo;
pm_target_t *target = i->data;
-
+   alpm_db_t *db = alpm_pkg_get_db(target->install);
+   if(db) {
+   repo = alpm_db_get_name(db);
+   if (strcmp(repo, "testing") == 0 || 
strcmp(repo,"community-testing") == 0) {
+   testing = 1;
+   }
+   }
if(verbose) {
rows = alpm_list_add(rows, create_verbose_row(target));
}
-
if(target->install) {
-   pm_asprintf(&str, "%s-%s", 
alpm_pkg_get_name(target->install),
-   alpm_pkg_get_version(target->install));
+   if (testing && config->highlighttesting) {
+   pm_asprintf(&str, "%s%s-%s%s", config->color == 
PM_COLOR_ON ? config->colstr.warn : "**",
+   
alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install),
+   config->color == 
PM_COLOR_ON ? config->colstr.nocolor : "**");
+   } else {
+   pm_asprintf(&str, "%s-%s", 
alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install));
+   }
} else if(isize == 0) {
pm_asprintf(&str, "%s-%s", 
alpm_pkg_get_name(target->remove),
alpm_pkg_get_version(target->remove));
-- 
2.23.0


[pacman-dev] [PATCH v2 2/2] pacman/pacman-conf, testpkg: Added translatable strings

2019-09-10 Thread Matthew Sexton
From: Matthew Sexton 

Added gettext macro to warnings, helps, and errors for translation.

Signed-off-by: Matthew Sexton 
---
Changes in v2:
- Moved "Include" outside of gettext macro so it doesn't get localised

 src/pacman/pacman-conf.c | 44 +++-
 src/util/testpkg.c   | 29 +++---
 2 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index d9e596b8..efc62cdd 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include "conf.h"
+#include "util.h"
 
 const char *myname = "pacman-conf", *myver = "1.0.0";
 
@@ -37,17 +38,17 @@ static void cleanup(void)
 static void usage(int ret)
 {
FILE *stream = (ret ? stderr : stdout);
-   fputs("pacman-conf - query pacman's configuration file\n", stream);
-   fputs("usage:  pacman-conf [options] [...]\n", stream);
-   fputs("pacman-conf (--repo-list|--help|--version)\n", stream);
-   fputs("options:\n", stream);
-   fputs("  -c, --config=  set an alternate configuration file\n", 
stream);
-   fputs("  -R, --rootdir= set an alternate installation root\n", 
stream);
-   fputs("  -r, --repo=  query options for a specific repo\n", 
stream);
-   fputs("  -v, --verbosealways show directive names\n", stream);
-   fputs("  -l, --repo-list  list configured repositories\n", stream);
-   fputs("  -h, --help   display this help information\n", stream);
-   fputs("  -V, --versiondisplay version information\n", stream);
+   fputs(_("pacman-conf - query pacman's configuration file\n"), stream);
+   fputs(_("usage:  pacman-conf [options] [...]\n"), stream);
+   fputs(_("pacman-conf (--repo-list|--help|--version)\n"), 
stream);
+   fputs(_("options:\n"), stream);
+   fputs(_("  -c, --config=  set an alternate configuration 
file\n"), stream);
+   fputs(_("  -R, --rootdir= set an alternate installation root\n"), 
stream);
+   fputs(_("  -r, --repo=  query options for a specific repo\n"), 
stream);
+   fputs(_("  -v, --verbosealways show directive names\n"), 
stream);
+   fputs(_("  -l, --repo-list  list configured repositories\n"), 
stream);
+   fputs(_("  -h, --help   display this help information\n"), 
stream);
+   fputs(_("  -V, --versiondisplay version information\n"), 
stream);
cleanup();
exit(ret);
 }
@@ -76,7 +77,7 @@ static void parse_opts(int argc, char **argv)
break;
case 'R':
if ((config->rootdir = strdup(optarg)) == NULL) 
{
-   fprintf(stderr, "error setting rootdir 
'%s': out of memory\n", optarg);
+   fprintf(stderr, _("error setting 
rootdir '%s': out of memory\n"), optarg);
cleanup();
exit(1);
}
@@ -106,7 +107,7 @@ static void parse_opts(int argc, char **argv)
}
 
if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
-   fprintf(stderr, "error parsing '%s'\n", config_file);
+   fprintf(stderr, _("error parsing '%s'\n"), config_file);
cleanup();
exit(1);
}
@@ -286,7 +287,7 @@ static int list_repo_directives(void)
}
 
if(!repo) {
-   fprintf(stderr, "error: repo '%s' not configured\n", repo_name);
+   fprintf(stderr, _("error: repo '%s' not configured\n"), 
repo_name);
return 1;
}
 
@@ -303,10 +304,10 @@ static int list_repo_directives(void)
} else if(strcasecmp(i->data, "Usage") == 0) {
show_usage("Usage", repo->usage);
} else if(strcasecmp(i->data, "Include") == 0) {
-   fputs("warning: 'Include' directives cannot be 
queried\n", stderr);
+   fprintf(stderr,_("warning: '%s' directives cannot be 
queried\n"), "Include");
ret = 1;
} else {
-   fprintf(stderr, "warning: unknown directive '%s'\n", 
(char*) i->data);
+   fprintf(stderr, _("warning: unknown directive '%s'\n"), 
(char*) i->data);
ret = 1;
}
}
@@ -379,10 +380,10 @@ static int list_directives(void)
show_siglevel("RemoteFileSigLevel", 
config->remotefilesiglevel, 1);
 
} else if(strcasecmp(i->data, "Include") == 0) {
-   fputs("warning: 'Include' directives cannot be 
queried\n", stderr);
+   fprintf(stderr, _("warning: '%s' directives cannot be 
queried\n"), "Include");
ret = 1;
} else {
-   

[pacman-dev] [PATCH v2 1/2] pacman/pacman-conf: removed hputs macro for usage display

2019-09-10 Thread Matthew Sexton
Signed-off-by: Matthew Sexton 
---
 src/pacman/pacman-conf.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index df874029..d9e596b8 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -37,19 +37,17 @@ static void cleanup(void)
 static void usage(int ret)
 {
FILE *stream = (ret ? stderr : stdout);
-#define hputs(x) fputs(x"\n", stream)
-   hputs("pacman-conf - query pacman's configuration file");
-   hputs("usage:  pacman-conf [options] [...]");
-   hputs("pacman-conf (--repo-list|--help|--version)");
-   hputs("options:");
-   hputs("  -c, --config=  set an alternate configuration file");
-   hputs("  -R, --rootdir= set an alternate installation root");
-   hputs("  -r, --repo=  query options for a specific repo");
-   hputs("  -v, --verbosealways show directive names");
-   hputs("  -l, --repo-list  list configured repositories");
-   hputs("  -h, --help   display this help information");
-   hputs("  -V, --versiondisplay version information");
-#undef hputs
+   fputs("pacman-conf - query pacman's configuration file\n", stream);
+   fputs("usage:  pacman-conf [options] [...]\n", stream);
+   fputs("pacman-conf (--repo-list|--help|--version)\n", stream);
+   fputs("options:\n", stream);
+   fputs("  -c, --config=  set an alternate configuration file\n", 
stream);
+   fputs("  -R, --rootdir= set an alternate installation root\n", 
stream);
+   fputs("  -r, --repo=  query options for a specific repo\n", 
stream);
+   fputs("  -v, --verbosealways show directive names\n", stream);
+   fputs("  -l, --repo-list  list configured repositories\n", stream);
+   fputs("  -h, --help   display this help information\n", stream);
+   fputs("  -V, --versiondisplay version information\n", stream);
cleanup();
exit(ret);
 }
-- 
2.23.0