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 = """
1111Sources of Lua 5.1/5.2/5.3/5.4 and logic to build them.
1212"""
1313
14+ [features ]
15+ ucid = [] # accept UniCode IDentifiers
16+
1417[workspace ]
1518members = [" testcrate" ]
1619
Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ impl Build {
108108
109109 if let Lua54 = version {
110110 config. define ( "LUA_COMPAT_5_3" , None ) ;
111+ #[ cfg( feature = "ucid" ) ]
112+ config. define ( "LUA_UCID" , None ) ;
111113 }
112114
113115 if cfg ! ( debug_assertions) {
Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ lua53 = []
1010lua52 = []
1111lua51 = []
1212
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" {
55 pub fn luaL_openlibs ( state : * mut c_void ) ;
66 pub fn lua_getfield ( state : * mut c_void , index : c_int , k : * const c_char ) ;
77 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 ;
89
910 #[ cfg( any( feature = "lua52" , feature = "lua53" , feature = "lua54" ) ) ]
1011 pub fn lua_getglobal ( state : * mut c_void , k : * const c_char ) ;
@@ -41,3 +42,16 @@ fn lua_works() {
4142 assert_eq ! ( version, "Lua 5.4" . as_bytes( ) ) ;
4243 }
4344}
45+
46+ #[ test]
47+ fn unicode_identifiers ( ) {
48+ unsafe {
49+ let state = luaL_newstate ( ) ;
50+ let code = "local 😀 = 0\0 " ;
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