[pacman-dev] [PATCH] doc/.gitignore: ignore all manpages

2018-02-10 Thread iff
From: Ivy Foster 

They're all generated during make.
---
I was going to add BUILDINFO.5 to the list, but this way covers future
additions.

 doc/.gitignore | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/doc/.gitignore b/doc/.gitignore
index 186f45e4..a9736555 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,16 +1,4 @@
-alpm-hooks.5
-PKGBUILD.5
-libalpm.3
-makepkg.8
-makepkg-template.1
-makepkg.conf.5
-pacman.8
-pacman-key.8
-pacman.conf.5
-pkgdelta.8
-repo-add.8
-repo-remove.8
-vercmp.8
+*.[1-8]
 asciidoc-manpage.css
 asciidoc.css
 asciidoc.js
-- 
2.16.1


Re: [pacman-dev] [PATCH v3 4/5] pacman-conf.c: Make cleanup run automagically at exit

2018-02-10 Thread Andrew Gregory
On 02/10/18 at 10:15pm, i...@escondida.tk wrote:
> From: Ivy Foster 
> 
> Since using atexit(3) draws in stdlib anyway and this changes every
> exit call at large and return call in main(), go ahead and use
> EXIT_SUCCESS and EXIt_FAILURE, too.
> 
> Signed-off-by: Ivy Foster 
> ---
>  src/pacman/pacman-conf.c | 29 +
>  1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index 8985b326..51df8803 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -18,7 +18,9 @@
>   */
>  
>  #include 
> +#include 
>  #include 
> +
>  #include "conf.h"
>  
>  #define MYNAME "pacman-conf"
> @@ -88,19 +90,14 @@ static void parse_opts(int argc, char **argv)
>   break;
>   case 'h':
>   usage(stdout);
> - cleanup();
> - exit(0);
> + exit(EXIT_SUCCESS);
>   case 'V':
>   printf("%s v%s\n", MYNAME, MYVER);
> - cleanup();
> - exit(0);
> - break;
> + exit(EXIT_SUCCESS);
>   case '?':
>   default:
>   usage(stderr);
> - cleanup();
> - exit(1);
> - break;
> + exit(EXIT_FAILURE);
>   }
>   }
>  
> @@ -401,11 +398,15 @@ int main(int argc, char **argv)
>  {
>   int ret = 0;
>  
> + if (atexit(cleanup) != 0) {
> + fputs("error: cannot set exit function\n", stderr);
> + return EXIT_FAILURE;
> + }

You're registering cleanup prior to initializing config.  At this
point in the patchset pacman-conf can't exit between the two, but
a later patch delays the initialization, which can lead to a segfault.

>   config = config_new();
>   parse_opts(argc, argv);
>   if(!config) {
> - ret = 1;
> - goto cleanup;
> + return EXIT_FAILURE;
>   }
>  
>   for(; optind < argc; optind++) {
> @@ -419,8 +420,7 @@ int main(int argc, char **argv)
>   if(repo_list) {
>   if(directives) {
>   fputs("error: directives may not be specified with 
> --repo-list\n", stderr);
> - ret = 1;
> - goto cleanup;
> + return EXIT_FAILURE;
>   }
>   list_repos();
>   } else if(repo_name) {
> @@ -429,10 +429,7 @@ int main(int argc, char **argv)
>   ret = list_directives();
>   }
>  
> -cleanup:
> - cleanup();
> -
> - return ret;
> + return ret ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
>  
>  /* vim: set ts=2 sw=2 noet: */
> -- 
> 2.16.1

-- 
apg


Re: [pacman-dev] [PATCH v3 2/5] pacman-conf.c: simplify usage()

2018-02-10 Thread Andrew Gregory
On 02/10/18 at 10:15pm, i...@escondida.tk wrote:
> From: Ivy Foster 
> 
> Signed-off-by: Ivy Foster 
> ---

There are two major changes here: adding short options to the usage
and the "simplification" of the usage function.  The short options
should be added in the patch that made them available, not here.  The
other changes need some sort of justification.  It's not obvious to me
that this is simpler.  Sure usage itself is a bit simpler, but now
parse_opts has to worry about calling cleanup and exit.

Other patches in this set similarly lack justification: using atexit
and EXIT_SUCCESS/EXIT_FAILURE and limiting parse_opts to command-line
options.

>  src/pacman/pacman-conf.c | 40 
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index 3c9a80e2..9136b262 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -34,24 +34,21 @@ static void cleanup(void)
>   config_free(config);
>  }
>  
> -static void usage(int ret)
> +static void usage(FILE *stream)
>  {
> - 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("  --config=  set an alternate configuration file");
> - hputs("  --rootdir= set an alternate installation root");
> - hputs("  --repo=  query options for a specific repo");
> - hputs("  --verbosealways show directive names");
> - hputs("  --repo-list  list configured repositories");
> - hputs("  --help   display this help information");
> - hputs("  --versiondisplay version information");
> -#undef hputs
> - cleanup();
> - exit(ret);
> + static const char help[] =
> + "pacman-conf: query pacman's configuration file\n"
> + "usage: pacman-conf [options] [directive]\n"
> + "   pacman-conf [ { -l, --repo-list } | { -h, --help } | { 
> -V, --version } ]\n"
> + "options:\n"
> + "-c, --config=  Read configuration from \n"
> + "-h, --help   Print help\n"
> + "-l, --repo-list  List configured repositories\n"
> + "-r, --repo=  Query options for a specific repo\n"
> + "-R, --rootdir=  Use  as system root\n"
> + "-v, --verboseAlways show directive names\n"
> + "-V, --versionPrint version\n";
> + fprintf(stream, "%s", help);
>  }
>  
>  static void parse_opts(int argc, char **argv)
> @@ -89,8 +86,9 @@ static void parse_opts(int argc, char **argv)
>   verbose = 1;
>   break;
>   case 'h':
> - usage(0);
> - break;
> + usage(stdout);
> + cleanup();
> + exit(0);
>   case 'V':
>   printf("%s v%s\n", myname, myver);
>   cleanup();
> @@ -98,7 +96,9 @@ static void parse_opts(int argc, char **argv)
>   break;
>   case '?':
>   default:
> - usage(1);
> + usage(stderr);
> + cleanup();
> + exit(1);
>   break;
>   }
>   }
> -- 
> 2.16.1


