Identify progname in more errors (fix #1860)

However, we should really use the argv[0] progname, not just jq.
Someday we may want to support aliases which automatically add certain
options, etc.
This commit is contained in:
Nicolas Williams committed 2019-03-24 23:36:18 -05:00
1 parent 0dab2b18d7
commit 2b4d51f697
3 files changed
+14 -14

No files matched your search

+7 -7
View File
@@ -37,7 +37,7 @@ static void memory_exhausted() {
if (nomem_handler.handler)
nomem_handler.handler(nomem_handler.data); // Maybe handler() will longjmp() to safety
// Or not
fprintf(stderr, "error: cannot allocate memory\n");
fprintf(stderr, "jq: error: cannot allocate memory\n");
abort();
}
#else /* USE_TLS */
@@ -59,16 +59,16 @@ static void tsd_fini(void) {
static void tsd_init(void) {
if (pthread_key_create(&nomem_handler_key, NULL) != 0) {
fprintf(stderr, "error: cannot create thread specific key");
fprintf(stderr, "jq: error: cannot create thread specific key");
abort();
}
if (atexit(tsd_fini) != 0) {
fprintf(stderr, "error: cannot set an exit handler");
fprintf(stderr, "jq: error: cannot set an exit handler");
abort();
}
struct nomem_handler *nomem_handler = calloc(1, sizeof(struct nomem_handler));
if (pthread_setspecific(nomem_handler_key, nomem_handler) != 0) {
fprintf(stderr, "error: cannot set thread specific data");
fprintf(stderr, "jq: error: cannot set thread specific data");
abort();
}
}
@@ -80,7 +80,7 @@ void jv_nomem_handler(jv_nomem_handler_f handler, void *data) {
nomem_handler = pthread_getspecific(nomem_handler_key);
if (nomem_handler == NULL) {
handler(data);
fprintf(stderr, "error: cannot allocate memory\n");
fprintf(stderr, "jq: error: cannot allocate memory\n");
abort();
}
nomem_handler->handler = handler;
@@ -95,7 +95,7 @@ static void memory_exhausted() {
if (nomem_handler)
nomem_handler->handler(nomem_handler->data); // Maybe handler() will longjmp() to safety
// Or not
fprintf(stderr, "error: cannot allocate memory\n");
fprintf(stderr, "jq: error: cannot allocate memory\n");
abort();
}
@@ -110,7 +110,7 @@ void jv_nomem_handler(jv_nomem_handler_f handler, void *data) {
}
static void memory_exhausted() {
fprintf(stderr, "error: cannot allocate memory\n");
fprintf(stderr, "jq: error: cannot allocate memory\n");
abort();
}