[Groonga-commit] groonga/groonga at 8b741f8 [master] Support custom plugins dir by grn_pugin_get_system_plugins_dir()

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Feb 5 14:47:34 JST 2015


Kouhei Sutou	2015-02-05 14:47:34 +0900 (Thu, 05 Feb 2015)

  New Revision: 8b741f8d6bc87db3baac635d725b81f8314c93f0
  https://github.com/groonga/groonga/commit/8b741f8d6bc87db3baac635d725b81f8314c93f0

  Message:
    Support custom plugins dir by grn_pugin_get_system_plugins_dir()

  Modified files:
    lib/plugin.c

  Modified: lib/plugin.c (+19 -12)
===================================================================
--- lib/plugin.c    2015-02-05 13:33:55 +0900 (86a1c14)
+++ lib/plugin.c    2015-02-05 14:47:34 +0900 (535cb9b)
@@ -455,8 +455,8 @@ grn_plugin_register_by_path(grn_ctx *ctx, const char *path)
 #ifdef WIN32
 static char *win32_plugins_dir = NULL;
 static char win32_plugins_dir_buffer[PATH_MAX];
-const char *
-grn_plugin_get_system_plugins_dir(void)
+static const char *
+grn_plugin_get_default_system_plugins_dir(void)
 {
   if (!win32_plugins_dir) {
     const char *base_dir;
@@ -474,13 +474,26 @@ grn_plugin_get_system_plugins_dir(void)
 }
 
 #else /* WIN32 */
-const char *
-grn_plugin_get_system_plugins_dir(void)
+static const char *
+grn_plugin_get_default_system_plugins_dir(void)
 {
   return GRN_PLUGINS_DIR;
 }
 #endif /* WIN32 */
 
+const char *
+grn_plugin_get_system_plugins_dir(void)
+{
+  const char *plugins_dir;
+
+  plugins_dir = getenv("GRN_PLUGINS_DIR");
+  if (!plugins_dir) {
+    plugins_dir = grn_plugin_get_default_system_plugins_dir();
+  }
+
+  return plugins_dir;
+}
+
 static char *
 grn_plugin_find_path_raw(grn_ctx *ctx, const char *path)
 {
@@ -594,10 +607,7 @@ grn_plugin_find_path(grn_ctx *ctx, const char *name)
   if (name[0] == '/') {
     path[0] = '\0';
   } else {
-    plugins_dir = getenv("GRN_PLUGINS_DIR");
-    if (!plugins_dir) {
-      plugins_dir = grn_plugin_get_system_plugins_dir();
-    }
+    plugins_dir = grn_plugin_get_system_plugins_dir();
     strcpy(path, plugins_dir);
 
     dir_last_char = plugins_dir[strlen(path) - 1];
@@ -670,10 +680,7 @@ grn_plugin_register(grn_ctx *ctx, const char *name)
         prefix_separator = "";
         suffix = "";
       } else {
-        prefix = getenv("GRN_PLUGINS_DIR");
-        if (!prefix) {
-          prefix = grn_plugin_get_system_plugins_dir();
-        }
+        prefix = grn_plugin_get_system_plugins_dir();
         if (prefix[strlen(prefix) - 1] != '/') {
           prefix_separator = "/";
         } else {
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index