winbash-checkins Mailing List for winbash - bash for win32
Brought to you by:
enricobrunetta,
xks
You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
(119) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: Enrico B. <enr...@us...> - 2002-03-29 17:13:03
|
Update of /cvsroot/winbash/winbash/lib/glob
In directory usw-pr-cvs1:/tmp/cvs-serv1614
Modified Files:
glob.c
Log Message:
In addition to defining OPENDIR_NOT_ROBUST, fix dir so that stat is happy about it not having a trailing '/'
Index: glob.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/glob/glob.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glob.c 11 Mar 2002 14:32:15 -0000 1.3
+++ glob.c 29 Mar 2002 17:13:00 -0000 1.4
@@ -220,6 +220,13 @@
#if defined (OPENDIR_NOT_ROBUST)
struct stat finfo;
+ int dir_len = 0;
+ if(dir) {
+ dir_len = strlen(dir);
+ if (dir[dir_len - 1] == '/')
+ dir[dir_len - 1] = '\0';
+ }
+
if (stat (dir, &finfo) < 0)
return ((char **) &glob_error_return);
|
|
From: Enrico B. <enr...@us...> - 2002-03-29 12:08:21
|
Update of /cvsroot/winbash/winbash/lib/readline In directory usw-pr-cvs1:/tmp/cvs-serv24649 Modified Files: complete.c Log Message: Fixed buffer overrun error. tmp was defined to be MAXPATH, which was way too small to copy the value of $PATH (in my case). This was causing a crash when trying to do the following: export PATH="$PATH:~/<TAB> (when you hit TAB, the strcpy (tmp, dirname) would fail, since dirname would contain the whole value for PATH) Index: complete.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/complete.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- complete.c 26 Mar 2002 13:31:08 -0000 1.8 +++ complete.c 29 Mar 2002 12:08:17 -0000 1.9 @@ -1484,7 +1484,7 @@ static WIN32_FIND_DATA entry; static HANDLE directory = NULL; static BOOL found = 0; - char tmp[MAX_PATH]; + char tmp[2048]; # define DIR void #else struct dirent *entry; |
|
From: kevin s. <xk...@us...> - 2002-03-29 10:54:21
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv10174 Modified Files: version.h Log Message: fixed (i hope) problems with scrolling/display when the end of the screen buffer has been reached. Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- version.h 27 Mar 2002 13:47:51 -0000 1.19 +++ version.h 29 Mar 2002 10:54:18 -0000 1.20 @@ -8,9 +8,9 @@ #define PATCHLEVEL 7 /* The last built version of this shell. */ -#define BUILDVERSION 41 +#define BUILDVERSION 42 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.7(41) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.7(42) GNU" |
|
From: kevin s. <xk...@us...> - 2002-03-29 10:54:07
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv10127 Modified Files: .build Log Message: fixed (i hope) problems with scrolling/display when the end of the screen buffer has been reached. Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- .build 27 Mar 2002 13:47:51 -0000 1.19 +++ .build 29 Mar 2002 10:54:04 -0000 1.20 @@ -1 +1 @@ -41 +42 |
|
From: kevin s. <xk...@us...> - 2002-03-29 10:51:31
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv9563
Modified Files:
display.c
Log Message:
fixed (i hope) problems with scrolling/display when the end of the
screen buffer has been reached.
Index: display.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/display.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- display.c 26 Mar 2002 17:20:27 -0000 1.7
+++ display.c 29 Mar 2002 10:51:28 -0000 1.8
@@ -1323,12 +1323,56 @@
int to;
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
+
if ( (_rl_last_v_pos != to) && (to <= _rl_screenheight)
&& haveConsole && GetConsoleScreenBufferInfo(hStdout, &csbi) )
{
csbi.dwCursorPosition.Y += to - _rl_last_v_pos;
- if ( SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition) )
- _rl_last_v_pos = to;
+
+ /* if moving past the end of the screen buffer,
+ we need to scroll the screen buffer up, discarding
+ the top n lines, where n=to-_rl_last_v_pos
+
+ XXX be wary of off-by-one errors here... */
+ if (csbi.dwCursorPosition.Y >= csbi.dwSize.Y)
+ {
+ SMALL_RECT scroll;
+ COORD new_coord;
+ CHAR_INFO fillchar;
+
+ /* discard the to n lines */
+ scroll.Top = to - _rl_last_v_pos;
+ scroll.Bottom = csbi.dwSize.Y - 1;
+ scroll.Left = 0;
+ scroll.Right = csbi.dwSize.X - 1;
+
+ /* scroll region is moving to beginning of screen
+ buffer */
+ new_coord.X = 0;
+ new_coord.Y = 0;
+
+ /* fill the right character and attributes */
+ fillchar.Char.AsciiChar = ' ';
+ fillchar.Attributes = csbi.wAttributes;
+
+ /* scrolling the console buffer moves to cursor,
+ so adjust _rl_last_v_pos here */
+ if (ScrollConsoleScreenBuffer(hStdout,
+ &scroll,
+ NULL, /* no clipping region */
+ new_coord,
+ &fillchar))
+ {
+ _rl_last_v_pos = to;
+ }
+ }
+ else
+ {
+ /* if not moving past the end of the screen buffer, just move
+ the cursor */
+ if ( SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition) )
+ _rl_last_v_pos = to;
+ }
}
}
|
|
From: kevin s. <xk...@us...> - 2002-03-27 15:27:17
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv29120
Modified Files:
rltty.c
Log Message:
* include ENABLE_WINDOW_INPUT in console mode flag so that we
can handle WINDOW_BUFFER_SIZE_EVENT's, which allows us to resize
the screen (terminal) when the console buffer size changes.
* in rl_prep_terminal, turn of echoing (set readline_echoing_p to 0)
if we're running in emacs (running_in_emacs is 1). this appears
to be necessary for running bash in xemacs.
Index: rltty.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/rltty.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rltty.c 25 Mar 2002 16:17:15 -0000 1.5
+++ rltty.c 27 Mar 2002 15:27:13 -0000 1.6
@@ -55,6 +55,8 @@
extern int errno;
#endif /* !errno */
+extern int running_in_emacs;
+
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
@@ -838,7 +840,8 @@
#include <windows.h>
-#define CONSOLE_MODE ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT
+#define CONSOLE_MODE \
+ ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT
/* global vars used by other modules */
@@ -882,7 +885,7 @@
rl_prep_terminal (meta_flag)
int meta_flag;
{
- readline_echoing_p = 1;
+ readline_echoing_p = running_in_emacs ? 0 : 1;
if ( !(haveConsole & INITIALIZED) )
{
|
|
From: kevin s. <xk...@us...> - 2002-03-27 15:22:53
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv27918
Modified Files:
input.c
Log Message:
handle WINDOW_BUFFER_SIZE_EVENT so that we can resize the screen when
the console buffer size changes.
Index: input.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/input.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- input.c 25 Mar 2002 10:45:42 -0000 1.1
+++ input.c 27 Mar 2002 15:22:50 -0000 1.2
@@ -539,6 +539,11 @@
case MOUSE_EVENT:
if ( (haveConsole & FOR_OUTPUT) && !rl_dispatching )
MouseEventProc(irec.Event.MouseEvent);
+ break;
+ case WINDOW_BUFFER_SIZE_EVENT:
+ /* we've (possibly) been resized, so adjust screen size */
+ rl_resize_terminal();
+ break;
default:
break;
}
|
|
From: kevin s. <xk...@us...> - 2002-03-27 13:47:55
|
Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv22858
Modified Files:
.build bashline.c version.h
Log Message:
fixed readline completion so that quotes will properly be added/removed when file names have spaces
Index: .build
===================================================================
RCS file: /cvsroot/winbash/winbash/.build,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- .build 26 Mar 2002 17:22:21 -0000 1.18
+++ .build 27 Mar 2002 13:47:51 -0000 1.19
@@ -1 +1 @@
-40
+41
Index: bashline.c
===================================================================
RCS file: /cvsroot/winbash/winbash/bashline.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- bashline.c 26 Mar 2002 03:34:34 -0000 1.7
+++ bashline.c 27 Mar 2002 13:47:51 -0000 1.8
@@ -78,6 +78,9 @@
static void snarf_hosts_from_file (), add_host_name ();
static void sort_hostname_list ();
+static char *bash_dequote_filename (char *, int);
+static char *bash_quote_filename (char *, int, char *);
+
#define DYNAMIC_HISTORY_COMPLETION
#if defined (DYNAMIC_HISTORY_COMPLETION)
static void dynamic_complete_history ();
@@ -92,6 +95,9 @@
extern int rl_filename_completion_desired;
int rl_hostname_completion_desired =0;
+/* imported from subst.c */
+extern int char_is_quoted (char *, int);
+
/* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual
completion functions which indicate what type of completion should be
done (at or before point) that can be bound to key sequences with
@@ -142,33 +148,6 @@
#endif
}
-rl_quote_func_t *orig_quote_filename;
-static char *
-bash_quote_filename (s, rtype, qcp)
- char *s;
- int rtype;
- char *qcp;
-{
- char *r;
-
- r = xmalloc (strlen (s) + 3);
- *r = *rl_completer_quote_characters;
- strcpy (r + 1, s);
- strcat(r, "\"");
- if (qcp)
- *qcp = *rl_completer_quote_characters;
- return r;
-}
-
-/* static char * */
-/* bash_dequote_filename(text, quote_char) */
-/* char *text; */
-/* int quote_char; */
-/* { */
-/* printf("bash_dequote_filename\n"); */
-/* return text; */
-/* } */
-
/* Called once from parse.y if we are going to use readline. */
void
initialize_readline ()
@@ -277,9 +256,10 @@
#endif
rl_completer_quote_characters = "\"'";
-/* orig_quote_filename = rl_filename_quoting_function; */
-/* rl_filename_quoting_function = bash_quote_filename; */
-/* rl_filename_dequoting_function = bash_dequote_filename; */
+
+ rl_filename_quoting_function = bash_quote_filename;
+ rl_filename_dequoting_function = bash_dequote_filename;
+ rl_char_is_quoted_p = char_is_quoted;
rl_filename_quote_characters = " ";
/* Need to modify this from the default; `$', `{', `\', and ``' are not
@@ -2112,3 +2092,92 @@
}
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+/* Quote a filename using double quotes.
+ NOTE: this is a simplified version of bash_quote_filename
+ found in bash 2.05a.
+ */
+static char *
+bash_quote_filename (s, rtype, qcp)
+ char *s;
+ int rtype;
+ char *qcp;
+{
+ char *rtext, *mtext;
+ char quote_char;
+ int rlen, cs;
+
+ rtext = (char *)NULL;
+
+ /* If RTYPE == MULT_MATCH, it means that there is
+ more than one match. In this case, we do not add
+ the closing quote or attempt to perform tilde
+ expansion. If RTYPE == SINGLE_MATCH, we try
+ to perform tilde expansion, because single and double
+ quotes inhibit tilde expansion by the shell. */
+
+ mtext = s;
+ if (mtext[0] == '~' && rtype == SINGLE_MATCH)
+ mtext = tilde_expand (s);
+
+ /* Leave the opening quote intact. The readline completion code takes
+ care of avoiding doubled opening quotes. */
+
+ rtext = xmalloc(strlen(mtext) + 3);
+
+ rtext[0] = '"';
+ strcpy(rtext + 1, mtext);
+
+ /* If there are multiple matches, don't add the closing quote. */
+ if (rtype != MULT_MATCH)
+ strcat(rtext, "\"");
+
+ if (mtext != s)
+ free (mtext);
+
+ return rtext;
+}
+
+/* NOTE: copied from bash 2.05a, bashline.c */
+/* Filename quoting for completion. */
+/* A function to strip unquoted quote characters (single quotes, double
+ quotes, and backslashes). It allows single quotes to appear
+ within double quotes, and vice versa. It should be smarter. */
+static char *
+bash_dequote_filename (text, quote_char)
+ char *text;
+ int quote_char;
+{
+ char *ret, *p, *r;
+ int l, quoted;
+
+ l = strlen (text);
+ ret = (char *)xmalloc (l + 1);
+ for (quoted = quote_char, p = text, r = ret; p && *p; p++)
+ {
+ /* Allow backslash-quoted characters to pass through unscathed. */
+ if (*p == '\\')
+ {
+ *r++ = *++p;
+ if (*p == '\0')
+ break;
+ continue;
+ }
+ /* Close quote. */
+ if (quoted && *p == quoted)
+ {
+ quoted = 0;
+ continue;
+ }
+ /* Open quote. */
+ if (quoted == 0 && (*p == '\'' || *p == '"'))
+ {
+ quoted = *p;
+ continue;
+ }
+ *r++ = *p;
+ }
+ *r = '\0';
+ return ret;
+}
+
Index: version.h
===================================================================
RCS file: /cvsroot/winbash/winbash/version.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- version.h 26 Mar 2002 17:22:21 -0000 1.18
+++ version.h 27 Mar 2002 13:47:51 -0000 1.19
@@ -8,9 +8,9 @@
#define PATCHLEVEL 7
/* The last built version of this shell. */
-#define BUILDVERSION 40
+#define BUILDVERSION 41
/* A version string for use by sccs and the what command. */
-#define SCCSVERSION "@(#)Bash version 1.14.7(40) GNU"
+#define SCCSVERSION "@(#)Bash version 1.14.7(41) GNU"
|
|
From: kevin s. <xk...@us...> - 2002-03-26 22:54:37
|
Update of /cvsroot/winbash/winbash/lib/readline In directory usw-pr-cvs1:/tmp/cvs-serv22718 Modified Files: terminal.c Log Message: added a comment explaining why i turned autowrap off. Index: terminal.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/terminal.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- terminal.c 25 Mar 2002 16:17:15 -0000 1.2 +++ terminal.c 26 Mar 2002 22:54:34 -0000 1.3 @@ -398,7 +398,13 @@ #endif /* HACK_TERMCAP_MOTION */ _rl_terminal_can_insert = 0; -/* _rl_term_autowrap = 1; */ + + /* in the original win32 port of readline 4.2, this was + being set to 1 (autowrap was turned on), but it appeared + to be causing some display problems, so i turned it off. + this could probably use some re-evaluation. + - kevin seguin (03.26.2002). + */ _rl_term_autowrap = 0; #else /* !__MINGW32__ */ |
|
From: kevin s. <xk...@us...> - 2002-03-26 17:22:24
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv23443 Modified Files: .build version.h Log Message: new build with clear-screen implemented for windows console app Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- .build 26 Mar 2002 16:10:53 -0000 1.17 +++ .build 26 Mar 2002 17:22:21 -0000 1.18 @@ -1 +1 @@ -39 +40 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- version.h 26 Mar 2002 16:10:53 -0000 1.17 +++ version.h 26 Mar 2002 17:22:21 -0000 1.18 @@ -8,9 +8,9 @@ #define PATCHLEVEL 7 /* The last built version of this shell. */ -#define BUILDVERSION 39 +#define BUILDVERSION 40 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.7(39) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.7(40) GNU" |
|
From: kevin s. <xk...@us...> - 2002-03-26 17:20:32
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv22830
Modified Files:
display.c
Log Message:
implement _rl_clear_screen for windows console app.
Index: display.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/display.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- display.c 26 Mar 2002 00:33:42 -0000 1.6
+++ display.c 26 Mar 2002 17:20:27 -0000 1.7
@@ -1587,20 +1587,73 @@
return;
}
-#endif /* __MINGW32__ */
+/* Standard error macro for reporting API errors */
+#define PERR(bSuccess, api){if(!(bSuccess)) \
+ printf("%s:Error %d from %s on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
+
+/**
+ * screen clearing function found at:
+ * ftp://ftp.microsoft.com/developr/win32dk/kb/q99/2/61.txt
+ */
+static void cls( HANDLE hConsole )
+{
+ COORD coordScreen = { 0, 0 }; /* here's where we'll home the
+ cursor */
+ BOOL bSuccess;
+ DWORD cCharsWritten;
+ CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
+ DWORD dwConSize; /* number of character cells in
+ the current buffer */
+
+ /* get the number of character cells in the current buffer */
+
+ bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
+ PERR( bSuccess, "GetConsoleScreenBufferInfo" );
+ dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
+
+ /* fill the entire screen with blanks */
+
+ bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
+ dwConSize, coordScreen, &cCharsWritten );
+ PERR( bSuccess, "FillConsoleOutputCharacter" );
+
+ /* get the current text attribute */
+
+ bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
+ PERR( bSuccess, "ConsoleScreenBufferInfo" );
+
+ /* now set the buffer's attributes accordingly */
+
+ bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
+ dwConSize, coordScreen, &cCharsWritten );
+ PERR( bSuccess, "FillConsoleOutputAttribute" );
+
+ /* put the cursor at (0, 0) */
+
+ bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
+ PERR( bSuccess, "SetConsoleCursorPosition" );
+ return;
+}
void
_rl_clear_screen ()
{
+ cls(hStdout);
+ cr();
+}
+
+#endif /* __MINGW32__ */
+
#ifndef __MINGW32__
+void
+_rl_clear_screen ()
+{
if (_rl_term_clrpag)
tputs (_rl_term_clrpag, 1, _rl_output_character_function);
else
-#endif
rl_crlf ();
}
-#ifndef __MINGW32__
/* Insert COUNT characters from STRING to the output stream. */
static void
insert_some_chars (string, count)
|
|
From: kevin s. <xk...@us...> - 2002-03-26 16:10:55
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv28964 Modified Files: .build version.h Log Message: new build with fix for adding to list of suffixes to try for exe's Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- .build 26 Mar 2002 13:37:22 -0000 1.16 +++ .build 26 Mar 2002 16:10:53 -0000 1.17 @@ -1 +1 @@ -38 +39 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- version.h 26 Mar 2002 13:37:22 -0000 1.16 +++ version.h 26 Mar 2002 16:10:53 -0000 1.17 @@ -8,9 +8,9 @@ #define PATCHLEVEL 7 /* The last built version of this shell. */ -#define BUILDVERSION 38 +#define BUILDVERSION 39 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.7(38) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.7(39) GNU" |
|
From: kevin s. <xk...@us...> - 2002-03-26 16:06:40
|
Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv27844
Modified Files:
nt_execute_cmd.c
Log Message:
* move initialization of list of suffixes for "executable" files
to function
* don't reset the list of suffixes to try (to_try) to the default
(base_to_try) after it's been initialized.
Index: nt_execute_cmd.c
===================================================================
RCS file: /cvsroot/winbash/winbash/nt_execute_cmd.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- nt_execute_cmd.c 26 Mar 2002 03:34:34 -0000 1.5
+++ nt_execute_cmd.c 26 Mar 2002 16:06:37 -0000 1.6
@@ -1189,6 +1189,25 @@
static const char *base_to_try[] = {".exe", ".com", ".bat", ".sh", ".pl", 0};
static const char **to_try = 0;
+/**
+ * One-time initialization of list to_try list.
+ */
+static void
+initialize_to_try()
+{
+ if (!to_try)
+ {
+ const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF");
+
+ if (nt_exe_suf)
+ to_try = nt_split(nt_exe_suf);
+ else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF"))
+ to_try=nt_add_split(base_to_try, nt_exe_suf);
+ if (!to_try)
+ to_try = base_to_try;
+ }
+}
+
/* Call repeatedly to get all names to try */
/* base = 0 on all but first call */
static const char *
@@ -1201,15 +1220,7 @@
if (!to_try)
{
- const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF");
-
- if (nt_exe_suf)
- to_try = nt_split(nt_exe_suf);
- else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF"))
- to_try=nt_add_split(base_to_try, nt_exe_suf);
- if (!to_try)
- to_try = base_to_try ;
- curr = to_try ;
+ initialize_to_try();
}
if (base)
@@ -1219,7 +1230,6 @@
char *pt;
curr = to_try;
orig = base;
- to_try = base_to_try;
for (dest = buf, pt = orig; *pt && (length < MAX_PATH_ALLOWED); pt++, length++)
{
*dest++ = *pt;
@@ -1255,15 +1265,9 @@
{
if (!to_try)
{
- const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF");
-
- if (nt_exe_suf)
- to_try = nt_split(nt_exe_suf);
- else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF"))
- to_try=nt_add_split(base_to_try, nt_exe_suf);
- if (!to_try)
- to_try = base_to_try ;
+ initialize_to_try();
}
+
if (file)
{
int i,len;
|
|
From: kevin s. <xk...@us...> - 2002-03-26 13:37:25
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv12714 Modified Files: .build version.h Log Message: new build with case-insensitive completion in readline off by default, like regular readline Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- .build 26 Mar 2002 00:34:58 -0000 1.15 +++ .build 26 Mar 2002 13:37:22 -0000 1.16 @@ -1 +1 @@ -37 +38 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- version.h 26 Mar 2002 00:34:58 -0000 1.15 +++ version.h 26 Mar 2002 13:37:22 -0000 1.16 @@ -8,9 +8,9 @@ #define PATCHLEVEL 7 /* The last built version of this shell. */ -#define BUILDVERSION 37 +#define BUILDVERSION 38 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.7(37) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.7(38) GNU" |
|
From: kevin s. <xk...@us...> - 2002-03-26 13:31:12
|
Update of /cvsroot/winbash/winbash/lib/readline In directory usw-pr-cvs1:/tmp/cvs-serv10670 Modified Files: complete.c Log Message: changed default value of _rl_completion_case_fold back to what is was in the original readline 4.2 win32 patch. to get case-insensitive completion, add the following to ~/.inputrc: set completion-ignore-case on Index: complete.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/complete.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- complete.c 25 Mar 2002 10:45:42 -0000 1.7 +++ complete.c 26 Mar 2002 13:31:08 -0000 1.8 @@ -126,7 +126,7 @@ #if defined (__MSDOS__) && !defined (__DJGPP__) int _rl_completion_case_fold = 1; #else -int _rl_completion_case_fold = 1; +int _rl_completion_case_fold; #endif /* Global variables available to applications using readline. */ |
|
From: Enrico B. <enr...@us...> - 2002-03-26 03:34:37
|
Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv7010
Modified Files:
bashline.c execute_cmd.c general.h nt_execute_cmd.c
Log Message:
improved file completion to include known executable extensions.
they default to {".exe", ".com", ".bat", ".sh", ".pl" } , but can
be overridden by using the NT_BASH_EXE_SUF and NT_BASH_EXE_ADD_SUF
Index: bashline.c
===================================================================
RCS file: /cvsroot/winbash/winbash/bashline.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- bashline.c 25 Mar 2002 11:22:00 -0000 1.6
+++ bashline.c 26 Mar 2002 03:34:34 -0000 1.7
@@ -1181,7 +1181,7 @@
}
/* If we have found a match, and it is an executable file, return it. */
- if (match && executable_file (val))
+ if (match && nt_executable_file_or_dir (val))
{
free (val);
val = ""; /* So it won't be NULL. */
Index: execute_cmd.c
===================================================================
RCS file: /cvsroot/winbash/winbash/execute_cmd.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- execute_cmd.c 20 Mar 2002 02:09:54 -0000 1.7
+++ execute_cmd.c 26 Mar 2002 03:34:34 -0000 1.8
@@ -3517,7 +3517,7 @@
/* If the file is a directory, then it is not "executable" in the
sense of the shell. */
if (S_ISDIR (finfo.st_mode))
- return (FS_EXISTS);
+ return (FS_EXISTS | FS_DIR);
#if defined (AFS)
/* We have to use access(2) to determine access because AFS does not
@@ -3580,6 +3580,7 @@
return (file_status (file) & FS_EXECABLE);
#endif /* !__NT_VC__ */
}
+
/* DOT_FOUND_IN_SEARCH becomes non-zero when find_user_command ()
encounters a `.' as the directory pathname while scanning the
Index: general.h
===================================================================
RCS file: /cvsroot/winbash/winbash/general.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- general.h 10 Mar 2002 23:25:31 -0000 1.3
+++ general.h 26 Mar 2002 03:34:34 -0000 1.4
@@ -154,6 +154,7 @@
#define FS_EXECABLE 0x2
#define FS_EXEC_PREFERRED 0x4
#define FS_EXEC_ONLY 0x8
+#define FS_DIR 0x10
/* Posix and USG systems do not guarantee to restart a read () that is
interrupted by a signal. */
Index: nt_execute_cmd.c
===================================================================
RCS file: /cvsroot/winbash/winbash/nt_execute_cmd.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- nt_execute_cmd.c 16 Mar 2002 02:46:59 -0000 1.4
+++ nt_execute_cmd.c 26 Mar 2002 03:34:34 -0000 1.5
@@ -1079,6 +1079,7 @@
return 0;
}
+
int
nt_file_exe_status (char **name)
{
@@ -1121,72 +1122,9 @@
return status;
}
}
- /* If the file is a directory, then it is not "executable" in the
- sense of the shell. */
- if(stat (*name, &finfo) >= 0 && S_ISDIR (finfo.st_mode))
- return orig_status;
return orig_status;
}
-/* Call repeatedly to get all names to try */
-/* base = 0 on all but first call */
-static const char *
-try_names (const char *base)
-{
- static const char *base_to_try[] =
- {"exe", "com", "sh", "pl", "bat", 0};
- static const char **to_try = 0;
- static const char **curr = 0;
- static const char *orig = 0;
-#define MAX_PATH_ALLOWED (_MAX_PATH + 128)
- static char buf[MAX_PATH_ALLOWED + 5];
- static const char *dest = 0;
-
- if (!to_try)
- {
-/**************
- * const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF");
- * if (nt_exe_suf) to_try = nt_split(nt_exe_suf);
- * else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF"))
- * to_try=nt_add_split(base_to_try, nt_exe_suf);
- * if (!to_try) to_try = base_to_try ;
- * curr = to_try ;
- ************/
- to_try = base_to_try;
- curr = to_try;
- }
- if (base)
- {
- int has_suffix = 0;
- int length = 0;
- char *pt;
- curr = to_try;
- orig = base;
- to_try = base_to_try;
- for (dest = buf, pt = orig; *pt && (length < MAX_PATH_ALLOWED);
- pt++, length++)
- {
- *dest++ = *pt;
- if (*pt == '.')
- has_suffix = 1;
- else if (*pt == '/' || *pt == '\\')
- has_suffix = 0;
- }
- if (has_suffix)
- {
- orig = 0;
- curr = 0;
- dest = 0;
- return 0;
- }
- *dest++ = '.';
- }
- if (!*curr)
- return 0;
- strcpy (dest, *curr++);
- return buf;
-}
-
const char **
nt_add_split (const char **base, const char *add)
{
@@ -1241,6 +1179,106 @@
}
ret[count] = 0;
return ret;
+}
+
+//these are used to do both file completion and to run an executable when invoked
+//without a file extension
+// (i.e. if you simply typed 'a' , it would look for .exe, .com etc.)
+
+#define MAX_PATH_ALLOWED (_MAX_PATH + 128)
+static const char *base_to_try[] = {".exe", ".com", ".bat", ".sh", ".pl", 0};
+static const char **to_try = 0;
+
+/* Call repeatedly to get all names to try */
+/* base = 0 on all but first call */
+static const char *
+try_names (const char *base)
+{
+ static const char **curr = 0;
+ static const char *orig = 0;
+ static char buf[MAX_PATH_ALLOWED + 5];
+ static const char *dest = 0;
+
+ if (!to_try)
+ {
+ const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF");
+
+ if (nt_exe_suf)
+ to_try = nt_split(nt_exe_suf);
+ else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF"))
+ to_try=nt_add_split(base_to_try, nt_exe_suf);
+ if (!to_try)
+ to_try = base_to_try ;
+ curr = to_try ;
+ }
+
+ if (base)
+ {
+ int has_suffix = 0;
+ int length = 0;
+ char *pt;
+ curr = to_try;
+ orig = base;
+ to_try = base_to_try;
+ for (dest = buf, pt = orig; *pt && (length < MAX_PATH_ALLOWED); pt++, length++)
+ {
+ *dest++ = *pt;
+ if (*pt == '.')
+ has_suffix = 1;
+ else if (*pt == '/' || *pt == '\\')
+ has_suffix = 0;
+ }
+ if (has_suffix)
+ {
+ orig = 0;
+ curr = 0;
+ dest = 0;
+ return 0;
+ }
+ }
+ if (!*curr)
+ return 0;
+ strcpy (dest, *curr++);
+ return buf;
+}
+
+/* Return non-zero if FILE exists and is executable or a directory.*/
+
+int
+nt_executable_file_or_dir (file)
+ char *file;
+{
+ int status = file_status (file);
+ if((status & FS_EXECABLE) || (status & FS_DIR))
+ return 1;
+ //try the different file extensions now
+ {
+ if (!to_try)
+ {
+ const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF");
+
+ if (nt_exe_suf)
+ to_try = nt_split(nt_exe_suf);
+ else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF"))
+ to_try=nt_add_split(base_to_try, nt_exe_suf);
+ if (!to_try)
+ to_try = base_to_try ;
+ }
+ if (file)
+ {
+ int i,len;
+ len = strlen(file);
+
+ for(i=0;to_try[i]!=0;i++) {
+ int cur_len = strlen(to_try[i]);
+ if(len>cur_len)
+ if( strnicmp(&file[len-cur_len],to_try[i],cur_len) == 0)
+ return 1;
+ continue;
+ }
+ }
+ }
+ return 0;
}
static char *
|
|
From: kevin s. <xk...@us...> - 2002-03-26 00:35:02
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv29212 Modified Files: .build version.h Log Message: new build Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- .build 25 Mar 2002 16:17:14 -0000 1.14 +++ .build 26 Mar 2002 00:34:58 -0000 1.15 @@ -1 +1 @@ -35 +37 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- version.h 25 Mar 2002 16:17:14 -0000 1.14 +++ version.h 26 Mar 2002 00:34:58 -0000 1.15 @@ -8,9 +8,9 @@ #define PATCHLEVEL 7 /* The last built version of this shell. */ -#define BUILDVERSION 35 +#define BUILDVERSION 37 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.7(35) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.7(37) GNU" |
|
From: kevin s. <xk...@us...> - 2002-03-26 00:33:45
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv28847
Modified Files:
display.c
Log Message:
use fflush and _rl_backspace in _rl_erase_at_end_of_line, instead
of _rl_clear_to_eol - this keeps the cursor from disappearing
when backspaces from the end of the line.
Index: display.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/display.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- display.c 25 Mar 2002 10:45:42 -0000 1.5
+++ display.c 26 Mar 2002 00:33:42 -0000 1.6
@@ -1522,10 +1522,15 @@
register int i;
_rl_backspace (l);
-/* for (i = 0; i < l; i++) */
-/* putc (' ', rl_outstream); */
-/* _rl_backspace (l); */
- _rl_clear_to_eol(l);
+ for (i = 0; i < l; i++)
+ putc (' ', rl_outstream);
+
+ /* flushing the stream here seems to solve some
+ display issues on windows */
+ fflush(rl_outstream);
+
+ _rl_backspace (l);
+
for (i = 0; i < l; i++)
visible_line[--_rl_last_c_pos] = '\0';
rl_display_fixed++;
|
|
From: kevin s. <xk...@us...> - 2002-03-25 16:17:19
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv3344/lib/readline
Modified Files:
rltty.c terminal.c
Log Message:
* use a block cursor
* calculate screen size (height/weight) based on console size.
Index: rltty.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/rltty.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rltty.c 25 Mar 2002 10:45:42 -0000 1.4
+++ rltty.c 25 Mar 2002 16:17:15 -0000 1.5
@@ -909,6 +909,18 @@
rlScreenStart = (int)csbi.dwCursorPosition.Y * (int)csbi.dwSize.X
+ (int)csbi.dwCursorPosition.X;
}
+
+ /* once we have handle to stdout, reset
+ screen size based on console geometry */
+ _rl_get_screen_size (0, 1);
+
+ /* use a block cursor */
+ {
+ CONSOLE_CURSOR_INFO cursor_info;
+ cursor_info.dwSize = 100;
+ cursor_info.bVisible = TRUE;
+ SetConsoleCursorInfo(hStdout, &cursor_info);
+ }
}
haveConsole |= INITIALIZED;
}
Index: terminal.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/terminal.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- terminal.c 25 Mar 2002 10:45:42 -0000 1.1
+++ terminal.c 25 Mar 2002 16:17:15 -0000 1.2
@@ -255,13 +255,17 @@
if ( (haveConsole & FOR_OUTPUT) && GetConsoleScreenBufferInfo(hStdout, &csbi) )
{
- _rl_screenwidth = csbi.dwSize.X;
- _rl_screenheight = csbi.dwSize.Y;
+ /* we want to be off by one so that line wrapping
+ does not get messed up */
+ _rl_screenwidth = csbi.dwSize.X - 1;
+ _rl_screenheight = csbi.dwSize.Y - 1;
}
else
{
- _rl_screenwidth = 80;
- _rl_screenheight = 24;
+ /* we want to be off by one so that line wrapping
+ does not get messed up */
+ _rl_screenwidth = 80 - 1;
+ _rl_screenheight = 24 - 1;
}
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
}
|
|
From: kevin s. <xk...@us...> - 2002-03-25 16:17:19
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv3344 Modified Files: .build version.h Log Message: * use a block cursor * calculate screen size (height/weight) based on console size. Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- .build 25 Mar 2002 10:57:25 -0000 1.13 +++ .build 25 Mar 2002 16:17:14 -0000 1.14 @@ -1 +1 @@ -34 +35 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- version.h 25 Mar 2002 10:57:25 -0000 1.13 +++ version.h 25 Mar 2002 16:17:14 -0000 1.14 @@ -8,9 +8,9 @@ #define PATCHLEVEL 7 /* The last built version of this shell. */ -#define BUILDVERSION 34 +#define BUILDVERSION 35 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.7(34) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.7(35) GNU" |
|
From: kevin s. <xk...@us...> - 2002-03-25 11:22:04
|
Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv7346
Modified Files:
bashline.c
Log Message:
tell readline that spaces in filenames need quoting (there
are likely other characters too....)
Index: bashline.c
===================================================================
RCS file: /cvsroot/winbash/winbash/bashline.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- bashline.c 25 Mar 2002 10:50:59 -0000 1.5
+++ bashline.c 25 Mar 2002 11:22:00 -0000 1.6
@@ -280,7 +280,7 @@
/* orig_quote_filename = rl_filename_quoting_function; */
/* rl_filename_quoting_function = bash_quote_filename; */
/* rl_filename_dequoting_function = bash_dequote_filename; */
-/* rl_filename_quote_characters = " "; */
+ rl_filename_quote_characters = " ";
/* Need to modify this from the default; `$', `{', `\', and ``' are not
word break characters. */
|
|
From: kevin s. <xk...@us...> - 2002-03-25 10:57:29
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv10444 Modified Files: .build version.h Log Message: now using readline 4.2 Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- .build 20 Mar 2002 02:09:54 -0000 1.12 +++ .build 25 Mar 2002 10:57:25 -0000 1.13 @@ -1 +1 @@ -24 +34 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- version.h 20 Mar 2002 02:09:55 -0000 1.12 +++ version.h 25 Mar 2002 10:57:25 -0000 1.13 @@ -1,16 +1,16 @@ -/* Version control for the shell. This file gets changed when you say - `make newversion' to the Makefile. It is created by newversion.aux. */ - -/* The distribution version number of this shell. */ -#define DISTVERSION "1.14" - -/* The patch level of this version of the shell. */ -#define PATCHLEVEL 7 - -/* The last built version of this shell. */ -#define BUILDVERSION 24 - -/* A version string for use by sccs and the what command. */ - -#define SCCSVERSION "@(#)Bash version 1.14.7(24) GNU" - +/* Version control for the shell. This file gets changed when you say + `make newversion' to the Makefile. It is created by newversion.aux. */ + +/* The distribution version number of this shell. */ +#define DISTVERSION "1.14" + +/* The patch level of this version of the shell. */ +#define PATCHLEVEL 7 + +/* The last built version of this shell. */ +#define BUILDVERSION 34 + +/* A version string for use by sccs and the what command. */ + +#define SCCSVERSION "@(#)Bash version 1.14.7(34) GNU" + |
|
From: kevin s. <xk...@us...> - 2002-03-25 10:57:04
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv10202 Modified Files: Makefile Log Message: use new readline 4.2 library. there is probably a better way to do this... Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/Makefile,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Makefile 20 Mar 2002 02:09:54 -0000 1.10 +++ Makefile 25 Mar 2002 10:57:00 -0000 1.11 @@ -18,17 +18,16 @@ DEFS += -DHAVE_STRCHR -DSHELL DEFS += -DMSDOS -DHAVE_ALLOCA -DHAVE_ALLOCA_H DEFS += -D__NT_VC__ -DCONIO -DOPENDIR_NOT_ROBUST +DEFS += -DREADLINE_LIBRARY CPPFLAGS += -I. CPPFLAGS += -I./lib CPPFLAGS += -I./dum_inc CPPFLAGS += $(DEFS) -CFLAGS = -MT -W2 - +CFLAGS = -MT -W2 Machine=i386 LDFLAGS += -nologo -incremental:no -subsystem:console -machine:IX86 - ifdef RELEASE CFLAGS += -O2 else @@ -39,7 +38,6 @@ VPATH := . VPATH := $(VPATH):./dum_inc -VPATH := $(VPATH):./lib/readline VPATH := $(VPATH):./lib/glob %.obj: %.c @@ -105,22 +103,6 @@ lib/glob/fnmatch.c \ lib/glob/glob.c -LIB_READLINE_SRCS = \ - lib/readline/bind.c \ - lib/readline/complete.c \ - lib/readline/display.c \ - lib/readline/funmap.c \ - lib/readline/history.c \ - lib/readline/isearch.c \ - lib/readline/keymaps.c \ - lib/readline/parens.c \ - lib/readline/readline.c \ - lib/readline/rltty.c \ - lib/readline/search.c \ - lib/readline/signals.c \ - lib/readline/tilde.c \ - lib/readline/vi_mode.c - WINBASH_SRCS = \ y.tab.c \ alias.c \ @@ -164,14 +146,14 @@ $(WINBASH_SRCS) # used for builing tags -CSOURCES = $(BASH-SRCS) +CSOURCES = $(BASH-SRCS) $(wildcard lib/readline/*.c) # FIXME -- this could be a little more specific. HSOURCES = $(wildcard *.h lib/readline/*.h builtins/*.h dum_inc/*.h) BASH-OBJS = $(BASH-SRCS:%.c=%.obj) -LDLIBS += builtins/builtins.lib -LDLIBS += user32.lib +LDLIBS += builtins/builtins.lib lib/readline/readline.lib +LDLIBS += user32.lib Advapi32.lib LDLIBS += Mpr.lib Winmm.lib #-------------------------------------------------------------------------- # Define all your symbols before here @@ -185,13 +167,16 @@ sh.exe : bash.exe cp $^ $@ -bash.exe : builtins/builtins.lib $(BASH-OBJS) +bash.exe : builtins/builtins.lib lib/readline/readline.lib $(BASH-OBJS) link.exe $(LDFLAGS) -out:$@ $^ $(LDLIBS) builtins/builtins.lib: $(BUILTIN_SRCS) cd builtins ; $(MAKE) +lib/readline/readline.lib: + cd lib/readline ; $(MAKE) + newversion.exe: newversion.c $(CC) $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) -o $@ $< @@ -200,6 +185,7 @@ newversion.obj newversion.exe newversion.pdb newversion.ilk \ TAGS cd builtins ; $(MAKE) clean + cd lib/readline ; $(MAKE) clean .distribution: ./newversion.exe -dir $(srcdir) -dist `./bash.exe -c 'echo $$BASH_VERSION'` |
|
From: kevin s. <xk...@us...> - 2002-03-25 10:51:03
|
Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv7748
Modified Files:
bashline.c
Log Message:
changes for readline 4.2. some things still need resolution:
* filename quoting
* rl_vi_comment_begin (this doesn't exist in readline 4.2 -
don't know if we even need/use it.
* rl_hostname_completion_desired
Index: bashline.c
===================================================================
RCS file: /cvsroot/winbash/winbash/bashline.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- bashline.c 11 Mar 2002 14:32:12 -0000 1.4
+++ bashline.c 25 Mar 2002 10:50:59 -0000 1.5
@@ -89,7 +89,8 @@
extern char *current_prompt_string, *ps1_prompt;
extern STRING_INT_ALIST word_token_alist[];
extern Function *rl_last_func;
-extern int rl_filename_completion_desired,rl_hostname_completion_desired;
+extern int rl_filename_completion_desired;
+int rl_hostname_completion_desired =0;
/* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual
completion functions which indicate what type of completion should be
@@ -117,7 +118,7 @@
#if defined (VI_MODE)
static void vi_edit_and_execute_command ();
-extern char *rl_vi_comment_begin;
+/* extern */ char *rl_vi_comment_begin;
#endif
static Function *old_rl_startup_hook = (Function *) NULL;
@@ -141,6 +142,33 @@
#endif
}
+rl_quote_func_t *orig_quote_filename;
+static char *
+bash_quote_filename (s, rtype, qcp)
+ char *s;
+ int rtype;
+ char *qcp;
+{
+ char *r;
+
+ r = xmalloc (strlen (s) + 3);
+ *r = *rl_completer_quote_characters;
+ strcpy (r + 1, s);
+ strcat(r, "\"");
+ if (qcp)
+ *qcp = *rl_completer_quote_characters;
+ return r;
+}
+
+/* static char * */
+/* bash_dequote_filename(text, quote_char) */
+/* char *text; */
+/* int quote_char; */
+/* { */
+/* printf("bash_dequote_filename\n"); */
+/* return text; */
+/* } */
+
/* Called once from parse.y if we are going to use readline. */
void
initialize_readline ()
@@ -248,7 +276,12 @@
rl_bind_key_in_map ('v', vi_edit_and_execute_command, vi_movement_keymap);
#endif
- rl_completer_quote_characters = "'\"";
+ rl_completer_quote_characters = "\"'";
+/* orig_quote_filename = rl_filename_quoting_function; */
+/* rl_filename_quoting_function = bash_quote_filename; */
+/* rl_filename_dequoting_function = bash_dequote_filename; */
+/* rl_filename_quote_characters = " "; */
+
/* Need to modify this from the default; `$', `{', `\', and ``' are not
word break characters. */
rl_completer_word_break_characters = " \t\n\"'@><=;|&("; /**/
@@ -1984,7 +2017,7 @@
rl_attempted_completion_function = (CPPFunction *)NULL;
rl_directory_completion_hook = (Function *)NULL;
rl_completer_word_break_characters = " \t\n\"\'";
-
+
rl_complete_internal (what_to_do);
rl_completion_entry_function = orig_func;
|
Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv5180
Modified Files:
COPYING ChangeLog Makefile README ansi_stdlib.h bind.c
chardefs.h complete.c display.c emacs_keymap.c funmap.c
history.c history.h isearch.c keymaps.c keymaps.h parens.c
posixstat.h readline.c readline.h rlconf.h rldefs.h rltty.c
search.c signals.c tilde.c tilde.h vi_keymap.c vi_mode.c
xmalloc.c
Added Files:
CHANGES callback.c compat.c config.h histexpand.c histfile.c
histlib.h histsearch.c input.c inputrc.Win32 kill.c macro.c
nls.c posixdir.h posixjmp.h rlprivate.h rlshell.h rlstdc.h
rltty.h rltypedefs.h rlwinsize.h savestring.c shell.c tcap.h
terminal.c undo.c util.c xmalloc.h
Removed Files:
STANDALONE memalloc.h
Log Message:
readline 4.2 for win32
--- NEW FILE: CHANGES ---
This document details the changes between this version, readline-4.2,
and the previous version, readline-4.1.
1. Changes to Readline
a. When setting the terminal attributes on systems using `struct termio',
readline waits for output to drain before changing the attributes.
b. A fix was made to the history word tokenization code to avoid attempts to
dereference a null pointer.
c. Readline now defaults rl_terminal_name to $TERM if the calling application
has left it unset, and tries to initialize with the resultant value.
d. Instead of calling (*rl_getc_function)() directly to get input in certain
places, readline now calls rl_read_key() consistently.
e. Fixed a bug in the completion code that allowed a backslash to quote a
single quote inside a single-quoted string.
f. rl_prompt is no longer assigned directly from the argument to readline(),
but uses memory allocated by readline. This allows constant strings to
be passed to readline without problems arising when the prompt processing
code wants to modify the string.
g. Fixed a bug that caused non-interactive history searches to return the
wrong line when performing multiple searches backward for the same string.
h. Many variables, function arguments, and function return values are now
declared `const' where appropriate, to improve behavior when linking with
C++ code.
i. The control character detection code now works better on systems where
`char' is unsigned by default.
j. The vi-mode numeric argument is now capped at 999999, just like emacs mode.
k. The Function, CPFunction, CPPFunction, and VFunction typedefs have been
replaced with a set of specific prototyped typedefs, though they are
still in the readline header files for backwards compatibility.
m. Nearly all of the (undocumented) internal global variables in the library
now have an _rl_ prefix -- there were a number that did not, like
screenheight, screenwidth, alphabetic, etc.
n. The ding() convenience function has been renamed to rl_ding(), though the
old function is still defined for backwards compatibility.
o. The completion convenience functions filename_completion_function,
username_completion_function, and completion_matches now have an rl_
prefix, though the old names are still defined for backwards compatibility.
p. The functions shared by readline and bash (linkage is satisfied from bash
when compiling with bash, and internally otherwise) now have an sh_ prefix.
q. Changed the shared library creation procedure on Linux and BSD/OS 4.x so
that the `soname' contains only the major version number rather than the
major and minor numbers.
r. Fixed a redisplay bug that occurred when the prompt spanned more than one
physical line and contained invisible characters.
s. Added a missing `includedir' variable to the Makefile.
t. When installing the shared libraries, make sure symbolic links are relative.
u. Added configure test so that it can set `${MAKE}' appropriately.
v. Fixed a bug in rl_forward that could cause the point to be set to before
the beginning of the line in vi mode.
w. Fixed a bug in the callback read-char interface to make it work when a
readline function pushes some input onto the input stream with
rl_execute_next (like the incremental search functions).
x. Fixed a file descriptor leak in the history file manipulation code that
was tripped when attempting to truncate a non-regular file (like
/dev/null).
y. Changes to make all of the exported readline functions declared in
readline.h have an rl_ prefix (rltty_set_default_bindings is now
rl_tty_set_default_bindings, crlf is now rl_crlf, etc.)
z. The formatted documentation included in the base readline distribution
is no longer removed on a `make distclean'.
aa. Some changes were made to avoid gcc warnings with -Wall.
bb. rl_get_keymap_by_name now finds keymaps case-insensitively, so
`set keymap EMACS' works.
cc. The history file writing and truncation functions now return a useful
status on error.
dd. Fixed a bug that could cause applications to dereference a NULL pointer
if a NULL second argument was passed to history_expand().
ee. If a hook function assigned to rl_event_hook sets rl_done to a non-zero
value, rl_read_key() now immediately returns '\n' (which is assumed to
be bound to accept-line).
2. New Features in Readline
a. The blink timeout for paren matching is now settable by applications,
via the rl_set_paren_blink_timeout() function.
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
it's now part of the public interface.
c. Readline has a new variable, rl_readline_state, which is a bitmap that
encapsulates the current state of the library; intended for use by
callbacks and hook functions.
d. rlfe has a new -l option to log input and output (-a appends to logfile),
a new -n option to set the readline application name, and -v and -h
options for version and help information.
e. rlfe can now perform filename completion for the inferior process if the
OS has a /proc/<PID>/cwd that can be read with readlink(2) to get the
inferior's current working directory.
f. A new file, rltypedefs.h, contains the new typedefs for function pointers
and is installed by `make install'.
g. New application-callable function rl_set_prompt(const char *prompt):
expands its prompt string argument and sets rl_prompt to the result.
h. New application-callable function rl_set_screen_size(int rows, int cols):
public method for applications to set readline's idea of the screen
dimensions.
i. The history example program (examples/histexamp.c) is now built as one
of the examples.
j. The documentation has been updated to cover nearly all of the public
functions and variables declared in readline.h.
k. New function, rl_get_screen_size (int *rows, int *columns), returns
readline's idea of the screen dimensions.
l. The timeout in rl_gather_tyi (readline keyboard input polling function)
is now settable via a function (rl_set_keyboard_input_timeout()).
m. Renamed the max_input_history variable to history_max_entries; the old
variable is maintained for backwards compatibility.
n. The list of characters that separate words for the history tokenizer is
now settable with a variable: history_word_delimiters. The default
value is as before.
o. There is a new history.3 manual page documenting the history library.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-4.1,
and the previous version, readline-4.0.
1. Changes to Readline
a. Changed the HTML documents so that the table-of-contents is no longer
a separate file.
b. Changes to the shared object configuration for: Irix 5.x, Irix 6.x,
OSF/1.
c. The shared library major and minor versions are now constructed
automatically by configure and substituted into the makefiles.
d. It's now possible to install the shared libraries separately from the
static libraries.
e. The history library tries to truncate the history file only if it is a
regular file.
f. A bug that caused _rl_dispatch to address negative array indices on
systems with signed chars was fixed.
g. rl-yank-nth-arg now leaves the history position the same as when it was
called.
h. Changes to the completion code to handle MS-DOS drive-letter:pathname
filenames.
i. Completion is now case-insensitive by default on MS-DOS.
j. Fixes to the history file manipulation code for MS-DOS.
k. Readline attempts to bind the arrow keys to appropriate defaults on MS-DOS.
l. Some fixes were made to the redisplay code for better operation on MS-DOS.
m. The quoted-insert code will now insert tty special chars like ^C.
n. A bug was fixed that caused the display code to reference memory before
the start of the prompt string.
o. More support for __EMX__ (OS/2).
p. A bug was fixed in readline's signal handling that could cause infinite
recursion in signal handlers.
q. A bug was fixed that caused the point to be less than zero when rl_forward
was given a very large numeric argument.
r. The vi-mode code now gets characters via the application-settable value
of rl_getc_function rather than calling rl_getc directly.
s. The history file code now uses O_BINARY mode when reading and writing
the history file on cygwin32.
t. Fixed a bug in the redisplay code for lines with more than 256 line
breaks.
u. A bug was fixed which caused invisible character markers to not be
stripped from the prompt string if the terminal was in no-echo mode.
v. Readline no longer tries to get the variables it needs for redisplay
from the termcap entry if the calling application has specified its
own redisplay function. Readline treats the terminal as `dumb' in
this case.
w. Fixes to the SIGWINCH code so that a multiple-line prompt with escape
sequences is redrawn correctly.
x. Changes to the install and install-shared targets so that the libraries
and header files are installed separately.
2. New Features in Readline
a. A new Readline `user manual' is in doc/rluserman.texinfo.
b. Parentheses matching is now always compiled into readline, and enabled
or disabled when the value of the `blink-matching-paren' variable is
changed.
c. MS-DOS systems now use ~/_inputrc as the last-ditch inputrc filename.
d. MS-DOS systems now use ~/_history as the default history file.
e. history-search-{forward,backward} now leave the point at the end of the
line when the string to search for is empty, like
{reverse,forward}-search-history.
f. history-search-{forward,backward} now leave the last history line found
in the readline buffer if the second or subsequent search fails.
g. New function for use by applications: rl_on_new_line_with_prompt, used
when an application displays the prompt itself before calling readline().
h. New variable for use by applications: rl_already_prompted. An application
that displays the prompt itself before calling readline() must set this to
a non-zero value.
i. A new variable, rl_gnu_readline_p, always 1. The intent is that an
application can verify whether or not it is linked with the `real'
readline library or some substitute.
j. Per Bothner's `rlfe' (pronounced `Ralphie') readline front-end program
is included in the examples subdirectory, though it is not built
by default.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-4.0,
and the previous version, readline-2.2.
1. Changes to Readline
a. The version number is now 4.0, to match the major and minor version
numbers on the shared readline and history libraries. Future
releases will maintain the identical numbering.
b. Fixed a typo in the `make install' recipe that copied libreadline.a
to libhistory.old right after installing it.
c. The readline and history info files are now installed out of the source
directory if they are not found in the build directory.
d. The library no longer exports a function named `savestring' -- backwards
compatibility be damned.
e. There is no longer any #ifdef SHELL code in the source files.
f. Some changes were made to the key binding code to fix memory leaks and
better support Win32 systems.
g. Fixed a silly typo in the paren matching code -- it's microseconds, not
milliseconds.
h. The readline library should be compilable by C++ compilers.
i. The readline.h public header file now includes function prototypes for
all readline functions, and some changes were made to fix errors in the
source files uncovered by the use of prototypes.
j. The maximum numeric argument is now clamped at 1000000.
k. Fixes to rl_yank_last_arg to make it behave better.
l. Fixed a bug in the display code that caused core dumps if the prompt
string length exceeded 1024 characters.
m. The menu completion code was fixed to properly insert a single completion
if there is only one match.
n. A bug was fixed that caused the display code to improperly display tabs
after newlines.
o. A fix was made to the completion code in which a typo caused the wrong
value to be passed to the function that computed the longest common
prefix of the list of matches.
p. The completion code now checks the value of rl_filename_completion_desired,
which is set by application-supplied completion functions to indicate
that filename completion is being performed, to decide whether or not to
call an application-supplied `ignore completions' function.
q. Code was added to the history library to catch history substitutions
using `&' without a previous history substitution or search having been
performed.
2. New Features in Readline
a. There is a new script, support/shobj-conf, to do system-specific shared
object and library configuration. It generates variables for configure
to substitute into makefiles. The README file provides a detailed
explanation of the shared library creation process.
b. Shared libraries and objects are now built in the `shlib' subdirectory.
There is a shlib/Makefile.in to control the build process. `make shared'
from the top-level directory is still the right way to build shared
versions of the libraries.
c. rlconf.h is now installed, so applications can find out which features
have been compiled into the installed readline and history libraries.
d. rlstdc.h is now an installed header file.
e. Many changes to the signal handling:
o Readline now catches SIGQUIT and cleans up the tty before returning;
o A new variable, rl_catch_signals, is available to application writers
to indicate to readline whether or not it should install its own
signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP,
SIGTTIN, and SIGTTOU;
o A new variable, rl_catch_sigwinch, is available to application
writers to indicate to readline whether or not it should install its
own signal handler for SIGWINCH, which will chain to the calling
applications's SIGWINCH handler, if one is installed;
o There is a new function, rl_free_line_state, for application signal
handlers to call to free up the state associated with the current
line after receiving a signal;
o There is a new function, rl_cleanup_after_signal, to clean up the
display and terminal state after receiving a signal;
o There is a new function, rl_reset_after_signal, to reinitialize the
terminal and display state after an application signal handler
returns and readline continues
f. There is a new function, rl_resize_terminal, to reset readline's idea of
the screen size after a SIGWINCH.
g. New public functions: rl_save_prompt and rl_restore_prompt. These were
previously private functions with a `_' prefix. These functions are
used when an application wants to write a message to the `message area'
with rl_message and have the prompt restored correctly when the message
is erased.
h. New function hook: rl_pre_input_hook, called just before readline starts
reading input, after initialization.
i. New function hook: rl_display_matches_hook, called when readline would
display the list of completion matches. The new function
rl_display_match_list is what readline uses internally, and is available
for use by application functions called via this hook.
j. New bindable function, delete-char-or-list, like tcsh.
k. A new variable, rl_erase_empty_line, which, if set by an application using
readline, will cause readline to erase, prompt and all, lines on which the
only thing typed was a newline.
l. There is a new script, support/shlib-install, to install and uninstall
the shared readline and history libraries.
m. A new bindable variable, `isearch-terminators', which is a string
containing the set of characters that should terminate an incremental
search without being executed as a command.
n. A new bindable function, forward-backward-delete-char.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-2.2,
and the previous version, readline-2.1.
1. Changes to Readline
a. Added a missing `extern' to a declaration in readline.h that kept
readline from compiling cleanly on some systems.
b. The history file is now opened with mode 0600 when it is written for
better security.
c. Changes were made to the SIGWINCH handling code so that prompt redisplay
is done better.
d. ^G now interrupts incremental searches correctly.
e. A bug that caused a core dump when the set of characters to be quoted
when completing words was empty was fixed.
f. Fixed a problem in the readline test program rltest.c that caused a core
dump.
g. The code that handles parser directives in inputrc files now displays
more error messages.
h. The history expansion code was fixed so that the appearance of the
history comment character at the beginning of a word inhibits history
expansion for that word and the rest of the input line.
i. The code that prints completion listings now behaves better if one or
more of the filenames contains non-printable characters.
j. The time delay when showing matching parentheses is now 0.5 seconds.
2. New Features in Readline
a. There is now an option for `iterative' yank-last-arg handline, so a user
can keep entering `M-.', yanking the last argument of successive history
lines.
b. New variable, `print-completions-horizontally', which causes completion
matches to be displayed across the screen (like `ls -x') rather than up
and down the screen (like `ls').
c. New variable, `completion-ignore-case', which causes filename completion
and matching to be performed case-insensitively.
d. There is a new bindable command, `magic-space', which causes history
expansion to be performed on the current readline buffer and a space to
be inserted into the result.
e. There is a new bindable command, `menu-complete', which enables tcsh-like
menu completion (successive executions of menu-complete insert a single
completion match, cycling through the list of possible completions).
f. There is a new bindable command, `paste-from-clipboard', for use on Win32
systems, to insert the text from the Win32 clipboard into the editing
buffer.
g. The key sequence translation code now understands printf-style backslash
escape sequences, including \NNN octal escapes. These escape sequences
may be used in key sequence definitions or macro values.
h. An `$include' inputrc file parser directive has been added.
--- NEW FILE: callback.c ---
/* callback.c -- functions to use readline as an X `callback' mechanism. */
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include "rlconf.h"
#if defined (READLINE_CALLBACKS)
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "readline.h"
#include "rlprivate.h"
/* **************************************************************** */
/* */
/* Callback Readline Functions */
/* */
/* **************************************************************** */
/* Allow using readline in situations where a program may have multiple
things to handle at once, and dispatches them via select(). Call
rl_callback_handler_install() with the prompt and a function to call
whenever a complete line of input is ready. The user must then
call rl_callback_read_char() every time some input is available, and
rl_callback_read_char() will call the user's function with the complete
text read in at each end of line. The terminal is kept prepped and
signals handled all the time, except during calls to the user's function. */
rl_vcpfunc_t *rl_linefunc; /* user callback function */
static int in_handler; /* terminal_prepped and signals set? */
/* Make sure the terminal is set up, initialize readline, and prompt. */
static void
_rl_callback_newline ()
{
rl_initialize ();
if (in_handler == 0)
{
in_handler = 1;
(*rl_prep_term_function) (_rl_meta_flag);
#if defined (HANDLE_SIGNALS)
rl_set_signals ();
#endif
}
readline_internal_setup ();
}
/* Install a readline handler, set up the terminal, and issue the prompt. */
void
rl_callback_handler_install (prompt, linefunc)
const char *prompt;
rl_vcpfunc_t *linefunc;
{
rl_set_prompt (prompt);
rl_linefunc = linefunc;
_rl_callback_newline ();
}
/* Read one character, and dispatch to the handler if it ends the line. */
void
rl_callback_read_char ()
{
char *line;
int eof;
if (rl_linefunc == NULL)
{
fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
abort ();
}
eof = readline_internal_char ();
/* We loop in case some function has pushed input back with rl_execute_next. */
for (;;)
{
if (rl_done)
{
line = readline_internal_teardown (eof);
(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
#endif
in_handler = 0;
(*rl_linefunc) (line);
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
_rl_init_line_state ();
/* Redisplay the prompt if readline_handler_{install,remove}
not called. */
if (in_handler == 0 && rl_linefunc)
_rl_callback_newline ();
}
if (rl_pending_input)
eof = readline_internal_char ();
else
break;
}
}
/* Remove the handler, and make sure the terminal is in its normal state. */
void
rl_callback_handler_remove ()
{
rl_linefunc = NULL;
if (in_handler)
{
in_handler = 0;
(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
#endif
}
}
#endif
--- NEW FILE: compat.c ---
/* compat.c -- backwards compatibility functions. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h>
#include "rlstdc.h"
#include "rltypedefs.h"
#include "readline.h"
extern void rl_free_undo_list __P((void));
extern int rl_maybe_save_line __P((void));
extern int rl_maybe_unsave_line __P((void));
extern int rl_maybe_replace_line __P((void));
extern int rl_crlf __P((void));
extern int rl_ding __P((void));
extern int rl_alphabetic __P((int));
extern char **rl_completion_matches __P((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function __P((const char *, int));
extern char *rl_filename_completion_function __P((const char *, int));
/* Provide backwards-compatible entry points for old function names. */
void
free_undo_list ()
{
rl_free_undo_list ();
}
int
maybe_replace_line ()
{
return rl_maybe_replace_line ();
}
int
maybe_save_line ()
{
return rl_maybe_save_line ();
}
int
maybe_unsave_line ()
{
return rl_maybe_unsave_line ();
}
int
ding ()
{
return rl_ding ();
}
int
crlf ()
{
return rl_crlf ();
}
int
alphabetic (c)
int c;
{
return rl_alphabetic (c);
}
char **
completion_matches (s, f)
const char *s;
rl_compentry_func_t *f;
{
return rl_completion_matches (s, f);
}
char *
username_completion_function (s, i)
const char *s;
int i;
{
return rl_username_completion_function (s, i);
}
char *
filename_completion_function (s, i)
const char *s;
int i;
{
return rl_filename_completion_function (s, i);
}
--- NEW FILE: config.h ---
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if on MINIX. */
/* #undef _MINIX */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
/* #undef STAT_MACROS_BROKEN */
#define VOID_SIGHANDLER 1
/* Define if you have the lstat function. */
/* #undef HAVE_LSTAT */
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the putenv function. */
#define HAVE_PUTENV 1
/* Define if you have the select function. */
/* #undef HAVE_SELECT */
/* Define if you have the setenv function. */
/* #undef HAVE_SETENV */
/* Define if you have the strcasecmp function. */
/* #undef HAVE_STRCASECMP */
/* Define if you have the setlocale function. */
#define HAVE_SETLOCALE 1
/* Define if you have the tcgetattr function. */
/* #undef HAVE_TCGETATTR */
/* Define if you have the strcoll function. */
#define HAVE_STRCOLL 1
#define STRCOLL_BROKEN 1
/* Define if you have the <dirent.h> header file. */
/* #undef HAVE_DIRENT_H */
/* Define if you have the <ndir.h> header file. */
/* #undef HAVE_NDIR_H */
/* Define if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <sys/dir.h> header file. */
/* #undef HAVE_SYS_DIR_H */
/* Define if you have the <sys/file.h> header file. */
/* #undef HAVE_SYS_FILE_H */
/* Define if you have the <sys/ndir.h> header file. */
/* #undef HAVE_SYS_NDIR_H */
/* Define if you have the <sys/pte.h> header file. */
/* #undef HAVE_SYS_PTE_H */
/* Define if you have the <sys/ptem.h> header file. */
/* #undef HAVE_SYS_PTEM_H */
/* Define if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
/* Define if you have the <sys/stream.h> header file. */
/* #undef HAVE_SYS_STREAM_H */
/* Define if you have the <termcap.h> header file. */
/* #undef HAVE_TERMCAP_H */
/* Define if you have the <termio.h> header file. */
/* #undef HAVE_TERMIO_H */
/* Define if you have the <termios.h> header file. */
/* #undef HAVE_TERMIOS_H */
/* Define if you have the <unistd.h> header file. */
/* #undef HAVE_UNISTD_H */
/* Define if you have the <varargs.h> header file. */
/* #define HAVE_VARARGS_H 1 */
/* Define if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
#define HAVE_LOCALE_H 1
/* Definitions pulled in from aclocal.m4. */
#define VOID_SIGHANDLER 1
/* #undef GWINSZ_IN_SYS_IOCTL */
/* #undef STRUCT_WINSIZE_IN_SYS_IOCTL */
/* #undef STRUCT_WINSIZE_IN_TERMIOS */
/* #undef TIOCSTAT_IN_SYS_IOCTL */
/* #undef FIONREAD_IN_SYS_IOCTL */
/* #undef SPEED_T_IN_SYS_TYPES */
#define HAVE_GETPW_DECLS 1
/* #undef STRUCT_DIRENT_HAS_D_INO */
/* #undef STRUCT_DIRENT_HAS_D_FILENO */
/* #undef HAVE_BSD_SIGNALS */
/* #undef HAVE_POSIX_SIGNALS */
/* #undef HAVE_USG_SIGHOLD */
#define MUST_REINSTALL_SIGHANDLERS 1
/* #undef HAVE_POSIX_SIGSETJMP */
/* config.h.bot */
/* modify settings or make new ones based on what autoconf tells us. */
/* Ultrix botches type-ahead when switching from canonical to
non-canonical mode, at least through version 4.3 */
#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
# define TERMIOS_MISSING
#endif
#if defined (STRCOLL_BROKEN)
# define HAVE_STRCOLL 1
#endif
#if defined (__STDC__) && defined (HAVE_STDARG_H)
# define PREFER_STDARG
# define USE_VARARGS
#else
# if defined (HAVE_VARARGS_H)
# define PREFER_VARARGS
# define USE_VARARGS
# endif
#endif
--- NEW FILE: histexpand.c ---
/* histexpand.c -- history expansion. */
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
This file contains the GNU History Library (the Library), a set of
routines for managing the text of previously typed lines.
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
[...1332 lines suppressed...]
last history !?string? search. */
static char *
history_find_word (line, ind)
char *line;
int ind;
{
char **words, *s;
int i, wind;
words = history_tokenize_internal (line, ind, &wind);
if (wind == -1 || words == 0)
return ((char *)NULL);
s = words[wind];
for (i = 0; i < wind; i++)
free (words[i]);
for (i = wind + 1; words[i]; i++)
free (words[i]);
free (words);
return s;
}
--- NEW FILE: histfile.c ---
/* histfile.c - functions to manipulate the history file. */
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
This file contains the GNU History Library (the Library), a set of
routines for managing the text of previously typed lines.
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
you can call. I think I have done that. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_FILE_H
# include <sys/file.h>
#endif
#include "posixstat.h"
#include <fcntl.h>
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#ifdef __MINGW32__
#include <io.h>
#endif
/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
on win 95/98/nt), we want to open files with O_BINARY mode so that there
is no \n -> \r\n conversion performed. On other systems, we don't want to
mess around with O_BINARY at all, so we ensure that it's defined to 0. */
#if defined (__EMX__) || defined (__CYGWIN__) || defined (__MINGW32__)
# ifndef O_BINARY
# define O_BINARY 0
# endif
#else /* !__EMX__ && !__CYGWIN__ */
# undef O_BINARY
# define O_BINARY 0
#endif /* !__EMX__ && !__CYGWIN__ */
#include <errno.h>
#if !defined (errno)
extern int errno;
#endif /* !errno */
#include "history.h"
#include "histlib.h"
#include "rlshell.h"
#include "xmalloc.h"
#ifdef __MINGW32__
#include "rldefs.h"
extern char *get_user_registry_string(char *keyName, char* valName);
#endif
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
filename to read_history (), or write_history (). */
static char *
history_filename (filename)
const char *filename;
{
char *return_val;
const char *home;
int home_len;
return_val = filename ? savestring (filename) : (char *)NULL;
if (return_val)
return (return_val);
home = sh_get_env_value ("HOME");
if (home == 0)
{
#if defined (__MINGW32__) && defined (INITFILES_IN_REGISTRY)
return_val = get_user_registry_string (READLINE_REGKEY, HISTFILE_REGVAL);
if (return_val)
return (return_val);
free (return_val);
#endif /* __MINGW32__ ... */
home = ".";
home_len = 1;
}
else
home_len = strlen (home);
return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
strcpy (return_val, home);
return_val[home_len] = '/';
#if defined (__MSDOS__)
strcpy (return_val + home_len + 1, "_history");
#else
strcpy (return_val + home_len + 1, ".history");
#endif
return (return_val);
}
/* Add the contents of FILENAME to the history list, a line at a time.
If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */
int
read_history (filename)
const char *filename;
{
return (read_history_range (filename, 0, -1));
}
/* Read a range of lines from FILENAME, adding them to the history list.
Start reading at the FROM'th line and end at the TO'th. If FROM
is zero, start at the beginning. If TO is less than FROM, read
until the end of the file. If FILENAME is NULL, then read from
~/.history. Returns 0 if successful, or errno if not. */
int
read_history_range (filename, from, to)
const char *filename;
int from, to;
{
register int line_start, line_end;
char *input, *buffer;
int file, current_line, chars_read;
struct stat finfo;
size_t file_size;
buffer = (char *)NULL;
input = history_filename (filename);
file = open (input, O_RDONLY|O_BINARY, 0666);
if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit;
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
if (file_size != finfo.st_size || file_size + 1 < file_size)
{
#if defined (EFBIG)
errno = EFBIG;
#endif
goto error_and_exit;
}
buffer = xmalloc (file_size + 1);
chars_read = read (file, buffer, file_size);
if (chars_read < 0)
{
error_and_exit:
if (file >= 0)
close (file);
FREE (input);
FREE (buffer);
return (errno);
}
close (file);
/* Set TO to larger than end of file if negative. */
if (to < 0)
to = chars_read;
/* Start at beginning of file, work to end. */
line_start = line_end = current_line = 0;
/* Skip lines until we are at FROM. */
while (line_start < chars_read && current_line < from)
{
for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
current_line++;
line_start = line_end + 1;
if (current_line == from)
break;
}
}
/* If there are lines left to gobble, then gobble them now. */
for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
buffer[line_end] = '\0';
if (buffer[line_start])
add_history (buffer + line_start);
current_line++;
if (current_line >= to)
break;
line_start = line_end + 1;
}
FREE (input);
FREE (buffer);
return (0);
}
/* Truncate the history file FNAME, leaving only LINES trailing lines.
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
on failure. */
int
history_truncate_file (fname, lines)
const char *fname;
int lines;
{
register int i;
int file, chars_read, rv;
char *buffer, *filename;
struct stat finfo;
size_t file_size;
buffer = (char *)NULL;
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
rv = 0;
/* Don't try to truncate non-regular files. */
if (file == -1 || fstat (file, &finfo) == -1)
{
rv = errno;
if (file != -1)
close (file);
goto truncate_exit;
}
if (S_ISREG (finfo.st_mode) == 0)
{
close (file);
#ifdef EFTYPE
rv = EFTYPE;
#else
rv = EINVAL;
#endif
goto truncate_exit;
}
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
if (file_size != finfo.st_size || file_size + 1 < file_size)
{
close (file);
#if defined (EFBIG)
rv = errno = EFBIG;
#elif defined (EOVERFLOW)
rv = errno = EOVERFLOW;
#else
rv = errno = EINVAL;
#endif
goto truncate_exit;
}
buffer = xmalloc (file_size + 1);
chars_read = read (file, buffer, file_size);
close (file);
if (chars_read <= 0)
{
rv = (chars_read < 0) ? errno : 0;
goto truncate_exit;
}
/* Count backwards from the end of buffer until we have passed
LINES lines. */
for (i = chars_read - 1; lines && i; i--)
{
if (buffer[i] == '\n')
lines--;
}
/* If this is the first line, then the file contains exactly the
number of lines we want to truncate to, so we don't need to do
anything. It's the first line if we don't find a newline between
the current value of i and 0. Otherwise, write from the start of
this line until the end of the buffer. */
for ( ; i; i--)
if (buffer[i] == '\n')
{
i++;
break;
}
/* Write only if there are more lines in the file than we want to
truncate to. */
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, buffer + i, chars_read - i);
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */
ftruncate (file, chars_read - i);
#endif
close (file);
}
truncate_exit:
FREE (buffer);
free (filename);
return rv;
}
/* Workhorse function for writing history. Writes NELEMENT entries
from the history list to FILENAME. OVERWRITE is non-zero if you
wish to replace FILENAME with the entries. */
static int
history_do_write (filename, nelements, overwrite)
const char *filename;
int nelements, overwrite;
{
register int i;
char *output;
int file, mode, rv;
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
output = history_filename (filename);
rv = 0;
if ((file = open (output, mode, 0600)) == -1)
{
FREE (output);
return (errno);
}
if (nelements > history_length)
nelements = history_length;
/* Build a buffer of all the lines to write, and write them in one syscall.
Suggested by Peter Ho (pe...@ro...). */
{
HIST_ENTRY **the_history; /* local */
register int j;
int buffer_size;
char *buffer;
the_history = history_list ();
/* Calculate the total number of bytes to write. */
for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
buffer_size += 1 + strlen (the_history[i]->line);
/* Allocate the buffer, and fill it. */
buffer = xmalloc (buffer_size);
for (j = 0, i = history_length - nelements; i < history_length; i++)
{
strcpy (buffer + j, the_history[i]->line);
j += strlen (the_history[i]->line);
buffer[j++] = '\n';
}
if (write (file, buffer, buffer_size) < 0)
rv = errno;
free (buffer);
}
close (file);
FREE (output);
return (rv);
}
/* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */
int
append_history (nelements, filename)
int nelements;
const char *filename;
{
return (history_do_write (filename, nelements, HISTORY_APPEND));
}
/* Overwrite FILENAME with the current history. If FILENAME is NULL,
then write the history list to ~/.history. Values returned
are as in read_history ().*/
int
write_history (filename)
const char *filename;
{
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
}
--- NEW FILE: histlib.h ---
/* histlib.h -- internal definitions for the history library. */
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
This file contains the GNU History Library (the Library), a set of
routines for managing the text of previously typed lines.
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
#define STREQN(a, b, n) (((n) == 0) ? (1) \
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#endif
#ifndef savestring
# ifndef strcpy
extern char *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif
#ifndef whitespace
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#endif
#ifndef _rl_digit_p
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#endif
#ifndef _rl_digit_value
#define _rl_digit_value(c) ((c) - '0')
#endif
#ifndef member
# ifndef strchr
extern char *strchr ();
# endif
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#endif
#ifndef FREE
# define FREE(x) if (x) free (x)
#endif
/* Possible history errors passed to hist_error. */
#define EVENT_NOT_FOUND 0
#define BAD_WORD_SPEC 1
#define SUBST_FAILED 2
#define BAD_MODIFIER 3
#define NO_PREV_SUBST 4
/* Possible definitions for history starting point specification. */
#define ANCHORED_SEARCH 1
#define NON_ANCHORED_SEARCH 0
/* Possible definitions for what style of writing the history file we want. */
#define HISTORY_APPEND 0
#define HISTORY_OVERWRITE 1
/* Some variable definitions shared across history source files. */
extern int history_offset;
#endif /* !_HISTLIB_H_ */
--- NEW FILE: histsearch.c ---
/* histsearch.c -- searching the history list. */
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
This file contains the GNU History Library (the Library), a set of
routines for managing the text of previously typed lines.
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h>
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h"
#include "histlib.h"
/* The list of alternate characters that can delimit a history search
string. */
char *history_search_delimiter_chars = (char *)NULL;
/* Search the history for STRING, starting at history_offset.
If DIRECTION < 0, then the search is through previous entries, else
through subsequent. If ANCHORED is non-zero, the string must
appear at the beginning of a history line, otherwise, the string
may appear anywhere in the line. If the string is found, then
current_history () is the history entry, and the value of this
function is the offset in the line of that history entry that the
string was found in. Otherwise, nothing is changed, and a -1 is
returned. */
static int
history_search_internal (string, direction, anchored)
const char *string;
int direction, anchored;
{
register int i, reverse;
register char *line;
register int line_index;
int string_len;
HIST_ENTRY **the_history; /* local */
i = history_offset;
reverse = (direction < 0);
/* Take care of trivial cases first. */
if (string == 0 || *string == '\0')
return (-1);
if (!history_length || ((i == history_length) && !reverse))
return (-1);
if (reverse && (i == history_length))
i--;
#define NEXT_LINE() do { if (reverse) i--; else i++; } while (0)
the_history = history_list ();
string_len = strlen (string);
while (1)
{
/* Search each line in the history list for STRING. */
/* At limit for direction? */
if ((reverse && i < 0) || (!reverse && i == history_length))
return (-1);
line = the_history[i]->line;
line_index = strlen (line);
/* If STRING is longer than line, no match. */
if (string_len > line_index)
{
NEXT_LINE ();
continue;
}
/* Handle anchored searches first. */
if (anchored == ANCHORED_SEARCH)
{
if (STREQN (string, line, string_len))
{
history_offset = i;
return (0);
}
NEXT_LINE ();
continue;
}
/* Do substring search. */
if (reverse)
{
line_index -= string_len;
while (line_index >= 0)
{
if (STREQN (string, line + line_index, string_len))
{
history_offset = i;
return (line_index);
}
line_index--;
}
}
else
{
register int limit;
limit = line_index - string_len + 1;
line_index = 0;
while (line_index < limit)
{
if (STREQN (string, line + line_index, string_len))
{
history_offset = i;
return (line_index);
}
line_index++;
}
}
NEXT_LINE ();
}
}
/* Do a non-anchored search for STRING through the history in DIRECTION. */
int
history_search (string, direction)
const char *string;
int direction;
{
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
}
/* Do an anchored search for string through the history in DIRECTION. */
int
history_search_prefix (string, direction)
const char *string;
int direction;
{
return (history_search_internal (string, direction, ANCHORED_SEARCH));
}
/* Search for STRING in the history list. DIR is < 0 for searching
backwards. POS is an absolute index into the history list at
which point to begin searching. */
int
history_search_pos (string, dir, pos)
const char *string;
int dir, pos;
{
int ret, old;
old = where_history ();
history_set_pos (pos);
if (history_search (string, dir) == -1)
{
history_set_pos (old);
return (-1);
}
ret = where_history ();
history_set_pos (old);
return ret;
}
--- NEW FILE: input.c ---
/* input.c -- character input functions for readline. */
/* Copyright (C) 1994 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#if defined (HAVE_SYS_FILE_H)
# include <sys/file.h>
#endif /* HAVE_SYS_FILE_H */
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_SELECT)
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
# include <sys/time.h>
# endif
#endif /* HAVE_SELECT */
#if defined (HAVE_SYS_SELECT_H)
# include <sys/select.h>
#endif
#if defined (FIONREAD_IN_SYS_IOCTL)
# include <sys/ioctl.h>
#endif
#include <stdio.h>
#include <errno.h>
#if !defined (errno)
extern int errno;
#endif /* !errno */
/* System-specific feature definitions and include files. */
#include "rldefs.h"
/* Some standard library routines. */
#include "readline.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
/* What kind of non-blocking I/O do we have? */
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
# define O_NDELAY O_NONBLOCK /* Posix style */
#endif
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
rl_getc_func_t *rl_getc_function = rl_getc;
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
static void rl_gather_tyi ();
/* **************************************************************** */
/* */
/* Character Input Buffering */
/* */
/* **************************************************************** */
static int pop_index, push_index;
static unsigned char ibuffer[512];
static int ibuffer_len = sizeof (ibuffer) - 1;
#define any_typein (push_index != pop_index)
int
_rl_any_typein ()
{
return any_typein;
}
/* Return the amount of space available in the buffer for stuffing
characters. */
static int
ibuffer_space ()
{
if (pop_index > push_index)
return (pop_index - push_index - 1);
else
return (ibuffer_len - (push_index - pop_index));
}
/* Get a key from the buffer of characters to be read.
Return the key in KEY.
Result is KEY if there was a key, or 0 if there wasn't. */
static int
rl_get_char (key)
int *key;
{
if (push_index == pop_index)
return (0);
*key = ibuffer[pop_index++];
if (pop_index >= ibuffer_len)
pop_index = 0;
return (1);
}
/* Stuff KEY into the *front* of the input buffer.
Returns non-zero if successful, zero if there is
no space left in the buffer. */
static int
rl_unget_char (key)
int key;
{
if (ibuffer_space ())
{
pop_index--;
if (pop_index < 0)
pop_index = ibuffer_len - 1;
ibuffer[pop_index] = key;
return (1);
}
return (0);
}
#ifndef __MINGW32__
/* If a character is available to be read, then read it
and stuff it into IBUFFER. Otherwise, just return. */
static void
rl_gather_tyi ()
{
int tty;
register int tem, result;
int chars_avail;
char input;
#if defined(HAVE_SELECT)
fd_set readfds, exceptfds;
struct timeval timeout;
#endif
tty = fileno (rl_instream);
#if defined (HAVE_SELECT)
FD_ZERO (&readfds);
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = _keyboard_input_timeout;
if (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) <= 0)
return; /* Nothing to read. */
#endif
result = -1;
#if defined (FIONREAD)
result = ioctl (tty, FIONREAD, &chars_avail);
#endif
#if defined (O_NDELAY)
if (result == -1)
{
tem = fcntl (tty, F_GETFL, 0);
fcntl (tty, F_SETFL, (tem | O_NDELAY));
chars_avail = read (tty, &input, 1);
fcntl (tty, F_SETFL, tem);
if (chars_avail == -1 && errno == EAGAIN)
return;
}
#endif /* O_NDELAY */
/* If there's nothing available, don't waste time trying to read
something. */
if (chars_avail <= 0)
return;
tem = ibuffer_space ();
if (chars_avail > tem)
chars_avail = tem;
/* One cannot read all of the available input. I can only read a single
character at a time, or else programs which require input can be
thwarted. If the buffer is larger than one character, I lose.
Damn! */
if (tem < ibuffer_len)
chars_avail = 0;
if (result != -1)
{
while (chars_avail--)
rl_stuff_char ((*rl_getc_function) (rl_instream));
}
else
{
if (chars_avail)
rl_stuff_char (input);
}
}
int
rl_set_keyboard_input_timeout (u)
int u;
{
int o;
o = _keyboard_input_timeout;
if (u > 0)
_keyboard_input_timeout = u;
return (o);
}
/* Is there input available to be read on the readline input file
descriptor? Only works if the system has select(2) or FIONREAD. */
int
_rl_input_available ()
{
#if defined(HAVE_SELECT)
fd_set readfds, exceptfds;
struct timeval timeout;
#endif
#if defined(FIONREAD)
int chars_avail;
#endif
int tty;
tty = fileno (rl_instream);
#if defined (HAVE_SELECT)
FD_ZERO (&readfds);
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = _keyboard_input_timeout;
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
#endif
#if defined (FIONREAD)
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
return (chars_avail);
#endif
return 0;
}
#endif /* !__MINGW32__ */
void
_rl_insert_typein (c)
int c;
{
int key, t, i;
char *string;
i = key = 0;
string = xmalloc (ibuffer_len + 1);
string[i++] = (char) c;
while ((t = rl_get_char (&key)) &&
_rl_keymap[key].type == ISFUNC &&
_rl_keymap[key].function == rl_insert)
string[i++] = key;
if (t)
rl_unget_char (key);
string[i] = '\0';
rl_insert_text (string);
free (string);
}
/* Add KEY to the buffer of characters to be read. Returns 1 if the
character was stuffed correctly; 0 otherwise. */
int
rl_stuff_char (key)
int key;
{
if (ibuffer_space () == 0)
return 0;
if (key == EOF)
{
key = NEWLINE;
rl_pending_input = EOF;
RL_SETSTATE (RL_STATE_INPUTPENDING);
}
ibuffer[push_index++] = key;
if (push_index >= ibuffer_len)
push_index = 0;
return 1;
}
/* Make C be the next command to be executed. */
int
rl_execute_next (c)
int c;
{
rl_pending_input = c;
RL_SETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
/* Clear any pending input pushed with rl_execute_next() */
int
rl_clear_pending_input ()
{
rl_pending_input = 0;
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
/* **************************************************************** */
/* */
/* Character Input */
/* */
/* **************************************************************** */
/* Read a key, including pending input. */
int
rl_read_key ()
{
int c;
rl_key_sequence_length++;
if (rl_pending_input)
{
c = rl_pending_input;
rl_clear_pending_input ();
}
else
{
/* If input is coming from a macro, then use that. */
if (c = _rl_next_macro_key ())
return (c);
/* If the user has an event function, then call it periodically. */
if (rl_event_hook)
{
while (rl_event_hook && rl_get_char (&c) == 0)
{
(*rl_event_hook) ();
if (rl_done) /* XXX - experimental */
return ('\n');
rl_gather_tyi ();
}
}
else
{
if (rl_get_char (&c) == 0)
c = (*rl_getc_function) (rl_instream);
}
}
return (c);
}
#ifndef __MINGW32__
int
rl_getc (stream)
FILE *stream;
{
int result;
unsigned char c;
while (1)
{
result = read (fileno (stream), &c, sizeof (unsigned char));
if (result == sizeof (unsigned char))
return (c);
/* If zero characters are returned, then the file that we are
reading from is empty! Return EOF in that case. */
if (result == 0)
return (EOF);
#if defined (__BEOS__)
if (errno == EINTR)
continue;
#endif
#if defined (EWOULDBLOCK)
# define X_EWOULDBLOCK EWOULDBLOCK
#else
# define X_EWOULDBLOCK -99
#endif
#if defined (EAGAIN)
# define X_EAGAIN EAGAIN
#else
# define X_EAGAIN -99
#endif
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
return (EOF);
continue;
}
#undef X_EWOULDBLOCK
#undef X_EAGAIN
/* If the error that we received was SIGINT, then try again,
this is simply an interrupted system call to read ().
Otherwise, some error ocurred, also signifying EOF. */
if (errno != EINTR)
return (EOF);
}
}
#else /* __MINGW32__ */
#include <windows.h>
#include <ctype.h>
#include <conio.h>
#include <io.h>
#define EXT_PREFIX 0x1f8
#define KEV irec.Event.KeyEvent /* to make life easier */
#define KST irec.Event.KeyEvent.dwControlKeyState
static int pending_key = 0;
static int pending_count = 0;
static int pending_prefix = 0;
extern int _rl_last_c_pos; /* imported from display.c */
extern int _rl_last_v_pos;
extern int rl_dispatching; /* imported from readline.c */
extern int rl_point;
extern int rl_done;
extern int rl_visible_prompt_length;
extern int _rl_screenwidth; /* imported from terminal.c */
extern int haveConsole; /* imported from rltty.c */
extern HANDLE hStdout, hStdin;
extern COORD rlScreenOrigin, rlScreenEnd;
extern int rlScreenStart, rlScreenMax;
static void MouseEventProc(MOUSE_EVENT_RECORD kev);
int rl_getc (stream)
FILE *stream;
{
int key;
if ( pending_count )
{
--pending_count;
...
[truncated message content] |