Make the library comptible with both Lua 5.1 and Lua 5.2

This commit is contained in:
Alexandre Erwin Ittner 2011-12-05 19:40:34 -02:00
parent 044877f838
commit 1fc031875f
2 changed files with 17 additions and 7 deletions

12
README
View File

@ -1,5 +1,5 @@
Lua-iconv: performs character set conversions in Lua Lua-iconv: performs character set conversions in Lua
(c) 2005-10 Alexandre Erwin Ittner <alexandre@ittner.com.br> (c) 2005-11 Alexandre Erwin Ittner <alexandre@ittner.com.br>
Project page: http://ittner.github.com/lua-iconv/ Project page: http://ittner.github.com/lua-iconv/
@ -11,8 +11,8 @@ sequence of corresponding characters in another codeset. The codesets
are those specified in the iconv.new() call that returned the conversion are those specified in the iconv.new() call that returned the conversion
descriptor, cd. descriptor, cd.
Lua-iconv 7 and later *requires* Lua 5.2. If you are using Lua 5.1, please Lua-iconv 7 *requires* Lua 5.1 or Lua 5.2. For Lua 5.0, use the first
use the release 6; For Lua 5.0, use the first release (lua-iconv-r1). release (lua-iconv-r1).
Details on iconv may be obtained in the Open Group's interface definition Details on iconv may be obtained in the Open Group's interface definition
(http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html). (http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html).
@ -39,7 +39,7 @@ untar the distribution package and, within the program directory, type:
make install make install
as root. The library will be compiled and installed on the in the correct as root. The library will be compiled and installed on the in the correct
path (which is defined in lua5.2.pc). Compiling on systems without pkg-config path (which is defined in lua5.x.pc). Compiling on systems without pkg-config
requires manual changes in the Makefile (this includes Windows). requires manual changes in the Makefile (this includes Windows).
@ -47,7 +47,7 @@ requires manual changes in the Makefile (this includes Windows).
=== Loading and initialization === === Loading and initialization ===
Lua-iconv is a shared library that must be loaded in the Lua interpreter Lua-iconv is a shared library that must be loaded in the Lua interpreter
before use. From Lua 5.1 and later, you can simply do a before use. You can simply do a
local iconv = require("iconv") local iconv = require("iconv")
@ -102,7 +102,7 @@ Lua-iconv is copyrighted free software: it can be used for both academic
and commercial purposes at absolutely no cost. There are no royalties and commercial purposes at absolutely no cost. There are no royalties
or GNU-like "copyleft" restrictions. The legal details are below: or GNU-like "copyleft" restrictions. The legal details are below:
Lua-iconv is (c) 2005-10 Alexandre Erwin Ittner Lua-iconv is (c) 2005-11 Alexandre Erwin Ittner
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -1,6 +1,6 @@
/* /*
* luaiconv - Performs character set conversions in Lua * luaiconv - Performs character set conversions in Lua
* (c) 2005-10 Alexandre Erwin Ittner <alexandre@ittner.com.br> * (c) 2005-11 Alexandre Erwin Ittner <alexandre@ittner.com.br>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -39,6 +39,16 @@
#define LIB_VERSION LIB_NAME " 7" #define LIB_VERSION LIB_NAME " 7"
#define ICONV_TYPENAME "iconv_t" #define ICONV_TYPENAME "iconv_t"
#if LUA_VERSION_NUM < 501
#error "Unsuported Lua version. You must use Lua >= 5.1"
#endif
#if LUA_VERSION_NUM < 502
#define luaL_newlib(L, f) { lua_newtable(L); luaL_register(L, NULL, f); }
#define lua_rawlen(L, i) lua_objlen(L, i)
#endif
#define BOXPTR(L, p) (*(void**)(lua_newuserdata(L, sizeof(void*))) = (p)) #define BOXPTR(L, p) (*(void**)(lua_newuserdata(L, sizeof(void*))) = (p))
#define UNBOXPTR(L, i) (*(void**)(lua_touserdata(L, i))) #define UNBOXPTR(L, i) (*(void**)(lua_touserdata(L, i)))