diff --git a/libs/arg.c b/libs/arg.c index 84e9072..c24f3ed 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -362,20 +362,20 @@ savehistory(char *input) fp = fopen(histfile, "w"); if (!fp) { - die("failed to open %s", histfile); + die("spmenu: failed to open %s", histfile); } for (i = histsz < maxhist ? 0 : histsz - maxhist; i < histsz; i++) { if (0 >= fprintf(fp, "%s\n", history[i])) { - die("failed to write to %s", histfile); + die("spmenu: failed to write to %s", histfile); } } if (histsz == 0 || histdup || (histsz > 0 && strcmp(input, history[histsz-1]) != 0)) { if (0 >= fputs(input, fp)) { - die("failed to write to %s", histfile); + die("spmenu: failed to write to %s", histfile); } } if (fclose(fp)) { - die("failed to close file %s", histfile); + die("spmenu: failed to close file %s", histfile); } out: diff --git a/libs/match.c b/libs/match.c index d5673df..192fe8b 100644 --- a/libs/match.c +++ b/libs/match.c @@ -48,7 +48,7 @@ fuzzymatch(void) if (number_of_matches) { // initialize array with matches if (!(fuzzymatches = realloc(fuzzymatches, number_of_matches * sizeof(struct item*)))) - die("cannot realloc %u bytes:", number_of_matches * sizeof(struct item*)); + die("spmenu: cannot realloc %u bytes:", number_of_matches * sizeof(struct item*)); for (i = 0, it = matches; it && i < number_of_matches; i++, it = it->right) { fuzzymatches[i] = it; } @@ -103,7 +103,7 @@ match(void) // separate input text into tokens to be matched individually for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " ")) if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv))) - die("cannot realloc %u bytes:", tokn * sizeof *tokv); + die("spmenu: cannot realloc %u bytes:", tokn * sizeof *tokv); len = tokc ? strlen(tokv[0]) : 0; matches = lhpprefix = lprefix = lsubstr = matchend = hpprefixend = prefixend = substrend = NULL; diff --git a/libs/sort.c b/libs/sort.c index 128309d..0f96671 100644 --- a/libs/sort.c +++ b/libs/sort.c @@ -8,10 +8,10 @@ tokenize(char *source, const char *delim, int *llen) while (token) { if (listlength + 1 >= list_size) { if (!(list = realloc(list, (list_size += 8) * sizeof(*list)))) - die("Unable to realloc %zu bytes\n", list_size * sizeof(*list)); + die("spmenu: unable to realloc %zu bytes\n", list_size * sizeof(*list)); } if (!(list[listlength] = strdup(token))) - die("Unable to strdup %zu bytes\n", strlen(token) + 1); + die("spmenu: unable to strdup %zu bytes\n", strlen(token) + 1); token = strtok(NULL, delim); listlength++; } diff --git a/libs/stream.c b/libs/stream.c index dfcb7c3..c114908 100644 --- a/libs/stream.c +++ b/libs/stream.c @@ -19,12 +19,12 @@ readstdin(void) if (i + 1 >= itemsiz) { itemsiz += 256; if (!(items = realloc(items, itemsiz * sizeof(*items)))) - die("cannot realloc %zu bytes:", itemsiz * sizeof(*items)); + die("spmenu: cannot realloc %zu bytes:", itemsiz * sizeof(*items)); } if ((p = strchr(buf, '\n'))) *p = '\0'; if (!(items[i].text = strdup(buf))) - die("cannot strdup %u bytes:", strlen(buf) + 1); + die("spmenu: cannot strdup %u bytes:", strlen(buf) + 1); items[i].hp = arrayhas(hpitems, hplength, items[i].text); drw_font_getexts(drw->font, buf, strlen(buf), &tmpmax, NULL, True); if (tmpmax > inputw) { @@ -80,12 +80,14 @@ readstdin(void) // spmenu:version if (!strncmp("version", items[i].ex, strlen("version"))) { - die("spmenu version %s", VERSION); + fprintf(stdout, "spmenu version %s", VERSION); + exit(0); } // spmenu:license if (!strncmp("license", items[i].ex, strlen("license"))) { - die("spmenu is licensed under the MIT license. See the included LICENSE file for more information."); + fprintf(stdout, "spmenu is licensed under the MIT license. See the included LICENSE file for more information."); + exit(0); } // spmenu:test