True print
* print handles any arguments
* copyright notices (not in examples yet)
--- a/CMakeLists.txt Mon Apr 27 12:51:53 2009 +0300
+++ b/CMakeLists.txt Thu May 21 00:13:26 2009 +0300
@@ -1,3 +1,19 @@
+
+## Copyright 2009 Myhailo Danylenko
+# This file is part of mcabber-lua.
+#
+# mcabber-lua is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.6)
project(mcabber-lua C)
--- a/TODO Mon Apr 27 12:51:53 2009 +0300
+++ b/TODO Thu May 21 00:13:26 2009 +0300
@@ -1,5 +1,4 @@
-print should allow other types to be printed
finish roster list information
non-setting settings?
mcabber_config_file use option to set dir?
@@ -23,4 +22,9 @@
fix add_feature to 1) not add existing items 2) not add default items
check all that callbacks for empty 'to' fields in print_info
reply routine?
+put here mcabber headers snapshot
+put here mcabber-modules patch
+change module name to just lua?
+go through TODO and remove done :/
+update build system
--- a/config.h.in Mon Apr 27 12:51:53 2009 +0300
+++ b/config.h.in Thu May 21 00:13:26 2009 +0300
@@ -1,3 +1,20 @@
+
+/* Copyright 2009 Myhailo Danylenko
+
+This file is part of mcabber-lua.
+
+mcabber-lua is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef MLUA_CONFIG_H
#define MLUA_CONFIG_H
--- a/docgen.pl Mon Apr 27 12:51:53 2009 +0300
+++ b/docgen.pl Thu May 21 00:13:26 2009 +0300
@@ -1,5 +1,20 @@
#! /usr/bin/perl
+# Copyright 2009 Myhailo Danylenko
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
use strict;
use warnings;
--- a/main.c Mon Apr 27 12:51:53 2009 +0300
+++ b/main.c Thu May 21 00:13:26 2009 +0300
@@ -1,3 +1,20 @@
+
+/* Copyright 2009 Myhailo Danylenko
+
+This file is part of mcabber-lua.
+
+mcabber-lua is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <glib.h>
#include <gmodule.h>
@@ -38,10 +55,40 @@
/// print
/// Prints its arguments to log with default priority.
-/// A: string/number, ...
+/// A: something, ...
static int lua_global_print (lua_State *L)
{
- lua_concat (L, lua_gettop (L));
+ int top = lua_gettop (L);
+ int i;
+ luaL_Buffer B;
+ luaL_buffinit (L, &B);
+ for (i = 1; i <= top; i++) {
+ int type = lua_type (L, i);
+ if (i > 1)
+ luaL_addchar (&B, '\t');
+ if (type == LUA_TSTRING) {
+ size_t len;
+ const char *str = lua_tolstring (L, i, &len);
+ luaL_addlstring (&B, str, len);
+ } else if (type == LUA_TNUMBER)
+ luaL_addstring (&B, lua_tostring (L, i)); // XXX: modifies
+ else if (type == LUA_TBOOLEAN) {
+ if (lua_toboolean (L, i))
+ luaL_addstring (&B, "true");
+ else
+ luaL_addstring (&B, "false");
+ } else if (type == LUA_TNIL)
+ luaL_addstring (&B, "nil");
+ else {
+ char xbuf[9];
+ luaL_addstring (&B, luaL_typename (L, i));
+ luaL_addstring (&B, ": 0x");
+ snprintf (&xbuf[0], 9, "%08x", (int) lua_topointer (L, i));
+ luaL_addlstring (&B, xbuf, 8); // XXX
+ }
+ }
+ luaL_pushresult (&B);
+
scr_LogPrint (LPRINT_LOGNORM | LPRINT_NOTUTF8, lua_tostring (L, -1));
return 0;
}
--- a/util.c Mon Apr 27 12:51:53 2009 +0300
+++ b/util.c Thu May 21 00:13:26 2009 +0300
@@ -1,5 +1,20 @@
-#include <glib.h> // g_ascii_strcasecmp
+/* Copyright 2009 Myhailo Danylenko
+
+This code is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <strings.h>
#include <lua.h>
#include <lauxlib.h>
@@ -8,7 +23,7 @@
enum_value_t string2enum (const char *string, const string2enum_t *set)
{
while (set->string) {
- if (!g_ascii_strcasecmp (string, set->string))
+ if (!strcasecmp (string, set->string))
return set->value;
++set;
}
@@ -80,6 +95,7 @@
luaL_argerror (L, index, "wrong key type of flags table");
lua_pop (L, 1);
}
+ return retval;
} else
luaL_argerror (L, index, "integer, string, or table of ones expected");
return 0; // never happens
--- a/util.h Mon Apr 27 12:51:53 2009 +0300
+++ b/util.h Thu May 21 00:13:26 2009 +0300
@@ -1,3 +1,18 @@
+
+/* Copyright 2009 Myhailo Danylenko
+
+This code is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef MISC_LUA_UTIL_H
#define MISC_LUA_UTIL_H