+/* luci.cutil.trim(str) */
+static int luci_trim(lua_State *L) {
+ luaL_checkstring(L, 1);
+ lua_settop(L, 1);
+
+ /* pattern and repl */
+ lua_pushliteral(L, "^%s*(.-)%s*$");
+ lua_pushliteral(L, "%1");
+
+ /* get str.gsub */
+ lua_getfield(L, 1, "gsub");
+ lua_insert(L, 1);
+
+ /* str.gsub(str, pattern, repl) */
+ lua_call(L, 3, 1);
+ return 1;
+}
+