File tree Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ description = """
11
11
Sources of Lua 5.1/5.2/5.3/5.4 and logic to build them.
12
12
"""
13
13
14
+ [features ]
15
+ ucid = [] # accept UniCode IDentifiers
16
+
14
17
[workspace ]
15
18
members = [" testcrate" ]
16
19
Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ impl Build {
108
108
109
109
if let Lua54 = version {
110
110
config. define ( "LUA_COMPAT_5_3" , None ) ;
111
+ #[ cfg( feature = "ucid" ) ]
112
+ config. define ( "LUA_UCID" , None ) ;
111
113
}
112
114
113
115
if cfg ! ( debug_assertions) {
Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ lua53 = []
10
10
lua52 = []
11
11
lua51 = []
12
12
13
- [build-dependencies ]
14
- lua-src = { path = " .." }
13
+ [build-dependencies .lua-src ]
14
+ path = " .."
15
+ features = [" ucid" ]
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ extern "C" {
5
5
pub fn luaL_openlibs ( state : * mut c_void ) ;
6
6
pub fn lua_getfield ( state : * mut c_void , index : c_int , k : * const c_char ) ;
7
7
pub fn lua_tolstring ( state : * mut c_void , index : c_int , len : * mut c_long ) -> * const c_char ;
8
+ pub fn luaL_loadstring ( state : * mut c_void , s : * const c_char ) -> c_int ;
8
9
9
10
#[ cfg( any( feature = "lua52" , feature = "lua53" , feature = "lua54" ) ) ]
10
11
pub fn lua_getglobal ( state : * mut c_void , k : * const c_char ) ;
@@ -41,3 +42,16 @@ fn lua_works() {
41
42
assert_eq ! ( version, "Lua 5.4" . as_bytes( ) ) ;
42
43
}
43
44
}
45
+
46
+ #[ test]
47
+ fn unicode_identifiers ( ) {
48
+ unsafe {
49
+ let state = luaL_newstate ( ) ;
50
+ let code = "local 😀 = 0\n " ;
51
+ let ret = luaL_loadstring ( state, code. as_ptr ( ) . cast ( ) ) ;
52
+ #[ cfg( feature = "lua54" ) ]
53
+ assert_eq ! ( 0 , ret) ;
54
+ #[ cfg( not( feature = "lua54" ) ) ]
55
+ assert_ne ! ( 0 , ret) ;
56
+ }
57
+ }
You can’t perform that action at this time.
0 commit comments