Skip to content

Commit

Permalink
support for language bindings to pass empty strings in place of nil
Browse files Browse the repository at this point in the history
this helps with integration in golang and other scenarios
  • Loading branch information
jaromil committed Oct 29, 2018
1 parent 47be7ee commit 89e271e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/zenroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,17 @@ int zenroom_exec(char *script, char *conf, char *keys,
if(!script) {
error(L, "NULL string as script for zenroom_exec()");
return EXIT_FAILURE; }
set_debug(verbosity);
if(script[0] == '\0') {
error(L, "Empty string as script for zenroom_exec()");
return EXIT_FAILURE; }

set_debug(verbosity);

Z = zen_init(conf, keys, data);
char *c, *k, *d;
c = (conf[0] == '\0') ? NULL : conf;
k = (keys[0] == '\0') ? NULL : keys;
d = (data[0] == '\0') ? NULL : data;
Z = zen_init(c, k, d);
if(!Z) {
error(L, "Initialisation failed.");
return EXIT_FAILURE; }
Expand Down Expand Up @@ -279,9 +286,17 @@ int zenroom_exec_tobuf(char *script, char *conf, char *keys,
if(!script) {
error(L, "NULL string as script for zenroom_exec()");
return EXIT_FAILURE; }
if(script[0] == '\0') {
error(L, "Empty string as script for zenroom_exec()");
return EXIT_FAILURE; }

set_debug(verbosity);

Z = zen_init(conf, keys, data);
char *c, *k, *d;
c = (conf[0] == '\0') ? NULL : conf;
k = (keys[0] == '\0') ? NULL : keys;
d = (data[0] == '\0') ? NULL : data;
Z = zen_init(c, k, d);
if(!Z) {
error(L, "Initialisation failed.");
return EXIT_FAILURE; }
Expand Down

0 comments on commit 89e271e

Please sign in to comment.