From b6782ccf1fa9e0f1778b79bdaf2367c8a84a1d6c Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 25 Aug 2017 10:23:25 -0700 Subject: Silence warnings --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 4c06a48..dfae909 100644 --- a/src/utils.c +++ b/src/utils.c @@ -157,7 +157,7 @@ char *feh_unique_filename(char *path, char *basename) { char *tmpname; char num[10]; - char cppid[10]; + char cppid[12]; static long int i = 1; struct stat st; pid_t ppid; -- cgit v1.2.3 From de36c62308fb982f9794db87a856fa6aae042ce6 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 3 Oct 2017 19:58:27 +0200 Subject: Make shell_escape available as a generic utility function --- src/slideshow.c | 23 ----------------------- src/utils.c | 23 +++++++++++++++++++++++ src/utils.h | 1 + 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'src/utils.c') diff --git a/src/slideshow.c b/src/slideshow.c index 4a71dc3..db389d5 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -464,29 +464,6 @@ void feh_action_run(feh_file * file, char *action, winwidget winwid) return; } -char *shell_escape(char *input) -{ - static char ret[1024]; - unsigned int out = 0, in = 0; - - ret[out++] = '\''; - for (in = 0; input[in] && (out < (sizeof(ret) - 7)); in++) { - if (input[in] == '\'') { - ret[out++] = '\''; - ret[out++] = '"'; - ret[out++] = '\''; - ret[out++] = '"'; - ret[out++] = '\''; - } - else - ret[out++] = input[in]; - } - ret[out++] = '\''; - ret[out++] = '\0'; - - return ret; -} - char *format_size(int size) { static char ret[5]; diff --git a/src/utils.c b/src/utils.c index dfae909..ec30d4a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -201,3 +201,26 @@ char *ereadfile(char *path) return estrdup(buffer); } + +char *shell_escape(char *input) +{ + static char ret[1024]; + unsigned int out = 0, in = 0; + + ret[out++] = '\''; + for (in = 0; input[in] && (out < (sizeof(ret) - 7)); in++) { + if (input[in] == '\'') { + ret[out++] = '\''; + ret[out++] = '"'; + ret[out++] = '\''; + ret[out++] = '"'; + ret[out++] = '\''; + } + else + ret[out++] = input[in]; + } + ret[out++] = '\''; + ret[out++] = '\0'; + + return ret; +} diff --git a/src/utils.h b/src/utils.h index c0d243b..22cbbf8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -46,6 +46,7 @@ char *estrjoin(const char *separator, ...); char path_is_url(char *path); char *feh_unique_filename(char *path, char *basename); char *ereadfile(char *path); +char *shell_escape(char *input); #define ESTRAPPEND(a,b) \ {\ -- cgit v1.2.3