View Full Version : String copy error?
Mark F
October 18th, 2002, 06:45 AM
I don't know where this bug is located but ...
When I pass a string that includes "\" characters to one of my functions, they get translated into printf escape sequences sometime before the lua_tostring() call returns.
For example - The string "\n" will have the \n changed to 0x0a. This is bad for trying to pass filenames.
Ron
October 18th, 2002, 06:56 AM
please clarify 'some of your functions'.
Mark F
October 18th, 2002, 08:36 AM
Sorry. Using the new WinLUAEx.dll that I just sent you. If I use this:
WINDOWS_SetDesktopBitmap("/n")
it works. If I use this:
WINDOWS_SetDesktopBitmap("\n")
it fails.
The C++ Code does this:
CString sFilename = lua_tostring(m_pState,1); // get .bmp filename
When it fails, the sFilename variable contains a string that is made up of 0x0a 0x00. This is the same output I'd get by running the string trough sprintf.
Ron
October 18th, 2002, 08:42 AM
I'm missing something here,.. \n is supposed to be 0x0a... it works that way in C too, if you want a slash use double \\... at least thats how it works in C....
Mark F
October 18th, 2002, 09:09 AM
When a string variable is passed into a registered LUA function, the function needs the exact value of that string variable, not a version that has had character replacement done on it. If the string "\n" is passed in, I need to see the string "\n" not 0x0a 0x00.
I am passing a file name through this interface and the literal string "c:\new" needs to be seen by the plugin as "c:\new".
Maybe I need to be using a different function to extract the string variable from the LUA stack? Right now I use lua_tostring() and get this unwanted substitution of characters. Is there a lua_torawstring()?
I'm sorry Ron. I'm not being clear. (I'll blame it on 3 hours sleep)
Ron
October 18th, 2002, 09:18 AM
I think we differ in opinion there ;-) I was always under the impression that the \n would be replaced immediately. I think this is a question for the Lua mailing list though.
I'm sorry Ron. I'm not being clear. (I'll blame it on 3 hours sleep)
Yeah I saw you where still/already up this morning 9 am European time.
Mark F
October 18th, 2002, 10:58 AM
Oooooh! It's a FEATURE! :D
*I* can accept this limitation. I'm not sure how many times I will be able to answer the questions and bug reports it generates, though. ;)
Let me know what "the list" says. Thanks.
Ron
October 18th, 2002, 12:23 PM
I didn't say that I was going to ask, since I consider it correct behaviour ;-)
Ron
October 18th, 2002, 12:25 PM
I can add it to the Lua docs, simply tell people to use forward slashes in path names. And mention that the backward slash is an escape character.
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.