[pacman-dev] [PATCH v2 5/5] pacman-conf.c: make parse_opts only parse opts

2018-02-10 Thread iff
From: Ivy Foster 

Previously, it also parsed the config file instead of simply setting
the (global) config_file variable

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index bb527b1a..90636437 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -99,10 +99,6 @@ static void parse_opts(int argc, char **argv)
exit(EXIT_FAILURE);
}
}
-
-   if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
-   fprintf(stderr, "error parsing '%s'\n", config_file);
-   }
 }
 
 static void list_repos(void)
@@ -402,8 +398,16 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
 
-   config = config_new();
parse_opts(argc, argv);
+
+   if(!(config = config_new())) {
+   /* config_new prints the appropriate error message */
+   return EXIT_FAILURE;
+   }
+   if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
+   fprintf(stderr, "error parsing '%s'\n", config_file);
+   return EXIT_FAILURE;
+   }
if(!config) {
return EXIT_FAILURE;
}
-- 
2.16.1


[pacman-dev] [PATCH v2 2/5] pacman-conf.c: simplify usage()

2018-02-10 Thread iff
From: Ivy Foster 

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 0f81ece6..61f4d0a1 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -34,24 +34,21 @@ static void cleanup(void)
config_free(config);
 }
 
-static void usage(int ret)
+static void usage(FILE *stream)
 {
-   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("  --config=  set an alternate configuration file");
-   hputs("  --rootdir= set an alternate installation root");
-   hputs("  --repo=  query options for a specific repo");
-   hputs("  --verbosealways show directive names");
-   hputs("  --repo-list  list configured repositories");
-   hputs("  --help   display this help information");
-   hputs("  --versiondisplay version information");
-#undef hputs
-   cleanup();
-   exit(ret);
+   static const char help[] =
+   "pacman-conf: query pacman's configuration file\n"
+   "usage: pacman-conf [options] [directive]\n"
+   "   pacman-conf [ { -l, --repo-list } | { -h, --help } | { 
-V, --version } ]\n"
+   "options:\n"
+   "-c, --config=  Read configuration from \n"
+   "-h, --help   Print help\n"
+   "-l, --repo-list  List configured repositories\n"
+   "-r, --repo=  Query options for a specific repo\n"
+   "-R, --rootdir=  Use  as system root\n"
+   "-v, --verboseAlways show directive names\n"
+   "-V, --versionPrint version\n";
+   fprintf(stream, "%s", help);
 }
 
 static void parse_opts(int argc, char **argv)
@@ -89,15 +86,18 @@ static void parse_opts(int argc, char **argv)
verbose = 1;
break;
case 'h':
-   usage(0);
-   break;
+   usage(stdout);
+   cleanup();
+   exit(0);
case 'V':
printf("%s v%s\n", myname, myver);
cleanup();
exit(0);
break;
default:
-   usage(1);
+   usage(stderr);
+   cleanup();
+   exit(1);
break;
}
}
-- 
2.16.1


[pacman-dev] [PATCH v2 4/5] pacman-conf.c: Make cleanup run automagically at exit

2018-02-10 Thread iff
From: Ivy Foster 

Since using atexit(3) draws in stdlib anyway and this changes every
exit call at large and return call in main(), go ahead and use
EXIT_SUCCESS and EXIt_FAILURE, too.

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 739588ae..bb527b1a 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -18,7 +18,9 @@
  */
 
 #include 
+#include 
 #include 
+
 #include "conf.h"
 
 #define MYNAME "pacman-conf"
@@ -88,18 +90,13 @@ static void parse_opts(int argc, char **argv)
break;
case 'h':
usage(stdout);
-   cleanup();
-   exit(0);
+   exit(EXIT_SUCCESS);
case 'V':
printf("%s v%s\n", MYNAME, MYVER);
-   cleanup();
-   exit(0);
-   break;
+   exit(EXIT_SUCCESS);
default:
usage(stderr);
-   cleanup();
-   exit(1);
-   break;
+   exit(EXIT_FAILURE);
}
}
 
@@ -400,11 +397,15 @@ int main(int argc, char **argv)
 {
int ret = 0;
 
+   if (atexit(cleanup) != 0) {
+   fputs("error: cannot set exit function\n", stderr);
+   return EXIT_FAILURE;
+   }
+
config = config_new();
parse_opts(argc, argv);
if(!config) {
-   ret = 1;
-   goto cleanup;
+   return EXIT_FAILURE;
}
 
for(; optind < argc; optind++) {
@@ -418,8 +419,7 @@ int main(int argc, char **argv)
if(repo_list) {
if(directives) {
fputs("error: directives may not be specified with 
--repo-list\n", stderr);
-   ret = 1;
-   goto cleanup;
+   return EXIT_FAILURE;
}
list_repos();
} else if(repo_name) {
@@ -428,10 +428,7 @@ int main(int argc, char **argv)
ret = list_directives();
}
 
-cleanup:
-   cleanup();
-
-   return ret;
+   return ret ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 /* vim: set ts=2 sw=2 noet: */
-- 
2.16.1


[pacman-dev] [PATCH v2 3/5] pacman-conf: Make myname and myver into cpp macros MYNAME and MYVER

2018-02-10 Thread iff
From: Ivy Foster 

This allows MYNAME to be used in place of the literal string
"pacman-conf" in usage

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 61f4d0a1..739588ae 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -21,7 +21,8 @@
 #include 
 #include "conf.h"
 
-const char *myname = "pacman-conf", *myver = "1.0.0";
+#define MYNAME "pacman-conf"
+#define MYVER "1.0.0"
 
 alpm_list_t *directives = NULL;
 char sep = '\n', *repo_name = NULL;
@@ -37,9 +38,9 @@ static void cleanup(void)
 static void usage(FILE *stream)
 {
static const char help[] =
-   "pacman-conf: query pacman's configuration file\n"
-   "usage: pacman-conf [options] [directive]\n"
-   "   pacman-conf [ { -l, --repo-list } | { -h, --help } | { 
-V, --version } ]\n"
+   MYNAME ": query pacman's configuration file\n"
+   "usage: " MYNAME " [options] [directive]\n"
+   "   " MYNAME " [ { -l, --repo-list } | { -h, --help } | { 
-V, --version } ]\n"
"options:\n"
"-c, --config=  Read configuration from \n"
"-h, --help   Print help\n"
@@ -90,7 +91,7 @@ static void parse_opts(int argc, char **argv)
cleanup();
exit(0);
case 'V':
-   printf("%s v%s\n", myname, myver);
+   printf("%s v%s\n", MYNAME, MYVER);
cleanup();
exit(0);
break;
-- 
2.16.1


[pacman-dev] [PATCH v2 1/5] pacman-conf.c: accept short options

2018-02-10 Thread iff
From: Ivy Foster 

Signed-off-by: Ivy Foster 
---
This verion of the patch simply drops the check for '?', since it's
caught by "default" anyway. The other patches are unchanged, except
where rebased against this modified patch.
 src/pacman/pacman-conf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 1e6f55f9..0f81ece6 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -59,7 +59,7 @@ static void parse_opts(int argc, char **argv)
int c;
config_file = CONFFILE;
 
