|
@@ -179,7 +179,9 @@ static int l_new_iriref_rel (lua_State *L)
|
|
|
* datatype has precedence. If both are nil, datatype is set to the default
|
|
|
* (xsd:string).
|
|
|
*
|
|
|
- * Data type can be either a namespace-prefixed or a fully qualified URI.
|
|
|
+ * Data type can be either a namespace-prefixed or a fully qualified URI. This
|
|
|
+ * must be specified with arg 4 (dtype_ns), set to `true` if the string passed
|
|
|
+ * is a namespace-prefixed URI. Volksdata cannot guess that.
|
|
|
*/
|
|
|
static int l_new_lit (lua_State *L)
|
|
|
{
|
|
@@ -187,17 +189,17 @@ static int l_new_lit (lua_State *L)
|
|
|
*data = luaL_checkstring (L, 1),
|
|
|
*dtype_str = lua_tostring (L, 2);
|
|
|
const char *lang = lua_tostring (L, 3);
|
|
|
+ const bool dtype_ns = lua_toboolean (L, 4);
|
|
|
|
|
|
VOLK_Term **tp = allocate_term (L);
|
|
|
VOLK_Term *dtype;
|
|
|
|
|
|
if (dtype_str) {
|
|
|
- // TODO check memory leak.
|
|
|
- dtype = VOLK_iriref_new_ns (dtype_str);
|
|
|
- if (!dtype) dtype = VOLK_iriref_new (dtype_str);
|
|
|
+ dtype = dtype_ns ? VOLK_iriref_new_ns (dtype_str) :
|
|
|
+ VOLK_iriref_new (dtype_str);
|
|
|
LUA_NLCHECK (dtype, "Error creating data type URI.");
|
|
|
*tp = VOLK_literal_new (data, dtype);
|
|
|
- LUA_NLCHECK (tp, "Error creating literal term.");
|
|
|
+ LUA_NLCHECK (*tp, "Error creating literal term.");
|
|
|
}
|
|
|
else if (lang) *tp = VOLK_lt_literal_new (data, (char *)lang);
|
|
|
else *tp = VOLK_literal_new (data, NULL);
|