]> git.draconx.ca Git - cdecl99.git/blobdiff - src/commands.c
libcdecl: Work around GNU libc snprintf bug.
[cdecl99.git] / src / commands.c
index dea4219837e624c5f83237ec46efc6fb41d1c061..faaf60785d1f69beb64005619292b0559121c38e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Main command implementation routines for cdecl99.
- * Copyright © 2011-2012, 2020-2021 Nick Bowler
+ * Copyright © 2011-2012, 2020-2021, 2023 Nick Bowler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -45,7 +45,7 @@ retry:
 
                tmp = realloc(buf, rc + 1);
                if (!tmp) {
-                       print_error("%s", _("failed to allocate memory)"));
+                       print_error("%s", _("failed to allocate memory"));
                        return NULL;
                }
 
@@ -59,15 +59,13 @@ retry:
 
 int run_command_explain(const char *arg)
 {
-       const struct cdecl_error *err;
        struct cdecl *decl;
        const char *str;
        int ret = -1;
 
        decl = cdecl_parse_decl(arg);
        if (!decl) {
-               err = cdecl_get_error();
-               print_error("%s", err->str);
+               print_error("%s", cdecl_get_error()->str);
                goto out;
        }
 
@@ -87,15 +85,13 @@ out:
 
 int run_command_simplify(const char *arg)
 {
-       const struct cdecl_error *err;
        struct cdecl *decl;
        const char *str;
        int ret = -1;
 
        decl = cdecl_parse_decl(arg);
        if (!decl) {
-               err = cdecl_get_error();
-               fprintf(stderr, "%s\n", err->str);
+               print_error("%s", cdecl_get_error()->str);
                goto out;
        }
 
@@ -126,7 +122,6 @@ out:
 
 int run_command_declare(const char *cmd)
 {
-       const struct cdecl_error *err;
        struct cdecl *decl;
        const char *str;
        int ret = -1;
@@ -134,8 +129,7 @@ int run_command_declare(const char *cmd)
        /* The name of the command is significant here. */
        decl = cdecl_parse_english(cmd);
        if (!decl) {
-               err = cdecl_get_error();
-               fprintf(stderr, "%s\n", err->str);
+               print_error("%s", cdecl_get_error()->str);
                goto out;
        }