Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!TKO-SONY-22.HUT.FI!gson From: gson@TKO-SONY-22.HUT.FI Newsgroups: gnu.bash.bug Subject: Re: Bash 1.04 Xenix diffs + general bug fixes Message-ID: <8912221333.AA08648@tko-sony-22.hut.fi> Date: 22 Dec 89 13:33:24 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 337 In my recent posting of Xenix diffs to Bash 1.04, I had forgotten to include the diffs to the readline library. Here they are. As in the original posting, the diffs to the Makefile are both site- and Xenix-specific, but the diffs to other files are supposed to be generally useful. The most extensive changes consist of moving most variable declaration to the beginning of readline.c so that static variables declared outside of functions will be visible in the entire file. Seems like there is no way in C to make a "forward declaration" of a static variable (what K&R call "external static") defined later in the same file, is there? One additional bug was discovered after the last posting: when running Bash from within Emacs using M-x shell, no prompts will be printed because of a missing fflush(). Fixed in the diffs below. -- Andreas Gustafsson Internet: gson@joker.hut.fi Voice: +358 0 563 5592 ================================ Cut here ================================ diff -c bash-1.04/readline/Makefile bash/readline/Makefile *** bash-1.04/readline/Makefile Tue Sep 26 13:41:49 1989 --- bash/readline/Makefile Fri Dec 22 13:38:26 1989 *************** *** 19,35 **** TYPES = -DVOID_SIGHANDLER # Define SYSV as -DSYSV if you are using a System V operating system. ! #SYSV = -DSYSV # HP-UX compilation requires the BSD library. #LOCAL_LIBS = -lBSD # Xenix compilation requires -ldir -lx ! #LOCAL_LIBS = -ldir -lx # Comment this out if you don't think that anyone will ever desire # the vi line editing mode and features. ! READLINE_DEFINES = -DVI_MODE DEBUG_FLAGS = -g LDFLAGS = $(DEBUG_FLAGS) --- 19,36 ---- TYPES = -DVOID_SIGHANDLER # Define SYSV as -DSYSV if you are using a System V operating system. ! SYSV = -DSYSV # HP-UX compilation requires the BSD library. #LOCAL_LIBS = -lBSD # Xenix compilation requires -ldir -lx ! # (well, at least SCO Xenix 386 doesn't need -ldir) ! LOCAL_LIBS = -lx # Comment this out if you don't think that anyone will ever desire # the vi line editing mode and features. ! # READLINE_DEFINES = -DVI_MODE DEBUG_FLAGS = -g LDFLAGS = $(DEBUG_FLAGS) *************** *** 36,44 **** CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) -I. # A good alternative is gcc -traditional. ! CC = gcc -traditional ! #CC = cc ! RANLIB = /usr/bin/ranlib AR = ar RM = rm CP = cp --- 37,45 ---- CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) -I. # A good alternative is gcc -traditional. ! #CC = gcc -traditional ! CC = cc ! RANLIB = /bin/ranlib AR = ar RM = rm CP = cp diff -c bash-1.04/readline/readline.c bash/readline/readline.c *** bash-1.04/readline/readline.c Sat Nov 4 11:42:01 1989 --- bash/readline/readline.c Fri Dec 22 12:52:23 1989 *************** *** 36,41 **** --- 36,45 ---- #include #include + #ifdef XENIX /* this is probably not the right place for this */ + #define SYSV + #endif + #ifdef __GNUC__ #define alloca __builtin_alloca #else *************** *** 52,57 **** --- 56,65 ---- #include #endif + #ifdef XENIX + #include + #endif + #include extern int errno; *************** *** 68,73 **** --- 76,84 ---- #define HACK_TERMCAP_MOTION + #ifdef XENIX + #include + #else #ifndef SYSV #include #else /* SYSV */ *************** *** 79,84 **** --- 90,96 ---- #define d_namlen d_reclen #endif /* hpux */ #endif /* SYSV */ + #endif /* Some standard library routines. */ #include "readline.h" *************** *** 138,144 **** --- 150,211 ---- #undef HANDLE_SIGNALS #endif #endif + + /* External variables that need to be declared before use, and related */ + /* declarations */ + + /**********/ + /* Parser */ + /**********/ + + /* Calling programs set this to have their argv[0]. */ + char *rl_readline_name = "other"; + + /* Non-zero means do not parse any lines other than comments and + parser directives. */ + static unsigned char parsing_conditionalized_out = 0; + + /* Stack of previous values of parsing_conditionalized_out. */ + static unsigned char *if_stack = (unsigned char *)NULL; + static int if_stack_depth = 0; + static int if_stack_size = 0; + + /*******************/ + /* Keyboard Macros */ + /*******************/ + + /* The currently executing macro string. If this is non-zero, + then it is a malloc ()'ed string where input is coming from. */ + static char *executing_macro = (char *)NULL; + + /* The offset in the above string to the next character to be read. */ + static int executing_macro_index = 0; + + /* Non-zero means to save keys that we dispatch on in a kbd macro. */ + static int defining_kbd_macro = 0; + + /* The current macro string being built. Characters get stuffed + in here by add_macro_char (). */ + static char *current_macro = (char *)NULL; + + /* The size of the buffer allocated to current_macro. */ + static int current_macro_size = 0; + + /* The index at which characters are being added to current_macro. */ + static int current_macro_index = 0; + + /* A structure used to save nested macro strings. + It is a linked list of string/index for each saved macro. */ + struct saved_macro { + struct saved_macro *next; + char *string; + int index; + }; + /* The list of saved macros. */ + struct saved_macro *macro_list = (struct saved_macro *)NULL; + + /* **************************************************************** */ /* */ *************** *** 297,303 **** if (!readline_echoing_p) { if (rl_prompt) ! fprintf (out_stream, "%s", rl_prompt); } else { --- 364,373 ---- if (!readline_echoing_p) { if (rl_prompt) ! { ! fprintf (out_stream, "%s", rl_prompt); ! fflush (out_stream); ! } } else { *************** *** 779,815 **** /* */ /* **************************************************************** */ - /* The currently executing macro string. If this is non-zero, - then it is a malloc ()'ed string where input is coming from. */ - static char *executing_macro = (char *)NULL; - - /* The offset in the above string to the next character to be read. */ - static int executing_macro_index = 0; - - /* Non-zero means to save keys that we dispatch on in a kbd macro. */ - static int defining_kbd_macro = 0; - - /* The current macro string being built. Characters get stuffed - in here by add_macro_char (). */ - static char *current_macro = (char *)NULL; - - /* The size of the buffer allocated to current_macro. */ - static int current_macro_size = 0; - - /* The index at which characters are being added to current_macro. */ - static int current_macro_index = 0; - - /* A structure used to save nested macro strings. - It is a linked list of string/index for each saved macro. */ - struct saved_macro { - struct saved_macro *next; - char *string; - int index; - }; - - /* The list of saved macros. */ - struct saved_macro *macro_list = (struct saved_macro *)NULL; - /* Set up to read subsequent input from STRING. STRING is free ()'ed when we are done with it. */ static --- 849,854 ---- *************** *** 990,996 **** /* Parsing of key-bindings begins in an enabled state. */ { - extern unsigned char parsing_conditionalized_out; parsing_conditionalized_out = 0; } } --- 1029,1034 ---- *************** *** 1972,1979 **** --- 2010,2019 ---- /* Terminal characters. This has C-s and C-q in it. */ static struct tchars original_tchars; + #ifdef TIOCGLTC /* Local special characters. This has the interrupt characters in it. */ static struct ltchars original_ltchars; + #endif /* We use this to get and set the tty_flags. */ static struct sgttyb the_ttybuff; *************** *** 2104,2109 **** --- 2144,2150 ---- #ifndef HANDLE_SIGNALS tio.c_lflag &= ~ISIG; + tio.c_iflag |= IGNBRK; /* break can also cause a SIGINT */ #endif tio.c_cc[VEOF] = 1; /* really: MIN */ *************** *** 5012,5029 **** /* **************************************************************** */ /* Conditionals. */ - - /* Calling programs set this to have their argv[0]. */ - char *rl_readline_name = "other"; - - /* Non-zero means do not parse any lines other than comments and - parser directives. */ - static unsigned char parsing_conditionalized_out = 0; - - /* Stack of previous values of parsing_conditionalized_out. */ - static unsigned char *if_stack = (unsigned char *)NULL; - static int if_stack_depth = 0; - static int if_stack_size = 0; /* Push parsing_conditionalized_out, and set parser state based on ARGS. */ parser_if (args) --- 5053,5058 ---- diff -c bash-1.04/readline/vi_mode.c bash/readline/vi_mode.c *** bash-1.04/readline/vi_mode.c Wed Sep 20 17:10:06 1989 --- bash/readline/vi_mode.c Fri Dec 22 12:51:52 1989 *************** *** 14,20 **** static int vi_histpos; /* Non-zero means enter insertion mode. */ ! static vi_doing_insert = 0; /* *** UNCLEAN *** */ /* Command keys which do movement for xxx_to commands. */ --- 14,21 ---- static int vi_histpos; /* Non-zero means enter insertion mode. */ ! /* This is used in readline.c, so it can't be static */ ! vi_doing_insert = 0; /* *** UNCLEAN *** */ /* Command keys which do movement for xxx_to commands. */ ================================ Cut here ================================