unzck: fix build with musl libc
authorPierre-Jean Texier <pjtexier@koncepto.io>
Thu, 23 Jan 2020 21:42:40 +0000 (22:42 +0100)
committerPierre-Jean Texier <pjtexier@koncepto.io>
Sun, 26 Jan 2020 20:43:06 +0000 (21:43 +0100)
On musl libc "stdout" is a preprocessor macro whose expansion leads to
compilation errors.

Fixes:

| In file included from ../git/src/unzck.c:31:
| ../git/src/unzck.c: In function 'parse_opt':
| ../git/src/unzck.c:78:24: error: expected identifier before '(' token
|    78 |             arguments->stdout = true;
|       |                        ^~~~~~
| ../git/src/unzck.c: In function 'main':
| ../git/src/unzck.c:141:20: error: expected identifier before '(' token
|   141 |     if(!(arguments.stdout)) {
|       |                    ^~~~~~

Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
src/unzck.c

index 8d6c62a5935373ed4f419e2632772a018d84df24..acb72d5173d3ba6236bc35d8a524ce018869393b 100644 (file)
@@ -58,7 +58,7 @@ struct arguments {
   char *args[1];
   zck_log_type log_level;
   bool dict;
-  bool stdout;
+  bool std_out;
   bool exit;
 };
 
@@ -75,7 +75,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
                 arguments->log_level = ZCK_LOG_DDEBUG;
             break;
         case 'c':
-            arguments->stdout = true;
+            arguments->std_out = true;
             break;
         case 'V':
             version();
@@ -138,7 +138,7 @@ int main (int argc, char *argv[]) {
         snprintf(out_name + strlen(base_name) - 4, 7, ".zdict");
 
     int dst_fd = STDOUT_FILENO;
-    if(!arguments.stdout) {
+    if(!arguments.std_out) {
         dst_fd = open(out_name, O_TRUNC | O_WRONLY | O_CREAT, 0666);
         if(dst_fd < 0) {
             dprintf(STDERR_FILENO, "Unable to open %s", out_name);