I am trying to install a window manager on my linux box, but there is an error with the source code from the designer. If anyone knows Lua, I would greatly appreciate the help.
Here is the original code:
function texfriendly_typeormod(nm) if string.find(nm, "A-Z") then >> return "\\type{"..string.gsub(nm, '_', '\_').."}" else return "\\code{"..nm.."}" end end
According to my compiler:
return "\\type{"..string.gsub(nm, '_', '\_').."}"
Tells me
---this---> '\_'
is an invalid escape.
Again, any help would be fantastic
I am trying to install a window manager on my linux box, but there is an error with the source code from the designer. If anyone knows Lua, I would greatly appreciate the help.
Here is the original code:
function texfriendly_typeormod(nm) if string.find(nm, "A-Z") then >> return "\\type{"..string.gsub(nm, '_', '\_').."}" else return "\\code{"..nm.."}" end end
According to my compiler:
return "\\type{"..string.gsub(nm, '_', '\_').."}"
Tells me
---this---> '\_'
is an invalid escape.
Again, any help would be fantastic
Hello there,
I'm not overly familiar with Lua, so forgive me if I am wrong in my assumptions, however the escape sequences used for strings are pretty much universal in form between languages.
If I've interpreted the code you've written correctly, you're trying to output a replaced string which provides the escaped version of the character '_' as '\_'?
If so, then I think you may need to put '\\_'.
If not, then I don't know and I hope you find the right solution.
Jim,
Hello there,
I'm not overly familiar with Lua, so forgive me if I am wrong in my assumptions, however the escape sequences used for strings are pretty much universal in form between languages.
If I've interpreted the code you've written correctly, you're trying to output a replaced string which provides the escaped version of the character '_' as '\_'?
If so, then I think you may need to put '\\_'.
If not, then I don't know and I hope you find the right solution.
Jim,
Yeah, as james said, \ is not only an escape character in regex, but also usually an escape character in strings in most languages, so you have to escape the backslash as well.
Yeah, as james said, \ is not only an escape character in regex, but also usually an escape character in strings in most languages, so you have to escape the backslash as well.
See, that is what I thought, but it is still throwing me an error when I run 'make.'
make[1]: Entering directory `/home/<user>/Downloads/ion-3-20090110/mod_tiling' /usr/local/bin/lua ../libextl/libextl-mkexports -module mod_tiling -o exports.c -h exports.h \ main.c tiling.c placement.c split.c split-stdisp.c splitfloat.c panehandle.c ops.c /usr/local/bin/lua: ../libextl/libextl-mkexports:761: attempt to call field 'getn' (a nil value) stack traceback: ../libextl/libextl-mkexports:761: in main chunk [C]: in ? make[1]: *** [exports.c] Error 1 make[1]: Leaving directory `/home/<user>/Downloads/ion-3-20090110/mod_tiling' make: *** [subdirs] Error 2
So i looked at line 761 and it has this:
if table.getn(inputs)==0 then usage() end
Is there just an issue with the variables being passed?
It seems like I am missing something totally obvious...
Thanks again.
See, that is what I thought, but it is still throwing me an error when I run 'make.'
make[1]: Entering directory `/home/<user>/Downloads/ion-3-20090110/mod_tiling' /usr/local/bin/lua ../libextl/libextl-mkexports -module mod_tiling -o exports.c -h exports.h \ main.c tiling.c placement.c split.c split-stdisp.c splitfloat.c panehandle.c ops.c /usr/local/bin/lua: ../libextl/libextl-mkexports:761: attempt to call field 'getn' (a nil value) stack traceback: ../libextl/libextl-mkexports:761: in main chunk [C]: in ? make[1]: *** [exports.c] Error 1 make[1]: Leaving directory `/home/<user>/Downloads/ion-3-20090110/mod_tiling' make: *** [subdirs] Error 2
So i looked at line 761 and it has this:
if table.getn(inputs)==0 then usage() end
Is there just an issue with the variables being passed?
It seems like I am missing something totally obvious...
Thanks again.
I'm guessing that file is a library, right?
It's a pretty unclear error message, but based on this:
/usr/local/bin/lua: ../libextl/libextl-mkexports:761: attempt to call field 'getn' (a nil value)
I would guess that either table, getn, or input is null. But since it's probably a library I guess that table and getn are there, so input is the likely suspect.
EDIT: Just to be clear, I don't know any Lua, so I'm just making an educated guess on this stuff.
I'm guessing that file is a library, right?
It's a pretty unclear error message, but based on this:
/usr/local/bin/lua: ../libextl/libextl-mkexports:761: attempt to call field 'getn' (a nil value)
I would guess that either table, getn, or input is null. But since it's probably a library I guess that table and getn are there, so input is the likely suspect.
EDIT: Just to be clear, I don't know any Lua, so I'm just making an educated guess on this stuff.