-   const char *short_opts = "";
+   const char *short_opts = "c:hlR:r:Vv";
struct option long_opts[] = {
{ "config", required_argument , NULL , 'c' },
{ "rootdir"   , required_argument , NULL , 'R' },
@@ -96,7 +96,6 @@ static void parse_opts(int argc, char **argv)
cleanup();
exit(0);
break;
-   case '?':
default:
usage(1);
break;
-- 
2.16.1


[pacman-dev] [PATCH v3 1/5] pacman-conf.c: accept short options

2018-02-10 Thread iff
From: Ivy Foster 

Signed-off-by: Ivy Foster 
---
As per agregory's request in #archlinux-pacman, this version of the
patch leaves the check for '?' well enough alone. '?' is
getopt_long(3)'s way of indicating user error, and we can think of
default: as indicating options forgotten in development.

 src/pacman/pacman-conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 1e6f55f9..3c9a80e2 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -59,7 +59,7 @@ static void parse_opts(int argc, char **argv)
int c;
config_file = CONFFILE;
 
-   const char *short_opts = "";
+   const char *short_opts = "c:hlR:r:Vv";
struct option long_opts[] = {
{ "config", required_argument , NULL , 'c' },
{ "rootdir"   , required_argument , NULL , 'R' },
-- 
2.16.1


[pacman-dev] [PATCH v3 5/5] pacman-conf.c: make parse_opts only parse opts

2018-02-10 Thread iff
From: Ivy Foster 

Previously, it also parsed the config file instead of simply setting
the (global) config_file variable

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 51df8803..4828dfec 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -100,10 +100,6 @@ static void parse_opts(int argc, char **argv)
exit(EXIT_FAILURE);
}
}
-
-   if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
-   fprintf(stderr, "error parsing '%s'\n", config_file);
-   }
 }
 
 static void list_repos(void)
@@ -403,8 +399,16 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
 
-   config = config_new();
parse_opts(argc, argv);
+
+   if(!(config = config_new())) {
+   /* config_new prints the appropriate error message */
+   return EXIT_FAILURE;
+   }
+   if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
+   fprintf(stderr, "error parsing '%s'\n", config_file);
+   return EXIT_FAILURE;
+   }
if(!config) {
return EXIT_FAILURE;
}
-- 
2.16.1


[pacman-dev] [PATCH v3 3/5] pacman-conf: Make myname and myver into cpp macros MYNAME and MYVER

2018-02-10 Thread iff
From: Ivy Foster 

This allows MYNAME to be used in place of the literal string
"pacman-conf" in usage

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 9136b262..8985b326 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -21,7 +21,8 @@
 #include 
 #include "conf.h"
 
-const char *myname = "pacman-conf", *myver = "1.0.0";
+#define MYNAME "pacman-conf"
+#define MYVER "1.0.0"
 
 alpm_list_t *directives = NULL;
 char sep = '\n', *repo_name = NULL;
@@ -37,9 +38,9 @@ static void cleanup(void)
 static void usage(FILE *stream)
 {
static const char help[] =
-   "pacman-conf: query pacman's configuration file\n"
-   "usage: pacman-conf [options] [directive]\n"
-   "   pacman-conf [ { -l, --repo-list } | { -h, --help } | { 
-V, --version } ]\n"
+   MYNAME ": query pacman's configuration file\n"
+   "usage: " MYNAME " [options] [directive]\n"
+   "   " MYNAME " [ { -l, --repo-list } | { -h, --help } | { 
-V, --version } ]\n"
"options:\n"
"-c, --config=  Read configuration from \n"
"-h, --help   Print help\n"
@@ -90,7 +91,7 @@ static void parse_opts(int argc, char **argv)
cleanup();
exit(0);
case 'V':
-   printf("%s v%s\n", myname, myver);
+   printf("%s v%s\n", MYNAME, MYVER);
cleanup();
exit(0);
break;
-- 
2.16.1


[pacman-dev] [PATCH v3 2/5] pacman-conf.c: simplify usage()

2018-02-10 Thread iff
From: Ivy Foster 

Signed-off-by: Ivy Foster 
---
 src/pacman/pacman-conf.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 3c9a80e2..9136b262 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -34,24 +34,21 @@ static void cleanup(void)
config_free(config);
 }
 
