[Rd] Location of source code for readline()

Peter Ehlers ehlers at ucalgary.ca
Mon May 31 00:37:57 CEST 2010


On 2010-05-30 15:33, Prof. John C Nash wrote:
> A few days ago on R-help I asked about a cross-platform timeout version of readline().
> Some suggestions, but only partial joy so far. I can get the Gnu bash  'read -t ...' to
> work in Windows by using the 'bash -c ' construct, but then R's system() function does not
> seem to allow this to pass through. Similarly a Perl and Free Pascal routine that I tried,
> the latter being a single executable that did the prompt and the timeout. (I can send code
> offline if anyone interested -- not fully protected against bad inputs, however.)
>
> Now I'm wondering where the code for readline is located in the R source. I've tracked as
> far as the 'do_readln' in names.c, but now want to find the actual code to see if I can
> patch it, though I am a real novice in C. Suggestions welcome.
>
> My application, FYI, is to have a script that will display something, and wait for a
> keypress (for readline it seems to need the Enter key) but timeout after a preset number
> of seconds. The setTimeLimit "almost" works -- but not for readline. I'm thinking of a
> modified readline like readline(prompt='Do you want to continue?', timeout=6).
>
> Note that the issue seems to be Windows. I haven't a Mac to try, but Linux can be made to
> function by various methods at the top.  Sigh.
>
> JN
>

I can't help with your project, but check scan.c for do_readln.

  -Peter Ehlers



More information about the R-devel mailing list