From baa6f1841030ae5717c3cc7b1fd7a1859b3a8834 Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tsisyk.com> Date: Wed, 15 Jul 2015 15:10:43 +0300 Subject: [PATCH] Fix modulename.functioname syntax for C procedures --- src/box/func.cc | 14 +++++++------- test/app/function1.c | 10 ++++++++++ test/app/function1.result | 2 ++ test/app/function1.test.lua | 3 +++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/box/func.cc b/src/box/func.cc index 21708cb6a0..73f00a346f 100644 --- a/src/box/func.cc +++ b/src/box/func.cc @@ -90,16 +90,16 @@ func_load(struct func *func) * Extract package name from function name. * E.g. name = foo.bar.baz, function = baz, package = foo.bar */ + const char *sym; const char *package = func->def.name; - const char *package_end = NULL; - const char *sym = package; - while ((sym = strchr(sym, '.'))) - package_end = sym; - if (package_end == NULL) { + const char *package_end = strrchr(package, '.'); + if (package_end != NULL) { + /* module.submodule.function => module.submodule, function */ + sym = package_end + 1; + } else { + /* package == function => function, function */ sym = package; package_end = package + strlen(package); - } else { - sym = package_end + 1; } /* First argument of searchpath: name */ diff --git a/test/app/function1.c b/test/app/function1.c index b73e500823..d0308c662b 100644 --- a/test/app/function1.c +++ b/test/app/function1.c @@ -1,8 +1,18 @@ #include "tarantool.h" +#include <stdio.h> int function1(struct request *request, struct port *port) { say_info("-- function1 - called --"); + printf("ok - function1\n"); + return 0; +} + +int +test(struct request *request, struct port *port) +{ + say_info("-- test - called --"); + printf("ok - test\n"); return 0; } diff --git a/test/app/function1.result b/test/app/function1.result index e69de29bb2..2081834134 100644 --- a/test/app/function1.result +++ b/test/app/function1.result @@ -0,0 +1,2 @@ +ok - function1 +ok - test diff --git a/test/app/function1.test.lua b/test/app/function1.test.lua index f84ff151a4..f63a02f9ae 100755 --- a/test/app/function1.test.lua +++ b/test/app/function1.test.lua @@ -15,8 +15,11 @@ net = require('net.box') box.schema.func.create('function1', {language = "C"}) box.schema.user.grant('guest', 'execute', 'function', 'function1') +box.schema.func.create('function1.test', {language = "C"}) +box.schema.user.grant('guest', 'execute', 'function', 'function1.test') c = net:new(os.getenv("LISTEN")) c:call('function1') +c:call('function1.test') os.exit(0) -- GitLab