-static void usage(int ret)
+static void usage(FILE *stream)
 {
-   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("  --config=  set an alternate configuration file");
-   hputs("  --rootdir= set an alternate installation root");
-   hputs("  --repo=  query options for a specific repo");
-   hputs("  --verbosealways show directive names");
-   hputs("  --repo-list  list configured repositories");
-   hputs("  --help   display this help information");
-   hputs("  --versiondisplay version information");
-#undef hputs
-   cleanup();
-   exit(ret);
+   static const char help[] =
+   "pacman-conf: query pacman's configuration file\n"
+   "usage: pacman-conf [options] [directive]\n"
+   "   pacman-conf [ { -l, --repo-list } | { -h, --help } | { 
-V, --version } ]\n"
+   "options:\n"
+   "-c, --config=  Read configuration from \n"
+   "-h, --help   Print help\n"
+   "-l, --repo-list  List configured repositories\n"
+   "-r, --repo=  Query options for a specific repo\n"
+   "-R, --rootdir=  Use  as system root\n"
+   "-v, --verboseAlways show directive names\n"
+   "-V, --versionPrint version\n";
+   fprintf(stream, "%s", help);
 }
 
 static void parse_opts(int argc, char **argv)
@@ -89,8 +86,9 @@ static void parse_opts(int argc, char **argv)
verbose = 1;
break;
case 'h':
-   usage(0);
-   break;
+   usage(stdout);
+   cleanup();
+   exit(0);
case 'V':
printf("%s v%s\n", myname, myver);
cleanup();
@@ -98,7 +96,9 @@ static void parse_opts(int argc, char **argv)
break;
case '?':
default:
-   usage(1);
+   usage(stderr);
+   cleanup();
+   exit(1);
break;
}
}
-- 
2.16.1


Re: [pacman-dev] [PATCH v3 5/5] pacman-conf.c: make parse_opts only parse opts

2018-02-10 Thread Andrew Gregory
On 02/10/18 at 10:15pm, i...@escondida.tk wrote:
> From: Ivy Foster 
> 
> Previously, it also parsed the config file instead of simply setting
> the (global) config_file variable

I think the original purpose of this patch is fundamentally
unnecessary, but it does (accidentally, I assume) fix a bug if parsing
the config file fails.

> Signed-off-by: Ivy Foster 
> ---
>  src/pacman/pacman-conf.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index 51df8803..4828dfec 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -100,10 +100,6 @@ static void parse_opts(int argc, char **argv)
>   exit(EXIT_FAILURE);
>   }
>   }
> -
> - if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
> - fprintf(stderr, "error parsing '%s'\n", config_file);
> - }
>  }
>  
>  static void list_repos(void)
> @@ -403,8 +399,16 @@ int main(int argc, char **argv)
>   return EXIT_FAILURE;
>   }
>  
> - config = config_new();
>   parse_opts(argc, argv);

config must be initialized before parse_opts because parse_opts
modifies it.

> +
> + if(!(config = config_new())) {
> + /* config_new prints the appropriate error message */
> + return EXIT_FAILURE;
> + }
> + if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
> + fprintf(stderr, "error parsing '%s'\n", config_file);
> + return EXIT_FAILURE;
> + }
>   if(!config) {
>   return EXIT_FAILURE;
>   }
> -- 
> 2.16.1


[pacman-dev] [PATCH] makepkg: use localized date strings

2018-02-10 Thread Chih-Hsuan Yen
From: Yen Chi Hsuan 

Before this change, LC_TIME=zh_TW.UTF-8 makepkg has the following line:

==> Making package: foobar 1-1 (日  2月 11 01:13:42 CST 2018)

With this patch, this line becomes:

==> Making package: foobar 1-1 (西元2018年02月11日 (週日) 01時13分57秒)

The latter is more natural for a Chinese native speaker.

Signed-off-by: Chih-Hsuan Yen 
---
 scripts/makepkg.sh.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 63b6c3e1..5e3af337 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1569,7 +1569,7 @@ if (( INFAKEROOT )); then
exit $E_OK
 fi
 
-msg "$(gettext "Making package: %s")" "$pkgbase $basever ($(date))"
+msg "$(gettext "Making package: %s")" "$pkgbase $basever ($(date +%c))"
 
 # if we are creating a source-only package, go no further
 if (( SOURCEONLY )); then
@@ -1597,7 +1597,7 @@ if (( SOURCEONLY )); then
msg "$(gettext "Signing package...")"
create_signature "$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
 
-   msg "$(gettext "Source package created: %s")" "$pkgbase ($(date))"
+   msg "$(gettext "Source package created: %s")" "$pkgbase ($(date +%c))"
exit $E_OK
 fi
 
@@ -1703,7 +1703,7 @@ if (( NOARCHIVE )); then
exit $E_OK
 fi
 
-msg "$(gettext "Finished making: %s")" "$pkgbase $basever ($(date))"
+msg "$(gettext "Finished making: %s")" "$pkgbase $basever ($(date +%c))"
 
 install_package && exit $E_OK || exit $E_INSTALL_FAILED
 
-- 
2.16.1