Path: utzoo!news-server.csri.toronto.edu!rutgers!att!bu.edu!transfer!lectroid!jjmhome!acestes!paradis From: paradis@acestes.UUCP (Jim Paradis) Newsgroups: comp.os.minix Subject: Bash patches (3/4) Message-ID: <164@acestes.UUCP> Date: 11 Mar 91 21:14:42 GMT Reply-To: paradis@acestes.UUCP (root:ng370ypF{eAHS:0:0:Super-User:/:/bin/bash) Organization: Alberichs Rings & Things Lines: 676 This is part 3 of the bash patches for MINIX. You should be sitting in the "readline" subdirectory of the main bash source directory when you apply these patches -------------8<---- cut here ---------8<---- cut here ----8<----------- *** bash-1.05/readline/Makefile Sat Feb 17 11:00:42 1990 --- minix_bash/readline/Makefile Thu Nov 1 23:00:52 1990 *************** *** 20,25 **** --- 20,26 ---- # Define SYSV as -DSYSV if you are using a System V operating system. #SYSV = -DSYSV + MINIX = -DMINIX # HP-UX compilation requires the BSD library. #LOCAL_LIBS = -lBSD *************** *** 33,39 **** DEBUG_FLAGS = -g LDFLAGS = $(DEBUG_FLAGS) ! CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) -I. # A good alternative is gcc -traditional. #CC = gcc -traditional --- 34,40 ---- DEBUG_FLAGS = -g LDFLAGS = $(DEBUG_FLAGS) ! CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) $(MINIX) -I. # A good alternative is gcc -traditional. #CC = gcc -traditional *************** *** 69,87 **** readline.o: readline.h chardefs.h keymaps.h history.h readline.c vi_mode.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) $*.c history.o: history.c history.h $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) $*.c funmap.o: readline.h $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) $*.c keymaps.o: emacs_keymap.c vi_keymap.c keymaps.h chardefs.h keymaps.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) $*.c libtest: libreadline.a libtest.c $(CC) -o libtest $(CFLAGS) $(CPPFLAGS) -L. libtest.c -lreadline -ltermcap --- 70,88 ---- readline.o: readline.h chardefs.h keymaps.h history.h readline.c vi_mode.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) readline.c history.o: history.c history.h $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) history.c funmap.o: readline.h $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) funmap.c keymaps.o: emacs_keymap.c vi_keymap.c keymaps.h chardefs.h keymaps.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ ! $(LOCAL_INCLUDES) keymaps.c libtest: libreadline.a libtest.c $(CC) -o libtest $(CFLAGS) $(CPPFLAGS) -L. libtest.c -lreadline -ltermcap *** bash-1.05/readline/readline.c Sun Feb 25 11:33:06 1990 --- minix_bash/readline/readline.c Fri Nov 2 00:11:20 1990 *************** *** 33,39 **** #include #include #include ! #include #include #ifdef __GNUC__ --- 33,41 ---- #include #include #include ! #ifndef MINIX ! #include ! #endif /* MINIX */ #include #ifdef __GNUC__ *************** *** 68,74 **** #define HACK_TERMCAP_MOTION ! #ifndef SYSV #include #else /* SYSV */ #if defined (xenix) --- 70,76 ---- #define HACK_TERMCAP_MOTION ! #if !defined(SYSV) && !defined(MINIX) #include #else /* SYSV */ #if defined (xenix) *************** *** 200,206 **** static FILE *in_stream, *out_stream; /* The names of the streams that we do input and output to. */ ! FILE *rl_instream = stdin, *rl_outstream = stdout; /* Non-zero means echo characters as they are read. */ int readline_echoing_p = 1; --- 202,208 ---- static FILE *in_stream, *out_stream; /* The names of the streams that we do input and output to. */ ! FILE *rl_instream = (FILE*)0, *rl_outstream = (FILE*)0; /* Non-zero means echo characters as they are read. */ int readline_echoing_p = 1; *************** *** 268,277 **** readline (prompt) char *prompt; { - static rl_prep_terminal (), rl_deprep_terminal (); char *readline_internal (); char *value; rl_prompt = prompt; /* If we are at EOF return a NULL string. */ --- 270,283 ---- readline (prompt) char *prompt; { char *readline_internal (); char *value; + if(!rl_instream) { + rl_instream = stdin; + rl_outstream = stdout; + } + rl_prompt = prompt; /* If we are at EOF return a NULL string. */ *************** *** 314,319 **** --- 320,330 ---- { int lastc, c, eof_found; + if(!rl_instream) { + rl_instream = stdin; + rl_outstream = stdout; + } + in_stream = rl_instream; out_stream = rl_outstream; lastc = eof_found = 0; *************** *** 468,474 **** int sig, code; struct sigcontext *scp; { - static rl_prep_terminal (), rl_deprep_terminal (); switch (sig) { --- 479,484 ---- *************** *** 492,498 **** rl_pending_input = 0; kill (getpid (), sig); ! sigsetmask (0); rl_prep_terminal (); rl_set_signals (); --- 502,510 ---- rl_pending_input = 0; kill (getpid (), sig); ! #ifndef MINIX ! sigsetmask (0); ! #endif /* MINIX */ rl_prep_terminal (); rl_set_signals (); *************** *** 631,639 **** if (result == -1) { ! fcntl (tty, F_SETFL, O_NDELAY); ! chars_avail = read (tty, &input, 1); ! fcntl (tty, F_SETFL, 0); if (chars_avail == -1 && errno == EAGAIN) return; } --- 643,655 ---- if (result == -1) { ! #ifndef MINIX ! fcntl (tty, F_SETFL, O_NDELAY); ! #endif /* MINIX */ ! chars_avail = read (tty, &input, 1); ! #ifndef MINIX ! fcntl (tty, F_SETFL, 0); ! #endif /* MINIX */ if (chars_avail == -1 && errno == EAGAIN) return; } *************** *** 677,683 **** } else { ! static int next_macro_key (); /* If input is coming from a macro, then use that. */ if (c = next_macro_key ()) --- 693,699 ---- } else { ! int next_macro_key (); /* If input is coming from a macro, then use that. */ if (c = next_macro_key ()) *************** *** 715,721 **** } /* I'm beginning to hate the declaration rules for various compilers. */ ! static void add_macro_char (); /* Do the command associated with KEY in MAP. If the associated command is really a keymap, then read --- 731,737 ---- } /* I'm beginning to hate the declaration rules for various compilers. */ ! void add_macro_char (); /* Do the command associated with KEY in MAP. If the associated command is really a keymap, then read *************** *** 785,791 **** case ISMACR: if (map[key].function != (Function *)NULL) { ! static with_macro_input (); char *macro = savestring ((char *)map[key].function); with_macro_input (macro); --- 801,807 ---- case ISMACR: if (map[key].function != (Function *)NULL) { ! int with_macro_input (); char *macro = savestring ((char *)map[key].function); with_macro_input (macro); *************** *** 836,849 **** struct saved_macro *macro_list = (struct saved_macro *)NULL; /* Forward declarations of static functions. Thank you C. */ ! static void push_executing_macro (), pop_executing_macro (); /* This one has to be declared earlier in the file. */ /* static void add_macro_char (); */ /* Set up to read subsequent input from STRING. STRING is free ()'ed when we are done with it. */ - static with_macro_input (string) char *string; { --- 852,864 ---- struct saved_macro *macro_list = (struct saved_macro *)NULL; /* Forward declarations of static functions. Thank you C. */ ! void push_executing_macro (), pop_executing_macro (); /* This one has to be declared earlier in the file. */ /* static void add_macro_char (); */ /* Set up to read subsequent input from STRING. STRING is free ()'ed when we are done with it. */ with_macro_input (string) char *string; { *************** *** 854,860 **** /* Return the next character available from a macro, or 0 if there are no macro characters. */ ! static int next_macro_key () { if (!executing_macro) --- 869,875 ---- /* Return the next character available from a macro, or 0 if there are no macro characters. */ ! int next_macro_key () { if (!executing_macro) *************** *** 870,876 **** } /* Save the currently executing macro on a stack of saved macros. */ ! static void push_executing_macro () { struct saved_macro *saver; --- 885,891 ---- } /* Save the currently executing macro on a stack of saved macros. */ ! void push_executing_macro () { struct saved_macro *saver; *************** *** 885,891 **** /* Discard the current macro, replacing it with the one on the top of the stack of saved macros. */ ! static void pop_executing_macro () { if (executing_macro) --- 900,906 ---- /* Discard the current macro, replacing it with the one on the top of the stack of saved macros. */ ! void pop_executing_macro () { if (executing_macro) *************** *** 905,911 **** } /* Add a character to the macro being built. */ ! static void add_macro_char (c) int c; { --- 920,926 ---- } /* Add a character to the macro being built. */ ! void add_macro_char (c) int c; { *************** *** 1026,1031 **** --- 1041,1051 ---- /* Initialize the entire state of the world. */ readline_initialize_everything () { + if(!rl_instream) { + rl_instream = stdin; + rl_outstream = stdout; + } + /* Find out if we are running in Emacs. */ running_in_emacs = (char *)getenv ("EMACS"); *************** *** 1065,1071 **** #ifdef NEW_TTY_DRIVER struct sgttyb ttybuff; ! int tty = fileno (rl_instream); if (ioctl (tty, TIOCGETP, &ttybuff) != -1) { --- 1085,1098 ---- #ifdef NEW_TTY_DRIVER struct sgttyb ttybuff; ! ! int tty; ! ! if(!rl_instream) { ! rl_instream = stdin; ! rl_outstream = stdout; ! } ! tty = fileno (rl_instream); if (ioctl (tty, TIOCGETP, &ttybuff) != -1) { *************** *** 1269,1278 **** so; what is the advantage in producing better code if we can't use it? */ /* The following two declarations belong inside the function block, not here. */ ! static void move_cursor_relative (); ! static void output_some_chars (); ! static void output_character_function (); ! static int compare_strings (); /* Basic redisplay algorithm. */ rl_redisplay () --- 1296,1305 ---- so; what is the advantage in producing better code if we can't use it? */ /* The following two declarations belong inside the function block, not here. */ ! void move_cursor_relative (); ! void output_some_chars (); ! void output_character_function (); ! int compare_strings (); /* Basic redisplay algorithm. */ rl_redisplay () *************** *** 1485,1491 **** no differences, as well as for end of line additions must be handeled. Could be made even smarter, but this works well enough */ - static update_line (old, new, current_line) register char *old, *new; int current_line; --- 1512,1517 ---- *************** *** 1632,1638 **** /* Move the cursor from last_c_pos to NEW, which are buffer indices. DATA is the contents of the screen line of interest; i.e., where the movement is being done. */ ! static void move_cursor_relative (new, data) int new; char *data; --- 1658,1664 ---- /* Move the cursor from last_c_pos to NEW, which are buffer indices. DATA is the contents of the screen line of interest; i.e., where the movement is being done. */ ! void move_cursor_relative (new, data) int new; char *data; *************** *** 1888,1894 **** } /* A function for the use of tputs () */ ! static void output_character_function (c) int c; { --- 1914,1920 ---- } /* A function for the use of tputs () */ ! void output_character_function (c) int c; { *************** *** 1896,1902 **** } /* Write COUNT characters from STRING to the output stream. */ ! static void output_some_chars (string, count) char *string; int count; --- 1922,1928 ---- } /* Write COUNT characters from STRING to the output stream. */ ! void output_some_chars (string, count) char *string; int count; *************** *** 1906,1912 **** /* Delete COUNT characters from the display line. */ - static delete_chars (count) int count; { --- 1932,1937 ---- *************** *** 1928,1934 **** } /* Insert COUNT character from STRING to the output stream. */ - static insert_some_chars (string, count) char *string; int count; --- 1953,1958 ---- *************** *** 2030,2042 **** static struct tchars original_tchars; /* Local special characters. This has the interrupt characters in it. */ ! static struct ltchars original_ltchars; /* We use this to get and set the tty_flags. */ static struct sgttyb the_ttybuff; /* Put the terminal in CBREAK mode so that we can detect key presses. */ - static rl_prep_terminal () { int tty = fileno (rl_instream); --- 2054,2067 ---- static struct tchars original_tchars; /* Local special characters. This has the interrupt characters in it. */ ! #ifdef TIOCGLTC ! static struct ltchars original_ltchars; ! #endif /* We use this to get and set the tty_flags. */ static struct sgttyb the_ttybuff; /* Put the terminal in CBREAK mode so that we can detect key presses. */ rl_prep_terminal () { int tty = fileno (rl_instream); *************** *** 2116,2132 **** the_ttybuff.sg_flags &= ~ECHO; the_ttybuff.sg_flags |= CBREAK; ! ioctl (tty, TIOCSETN, &the_ttybuff); } /* Restore the terminal to its original state. */ - static rl_deprep_terminal () { int tty = fileno (rl_instream); the_ttybuff.sg_flags = original_tty_flags; ! ioctl (tty, TIOCSETN, &the_ttybuff); readline_echoing_p = 1; #if defined (TIOCLGET) && defined (LPASS8) --- 2141,2164 ---- the_ttybuff.sg_flags &= ~ECHO; the_ttybuff.sg_flags |= CBREAK; ! #ifdef TIOCSETN ! ioctl (tty, TIOCSETN, &the_ttybuff); ! #else ! ioctl (tty, TIOCSETP, &the_ttybuff); ! #endif } /* Restore the terminal to its original state. */ rl_deprep_terminal () { int tty = fileno (rl_instream); the_ttybuff.sg_flags = original_tty_flags; ! #ifdef TIOCSETN ! ioctl (tty, TIOCSETN, &the_ttybuff); ! #else ! ioctl (tty, TIOCSETP, &the_ttybuff); ! #endif readline_echoing_p = 1; #if defined (TIOCLGET) && defined (LPASS8) *************** *** 2154,2160 **** static struct termio otio; - static rl_prep_terminal () { int tty = fileno (rl_instream); --- 2186,2191 ---- *************** *** 2178,2184 **** ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */ } - static rl_deprep_terminal () { int tty = fileno (rl_instream); --- 2209,2214 ---- *************** *** 5190,5196 **** { extern char *possible_control_prefixes[], *possible_meta_prefixes[]; char *rindex (), *funname, *kname; ! static int substring_member_of_array (); register int c; int key, i; --- 5220,5226 ---- { extern char *possible_control_prefixes[], *possible_meta_prefixes[]; char *rindex (), *funname, *kname; ! int substring_member_of_array (); register int c; int key, i; *************** *** 5411,5421 **** /* **************************************************************** */ /* Return non-zero if any members of ARRAY are a substring in STRING. */ ! static int substring_member_of_array (string, array) char *string, **array; { ! static char *strindex (); while (*array) { --- 5441,5451 ---- /* **************************************************************** */ /* Return non-zero if any members of ARRAY are a substring in STRING. */ ! int substring_member_of_array (string, array) char *string, **array; { ! char *strindex (); while (*array) { *************** *** 5466,5472 **** /* Determine if s2 occurs in s1. If so, return a pointer to the match in s1. The compare is case insensitive. */ ! static char * strindex (s1, s2) register char *s1, *s2; { --- 5496,5502 ---- /* Determine if s2 occurs in s1. If so, return a pointer to the match in s1. The compare is case insensitive. */ ! char * strindex (s1, s2) register char *s1, *s2; { -- Jim Paradis UUCP: harvard!m2c!jjmhome!acestes!paradis 9 Carlstad St. AT&T: (508) 792-3810 Worcester, MA 01607-1569 ICBM: 42deg 13' 52", 71deg 47' 51"