From d83329a7b8ac152cc1f8f9dfa3128a6abd121ab4 Mon Sep 17 00:00:00 2001 From: sebastid Date: Fri, 30 Sep 2005 00:46:15 +0000 Subject: [PATCH] Move ecore_file_app_exe_get since it doesn't use path SVN revision: 17075 --- legacy/ecore/src/lib/ecore_file/ecore_file.c | 101 ++++++++++++++++++ .../src/lib/ecore_file/ecore_file_path.c | 101 ------------------ 2 files changed, 101 insertions(+), 101 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index a2531142a5..fe6be88319 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c @@ -2,6 +2,7 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "ecore_file_private.h" +#include static int init = 0; @@ -270,3 +271,103 @@ ecore_file_ls(const char *dir) ecore_list_goto_first(list); return list; } + +char * +ecore_file_app_exe_get(const char *app) +{ + char *p, *pp, *exe1 = NULL, *exe2 = NULL; + char *exe; + int in_quot_dbl = 0, in_quot_sing = 0; + + p = (char *)app; + while ((*p) && (isspace(*p))) p++; + exe1 = p; + while (*p) + { + if (in_quot_sing) + { + if (*p == '\'') + in_quot_sing = 0; + } + else if (in_quot_dbl) + { + if (*p == '\"') + in_quot_dbl = 0; + } + else + { + if (*p == '\'') + in_quot_sing = 1; + else if (*p == '\"') + in_quot_dbl = 1; + if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\')))) + break; + } + p++; + } + exe2 = p; + if (exe2 == exe1) return NULL; + exe = malloc(exe2 - exe1 + 1); + if (!exe) return NULL; + p = exe1; + in_quot_dbl = 0; + in_quot_sing = 0; + pp = exe; + while (*p) + { + if (in_quot_sing) + { + if (*p == '\'') + in_quot_sing = 0; + else + { + *pp = *p; + pp++; + } + } + else if (in_quot_dbl) + { + if (*p == '\"') + in_quot_dbl = 0; + else + { + /* techcincally this is wrong. double quotes also accept + * special chars: + * + * $, `, \ + */ + *pp = *p; + pp++; + } + } + else + { + /* technically we should handle special chars: + * + * $, `, \, etc. + */ + if ((p > app) && (p[-1] == '\\')) + { + if (*p != '\n') + { + *pp = *p; + pp++; + } + } + else if (*p == '\'') + in_quot_sing = 1; + else if (*p == '\"') + in_quot_dbl = 1; + else if (isspace(*p)) + break; + else + { + *pp = *p; + pp++; + } + } + p++; + } + *pp = 0; + return exe; +} diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_path.c b/legacy/ecore/src/lib/ecore_file/ecore_file_path.c index 707b603a1c..a9c5963dca 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_path.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_path.c @@ -2,7 +2,6 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "ecore_file_private.h" -#include static int init = 0; static Ecore_List *__ecore_file_path_bin; @@ -74,103 +73,3 @@ ecore_file_app_installed(const char *exe) } return 0; } - -char * -ecore_file_app_exe_get(const char *app) -{ - char *p, *pp, *exe1 = NULL, *exe2 = NULL; - char *exe; - int in_quot_dbl = 0, in_quot_sing = 0; - - p = (char *)app; - while ((*p) && (isspace(*p))) p++; - exe1 = p; - while (*p) - { - if (in_quot_sing) - { - if (*p == '\'') - in_quot_sing = 0; - } - else if (in_quot_dbl) - { - if (*p == '\"') - in_quot_dbl = 0; - } - else - { - if (*p == '\'') - in_quot_sing = 1; - else if (*p == '\"') - in_quot_dbl = 1; - if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\')))) - break; - } - p++; - } - exe2 = p; - if (exe2 == exe1) return NULL; - exe = malloc(exe2 - exe1 + 1); - if (!exe) return NULL; - p = exe1; - in_quot_dbl = 0; - in_quot_sing = 0; - pp = exe; - while (*p) - { - if (in_quot_sing) - { - if (*p == '\'') - in_quot_sing = 0; - else - { - *pp = *p; - pp++; - } - } - else if (in_quot_dbl) - { - if (*p == '\"') - in_quot_dbl = 0; - else - { - /* techcincally this is wrong. double quotes also accept - * special chars: - * - * $, `, \ - */ - *pp = *p; - pp++; - } - } - else - { - /* technically we should handle special chars: - * - * $, `, \, etc. - */ - if ((p > app) && (p[-1] == '\\')) - { - if (*p != '\n') - { - *pp = *p; - pp++; - } - } - else if (*p == '\'') - in_quot_sing = 1; - else if (*p == '\"') - in_quot_dbl = 1; - else if (isspace(*p)) - break; - else - { - *pp = *p; - pp++; - } - } - p++; - } - *pp = 0; - return exe; -}