[haiku-commits] haiku: hrev49366 - src/libs/edit

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 4 Jul 2015 22:42:45 +0200 (CEST)

hrev49366 adds 1 changeset to branch 'master'
old head: d1620177b945d97ecdcd4d3b0b374fa6236a14cf
new head: 7e24b659c4d8ba302e3f5e59b1a432bd60727a4c
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=7e24b659c4d8+%5Ed1620177b945

----------------------------------------------------------------------------

7e24b659c4d8: build: Convert to external libedit build package

* Drop lib/edit and matching bsd header
* Convert Debugger to libedit build package
* Should solve problems with libedit consumers
not defining _BSD_SOURCE
* Progress on #10267

[ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49366
Commit: 7e24b659c4d8ba302e3f5e59b1a432bd60727a4c
URL: http://cgit.haiku-os.org/haiku/commit/?id=7e24b659c4d8
Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date: Sat Jul 4 20:29:05 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/10267

----------------------------------------------------------------------------

50 files changed, 44 insertions(+), 17453 deletions(-)
build/jam/BuildFeatures | 17 +
build/jam/DefaultBuildProfiles | 4 +
headers/compatibility/bsd/histedit.h | 236 -----
src/apps/debugger/Jamfile | 26 +-
src/bin/network/ftp/Jamfile | 7 +-
src/libs/Jamfile | 1 -
src/libs/edit/Jamfile | 41 -
src/libs/edit/Makefile | 70 --
src/libs/edit/chared.c | 776 ---------------
src/libs/edit/chared.h | 168 ----
src/libs/edit/common.c | 920 -----------------
src/libs/edit/common.h | 39 -
src/libs/edit/editline.3 | 788 ---------------
src/libs/edit/editrc.5 | 516 ----------
src/libs/edit/el.c | 556 -----------
src/libs/edit/el.h | 149 ---
src/libs/edit/emacs.c | 503 ----------
src/libs/edit/emacs.h | 24 -
src/libs/edit/fcns.c | 58 --
src/libs/edit/fcns.h | 109 --
src/libs/edit/help.c | 211 ----
src/libs/edit/help.h | 5 -
src/libs/edit/hist.c | 202 ----
src/libs/edit/hist.h | 77 --
src/libs/edit/history.c | 979 ------------------
src/libs/edit/key.c | 687 -------------
src/libs/edit/key.h | 81 --
src/libs/edit/makelist | 250 -----
src/libs/edit/map.c | 1410 --------------------------
src/libs/edit/map.h | 75 --
src/libs/edit/parse.c | 261 -----
src/libs/edit/parse.h | 48 -
src/libs/edit/prompt.c | 165 ----
src/libs/edit/prompt.h | 58 --
src/libs/edit/read.c | 610 ------------
src/libs/edit/read.h | 58 --
src/libs/edit/refresh.c | 1137 ---------------------
src/libs/edit/refresh.h | 59 --
src/libs/edit/search.c | 631 ------------
src/libs/edit/search.h | 66 --
src/libs/edit/sig.c | 192 ----
src/libs/edit/sig.h | 69 --
src/libs/edit/sys.h | 109 --
src/libs/edit/term.c | 1585 ------------------------------
src/libs/edit/term.h | 123 ---
src/libs/edit/tokenizer.c | 439 ---------
src/libs/edit/tty.c | 1251 -----------------------
src/libs/edit/tty.h | 480 ---------
src/libs/edit/vi.c | 1120 ---------------------
src/libs/edit/vi.h | 51 -

----------------------------------------------------------------------------

diff --git a/build/jam/BuildFeatures b/build/jam/BuildFeatures
index 8f47653..87bdc09 100644
--- a/build/jam/BuildFeatures
+++ b/build/jam/BuildFeatures
@@ -448,6 +448,23 @@ if [ IsPackageAvailable zlib_devel ] {
}


+# libedit
+if [ IsPackageAvailable libedit_devel ] {
+ ExtractBuildFeatureArchives libedit :
+ file: base libedit
+ runtime: lib
+ file: devel libedit_devel
+ depends: base
+ library: $(developLibDir)/libedit.so
+ headers: $(developHeadersDir)
+ ;
+
+ EnableBuildFeatures libedit ;
+} else {
+ Echo "libedit support not available on $(TARGET_PACKAGING_ARCH)" ;
+}
+
+
# libsolv
if [ IsPackageAvailable libsolv_devel ] {
ExtractBuildFeatureArchives libsolv :
diff --git a/build/jam/DefaultBuildProfiles b/build/jam/DefaultBuildProfiles
index 7c0ae9b..daa7e65 100644
--- a/build/jam/DefaultBuildProfiles
+++ b/build/jam/DefaultBuildProfiles
@@ -168,6 +168,8 @@ rule DefineDefaultBuildProfiles
grep
haikuporter
less
+ libedit
+ libedit_devel
m4
make
ncurses
@@ -193,6 +195,8 @@ rule DefineDefaultBuildProfiles
gcc
icu
libsolv
+ libedit
+ libedit_devel
ncurses
ncurses_devel
zlib
diff --git a/headers/compatibility/bsd/histedit.h
b/headers/compatibility/bsd/histedit.h
deleted file mode 100644
index 216a9f1..0000000
--- a/headers/compatibility/bsd/histedit.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)histedit.h 8.2 (Berkeley) 1/3/94
- * $NetBSD: histedit.h,v 1.28 2005/07/14 15:00:58 christos Exp $
- * $FreeBSD: src/include/histedit.h,v 1.9.10.1 2005/10/09 03:44:00 delphij Exp
$
- */
-
-/*
- * histedit.h: Line editor and history interface.
- */
-#ifndef _HISTEDIT_H_
-#define _HISTEDIT_H_
-
-
-#ifdef _BSD_SOURCE
-
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <stdio.h>
-
-__BEGIN_DECLS
-
-/*
- * ==== Editing ====
- */
-
-typedef struct editline EditLine;
-
-/*
- * For user-defined function interface
- */
-typedef struct lineinfo {
- const char *buffer;
- const char *cursor;
- const char *lastchar;
-} LineInfo;
-
-/*
- * EditLine editor function return codes.
- * For user-defined function interface
- */
-#define CC_NORM 0
-#define CC_NEWLINE 1
-#define CC_EOF 2
-#define CC_ARGHACK 3
-#define CC_REFRESH 4
-#define CC_CURSOR 5
-#define CC_ERROR 6
-#define CC_FATAL 7
-#define CC_REDISPLAY 8
-#define CC_REFRESH_BEEP 9
-
-/*
- * Initialization, cleanup, and resetting
- */
-EditLine *el_init(const char *, FILE *, FILE *, FILE *);
-void el_end(EditLine *);
-void el_reset(EditLine *);
-
-/*
- * Get a line, a character or push a string back in the input queue
- */
-const char *el_gets(EditLine *, int *);
-int el_getc(EditLine *, char *);
-void el_push(EditLine *, char *);
-
-/*
- * Beep!
- */
-void el_beep(EditLine *);
-
-/*
- * High level function internals control
- * Parses argc, argv array and executes builtin editline commands
- */
-int el_parse(EditLine *, int, const char **);
-
-/*
- * Low level editline access functions
- */
-int el_set(EditLine *, int, ...);
-int el_get(EditLine *, int, void *);
-#if 0
-unsigned char _el_fn_complete(EditLine *, int);
-#endif
-
-/*
- * el_set/el_get parameters
- */
-#define EL_PROMPT 0 /* , el_pfunc_t); */
-#define EL_TERMINAL 1 /* , const char *); */
-#define EL_EDITOR 2 /* , const char *); */
-#define EL_SIGNAL 3 /* , int); */
-#define EL_BIND 4 /* , const char *, ..., NULL); */
-#define EL_TELLTC 5 /* , const char *, ..., NULL); */
-#define EL_SETTC 6 /* , const char *, ..., NULL); */
-#define EL_ECHOTC 7 /* , const char *, ..., NULL); */
-#define EL_SETTY 8 /* , const char *, ..., NULL); */
-#define EL_ADDFN 9 /* , const char *, const char * */
- /* , el_func_t); */
-#define EL_HIST 10 /* , hist_fun_t, const char *); */
-#define EL_EDITMODE 11 /* , int); */
-#define EL_RPROMPT 12 /* , el_pfunc_t); */
-#define EL_GETCFN 13 /* , el_rfunc_t); */
-#define EL_CLIENTDATA 14 /* , void *); */
-#define EL_UNBUFFERED 15 /* , int); */
-#define EL_PREP_TERM 16 /* , int); */
-
-#define EL_BUILTIN_GETCFN (NULL)
-
-/*
- * Source named file or $PWD/.editrc or $HOME/.editrc
- */
-int el_source(EditLine *, const char *);
-
-/*
- * Must be called when the terminal changes size; If EL_SIGNAL
- * is set this is done automatically otherwise it is the responsibility
- * of the application
- */
-void el_resize(EditLine *);
-
-
-/*
- * Set user private data.
- */
-void el_data_set __P((EditLine *, void *));
-void * el_data_get __P((EditLine *));
-
-/*
- * User-defined function interface.
- */
-const LineInfo *el_line(EditLine *);
-int el_insertstr(EditLine *, const char *);
-void el_deletestr(EditLine *, int);
-
-
-/*
- * ==== History ====
- */
-
-typedef struct history History;
-
-typedef struct HistEvent {
- int num;
- const char *str;
-} HistEvent;
-
-/*
- * History access functions.
- */
-History * history_init(void);
-void history_end(History *);
-
-int history(History *, HistEvent *, int, ...);
-
-#define H_FUNC 0 /* , UTSL */
-#define H_SETSIZE 1 /* , const int); */
-#define H_EVENT 1 /* , const int); */
-#define H_GETSIZE 2 /* , void); */
-#define H_FIRST 3 /* , void); */
-#define H_LAST 4 /* , void); */
-#define H_PREV 5 /* , void); */
-#define H_NEXT 6 /* , void); */
-#define H_CURR 8 /* , const int); */
-#define H_SET 7 /* , int); */
-#define H_ADD 9 /* , const char *); */
-#define H_ENTER 10 /* , const char *); */
-#define H_APPEND 11 /* , const char *); */
-#define H_END 12 /* , void); */
-#define H_NEXT_STR 13 /* , const char *); */
-#define H_PREV_STR 14 /* , const char *); */
-#define H_NEXT_EVENT 15 /* , const int); */
-#define H_PREV_EVENT 16 /* , const int); */
-#define H_LOAD 17 /* , const char *); */
-#define H_SAVE 18 /* , const char *); */
-#define H_CLEAR 19 /* , void); */
-#define H_SETUNIQUE 20 /* , int); */
-#define H_GETUNIQUE 21 /* , void); */
-#define H_DEL 22 /* , int); */
-
-
-/*
- * ==== Tokenization ====
- */
-
-typedef struct tokenizer Tokenizer;
-
-/*
- * String tokenization functions, using simplified sh(1) quoting rules
- */
-Tokenizer *tok_init(const char *);
-void tok_end(Tokenizer *);
-void tok_reset(Tokenizer *);
-int tok_line(Tokenizer *, const LineInfo *,
- int *, const char ***, int *, int *);
-int tok_str(Tokenizer *, const char *,
- int *, const char ***);
-
-__END_DECLS
-
-
-#endif
-
-
-#endif /* _HISTEDIT_H_ */
diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile
index 2b8ae87..6e71466 100644
--- a/src/apps/debugger/Jamfile
+++ b/src/apps/debugger/Jamfile
@@ -9,6 +9,8 @@ UseHeaders [ FDirName
$(TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH))
UsePrivateHeaders app debug interface kernel package shared libroot ;
UsePrivateSystemHeaders ;

+UseBuildFeatureHeaders libedit ;
+
LINKFLAGS += -Wl,--exclude-libs,ALL ;

SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
@@ -71,12 +73,7 @@ SourceHdrs
: [ FDirName $(SUBDIR) dwarf ]
;

-# since syscall_numbers.h is generated on the fly, we need to explicitly
-# let Jam know about the dependency.
-Includes [ FGristFiles TeamDebugger.cpp ]
- : <syscalls!$(TARGET_PACKAGING_ARCH)>syscall_numbers.h ;
-
-Application Debugger :
+local sources =
Debugger.cpp

# arch
@@ -384,7 +381,18 @@ Application Debugger :
FloatValue.cpp
IntegerValue.cpp
StringValue.cpp
+;

+# since syscall_numbers.h is generated on the fly, we need to explicitly
+# let Jam know about the dependency.
+Includes [ FGristFiles $(sources) ] :
+ <syscalls!$(TARGET_PACKAGING_ARCH)>syscall_numbers.h
+ [ BuildFeatureAttribute ncurses : headers ]
+ [ BuildFeatureAttribute libedit : headers ]
+;
+
+Application Debugger :
+ $(sources)
:
<nogrist>Debugger_demangler.o
<nogrist>Debugger_disasm_x86.o
@@ -392,17 +400,17 @@ Application Debugger :
<nogrist>Debugger_dwarf.o
<nogrist>DebugAnalyzer_gui_table.o

- [ BuildFeatureAttribute ncurses : library ]
-
libudis86.a
<bin>debug_utils.a
libcolumnlistview.a
libshared.a
- libedit.a

[ TargetLibstdc++ ]
be package tracker libbsd.so libdebug.so

+ [ BuildFeatureAttribute ncurses : library ]
+ [ BuildFeatureAttribute libedit : library ]
+
: Debugger.rdef
;

diff --git a/src/bin/network/ftp/Jamfile b/src/bin/network/ftp/Jamfile
index 03df606..097fa70 100644
--- a/src/bin/network/ftp/Jamfile
+++ b/src/bin/network/ftp/Jamfile
@@ -11,6 +11,8 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
SubDirCcFlags [ FDefines _BSD_SOURCE=1 ] ;

+UseBuildFeatureHeaders libedit ;
+
BinCommand ftp :
cmds.c
cmdtab.c
@@ -22,7 +24,10 @@ BinCommand ftp :
progressbar.c
ruserpass.c
util.c
- : libedit.a [ BuildFeatureAttribute ncurses : library ] libutil.a
libbsd.so
+ :
+ [ BuildFeatureAttribute libedit : library ]
+ [ BuildFeatureAttribute ncurses : library ]
+ libutil.a libbsd.so
$(TARGET_NETWORK_LIBS)
;

diff --git a/src/libs/Jamfile b/src/libs/Jamfile
index 9249c7d..45dfabb 100644
--- a/src/libs/Jamfile
+++ b/src/libs/Jamfile
@@ -5,7 +5,6 @@ SubInclude HAIKU_TOP src libs alm ;
SubInclude HAIKU_TOP src libs bsd ;
SubInclude HAIKU_TOP src libs compat ;
SubInclude HAIKU_TOP src libs crypt ;
-SubInclude HAIKU_TOP src libs edit ;
SubInclude HAIKU_TOP src libs fluidsynth ;
SubInclude HAIKU_TOP src libs glut ;
SubInclude HAIKU_TOP src libs gnu ;
diff --git a/src/libs/edit/Jamfile b/src/libs/edit/Jamfile
deleted file mode 100644
index 779441a..0000000
--- a/src/libs/edit/Jamfile
+++ /dev/null
@@ -1,41 +0,0 @@
-SubDir HAIKU_TOP src libs edit ;
-
-SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
-
-UseBuildFeatureHeaders ncurses ;
-UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
-
-local defines = [ FDefines SCCSID=0 _BSD_SOURCE=1 ] ;
-SubDirCcFlags $(defines) ;
-
-local sources =
- chared.c
- common.c
- el.c
- emacs.c
- fcns.c
- help.c
- hist.c
- history.c
- key.c
- map.c
- parse.c
- prompt.c
- read.c
- refresh.c
- search.c
- sig.c
- tokenizer.c
- term.c
- tty.c
- vi.c
-;
-
-Includes [ FGristFiles $(sources) ]
- : [ BuildFeatureAttribute ncurses : headers ] ;
-
-
-StaticLibrary libedit.a :
- $(sources)
-;
-
diff --git a/src/libs/edit/Makefile b/src/libs/edit/Makefile
deleted file mode 100644
index 1697b3f..0000000
--- a/src/libs/edit/Makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-# $NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-# $FreeBSD: src/lib/libedit/Makefile,v 1.30 2005/08/07 20:51:52 stefanf Exp $
-
-LIB= edit
-SHLIB_MAJOR= 5
-SHLIBDIR?= /lib
-
-OSRCS= chared.c common.c el.c emacs.c fcns.c help.c hist.c key.c map.c \
- parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c
-
-DPADD= ${LIBNCURSES}
-LDADD= -lncurses
-
-MAN= editline.3 editrc.5
-
-MLINKS= editline.3 el_deletestr.3 editline.3 el_end.3 editline.3
el_init.3 \
- editline.3 el_get.3 editline.3 el_getc.3 editline.3 el_gets.3 \
- editline.3 history.3 editline.3 history_end.3 \
- editline.3 history_init.3 editline.3 el_insertstr.3 \
- editline.3 el_line.3 editline.3 el_parse.3 editline.3 el_push.3 \
- editline.3 el_reset.3 editline.3 el_resize.3 editline.3 el_set.3 \
- editline.3 el_source.3 \
- editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \
- editline.3 tok_line.3 editline.3 tok_str.3
-
-# For speed and debugging
-#SRCS= ${OSRCS} tokenizer.c history.c
-# For protection
-SRCS= editline.c tokenizer.c history.c
-SRCS+= common.h emacs.h fcns.h help.h vi.h
-CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h
-
-CFLAGS+= -I. -I${.CURDIR}
-CFLAGS+= #-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
-CFLAGS+= #-DDEBUG_PASTE -DDEBUG_EDIT
-
-AHDR= vi.h emacs.h common.h
-ASRC= ${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c
-
-.for hdr in vi emacs common
-${hdr}.h: ${hdr}.c makelist
- sh ${.CURDIR}/makelist -h ${.CURDIR}/${hdr}.c > ${.TARGET}
-.endfor
-
-fcns.h: ${AHDR} makelist
- sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET}
-
-fcns.c: ${AHDR} fcns.h makelist
- sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET}
-
-help.c: ${ASRC} makelist
- sh ${.CURDIR}/makelist -bc ${ASRC} > ${.TARGET}
-
-help.h: ${ASRC} makelist
- sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET}
-
-editline.c: ${OSRCS}
- sh ${.CURDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET}
-
-# minimal dependency to make "make depend" optional
-editline.o editline.po editline.So editline.ln: \
- common.h emacs.h fcns.c fcns.h help.c help.h vi.h
-
-test.o: ${.CURDIR}/TEST/test.c
-
-test: test.o libedit.a ${DPADD} ${LIBTERMCAP}
- ${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD}
-
-.include <bsd.lib.mk>
diff --git a/src/libs/edit/chared.c b/src/libs/edit/chared.c
deleted file mode 100644
index ea401da..0000000
--- a/src/libs/edit/chared.c
+++ /dev/null
@@ -1,776 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $
- */
-
-#if !defined(lint) && !defined(SCCSID)
-static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint && not SCCSID */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libedit/chared.c,v 1.10 2005/08/09 13:31:59
stefanf Exp $");
-
-/*
- * chared.c: Character editor utilities
- */
-#include "sys.h"
-
-#include <stdlib.h>
-#include "el.h"
-
-private void ch__clearmacro(EditLine *);
-
-/* value to leave unused in line buffer */
-#define EL_LEAVE 2
-
-/* cv_undo():
- * Handle state for the vi undo command
- */
-void
-cv_undo(EditLine *el)
-{
- c_undo_t *vu = &el->el_chared.c_undo;
- c_redo_t *r = &el->el_chared.c_redo;
- unsigned int size;
-
- /* Save entire line for undo */
- size = el->el_line.lastchar - el->el_line.buffer;
- vu->len = size;
- vu->cursor = el->el_line.cursor - el->el_line.buffer;
- memcpy(vu->buf, el->el_line.buffer, size);
-
- /* save command info for redo */
- r->count = el->el_state.doingarg ? el->el_state.argument : 0;
- r->action = el->el_chared.c_vcmd.action;
- r->pos = r->buf;
- r->cmd = el->el_state.thiscmd;
- r->ch = el->el_state.thisch;
-}
-
-/* cv_yank():
- * Save yank/delete data for paste
- */
-void
-cv_yank(EditLine *el, const char *ptr, int size)
-{
- c_kill_t *k = &el->el_chared.c_kill;
-
- memcpy(k->buf, ptr, size +0u);
- k->last = k->buf + size;
-}
-
-
-/* c_insert():
- * Insert num characters
- */
-void
-c_insert(EditLine *el, int num)
-{
- char *cp;
-
- if (el->el_line.lastchar + num >= el->el_line.limit) {
- if (!ch_enlargebufs(el, num +0u))
- return; /* can't go past end of buffer */
- }
-
- if (el->el_line.cursor < el->el_line.lastchar) {
- /* if I must move chars */
- for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--)
- cp[num] = *cp;
- }
- el->el_line.lastchar += num;
-}
-
-
-/* c_delafter():
- * Delete num characters after the cursor
- */
-void
-c_delafter(EditLine *el, int num)
-{
-
- if (el->el_line.cursor + num > el->el_line.lastchar)
- num = el->el_line.lastchar - el->el_line.cursor;
-
- if (el->el_map.current != el->el_map.emacs) {
- cv_undo(el);
- cv_yank(el, el->el_line.cursor, num);
- }
-
- if (num > 0) {
- char *cp;
-
- for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
- *cp = cp[num];
-
- el->el_line.lastchar -= num;
- }
-}
-
-
-/* c_delafter1():
- * Delete the character after the cursor, do not yank
- */
-void
-c_delafter1(EditLine *el)
-{
- char *cp;
-
- for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
- *cp = cp[1];
-
- el->el_line.lastchar--;
-}
-
-
-/* c_delbefore():
- * Delete num characters before the cursor
- */
-void
-c_delbefore(EditLine *el, int num)
-{
-
- if (el->el_line.cursor - num < el->el_line.buffer)
- num = el->el_line.cursor - el->el_line.buffer;
-
- if (el->el_map.current != el->el_map.emacs) {
- cv_undo(el);
- cv_yank(el, el->el_line.cursor - num, num);
- }
-
- if (num > 0) {
- char *cp;
-
- for (cp = el->el_line.cursor - num;
- cp <= el->el_line.lastchar;
- cp++)
- *cp = cp[num];
-
- el->el_line.lastchar -= num;
- }
-}
-
-
-/* c_delbefore1():
- * Delete the character before the cursor, do not yank
- */
-void
-c_delbefore1(EditLine *el)
-{
- char *cp;
-
- for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
- *cp = cp[1];
-
- el->el_line.lastchar--;
-}
-
-
-/* ce__isword():
- * Return if p is part of a word according to emacs
- */
-int
-ce__isword(int p)
-{
- return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
-}
-
-
-/* cv__isword():
- * Return if p is part of a word according to vi
- */
-int
-cv__isword(int p)
-{
- if (isalnum(p) || p == '_')
- return 1;
- if (isgraph(p))
- return 2;
- return 0;
-}
-
-
-/* cv__isWord():
- * Return if p is part of a big word according to vi
- */
-int
-cv__isWord(int p)
-{
- return (!isspace(p));
-}
-
-
-/* c__prev_word():
- * Find the previous word
- */
-char *
-c__prev_word(char *p, char *low, int n, int (*wtest)(int))
-{
- p--;
-
- while (n--) {
- while ((p >= low) && !(*wtest)((unsigned char) *p))
- p--;
- while ((p >= low) && (*wtest)((unsigned char) *p))
- p--;
- }
-
- /* cp now points to one character before the word */
- p++;
- if (p < low)
- p = low;
- /* cp now points where we want it */
- return (p);
-}
-
-
-/* c__next_word():
- * Find the next word
- */
-char *
-c__next_word(char *p, char *high, int n, int (*wtest)(int))
-{
- while (n--) {
- while ((p < high) && !(*wtest)((unsigned char) *p))
- p++;
- while ((p < high) && (*wtest)((unsigned char) *p))
- p++;
- }
- if (p > high)
- p = high;
- /* p now points where we want it */
- return (p);
-}
-
-/* cv_next_word():
- * Find the next word vi style
- */
-char *
-cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
-{
- int test;
-
- while (n--) {
- test = (*wtest)((unsigned char) *p);
- while ((p < high) && (*wtest)((unsigned char) *p) == test)
- p++;
- /*
- * vi historically deletes with cw only the word preserving the
- * trailing whitespace! This is not what 'w' does..
- */
- if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
- while ((p < high) && isspace((unsigned char) *p))
- p++;
- }
-
- /* p now points where we want it */
- if (p > high)
- return (high);
- else
- return (p);
-}
-
-
-/* cv_prev_word():
- * Find the previous word vi style
- */
-char *
-cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
-{
- int test;
-
- p--;
- while (n--) {
- while ((p > low) && isspace((unsigned char) *p))
- p--;
- test = (*wtest)((unsigned char) *p);
- while ((p >= low) && (*wtest)((unsigned char) *p) == test)
- p--;
- }
- p++;
-
- /* p now points where we want it */
- if (p < low)
- return (low);
- else
- return (p);
-}
-
-
-#ifdef notdef
-/* c__number():
- * Ignore character p points to, return number appearing after that.
- * A '$' by itself means a big number; "$-" is for negative; '^' means 1.
- * Return p pointing to last char used.
- */
-char *
-c__number(
- char *p, /* character position */
- int *num, /* Return value */
- int dval) /* dval is the number to subtract from like $-3 */
-{
- int i;
- int sign = 1;
-
- if (*++p == '^') {
- *num = 1;
- return (p);
- }
- if (*p == '$') {
- if (*++p != '-') {
- *num = 0x7fffffff; /* Handle $ */
- return (--p);
- }
- sign = -1; /* Handle $- */
- ++p;
- }
- for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0')
- continue;
- *num = (sign < 0 ? dval - i : i);
- return (--p);
-}
-#endif
-
-/* cv_delfini():
- * Finish vi delete action
- */
-void
-cv_delfini(EditLine *el)
-{
- int size;
- int action = el->el_chared.c_vcmd.action;
-
- if (action & INSERT)
- el->el_map.current = el->el_map.key;
-
- if (el->el_chared.c_vcmd.pos == 0)
- /* sanity */
- return;
-
- size = el->el_line.cursor - el->el_chared.c_vcmd.pos;
- if (size == 0)
- size = 1;
- el->el_line.cursor = el->el_chared.c_vcmd.pos;
- if (action & YANK) {
- if (size > 0)
- cv_yank(el, el->el_line.cursor, size);
- else
- cv_yank(el, el->el_line.cursor + size, -size);
- } else {
- if (size > 0) {
- c_delafter(el, size);
- re_refresh_cursor(el);
- } else {
- c_delbefore(el, -size);
- el->el_line.cursor += size;
- }
- }
- el->el_chared.c_vcmd.action = NOP;
-}
-
-
-#ifdef notdef
-/* ce__endword():
- * Go to the end of this word according to emacs
- */
-char *
-ce__endword(char *p, char *high, int n)
-{
- p++;
-
- while (n--) {
- while ((p < high) && isspace((unsigned char) *p))
- p++;
- while ((p < high) && !isspace((unsigned char) *p))
- p++;
- }
-
- p--;
- return (p);
-}
-#endif
-
-
-/* cv__endword():
- * Go to the end of this word according to vi
- */
-char *
-cv__endword(char *p, char *high, int n, int (*wtest)(int))
-{
- int test;
-
- p++;
-
- while (n--) {
- while ((p < high) && isspace((unsigned char) *p))
- p++;
-
- test = (*wtest)((unsigned char) *p);
- while ((p < high) && (*wtest)((unsigned char) *p) == test)
- p++;
- }
- p--;
- return (p);
-}
-
-/* ch_init():
- * Initialize the character editor
- */
-int
-ch_init(EditLine *el)
-{
- c_macro_t *ma = &el->el_chared.c_macro;
-
- el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
- if (el->el_line.buffer == NULL)
- return (-1);
-
- (void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
- el->el_line.cursor = el->el_line.buffer;
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ -
EL_LEAVE];
-
- el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ);
- if (el->el_chared.c_undo.buf == NULL)
- return (-1);
- (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
- el->el_chared.c_undo.len = -1;
- el->el_chared.c_undo.cursor = 0;
- el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ);
- if (el->el_chared.c_redo.buf == NULL)
- return (-1);
- el->el_chared.c_redo.pos = el->el_chared.c_redo.buf;
- el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ;
- el->el_chared.c_redo.cmd = ED_UNASSIGNED;
-
- el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_vcmd.pos = el->el_line.buffer;
-
- el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
- if (el->el_chared.c_kill.buf == NULL)
- return (-1);
- (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
- el->el_chared.c_kill.mark = el->el_line.buffer;
- el->el_chared.c_kill.last = el->el_chared.c_kill.buf;
-
- el->el_map.current = el->el_map.key;
-
- el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
- el->el_state.doingarg = 0;
- el->el_state.metanext = 0;
- el->el_state.argument = 1;
- el->el_state.lastcmd = ED_UNASSIGNED;
-
- ma->level = -1;
- ma->offset = 0;
- ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
- if (ma->macro == NULL)
- return (-1);
- return (0);
-}
-
-/* ch_reset():
- * Reset the character editor
- */
-void
-ch_reset(EditLine *el, int mclear)
-{
- el->el_line.cursor = el->el_line.buffer;
- el->el_line.lastchar = el->el_line.buffer;
-
- el->el_chared.c_undo.len = -1;
- el->el_chared.c_undo.cursor = 0;
-
- el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_vcmd.pos = el->el_line.buffer;
-
- el->el_chared.c_kill.mark = el->el_line.buffer;
-
- el->el_map.current = el->el_map.key;
-
- el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
- el->el_state.doingarg = 0;
- el->el_state.metanext = 0;
- el->el_state.argument = 1;
- el->el_state.lastcmd = ED_UNASSIGNED;
-
- el->el_history.eventno = 0;
-
- if (mclear)
- ch__clearmacro(el);
-}
-
-private void
-ch__clearmacro(el)
- EditLine *el;
-{
- c_macro_t *ma = &el->el_chared.c_macro;
- while (ma->level >= 0)
- el_free((ptr_t)ma->macro[ma->level--]);
-}
-
-/* ch_enlargebufs():
- * Enlarge line buffer to be able to hold twice as much characters.
- * Returns 1 if successful, 0 if not.
- */
-int
-ch_enlargebufs(el, addlen)
- EditLine *el;
- size_t addlen;
-{
- size_t sz, newsz;
- char *newbuffer, *oldbuf, *oldkbuf;
-
- sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
- newsz = sz * 2;
- /*
- * If newly required length is longer than current buffer, we need
- * to make the buffer big enough to hold both old and new stuff.
- */
- if (addlen > sz) {
- while(newsz - sz < addlen)
- newsz *= 2;
- }
-
- /*
- * Reallocate line buffer.
- */
- newbuffer = el_realloc(el->el_line.buffer, newsz);
- if (!newbuffer)
- return 0;
-
- /* zero the newly added memory, leave old data in */
- (void) memset(&newbuffer[sz], 0, newsz - sz);
-
- oldbuf = el->el_line.buffer;
-
- el->el_line.buffer = newbuffer;
- el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
- el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
- /* don't set new size until all buffers are enlarged */
- el->el_line.limit = &newbuffer[sz - EL_LEAVE];
-
- /*
- * Reallocate kill buffer.
- */
- newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz);
- if (!newbuffer)
- return 0;
-
- /* zero the newly added memory, leave old data in */
- (void) memset(&newbuffer[sz], 0, newsz - sz);
-
- oldkbuf = el->el_chared.c_kill.buf;
-
- el->el_chared.c_kill.buf = newbuffer;
- el->el_chared.c_kill.last = newbuffer +
- (el->el_chared.c_kill.last - oldkbuf);
- el->el_chared.c_kill.mark = el->el_line.buffer +
- (el->el_chared.c_kill.mark - oldbuf);
-
- /*
- * Reallocate undo buffer.
- */
- newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz);
- if (!newbuffer)
- return 0;
-
- /* zero the newly added memory, leave old data in */
- (void) memset(&newbuffer[sz], 0, newsz - sz);
- el->el_chared.c_undo.buf = newbuffer;
-
- newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
- if (!newbuffer)
- return 0;
- el->el_chared.c_redo.pos = newbuffer +
- (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf);
- el->el_chared.c_redo.lim = newbuffer +
- (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
- el->el_chared.c_redo.buf = newbuffer;
-
- if (!hist_enlargebuf(el, sz, newsz))
- return 0;
-
- /* Safe to set enlarged buffer size */
- el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
- return 1;
-}
-
-/* ch_end():
- * Free the data structures used by the editor
- */
-void
-ch_end(EditLine *el)
-{
- el_free((ptr_t) el->el_line.buffer);
- el->el_line.buffer = NULL;
- el->el_line.limit = NULL;
- el_free((ptr_t) el->el_chared.c_undo.buf);
- el->el_chared.c_undo.buf = NULL;
- el_free((ptr_t) el->el_chared.c_redo.buf);
- el->el_chared.c_redo.buf = NULL;
- el->el_chared.c_redo.pos = NULL;
- el->el_chared.c_redo.lim = NULL;
- el->el_chared.c_redo.cmd = ED_UNASSIGNED;
- el_free((ptr_t) el->el_chared.c_kill.buf);
- el->el_chared.c_kill.buf = NULL;
- ch_reset(el, 1);
- el_free((ptr_t) el->el_chared.c_macro.macro);
- el->el_chared.c_macro.macro = NULL;
-}
-
-
-/* el_insertstr():
- * Insert string at cursorI
- */
-public int
-el_insertstr(EditLine *el, const char *s)
-{
- size_t len;
-
- if ((len = strlen(s)) == 0)
- return (-1);
- if (el->el_line.lastchar + len >= el->el_line.limit) {
- if (!ch_enlargebufs(el, len))
- return (-1);
- }
-
- c_insert(el, (int)len);
- while (*s)
- *el->el_line.cursor++ = *s++;
- return (0);
-}
-
-
-/* el_deletestr():
- * Delete num characters before the cursor
- */
-public void
-el_deletestr(EditLine *el, int n)
-{
- if (n <= 0)
- return;
-
- if (el->el_line.cursor < &el->el_line.buffer[n])
- return;
-
- c_delbefore(el, n); /* delete before dot */
- el->el_line.cursor -= n;
- if (el->el_line.cursor < el->el_line.buffer)
- el->el_line.cursor = el->el_line.buffer;
-}
-
-/* c_gets():
- * Get a string
- */
-int
-c_gets(EditLine *el, char *buf, const char *prompt)
-{
- char ch;
- int len;
- char *cp = el->el_line.buffer;
-
- if (prompt) {
- len = strlen(prompt);
- memcpy(cp, prompt, len + 0u);
- cp += len;
- }
- len = 0;
-
- for (;;) {
- el->el_line.cursor = cp;
- *cp = ' ';
- el->el_line.lastchar = cp + 1;
- re_refresh(el);
-
- if (el_getc(el, &ch) != 1) {
- ed_end_of_file(el, 0);
- len = -1;
- break;
- }
-
- switch (ch) {
-
- case '\010': /* Delete and backspace */
- case '\177':
- if (len <= 0) {
- len = -1;
- break;
- }
- cp--;
- continue;
-
- case '\033': /* ESC */
- case '\r': /* Newline */
- case '\n':
- buf[len] = ch;
- break;
-
- default:
- if (len >= EL_BUFSIZ - 16)
- term_beep(el);
- else {
- buf[len++] = ch;
- *cp++ = ch;
- }
- continue;
- }
- break;
- }
-
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
- return len;
-}
-
-
-/* c_hpos():
- * Return the current horizontal position of the cursor
- */
-int
-c_hpos(EditLine *el)
-{
- char *ptr;
-
- /*
- * Find how many characters till the beginning of this line.
- */
- if (el->el_line.cursor == el->el_line.buffer)
- return (0);
- else {
- for (ptr = el->el_line.cursor - 1;
- ptr >= el->el_line.buffer && *ptr != '\n';
- ptr--)
- continue;
- return (el->el_line.cursor - ptr - 1);
- }
-}
diff --git a/src/libs/edit/chared.h b/src/libs/edit/chared.h
deleted file mode 100644
index b036b03..0000000
--- a/src/libs/edit/chared.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)chared.h 8.1 (Berkeley) 6/4/93
- * $NetBSD: chared.h,v 1.16 2005/08/08 14:05:37 christos Exp $
- * $FreeBSD: src/lib/libedit/chared.h,v 1.8 2005/08/09 13:37:59 stefanf Exp $
- */
-
-/*
- * el.chared.h: Character editor interface
- */
-#ifndef _h_el_chared
-#define _h_el_chared
-
-#include <ctype.h>
-#include <string.h>
-
-#include "histedit.h"
-
-#define EL_MAXMACRO 10
-
-/*
- * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
- * like real vi: i.e. the transition from command<->insert modes moves
- * the cursor.
- *
- * On the other hand we really don't want to move the cursor, because
- * all the editing commands don't include the character under the cursor.
- * Probably the best fix is to make all the editing commands aware of
- * this fact.
- */
-#define VI_MOVE
-
-
-typedef struct c_macro_t {
- int level;
- int offset;
- char **macro;
-} c_macro_t;
-
-/*
- * Undo information for vi - no undo in emacs (yet)
- */
-typedef struct c_undo_t {
- int len; /* length of saved line */
- int cursor; /* position of saved cursor */
- char *buf; /* full saved text */
-} c_undo_t;
-
-/* redo for vi */
-typedef struct c_redo_t {
- char *buf; /* redo insert key sequence */
- char *pos;
- char *lim;
- el_action_t cmd; /* command to redo */
- char ch; /* char that invoked it */
- int count;
- int action; /* from cv_action() */
-} c_redo_t;
-
-/*
- * Current action information for vi
- */
-typedef struct c_vcmd_t {
- int action;
- char *pos;
-} c_vcmd_t;
-
-/*
- * Kill buffer for emacs
- */
-typedef struct c_kill_t {
- char *buf;
- char *last;
- char *mark;
-} c_kill_t;
-
-/*
- * Note that we use both data structures because the user can bind
- * commands from both editors!
- */
-typedef struct el_chared_t {
- c_undo_t c_undo;
- c_kill_t c_kill;
- c_redo_t c_redo;
- c_vcmd_t c_vcmd;
- c_macro_t c_macro;
-} el_chared_t;
-
-
-#define STReof "^D\b\b"
-#define STRQQ "\"\""
-
-#define isglob(a) (strchr("*[]?", (a)) != NULL)
-#define isword(a) (isprint(a))
-
-#define NOP 0x00
-#define DELETE 0x01
-#define INSERT 0x02
-#define YANK 0x04
-
-#define CHAR_FWD (+1)
-#define CHAR_BACK (-1)
-
-#define MODE_INSERT 0
-#define MODE_REPLACE 1
-#define MODE_REPLACE_1 2
-
-#include "common.h"
-#include "vi.h"
-#include "emacs.h"
-#include "search.h"
-#include "fcns.h"
-
-
-int cv__isword(int);
-int cv__isWord(int);
-void cv_delfini(EditLine *);
-char *cv__endword(char *, char *, int, int (*)(int));
-int ce__isword(int);
-void cv_undo(EditLine *);
-void cv_yank(EditLine *, const char *, int);
-char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
-char *cv_prev_word(char *, char *, int, int (*)(int));
-char *c__next_word(char *, char *, int, int (*)(int));
-char *c__prev_word(char *, char *, int, int (*)(int));
-void c_insert(EditLine *, int);
-void c_delbefore(EditLine *, int);
-void c_delbefore1(EditLine *);
-void c_delafter(EditLine *, int);
-void c_delafter1(EditLine *);
-int c_gets(EditLine *, char *, const char *);
-int c_hpos(EditLine *);
-
-int ch_init(EditLine *);
-void ch_reset(EditLine *, int);
-int ch_enlargebufs(EditLine *, size_t);
-void ch_end(EditLine *);
-
-#endif /* _h_el_chared */
diff --git a/src/libs/edit/common.c b/src/libs/edit/common.c
deleted file mode 100644
index ac6d871..0000000
--- a/src/libs/edit/common.c
+++ /dev/null
@@ -1,920 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $NetBSD: common.c,v 1.18 2005/08/08 14:05:37 christos Exp $
- */
-
-#if !defined(lint) && !defined(SCCSID)
-static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint && not SCCSID */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libedit/common.c,v 1.11 2005/08/09 13:37:59
stefanf Exp $");
-
-/*
- * common.c: Common Editor functions
- */
-#include "sys.h"
-#include "el.h"
-
-/* ed_end_of_file():
- * Indicate end of file
- * [^D]
- */
-el_action_t
-/*ARGSUSED*/
-ed_end_of_file(EditLine *el, int c __unused)
-{
-
- re_goto_bottom(el);
- *el->el_line.lastchar = '\0';
- return (CC_EOF);
-}
-
-
-/* ed_insert():
- * Add character to the line
- * Insert a character [bound to all insert keys]
- */
-el_action_t
-ed_insert(EditLine *el, int c)
-{
- int count = el->el_state.argument;
-
- if (c == '\0')
- return (CC_ERROR);
-
- if (el->el_line.lastchar + el->el_state.argument >=
- el->el_line.limit) {
- /* end of buffer space, try to allocate more */
- if (!ch_enlargebufs(el, (size_t) count))
- return CC_ERROR; /* error allocating more */
- }
-
- if (count == 1) {
- if (el->el_state.inputmode == MODE_INSERT
- || el->el_line.cursor >= el->el_line.lastchar)
- c_insert(el, 1);
-
- *el->el_line.cursor++ = c;
- re_fastaddc(el); /* fast refresh for one char. */
- } else {
- if (el->el_state.inputmode != MODE_REPLACE_1)
- c_insert(el, el->el_state.argument);
-
- while (count-- && el->el_line.cursor < el->el_line.lastchar)
- *el->el_line.cursor++ = c;
- re_refresh(el);
- }
-
- if (el->el_state.inputmode == MODE_REPLACE_1)
- return vi_command_mode(el, 0);
-
- return (CC_NORM);
-}
-
-
-/* ed_delete_prev_word():
- * Delete from beginning of current word to cursor
- * [M-^?] [^W]
- */
-el_action_t
-/*ARGSUSED*/
-ed_delete_prev_word(EditLine *el, int c __unused)
-{
- char *cp, *p, *kp;
-
- if (el->el_line.cursor == el->el_line.buffer)
- return (CC_ERROR);
-
- cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
- el->el_state.argument, ce__isword);
-
- for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
- *kp++ = *p;
- el->el_chared.c_kill.last = kp;
-
- c_delbefore(el, el->el_line.cursor - cp); /* delete before dot */
- el->el_line.cursor = cp;
- if (el->el_line.cursor < el->el_line.buffer)
- el->el_line.cursor = el->el_line.buffer; /* bounds check */
- return (CC_REFRESH);
-}
-
-
-/* ed_delete_next_char():
- * Delete character under cursor
- * [^D] [x]
- */
-el_action_t
-/*ARGSUSED*/
-ed_delete_next_char(EditLine *el, int c __unused)
-{
-#ifdef notdef /* XXX */
-#define EL el->el_line
- (void) fprintf(el->el_errlfile,
- "\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n",
- EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
- EL.lastchar, EL.limit, EL.limit);
-#endif
- if (el->el_line.cursor == el->el_line.lastchar) {
- /* if I'm at the end */
- if (el->el_map.type == MAP_VI) {
- if (el->el_line.cursor == el->el_line.buffer) {
- /* if I'm also at the beginning */
-#ifdef KSHVI
- return (CC_ERROR);
-#else
- term_overwrite(el, STReof, 4);
- /* then do an EOF */
- term__flush();
- return (CC_EOF);
-#endif
- } else {
-#ifdef KSHVI
- el->el_line.cursor--;
-#else
- return (CC_ERROR);
-#endif
- }
- } else {
- if (el->el_line.cursor != el->el_line.buffer)
- el->el_line.cursor--;
- else
- return (CC_ERROR);
- }
- }
- c_delafter(el, el->el_state.argument); /* delete after dot */
- if (el->el_line.cursor >= el->el_line.lastchar &&
- el->el_line.cursor > el->el_line.buffer)
- /* bounds check */
- el->el_line.cursor = el->el_line.lastchar - 1;
- return (CC_REFRESH);
-}
-
-
-/* ed_kill_line():
- * Cut to the end of line
- * [^K] [^K]
- */
-el_action_t
-/*ARGSUSED*/
-ed_kill_line(EditLine *el, int c __unused)
-{
- char *kp, *cp;
-
- cp = el->el_line.cursor;
- kp = el->el_chared.c_kill.buf;
- while (cp < el->el_line.lastchar)
- *kp++ = *cp++; /* copy it */
- el->el_chared.c_kill.last = kp;
- /* zap! -- delete to end */
- el->el_line.lastchar = el->el_line.cursor;
- return (CC_REFRESH);
-}
-
-
-/* ed_move_to_end():
- * Move cursor to the end of line
- * [^E] [^E]
- */
-el_action_t
-/*ARGSUSED*/
-ed_move_to_end(EditLine *el, int c __unused)
-{
-
- el->el_line.cursor = el->el_line.lastchar;
- if (el->el_map.type == MAP_VI) {
-#ifdef VI_MOVE
- el->el_line.cursor--;
-#endif
- if (el->el_chared.c_vcmd.action != NOP) {
- cv_delfini(el);
- return (CC_REFRESH);
- }
- }
- return (CC_CURSOR);
-}
-
-
-/* ed_move_to_beg():
- * Move cursor to the beginning of line
- * [^A] [^A]
- */
-el_action_t
-/*ARGSUSED*/
-ed_move_to_beg(EditLine *el, int c __unused)
-{
-
- el->el_line.cursor = el->el_line.buffer;
-
- if (el->el_map.type == MAP_VI) {
- /* We want FIRST non space character */
- while (isspace((unsigned char) *el->el_line.cursor))
- el->el_line.cursor++;
- if (el->el_chared.c_vcmd.action != NOP) {
- cv_delfini(el);
- return (CC_REFRESH);
- }
- }
- return (CC_CURSOR);
-}
-
-
-/* ed_transpose_chars():
- * Exchange the character to the left of the cursor with the one under it
- * [^T] [^T]
- */
-el_action_t
-ed_transpose_chars(EditLine *el, int c)
-{
-
- if (el->el_line.cursor < el->el_line.lastchar) {
- if (el->el_line.lastchar <= &el->el_line.buffer[1])
- return (CC_ERROR);
- else
- el->el_line.cursor++;
- }
- if (el->el_line.cursor > &el->el_line.buffer[1]) {
- /* must have at least two chars entered */
- c = el->el_line.cursor[-2];
- el->el_line.cursor[-2] = el->el_line.cursor[-1];
- el->el_line.cursor[-1] = c;
- return (CC_REFRESH);
- } else
- return (CC_ERROR);
-}
-
-
-/* ed_next_char():
- * Move to the right one character
- * [^F] [^F]
- */
-el_action_t
-/*ARGSUSED*/
-ed_next_char(EditLine *el, int c __unused)
-{
- char *lim = el->el_line.lastchar;
-
- if (el->el_line.cursor >= lim ||
- (el->el_line.cursor == lim - 1 &&
- el->el_map.type == MAP_VI &&
- el->el_chared.c_vcmd.action == NOP))
- return (CC_ERROR);
-
- el->el_line.cursor += el->el_state.argument;
- if (el->el_line.cursor > lim)
- el->el_line.cursor = lim;
-
- if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action != NOP) {
- cv_delfini(el);
- return (CC_REFRESH);
- }
- return (CC_CURSOR);
-}
-
-
-/* ed_prev_word():
- * Move to the beginning of the current word
- * [M-b] [b]
- */
-el_action_t
-/*ARGSUSED*/
-ed_prev_word(EditLine *el, int c __unused)
-{
-
- if (el->el_line.cursor == el->el_line.buffer)
- return (CC_ERROR);
-
- el->el_line.cursor = c__prev_word(el->el_line.cursor,
- el->el_line.buffer,
- el->el_state.argument,
- ce__isword);
-
- if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action != NOP) {
- cv_delfini(el);
- return (CC_REFRESH);
- }
- return (CC_CURSOR);
-}
-
-
-/* ed_prev_char():
- * Move to the left one character
- * [^B] [^B]
- */
-el_action_t
-/*ARGSUSED*/
-ed_prev_char(EditLine *el, int c __unused)
-{
-
- if (el->el_line.cursor > el->el_line.buffer) {
- el->el_line.cursor -= el->el_state.argument;
- if (el->el_line.cursor < el->el_line.buffer)
- el->el_line.cursor = el->el_line.buffer;
-
- if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action != NOP) {
- cv_delfini(el);
- return (CC_REFRESH);
- }
- return (CC_CURSOR);
- } else
- return (CC_ERROR);
-}
-
-
-/* ed_quoted_insert():
- * Add the next character typed verbatim
- * [^V] [^V]
- */
-el_action_t
-ed_quoted_insert(EditLine *el, int c)
-{
- int num;
- char tc;
-
- tty_quotemode(el);
- num = el_getc(el, &tc);
- c = (unsigned char) tc;
- tty_noquotemode(el);
- if (num == 1)
- return (ed_insert(el, c));
- else
- return (ed_end_of_file(el, 0));
-}
-
-
-/* ed_digit():
- * Adds to argument or enters a digit
- */
-el_action_t
-ed_digit(EditLine *el, int c)
-{
-
- if (!isdigit((unsigned char) c))
- return (CC_ERROR);
-
- if (el->el_state.doingarg) {
- /* if doing an arg, add this in... */
- if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
- el->el_state.argument = c - '0';
- else {
- if (el->el_state.argument > 1000000)
- return (CC_ERROR);
- el->el_state.argument =
- (el->el_state.argument * 10) + (c - '0');
- }
- return (CC_ARGHACK);
- }
-
- return ed_insert(el, c);
-}
-
-
-/* ed_argument_digit():
- * Digit that starts argument
- * For ESC-n
- */
-el_action_t
-ed_argument_digit(EditLine *el, int c)
-{
-
- if (!isdigit((unsigned char) c))
- return (CC_ERROR);
-
- if (el->el_state.doingarg) {
- if (el->el_state.argument > 1000000)
- return (CC_ERROR);
- el->el_state.argument = (el->el_state.argument * 10) +
- (c - '0');
- } else { /* else starting an argument */
- el->el_state.argument = c - '0';
- el->el_state.doingarg = 1;
- }
- return (CC_ARGHACK);
-}
-
-
-/* ed_unassigned():
- * Indicates unbound character
- * Bound to keys that are not assigned
- */
-el_action_t
-/*ARGSUSED*/
-ed_unassigned(EditLine *el, int c __unused)
-{
-
- return (CC_ERROR);
-}
-
-
-/**
- ** TTY key handling.
- **/
-
-/* ed_tty_sigint():
- * Tty interrupt character
- * [^C]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_sigint(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_tty_dsusp():
- * Tty delayed suspend character
- * [^Y]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_dsusp(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_tty_flush_output():
- * Tty flush output characters
- * [^O]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_flush_output(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_tty_sigquit():
- * Tty quit character
- * [^\]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_sigquit(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_tty_sigtstp():
- * Tty suspend character
- * [^Z]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_sigtstp(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_tty_stop_output():
- * Tty disallow output characters
- * [^S]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_stop_output(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_tty_start_output():
- * Tty allow output characters
- * [^Q]
- */
-el_action_t
-/*ARGSUSED*/
-ed_tty_start_output(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_newline():
- * Execute command
- * [^J]
- */
-el_action_t
-/*ARGSUSED*/
-ed_newline(EditLine *el, int c __unused)
-{
-
- re_goto_bottom(el);
- *el->el_line.lastchar++ = '\n';
- *el->el_line.lastchar = '\0';
- return (CC_NEWLINE);
-}
-
-
-/* ed_delete_prev_char():
- * Delete the character to the left of the cursor
- * [^?]
- */
-el_action_t
-/*ARGSUSED*/
-ed_delete_prev_char(EditLine *el, int c __unused)
-{
-
- if (el->el_line.cursor <= el->el_line.buffer)
- return (CC_ERROR);
-
- c_delbefore(el, el->el_state.argument);
- el->el_line.cursor -= el->el_state.argument;
- if (el->el_line.cursor < el->el_line.buffer)
- el->el_line.cursor = el->el_line.buffer;
- return (CC_REFRESH);
-}
-
-
-/* ed_clear_screen():
- * Clear screen leaving current line at the top
- * [^L]
- */
-el_action_t
-/*ARGSUSED*/
-ed_clear_screen(EditLine *el, int c __unused)
-{
-
- term_clear_screen(el); /* clear the whole real screen */
- re_clear_display(el); /* reset everything */
- return (CC_REFRESH);
-}
-
-
-/* ed_redisplay():
- * Redisplay everything
- * ^R
- */
-el_action_t
-/*ARGSUSED*/
-ed_redisplay(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_REDISPLAY);
-}
-
-
-/* ed_start_over():
- * Erase current line and start from scratch
- * [^G]
- */
-el_action_t
-/*ARGSUSED*/
-ed_start_over(EditLine *el, int c __unused)
-{
-
- ch_reset(el, 0);
- return (CC_REFRESH);
-}
-
-
-/* ed_sequence_lead_in():
- * First character in a bound sequence
- * Placeholder for external keys
- */
-el_action_t
-/*ARGSUSED*/
-ed_sequence_lead_in(EditLine *el __unused,
- int c __unused)
-{
-
- return (CC_NORM);
-}
-
-
-/* ed_prev_history():
- * Move to the previous history line
- * [^P] [k]
- */
-el_action_t
-/*ARGSUSED*/
-ed_prev_history(EditLine *el, int c __unused)
-{
- char beep = 0;
- int sv_event = el->el_history.eventno;
-
- el->el_chared.c_undo.len = -1;
- *el->el_line.lastchar = '\0'; /* just in case */
-
- if (el->el_history.eventno == 0) { /* save the current buffer
- * away */
- (void) strncpy(el->el_history.buf, el->el_line.buffer,
- EL_BUFSIZ);
- el->el_history.last = el->el_history.buf +
- (el->el_line.lastchar - el->el_line.buffer);
- }
- el->el_history.eventno += el->el_state.argument;
-
- if (hist_get(el) == CC_ERROR) {
- if (el->el_map.type == MAP_VI) {
- el->el_history.eventno = sv_event;
- return CC_ERROR;
- }
- beep = 1;
- /* el->el_history.eventno was fixed by first call */
- (void) hist_get(el);
- }
- if (beep)
- return CC_REFRESH_BEEP;
- return CC_REFRESH;
-}
-
-
-/* ed_next_history():
- * Move to the next history line
- * [^N] [j]
- */
-el_action_t
-/*ARGSUSED*/
-ed_next_history(EditLine *el, int c __unused)
-{
- el_action_t beep = CC_REFRESH, rval;
-
- el->el_chared.c_undo.len = -1;
- *el->el_line.lastchar = '\0'; /* just in case */
-
- el->el_history.eventno -= el->el_state.argument;
-
- if (el->el_history.eventno < 0) {
- el->el_history.eventno = 0;
- beep = CC_REFRESH_BEEP;
- }
- rval = hist_get(el);
- if (rval == CC_REFRESH)
- return beep;
- return rval;
-
-}
-
-
-/* ed_search_prev_history():
- * Search previous in history for a line matching the current
- * next search history [M-P] [K]
- */
-el_action_t
-/*ARGSUSED*/
-ed_search_prev_history(EditLine *el, int c __unused)
-{
- const char *hp;
- int h;
- bool_t found = 0;
-
- el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_undo.len = -1;
- *el->el_line.lastchar = '\0'; /* just in case */
- if (el->el_history.eventno < 0) {
-#ifdef DEBUG_EDIT
- (void) fprintf(el->el_errfile,
- "e_prev_search_hist(): eventno < 0;\n");
-#endif
- el->el_history.eventno = 0;
- return (CC_ERROR);
- }
- if (el->el_history.eventno == 0) {
- (void) strncpy(el->el_history.buf, el->el_line.buffer,
- EL_BUFSIZ);
- el->el_history.last = el->el_history.buf +
- (el->el_line.lastchar - el->el_line.buffer);
- }
- if (el->el_history.ref == NULL)
- return (CC_ERROR);
-
- hp = HIST_FIRST(el);
- if (hp == NULL)
- return (CC_ERROR);
-
- c_setpat(el); /* Set search pattern !! */
-
- for (h = 1; h <= el->el_history.eventno; h++)
- hp = HIST_NEXT(el);
-
- while (hp != NULL) {
-#ifdef SDEBUG
- (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
-#endif
- if ((strncmp(hp, el->el_line.buffer, (size_t)
- (el->el_line.lastchar - el->el_line.buffer)) ||
- hp[el->el_line.lastchar - el->el_line.buffer]) &&
- c_hmatch(el, hp)) {
- found++;
- break;
- }
- h++;
- hp = HIST_NEXT(el);
- }
-
- if (!found) {
-#ifdef SDEBUG
- (void) fprintf(el->el_errfile, "not found\n");
-#endif
- return (CC_ERROR);
- }
- el->el_history.eventno = h;
-
- return (hist_get(el));
-}
-
-
-/* ed_search_next_history():
- * Search next in history for a line matching the current
- * [M-N] [J]
- */
-el_action_t
-/*ARGSUSED*/
-ed_search_next_history(EditLine *el, int c __unused)
-{
- const char *hp;
- int h;
- bool_t found = 0;
-
- el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_undo.len = -1;
- *el->el_line.lastchar = '\0'; /* just in case */
-
- if (el->el_history.eventno == 0)
- return (CC_ERROR);
-
- if (el->el_history.ref == NULL)
- return (CC_ERROR);
-
- hp = HIST_FIRST(el);
- if (hp == NULL)
- return (CC_ERROR);
-
- c_setpat(el); /* Set search pattern !! */
-
- for (h = 1; h < el->el_history.eventno && hp; h++) {
-#ifdef SDEBUG
- (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
-#endif
- if ((strncmp(hp, el->el_line.buffer, (size_t)
- (el->el_line.lastchar - el->el_line.buffer)) ||
- hp[el->el_line.lastchar - el->el_line.buffer]) &&
- c_hmatch(el, hp))
- found = h;
- hp = HIST_NEXT(el);
- }
-
- if (!found) { /* is it the current history number? */
- if (!c_hmatch(el, el->el_history.buf)) {
-#ifdef SDEBUG
- (void) fprintf(el->el_errfile, "not found\n");
-#endif
- return (CC_ERROR);
- }
- }
- el->el_history.eventno = found;
-
- return (hist_get(el));
-}
-
-
-/* ed_prev_line():
- * Move up one line
- * Could be [k] [^p]
- */
-el_action_t
-/*ARGSUSED*/
-ed_prev_line(EditLine *el, int c __unused)
-{
- char *ptr;
- int nchars = c_hpos(el);
-
- /*
- * Move to the line requested
- */
- if (*(ptr = el->el_line.cursor) == '\n')
- ptr--;
-
- for (; ptr >= el->el_line.buffer; ptr--)
- if (*ptr == '\n' && --el->el_state.argument <= 0)
- break;
-
- if (el->el_state.argument > 0)
- return (CC_ERROR);
-
- /*
- * Move to the beginning of the line
- */
- for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
- continue;
-
- /*
- * Move to the character requested
- */
- for (ptr++;
- nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
- ptr++)
- continue;
-
- el->el_line.cursor = ptr;
- return (CC_CURSOR);
-}
-
-
-/* ed_next_line():
- * Move down one line
- * Could be [j] [^n]
- */
-el_action_t
-/*ARGSUSED*/
-ed_next_line(EditLine *el, int c __unused)
-{
- char *ptr;
- int nchars = c_hpos(el);
-
- /*
- * Move to the line requested
- */
- for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
- if (*ptr == '\n' && --el->el_state.argument <= 0)
- break;
-
- if (el->el_state.argument > 0)
- return (CC_ERROR);
-
- /*
- * Move to the character requested
- */
- for (ptr++;
- nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
- ptr++)
- continue;
-
- el->el_line.cursor = ptr;
- return (CC_CURSOR);
-}
-
-
-/* ed_command():
- * Editline extended command
- * [M-X] [:]
- */
-el_action_t
-/*ARGSUSED*/
-ed_command(EditLine *el, int c __unused)
-{
- char tmpbuf[EL_BUFSIZ];
- int tmplen;
-
- tmplen = c_gets(el, tmpbuf, "\n: ");
- term__putc('\n');
-
- if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
- term_beep(el);
-
- el->el_map.current = el->el_map.key;
- re_clear_display(el);
- return CC_REFRESH;
-}
diff --git a/src/libs/edit/common.h b/src/libs/edit/common.h
deleted file mode 100644
index 866bfef..0000000
--- a/src/libs/edit/common.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Automatically generated file, do not edit */
-#ifndef _h_common_c
-#define _h_common_c
-el_action_t ed_end_of_file (EditLine *, int);
-el_action_t ed_insert (EditLine *, int);
-el_action_t ed_delete_prev_word (EditLine *, int);
-el_action_t ed_delete_next_char (EditLine *, int);
-el_action_t ed_kill_line (EditLine *, int);
-el_action_t ed_move_to_end (EditLine *, int);
-el_action_t ed_move_to_beg (EditLine *, int);
-el_action_t ed_transpose_chars (EditLine *, int);
-el_action_t ed_next_char (EditLine *, int);
-el_action_t ed_prev_word (EditLine *, int);
-el_action_t ed_prev_char (EditLine *, int);
-el_action_t ed_quoted_insert (EditLine *, int);
-el_action_t ed_digit (EditLine *, int);
-el_action_t ed_argument_digit (EditLine *, int);
-el_action_t ed_unassigned (EditLine *, int);
-el_action_t ed_tty_sigint (EditLine *, int);
-el_action_t ed_tty_dsusp (EditLine *, int);
-el_action_t ed_tty_flush_output (EditLine *, int);
-el_action_t ed_tty_sigquit (EditLine *, int);
-el_action_t ed_tty_sigtstp (EditLine *, int);
-el_action_t ed_tty_stop_output (EditLine *, int);
-el_action_t ed_tty_start_output (EditLine *, int);
-el_action_t ed_newline (EditLine *, int);
-el_action_t ed_delete_prev_char (EditLine *, int);
-el_action_t ed_clear_screen (EditLine *, int);
-el_action_t ed_redisplay (EditLine *, int);
-el_action_t ed_start_over (EditLine *, int);
-el_action_t ed_sequence_lead_in (EditLine *, int);
-el_action_t ed_prev_history (EditLine *, int);
-el_action_t ed_next_history (EditLine *, int);
-el_action_t ed_search_prev_history (EditLine *, int);
-el_action_t ed_search_next_history (EditLine *, int);
-el_action_t ed_prev_line (EditLine *, int);
-el_action_t ed_next_line (EditLine *, int);
-el_action_t ed_command (EditLine *, int);
-#endif /* _h_common_c */
diff --git a/src/libs/edit/editline.3 b/src/libs/edit/editline.3
deleted file mode 100644
index a3128a8..0000000
--- a/src/libs/edit/editline.3
+++ /dev/null
@@ -1,788 +0,0 @@
-.\" $NetBSD: editline.3,v 1.50 2005/10/12 09:29:43 wiz Exp $
-.\"
-.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 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 NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
-.\" contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/libedit/editline.3,v 1.29 2005/11/24 10:32:39 ru Exp $
-.\"
-.Dd October 4, 2005
-.Os
-.Dt EDITLINE 3
-.Sh NAME
-.Nm editline ,
-.Nm el_init ,
-.Nm el_end ,
-.Nm el_reset ,
-.Nm el_gets ,
-.Nm el_getc ,
-.Nm el_push ,

[ *** diff truncated: 15366 lines dropped *** ]



Other related posts:

  • » [haiku-commits] haiku: hrev49366 - src/libs/edit - kallisti5