Hi Ben- just a belated comment... I took a look at linenoise, and apparently it does
malloc/memmove/realloc (and expects the caller to free() each line of input)...is that
something you want in EPICS? Hasn't that been a problem in the past in other areas?
Perhaps not a big deal for relatively low-traffic console input, but may be one of
those things that can creep up on you later, if eg. a large amount of input is piped
in or something.
Don't mean to rain on your parade :))
Mike
-------
Michael Laznovsky ∷ GFA Controls
WBGB/008 ∷ Paul Scherrer Institut
CH-5232 Villigen PSI ∷ Switzerland
+41 (0)56.310.5301 ∷ http://www.psi.ch
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Benjamin Franksen
Sent: Freitag, 9. Februar 2018 17:55
To: EPICS Core-Talk
Subject: bundling linenoise with base
Hi Everyone
I have just finished an experimental addition to EPICS base and wondered
if you might be interested. It began when I investigated building our
RTEMS IOCs statically -- presumably the way most people use RTEMS with
EPICS -- instead of using cexpsh and gesys and then loading modules at
runtime as we used to. So I am now stuck with the iocsh and found that I
missed things like command line completion and history.
The code in base (I haven't yet look at versions beyond 3.14) has a very
simple API (epicsReadline.h) for accessing the command line library
chosen by the user (by setting COMMANDLINE_LIBRARY). The wrapper code
(epicsReadline.c) is a bit messy/repetitive (#if ...# elif...) but
otherwise not hard to grok. It assume the COMMANDLINE_LIBRARY is
pre-installed system-wide, though. This is a pain, especially with
RTEMS, but also with various other host systems, see recurring questions
on tech-talk about libreadline in various versions, with or without
libcurses or libncurses. And as it turns out, almost none of the
advanced features offered by libreadline are used in the iocsh.
I looked around a bit and found a very nice and small library named
linenoise [1]. It has all the features, compiles against (and actually
works on, with a few minor modifications) RTEMS (only tested 4.9 so
far), and has no more than 820 lines of code (without comments,
according to cloc [2]). It has been expressly designed for being
bundled. So I added a copy to base and wrote the epicsReadline wrapper
code for it, adding another variant for COMMANDLINE_LIBRARY. In
addition, with a few additional lines of code in the wrapper for
linenoise I was able to implement command completion as well as argument
hints.
I think bundling linenoise with base and making it the default command
line library for the iocsh (except on vxWorks which apparently has no
termios) would be smart move. If there is interest, I can submit patches
(merge request, whatever) against the launchpad repo.
Another solution would be to change the epicsReadline API in such a way
that an EPICS support module can replace the three exported functions
with another implementation; this could be done inside the main
function, for instance.
[1] https://github.com/antirez/linenoise
[2] https://github.com/AlDanial/cloc
Cheers
Ben
--
"Make it so they have to reboot after every typo." ― Scott Adams
- Replies:
- Re: bundling linenoise with base Benjamin Franksen
- References:
- bundling linenoise with base Benjamin Franksen
- Navigate by Date:
- Prev:
Build failed in Jenkins: epics-base-3.16-test #86 APS Jenkins
- Next:
Jenkins build is back to normal : epics-base-3.16-mac-test #196 APS Jenkins
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: bundling linenoise with base Benjamin Franksen
- Next:
Re: bundling linenoise with base Benjamin Franksen
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
|