RiscLua 6.0
GavinWraith (26) 1563 posts |
It works OK for me with StrongED 4.70a9 (01 Aug 2015). |
David Gee (1833) 268 posts |
Didn’t know there was a new version out. Will try it and see what happens. |
David Gee (1833) 268 posts |
Have tried it. Still the same—causes !StrongEd to crash when backspace key is pressed. The ^H^H phenomenon occurs with !DeskEdit, !Edit and !Zap as well. Just in case it made a difference, I’ve tried !Nettle as well but the samw happens there too. I’ve restored the previous version of RiscLua and in that, the behaviour on input is correct. Looks like this is a bug in the version of !GCC you’ve used. |
GavinWraith (26) 1563 posts |
What machine and what version of RISC OS are you using? RiscLua 6 is compiled with GCC 4.7.4 rel2 , not using the shared C library. When you type in text at the > prompt it is fgets that reads in the string from stdin and puts that echoes it back. The problem looks like it lies with one or other of these. What happens if you make a text file containing just , you give it type Lua and doubleclick on it?
|
Rick Murray (539) 13806 posts |
Mmm. Needs work. :-) Downloaded from !Store. Lua starts, places an icon on the iconbar. It seems that the Obey files are like: wimpslot -32K stick rlua6:Tools.<something> Either prefix “stick” with “rlua6:” or add RiscLua’s path to Run$Path; as the method you’re using is only going to work if RiscLua’s directory is the CSD. Tweaked TaskW to run. It says to drag a file to the icon bar icon to run it in a TaskWindow. Well, uh, all of the examples cause “ So I decide to open a TaskWindow and try Lua directly. Perhaps you might like to probe for these things on first run, you shouldn’t assume that it is all present as standard (it wasn’t on my machine). I created “abi-2/0” and copied in libgcc* and libunix* that I downloaded a couple of weeks ago for trying Otter. Tried “lua” in a TaskWindow again. Crash. Oops. Fatal signal received: Illegal Instruction Stack backtrace: Running thread 0x40ac4 ( 3587f34) pc: 5ace6014 lr: 5ace6428 sp: 3587f38 __write_backtrace() ( 3587fa0) pc: 5ace615c lr: 5ace7fe0 sp: 3587fa4 __unixlib_raise_signal() ( 3587fb0) pc: 5ace7e94 lr: b958 sp: 3586e1c __h_cback() Register dump at 03587fb4: a1: 68dfc a2: 0 a3: 407f7000 a4: 88 v1: 68dfc v2: 68d80 v3: 1 v4: 6918c v5: 1 v6: c sl: 3586208 fp: 3586e78 ip: 3586e38 sp: 3586e1c lr: b958 pc: 20980 cpsr: 60000110 0002096c : n_.. : 00005f6e : ANDEQ R5,R0,R14,ROR #30 00020970 : ...ÿ : ff000014 : Undefined instruction 00020974 : .À á : e1a0c00d : MOV R12,R13 00020978 : pØ-é : e92dd870 : STMDB R13!,{R4-R6,R11,R12,R14,PC} 0002097c : .⇑-í : ed2d8b02 : VPUSH {D8} ; VFP or ASIMD required 00020980 : .°Lâ : e24cb004 : SUB R11,R12,#4 00020984 : ..]á : e15d000a : CMP R13,R10 00020988 : ʧÿ» : bbffa7ca : BLLT &0000A8B8 0002098c : .ÐMâ : e24dd008 : SUB R13,R13,#8 ( 3586e78) pc: b8b4 lr: 10728 sp: 3586e7c pmain() ( 3586ea8) pc: 104cc lr: 10a70 sp: 3586eac luaD_precall() ( 3586ec0) pc: 10a20 lr: c048 sp: 3586ec4 luaD_call() ( 3586ed0) pc: c034 lr: fe0c sp: 3586ed4 f_call() ( 3586f6c) pc: fdb4 lr: 10d6c sp: 3586f70 luaD_rawrunprotected() ( 3586f98) pc: 10d34 lr: dde4 sp: 3586f9c luaD_pcall() ( 3586fc8) pc: dd60 lr: ad9c sp: 3586fcc lua_pcallk() ( 3586fec) pc: ad34 lr: 5acfcbe4 sp: 3586ff0 main() * I’ll say something for GCC – it’s a nice looking backtrace. |
Malcolm Hussain-Gambles (1596) 811 posts |
“Oh! Suits you sir” |
John Williams (567) 768 posts |
Irrelevant to RISC OS, but that should, IIRC, be “Suit you, Sir!” Apparently often misquoted. |
Fred Graute (114) 645 posts |
It’s fine here, running the latest StrongED.
RiscLua 5.71 does not exhibit this behaviour so it’s likely down to the switch to GCC. One thing to check is how characters read are typed, as char or int?
It looks like SharedLibs hasn’t been updated for GCC 4.7.2. I upgraded my copy using PackMan, it has additional directories; abi-1/0 and abi-2/0. |
Rick Murray (539) 13806 posts |
(and John’s correction) Sorry, I never found The Fast Show to be either funny or worth watching, so while I recognise the quote, I don’t know its context… |
GavinWraith (26) 1563 posts |
Apologies for that. I have been uploading corrections to my website and plingstore fairly frequently – not because RiscLua itself has changed but the libraries and examples have. All information about how it fails to run on other setups than my own are very useful. Maybe it would make sense to have separate downloads for examples and for libraries.
My copy has At the moment the only examples which are wimp tasks (i.e. cannot be run in a taskwindow) are !Eph and !Snerp. !Eph does what Acorn’s !Msg did, as found in the C/C++ package’s !SetPaths. That is, it puts out a temporary message – the message and the delay time in seconds are RunImage’s command line parameters. !Snerp is different from the application of that name in earlier distributions. It is a demonstration of how to use the libraries In some sense this has been an experiment in trying to separate wimp programs into two components – the detail hidden in libraries, the structure exposed in the !RunImage that uses the libraries. Whether the result is any more intelligible in RiscLua than in BASIC or C I am not sure. For example, what happens in the main window is given by The iconbar-icon menu is defined by which should give an impression of the level of readability.
|
David Gee (1833) 268 posts |
In response to Gavin above, I was using VRPC with RO 4.39. If I used
it works as it should—but if there is an input statement in the Lua code, it also exhibits the ^H problem. I notice that a program compiled using Norcroft C and using gets() works correctly. I think next I’ll check how GCC behaves on my Raspberry Pi. |
GavinWraith (26) 1563 posts |
Did you remember to drag the contents of the v3 directory over !rlua6? In the zipped distribution the lua6 and luac6 files in !rlua6 have been compiled for ARMv7 platforms with vfp. The lua6 and luac6 files in v3.!rlua6 have been compiled for ARMv3 platforms with softfloat. |
David Gee (1833) 268 posts |
I didi drag the V3 directory over !rlua6 (actually, I forgot to do so at first, and got a message saying something like “this version needs ARM v6”). |
David Gee (1833) 268 posts |
Gavin: Further to the original (^H^H^H) problem, you could use the OS routines to do the input—in this case OS_Read_Line32. This works correctly with GCC and allows the usual RISC OS line editing facilities to work. It can be called either using If you’re using fgets() because you sometimes need to read from a file you could have a routine which only calls the SWI if the ‘file’ is standard input. |
GavinWraith (26) 1563 posts |
Thanks. Yes I tried this, but I must have made a pig’s ear of it, because it caused a crash, so I left well alone. Also, I wanted to keep the lua binary as close as possible to the standard distribution, and restrict everything to do with RISC OS to the riscos library, if possible. Obviously, allowing the use of !,?,$ in identifiers (a nod to BASIC) could not very well be so confined, so had to be done with a #ifdef RISCOS … #endif patch in llex.c. |
David Gee (1833) 268 posts |
I’ve tried this just now, actually using OS_Read_Line (on RO 4.39) on the ARM v3 version. It works fine, the only difference is that typing CTRL-d at the prompt doesn’t terminate lua6, instead you have to press Escape instead. The code changes (to “lua.c” i.e. c.lua) are minor. I’ve added an include: #include <swis.h> changed a #define: #define lua_readline(L,b,p) \ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ my_gets(b, LUA_MAXINPUT) != NULL) /* get line */ and added the following code: /* Read line -- SWI &0E (14) */ void ro_read_line(char* buf, int size, int lo, int hi, int* count) { _swi(14,_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1),buf,size,lo,hi,count); } /* Routine to emulate fgets(str,n,stdin) but using RO routines */ char* my_gets(char* str, int n) { int count; /* number of characters read */ ro_read_line(str,n,0,255,&count); str[count]=0; return str; } |
David Gee (1833) 268 posts |
Just to add with respect to the problems I encountered modifying the TaskWindow mode file for StrongEd, using Note: This change can be made successfully on RO 5.21/Pi version 1. The problem encountered here is on RO 4.39/VRPC. |
David Gee (1833) 268 posts |
I’ve modified the code for the revised version of “lua.c” to call the X version of the SWI: /* Read line -- SWI &0E (14) */ _kernel_oserror* ro_read_line(char* buf, int size, int lo, int hi, int* count) { return _swix(14,_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1),buf,size,lo,hi,count); } /* Routine to emulate fgets(str,n,stdin) but using RO routines */ char* my_gets(char* str, int n) { int count; /* number of characters read */ _kernel_oserror* err; /* error return -- NULL if OK */ err = ro_read_line(str,n,0,255,&count); if (err) { fprintf(stderr, "Error %d: %s\n", err->errnum, err->errmess); return NULL; /* fgets() returns NULL if an error occurs */ } else { str[count]=0; return str; } } Everything else stays the same as in the previous post (i.e. the altered |
David Gee (1833) 268 posts |
I’ve found while these changes work OK in running Lua interactively, they make no difference if you write a program in Lua—you still get ^H if you backspace. I can’t find any other instances of fgets (or fscanf, for that matter) in the code—am I missing something? |
GavinWraith (26) 1563 posts |
That is nothing to do with Lua, surely, but the text editor you use to write the program. I tend to use StrongED for creating text (currently version 4.70a9) – whether for programs or for anything else – and I have no such problem. What version are you using? |
David Gee (1833) 268 posts |
A misunderstanding, I think. What I meant was, if I write a program in Lua that uses |
GavinWraith (26) 1563 posts |
Only if you run it in a command window. If you run it in a taskwindow there should be no problem. |
David Gee (1833) 268 posts |
I was wondering where in the Lua source is the code that is used by io:input? I can’t use a TaskWindow successfully since StrongEd crashes if I modify the mode file as suggested (see post above). |
GavinWraith (26) 1563 posts |
|
Bryan Hogan (339) 589 posts |
If you want to know more about RiscLua, Gavin will be telling us all about it at the next ROUGOL meeting on Monday 16th November: http://www.rougol.jellybaby.net/ Entance is free so come along and ask lots of questions! |