summaryrefslogtreecommitdiffstats
path: root/lib/libedit/parse.c
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-08-07 20:55:59 +0000
committerstefanf <stefanf@FreeBSD.org>2005-08-07 20:55:59 +0000
commit6fecd62c1ea649a0bcfd4f7b510e76afbeb46485 (patch)
tree8538b11e03844d50562fadbdbfa30a6bc7066ca1 /lib/libedit/parse.c
parent298c8993412f5773e585c3b34b44696e850d79b2 (diff)
downloadFreeBSD-src-6fecd62c1ea649a0bcfd4f7b510e76afbeb46485.zip
FreeBSD-src-6fecd62c1ea649a0bcfd4f7b510e76afbeb46485.tar.gz
Sync libedit with recent NetBSD developments. Including improvements to the
vi-mode, removal of clause 3, cleanups and the export of the tokenization functions. Not included: config.h, filecomplete.{c,h}
Diffstat (limited to 'lib/libedit/parse.c')
-rw-r--r--lib/libedit/parse.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c
index f83dc94..0ffe51d 100644
--- a/lib/libedit/parse.c
+++ b/lib/libedit/parse.c
@@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -33,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: parse.c,v 1.13 2000/09/04 22:06:31 lukem Exp $
+ * $NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -57,17 +53,16 @@ __FBSDID("$FreeBSD$");
*/
#include "sys.h"
#include "el.h"
-#include "tokenizer.h"
#include <stdlib.h>
private const struct {
- char *name;
- int (*func)(EditLine *, int, char **);
+ const char *name;
+ int (*func)(EditLine *, int, const char **);
} cmds[] = {
{ "bind", map_bind },
{ "echotc", term_echotc },
{ "edit", el_editmode },
- { "history", hist_list },
+ { "history", hist_command },
{ "telltc", term_telltc },
{ "settc", term_settc },
{ "setty", tty_stty },
@@ -81,12 +76,12 @@ private const struct {
protected int
parse_line(EditLine *el, const char *line)
{
- char **argv;
+ const char **argv;
int argc;
Tokenizer *tok;
tok = tok_init(NULL);
- tok_line(tok, line, &argc, &argv);
+ tok_str(tok, line, &argc, &argv);
argc = el_parse(el, argc, argv);
tok_end(tok);
return (argc);
@@ -97,9 +92,9 @@ parse_line(EditLine *el, const char *line)
* Command dispatcher
*/
public int
-el_parse(EditLine *el, int argc, char *argv[])
+el_parse(EditLine *el, int argc, const char *argv[])
{
- char *ptr;
+ const char *ptr;
int i;
if (argc < 1)
@@ -139,7 +134,7 @@ el_parse(EditLine *el, int argc, char *argv[])
* the appropriate character or -1 if the escape is not valid
*/
protected int
-parse__escape(const char **const ptr)
+parse__escape(const char **ptr)
{
const char *p;
int c;
@@ -204,7 +199,7 @@ parse__escape(const char **const ptr)
c = *p;
break;
}
- } else if (*p == '^' && isascii(p[1]) && (p[1] == '?' || isalpha(p[1]))) {
+ } else if (*p == '^') {
p++;
c = (*p == '?') ? '\177' : (*p & 0237);
} else
@@ -212,6 +207,7 @@ parse__escape(const char **const ptr)
*ptr = ++p;
return ((unsigned char)c);
}
+
/* parse__string():
* Parse the escapes from in and put the raw string out
*/
@@ -234,6 +230,14 @@ parse__string(char *out, const char *in)
*out++ = n;
break;
+ case 'M':
+ if (in[1] == '-' && in[2] != '\0') {
+ *out++ = '\033';
+ in += 2;
+ break;
+ }
+ /*FALLTHROUGH*/
+
default:
*out++ = *in++;
break;
OpenPOWER on IntegriCloud