lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 09.05.2014 22:26, William Ahern wrote:
On Fri, May 09, 2014 at 10:52:57PM +0000, Bernd Eggink wrote:
I created a standalone version of luaprompt on a BeagleBoneBlack(ARM
processor, Angstr?m Linux). No problems with the compilation, but _any_
call instantly exited with return code 1.

After a little experimenting I found the reason: On this system getopt()
returns 255 instead of 1 (IMHO a bug in the library). To work around it,
I suggest changing the option parsing loop like this:

     while(1) {
         option = getopt (argc, argv, "ivphe:l:");
         if (option == -1 || option == 255) break;
	...
     }

Probably this change won't do any harm on systems where getopt returns
the correct value.

What version are you using? The latest version I found has the code

   char option;
   ...
   while ((option = getopt (argc, argv, "ivphe:l:")) != -1) {

and presumably the char type is unsigned on this platform. The bug is in
luaprompt. The type of option should be int, to match the return type of
getopt. The code is effectively

   unsigned char option = -1; /* option is= 255 */
   if (option == -1) /* option is promoted to int in equality test  */

You're right; I hadn't looked at the declaration. Changing the type to 'int' fixes it. Thanks!

Bernd

--
http://sudrala.de