Don't place conky_ in front of lua functionnames if it's already there
authorNikolas Garofil <garo@dunaldi.garofil.be>
Sat, 25 Jul 2009 10:03:09 +0000 (12:03 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Sat, 25 Jul 2009 10:03:09 +0000 (12:03 +0200)
doc/variables.xml
src/llua.c
src/llua.h

index fbdd5cb..a539389 100644 (file)
         </term>
         <listitem>Executes a Lua function with given parameters,
         then prints the returned string. See also 'lua_load' on how
-        to load scripts. 
+        to load scripts. Conky puts 'conky_' in front of function_name
+        to prevent accidental calls to the wrong function unless you
+        put you place 'conky_' in front of it yourself.
         <para /></listitem>
     </varlistentry>
     <varlistentry>
         <listitem>Executes a Lua function with given parameters and
         draws a bar. Expects result value to be an integer between
         0 and 100. See also 'lua_load' on how to load scripts. 
+        Conky puts 'conky_' in front of function_name to prevent
+        accidental calls to the wrong function unless you
+        put you place 'conky_' in front of it yourself.
         <para /></listitem>
     </varlistentry>
     <varlistentry>
         <listitem>Executes a Lua function with given parameters and
         draws a gauge. Expects result value to be an integer
         between 0 and 100. See also 'lua_load' on how to load
-        scripts. 
+        scripts. Conky puts 'conky_' in front of function_name
+        to prevent accidental calls to the wrong function unless you
+        put you place 'conky_' in front of it yourself.
         <para /></listitem>
     </varlistentry>
     <varlistentry>
         load scripts. Takes the switch '-t' to use a temperature
         gradient, which makes the gradient values change depending
         on the amplitude of a particular graph value (try it and
-        see). 
+        see). Conky puts 'conky_' in front of function_name
+        to prevent accidental calls to the wrong function unless you
+        put you place 'conky_' in front of it yourself.
         <para /></listitem>
     </varlistentry>
     <varlistentry>
         <listitem>Executes a Lua function with given parameters as
         per $lua, then parses and prints the result value as per
         the syntax for Conky's TEXT section. See also 'lua_load' on
-        how to load scripts. 
+        how to load scripts. Conky puts 'conky_' in front of function_name
+        to prevent accidental calls to the wrong function unless you
+        put you place 'conky_' in front of it yourself.
         <para /></listitem>
     </varlistentry>
     <varlistentry>
index d5afd0d..22ac592 100644 (file)
@@ -136,7 +136,11 @@ char *llua_do_call(const char *string, int retc)
        }
 
        /* call only conky_ prefixed functions */
-       snprintf(func, 64, "conky_%s", ptr);
+       if(strncmp(ptr, LUAPREFIX, strlen(LUAPREFIX)) == 0) {
+               snprintf(func, 64, "%s", ptr);
+       }else{
+               snprintf(func, 64, "%s%s", LUAPREFIX, ptr);
+       }
 
        /* push the function name to stack */
        lua_getglobal(lua_L, func);
index 793a181..f19da18 100644 (file)
@@ -32,6 +32,8 @@
 #include "x11.h"
 #endif /* X11 */
 
+#define LUAPREFIX "conky_"
+
 /* load a lua script */
 void llua_load(const char *script);
 /* call a function with args, and return a string from it (must be free'd) */