From: fennecdjay Date: Thu, 14 Mar 2019 21:06:20 +0000 (+0100) Subject: :art: Use globbing X-Git-Tag: nightly~2701 X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=26b29578b21deacfd6a9a7a482d1ef25b35954c0;p=gwion.git :art: Use globbing --- diff --git a/.travis.yml b/.travis.yml index c91f6f85..65bb4962 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: c os: - linux # - osx -# - windows + - windows addons: # coverity_scan: @@ -35,11 +35,11 @@ env: - USE_DOUBLE=1 - USE_DOUBLE=0 -#matrix: -# allow_failures: -# - os: +matrix: + allow_failures: + - os: # - osx -# - windows + - windows compiler: - gcc diff --git a/src/plug.c b/src/plug.c index 0df04f8c..0eb8beab 100644 --- a/src/plug.c +++ b/src/plug.c @@ -16,10 +16,7 @@ #include "object.h" #include "import.h" #include "gwion.h" - -static inline int so_filter(const struct dirent* dir) { - return strstr(dir->d_name, ".so") ? 1 : 0; -} +#include "glob.h" typedef m_bool (*import)(Gwi); typedef m_str (*modstr)(void); @@ -69,17 +66,15 @@ ANN PlugInfo* new_plug(const Vector list) { map_init(&p->drv); for(m_uint i = 0; i < vector_size(list); i++) { const m_str dir = (m_str)vector_at(list, i); - struct dirent **file; - int n = scandir(dir, &file, so_filter, alphasort); - if(n > 0) { - while(n--) { - char c[strlen(dir) + strlen(file[n]->d_name) + 2]; - sprintf(c, "%s/%s", dir, file[n]->d_name); - plug_get(p, c); - free(file[n]); - } - free(file); - } + char gname[strlen(dir) + 6]; + strcpy(gname, dir); + strcpy(gname + strlen(dir), "/*.so"); + glob_t results; + if(glob(gname, 0, NULL, &results)) + continue; + for(int i = 0; i < results.gl_pathc; i++) + plug_get(p, results.gl_pathv[i]); + globfree(& results); } return p; }