prefix die() calls with spmenu:
This commit is contained in:
parent
c7b3e99892
commit
7c301a0bd4
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue