@@ -5,7 +5,7 @@ MANPREFIX := $(PREFIX)/share/man | |||||
CC ?= gcc | CC ?= gcc | ||||
CFLAGS += -std=c99 -Wall -pedantic | CFLAGS += -std=c99 -Wall -pedantic | ||||
CPPFLAGS += -I$(PREFIX)/include -D_XOPEN_SOURCE=500 | |||||
CPPFLAGS += -I$(PREFIX)/include -D_XOPEN_SOURCE=700 | |||||
LDFLAGS += -L$(PREFIX)/lib | LDFLAGS += -L$(PREFIX)/lib | ||||
LIBS := -lX11 -lImlib2 | LIBS := -lX11 -lImlib2 | ||||
@@ -825,8 +825,9 @@ int main(int argc, char **argv) | |||||
fileidx = 0; | fileidx = 0; | ||||
if (options->from_stdin) { | if (options->from_stdin) { | ||||
n = 0; | |||||
filename = NULL; | filename = NULL; | ||||
while ((len = get_line(&filename, &n, stdin)) > 0) { | |||||
while ((len = getline(&filename, &n, stdin)) > 0) { | |||||
if (filename[len-1] == '\n') | if (filename[len-1] == '\n') | ||||
filename[len-1] = '\0'; | filename[len-1] = '\0'; | ||||
check_add_file(filename, true); | check_add_file(filename, true); | ||||
@@ -883,9 +884,9 @@ int main(int argc, char **argv) | |||||
const char *name[] = { "image-info", "key-handler" }; | const char *name[] = { "image-info", "key-handler" }; | ||||
for (i = 0; i < ARRLEN(cmd); i++) { | for (i = 0; i < ARRLEN(cmd); i++) { | ||||
len = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12; | |||||
*cmd[i] = (char*) s_malloc(len); | |||||
snprintf(*cmd[i], len, "%s%s/sxiv/exec/%s", homedir, dsuffix, name[i]); | |||||
n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12; | |||||
*cmd[i] = (char*) s_malloc(n); | |||||
snprintf(*cmd[i], n, "%s%s/sxiv/exec/%s", homedir, dsuffix, name[i]); | |||||
if (access(*cmd[i], X_OK) != 0) { | if (access(*cmd[i], X_OK) != 0) { | ||||
free(*cmd[i]); | free(*cmd[i]); | ||||
*cmd[i] = NULL; | *cmd[i] = NULL; | ||||
@@ -96,36 +96,6 @@ void die(const char* fmt, ...) | |||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
} | } | ||||
ssize_t get_line(char **buf, size_t *n, FILE *stream) | |||||
{ | |||||
size_t len; | |||||
char *s; | |||||
if (*buf == NULL || *n == 0) { | |||||
*n = BUF_SIZE; | |||||
*buf = (char*) s_malloc(*n); | |||||
} | |||||
s = *buf; | |||||
while (true) { | |||||
if (fgets(s, *n - (s - *buf), stream) == NULL) | |||||
return -1; | |||||
len = strlen(s); | |||||
if (feof(stream)) | |||||
break; | |||||
if (len > 0 && s[len-1] == '\n') | |||||
break; | |||||
if (len + 1 == *n - (s - *buf)) { | |||||
*buf = (char*) s_realloc(*buf, 2 * *n); | |||||
s = *buf + *n - 1; | |||||
*n *= 2; | |||||
} else { | |||||
s += len; | |||||
} | |||||
} | |||||
return s - *buf + len; | |||||
} | |||||
void size_readable(float *size, const char **unit) | void size_readable(float *size, const char **unit) | ||||
{ | { | ||||
const char *units[] = { "", "K", "M", "G" }; | const char *units[] = { "", "K", "M", "G" }; | ||||
@@ -68,8 +68,6 @@ char* s_strdup(const char*); | |||||
void warn(const char*, ...); | void warn(const char*, ...); | ||||
void die(const char*, ...); | void die(const char*, ...); | ||||
ssize_t get_line(char**, size_t*, FILE*); | |||||
void size_readable(float*, const char**); | void size_readable(float*, const char**); | ||||
char* absolute_path(const char*); | char* absolute_path(const char*); | ||||