ffi string definitions

  • From: Patrick Masotta <masottaus@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 18 Jul 2012 02:18:19 -0700 (PDT)


1) I'm trying to pass a Regular Expresion from LUA to C on a string defined 

ffi.new("char[?]", 0, "^[cC]:\\.*$");
(forget about the length 0 on the definition)

but LUA/FFI "interprets" the \\ finally adding a single \ to the string
then I'm forced to pass "^[cC]:\\\\.*$" (Escaping LUA, then Escaping the regex)

is there anyway to force the no-interpretation of string content in the ffi 
definition? i.e I can do that in BASH just using single quotes instead of 
double quotes.

2) is there any way I can define ffi multi line strings like this

ffi.new("char[?]", 0, "This is the definition\n"
                      "of a multiline string." );

I cannot make it work; defining messages just in one line sometimes is a real 


Other related posts: