[comp.sources.x] v03i066: Patches to xdbx, Part02/03

argv@island.uu.net (Dan Heller) (04/06/89)

Submitted-by: Ps Cheung <po@volta.ece.utexas.edu>
Posting-number: Volume 3, Issue 66
Archive-name: xdbx.patch/part02

#!/bin/sh
echo x - xdbx.patch.2
sed 's/^X//' > xdbx.patch.2 <<'+END+OF+xdbx.patch.2'
Xdiff -c xdbx1.0/Imakefile xdbx1.1/Imakefile
X*** xdbx1.0/Imakefile	Fri Mar 24 01:18:40 1989
X--- xdbx1.1/Imakefile	Fri Mar 24 00:49:04 1989
X***************
X*** 1,14 ****
X  #ifdef VaxArchitecture
X! 	DEFINES = -DBSD		/* Berkeley dbx */
X  #endif
X  
X  LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  
X!            SRCS = calldbx.c command.c dbx.c dialog.c handler.c parser.c \
X! 		  regex.c signs.c signals.c source.c utils.c windows.c xdbx.c
X  
X!            OBJS = calldbx.o command.o dbx.o dialog.o handler.o parser.o \
X! 		  regex.o signs.o signals.o source.o utils.o windows.o xdbx.o
X  
X  ComplexProgramTarget(xdbx)
X  InstallAppDefaults(XDbx)
X--- 1,19 ----
X  #ifdef VaxArchitecture
X!         DEFINES = -DBSD		/* Berkeley dbx */
X  #endif
X+ /*      
X+         DEFINES = -DSUNOS4_0
X+ */
X  
X  LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  
X!            SRCS = calldbx.c command.c dbx.c dialog.c filemenu.c handler.c \
X!                   parser.c regex.c signs.c signals.c source.c utils.c \
X!            	  windows.c xdbx.c
X  
X!            OBJS = calldbx.o command.o dbx.o dialog.o filemenu.o handler.o \
X!                   parser.o regex.o signs.o signals.o source.o utils.o \
X!                   windows.o xdbx.o
X  
X  ComplexProgramTarget(xdbx)
X  InstallAppDefaults(XDbx)
Xdiff -c xdbx1.0/Makefile xdbx1.1/Makefile
X*** xdbx1.0/Makefile	Fri Mar 24 01:18:40 1989
X--- xdbx1.1/Makefile	Fri Mar 24 00:47:51 1989
X***************
X*** 135,145 ****
X  
X  LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  
X!            SRCS = calldbx.c command.c dbx.c dialog.c handler.c parser.c \
X!                   regex.c signs.c signals.c source.c utils.c windows.c xdbx.c
X  
X!            OBJS = calldbx.o command.o dbx.o dialog.o handler.o parser.o \
X! 		  regex.o signs.o signals.o source.o utils.o windows.o xdbx.o
X  
X   PROGRAM = xdbx
X  
X--- 135,147 ----
X  
X  LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  
X!            SRCS = calldbx.c command.c dbx.c dialog.c filemenu.c handler.c \
X!                   parser.c regex.c signs.c signals.c source.c utils.c \
X!            	  windows.c xdbx.c
X  
X!            OBJS = calldbx.o command.o dbx.o dialog.o filemenu.o handler.o \
X!                   parser.o regex.o signs.o signals.o source.o utils.o \
X!                   windows.o xdbx.o
X  
X   PROGRAM = xdbx
X  
Xdiff -c xdbx1.0/bsd_regex.h xdbx1.1/bsd_regex.h
X*** xdbx1.0/bsd_regex.h	Fri Mar 24 01:18:41 1989
X--- xdbx1.1/bsd_regex.h	Fri Mar 31 05:05:19 1989
X***************
X*** 54,64 ****
X  #define C_FILE          6
X  #define C_DEBUG         7
X  #define C_CD          	8
X  
X  
X  static PatternRec output_pattern[] = {
X      /* exec */
X!     {"\\(.*\n\\)*\\(\[[0-9]+\] \\)?\\(\\(stopped\\|Bus error\\|Segmentation \
X  fault\\|Interrupt\\) in \\([^ ]+\\) at line \
X  \\([0-9]+\\)\\( in file \"\\([^ ]+\\)\"\\)?\\)\n", 
X       NULL,
X--- 54,65 ----
X  #define C_FILE          6
X  #define C_DEBUG         7
X  #define C_CD          	8
X+ #define C_USE          	9
X  
X  
X  static PatternRec output_pattern[] = {
X      /* exec */
X!     {"\\(.*\n\\)*.*\\(\[[0-9]+\] \\)?\\(\\(stopped\\|Bus error\\|Segmentation \
X  fault\\|Interrupt\\) in \\([^ ]+\\) at line \
X  \\([0-9]+\\)\\( in file \"\\([^ ]+\\)\"\\)?\\)\n", 
X       NULL,
X***************
X*** 98,109 ****
X  };
X  
X  static PatternRec command_pattern[] = {
X!     {"[ ]*\\(run\\|cont\\|next\\|step\\).*\n",  NULL, {-1, -1, -1, -1, -1}},
X!     {"[ ]*stop[ ]+at[ ]+[0-9]+.*\n",            NULL, {-1, -1, -1, -1, -1}},
X!     {"[ ]*stop[ ]+in[ ]+.*\n",                  NULL, {-1, -1, -1, -1, -1}},
X      {"[ ]*\\(up\\|down\\).*\n",                 NULL, {-1, -1, -1, -1, -1}},
X!     {"[ ]*delete.*\n",                          NULL, {-1, -1, -1,  1, -1}},
X      {"[ ]*func[ ]*\\([^ ]+\\)[ ]*\n",           NULL, {-1, -1,  1, -1, -1}},
X      {"[ ]*file[ ]*\\([^ ]+\\)[ ]*\n",           NULL, {-1, -1, -1, -1,  1}},
X      NULL
X  };
X--- 99,112 ----
X  };
X  
X  static PatternRec command_pattern[] = {
X!     {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|return\\|r\\).*\n",
X! 						NULL, {-1, -1, -1, -1, -1}},
X!     {"[ ]*\\(stop\\|st\\)[ ]+at[ ]+[0-9]+.*\n", NULL, {-1, -1, -1, -1, -1}},
X!     {"[ ]*\\(stop\\|st\\)[ ]+in[ ]+.*\n",       NULL, {-1, -1, -1, -1, -1}},
X      {"[ ]*\\(up\\|down\\).*\n",                 NULL, {-1, -1, -1, -1, -1}},
X!     {"[ ]*\\(delete\\|d\\).*\n",                NULL, {-1, -1, -1,  1, -1}},
X      {"[ ]*func[ ]*\\([^ ]+\\)[ ]*\n",           NULL, {-1, -1,  1, -1, -1}},
X      {"[ ]*file[ ]*\\([^ ]+\\)[ ]*\n",           NULL, {-1, -1, -1, -1,  1}},
X+     {"[ ]*use[ ]*.*\n",           		NULL, {-1, -1, -1, -1,  1}},
X      NULL
X  };
Xdiff -c xdbx1.0/calldbx.c xdbx1.1/calldbx.c
X*** xdbx1.0/calldbx.c	Fri Mar 24 01:18:41 1989
X--- xdbx1.1/calldbx.c	Thu Mar 30 21:27:16 1989
X***************
X*** 18,24 ****
X   ******************************************************************************/
X  
X  
X! #include	<sys/ioctl.h>
X  #include	"global.h"
X  
X  FILE   	    	*dbxfp = NULL;		/* file pointer to dbx */
X--- 18,24 ----
X   ******************************************************************************/
X  
X  
X! #include	<sgtty.h>
X  #include	"global.h"
X  
X  FILE   	    	*dbxfp = NULL;		/* file pointer to dbx */
X***************
X*** 38,44 ****
X      int  i, master; 
X      char c;
X  
X!     for (c='p'; c<='q'; c++) {
X  	pty[8] = c;
X  	for (i=0; i<16; i++) {
X  	    pty[9] = "0123456789abcdef"[i];
X--- 38,44 ----
X      int  i, master; 
X      char c;
X  
X!     for (c='p'; c<='s'; c++) {
X  	pty[8] = c;
X  	for (i=0; i<16; i++) {
X  	    pty[9] = "0123456789abcdef"[i];
X***************
X*** 46,52 ****
X  		return (master); 
X  	}
X      }
X!     fprintf(stderr, "xdbx: all ptys in use: ptyp0 - ptyqf\n");
X      exit(1);
X  }
X  
X--- 46,52 ----
X  		return (master); 
X  	}
X      }
X!     fprintf(stderr, "xdbx: all ptys in use\n");
X      exit(1);
X  }
X  
X***************
X*** 70,85 ****
X  int argc;
X  char *argv[];
X  {
X!     int  master;	/* file descriptor of master pty */
X!     int  slave; 	/* file descriptor to slave pty */
X!     int  n = 0;
X  
X      master = openMaster();
X      slave = openSlave();
X  
X! #ifndef BSD
X!     ioctl(master, TIOCPKT, &n);		/* disable packet mode */
X! #endif
X  
X      dbxpid = fork();
X      if (dbxpid == -1) {
X--- 70,91 ----
X  int argc;
X  char *argv[];
X  {
X!     struct sgttyb Sgtty;
X!     int  	  master;		/* file descriptor of master pty */
X!     int  	  slave; 		/* file descriptor to slave pty */
X!     char 	  *debugger, 		/* name of executable debugger */
X! 		  errmsg[LINESIZ];
X  
X+     debugger = (char *) getenv("DEBUGGER");	/* first looks up env var */
X+     if (debugger == NULL)
X+ 	debugger = XtNewString(DEBUGGER);
X+   
X      master = openMaster();
X      slave = openSlave();
X  
X!     ioctl(slave, TIOCGETP, &Sgtty);
X!     Sgtty.sg_flags &= ~(ECHO|CRMOD);        	/* no echo, no NL to CR */
X!     ioctl(slave, TIOCSETP, &Sgtty);
X  
X      dbxpid = fork();
X      if (dbxpid == -1) {
X***************
X*** 118,126 ****
X  	    close(slave);
X  	fcntl(1, F_SETFL, FAPPEND);
X  	setbuf(stdout, NULL);
X! 	argv[0] = "dbx";
X! 	execvp("dbx", argv);
X! 	perror("Cannot call dbx");
X  	exit(1);
X      }
X  }
X--- 124,133 ----
X  	    close(slave);
X  	fcntl(1, F_SETFL, FAPPEND);
X  	setbuf(stdout, NULL);
X! 	argv[0] = debugger;
X! 	execvp(debugger, argv);
X! 	sprintf(errmsg, "Cannot call %s", debugger);
X! 	perror(errmsg);
X  	exit(1);
X      }
X  }
Xdiff -c xdbx1.0/command.c xdbx1.1/command.c
X*** xdbx1.0/command.c	Fri Mar 24 01:18:37 1989
X--- xdbx1.1/command.c	Fri Mar 24 01:03:04 1989
X***************
X*** 18,43 ****
X   ******************************************************************************/
X  
X  
X  #include <signal.h>
X  #include <ctype.h>
X- #include <X11/Xos.h>
X- #include <sys/stat.h>
X  #include <sys/wait.h>
X- #ifdef sparc
X- #include <dirent.h>
X- #else
X- #include <sys/dir.h>
X- #endif
X  #include "global.h"
X  
X  char 		Command[LINESIZ] = "";	/* xdbx command string */
X  
X! static String  	filelist[MAXFILES]; 	/* list of file names in fileMenu */
X! static int	nfiles = 0;		/* number of files in filelist */
X! static Widget	fileMenu = NULL, 	/* list widget as file menu */
X! 		popupshell;		/* parent of fileMenu */
X  
X- 
X  /* ARGSUSED */
X  static void DoIt (w, client_data, call_data)
X      Widget w;
X--- 18,41 ----
X   ******************************************************************************/
X  
X  
X+ /*  Command.c
X+  *
X+  *  This file contains 
X+  *    CreateCommandPanel() : create a window with command buttons.
X+  *    AddButton() :	Add a command button into the command window.
X+  *    command callbacks for the command buttons.
X+  */
X+  
X  #include <signal.h>
X  #include <ctype.h>
X  #include <sys/wait.h>
X  #include "global.h"
X  
X  char 		Command[LINESIZ] = "";	/* xdbx command string */
X  
X! extern void 	File();
X! extern void 	SetUpFileMenu();
X  
X  /* ARGSUSED */
X  static void DoIt (w, client_data, call_data)
X      Widget w;
X***************
X*** 51,56 ****
X--- 49,71 ----
X  }
X  
X  /* ARGSUSED */
X+ #ifdef BSD
X+ static void Return (w, client_data, call_data)
X+     Widget w;
X+     caddr_t client_data;
X+     caddr_t call_data;
X+ {
X+     char *funcname;
X+     int  nbytes;
X+ 
X+     funcname = XFetchBytes(XtDisplay(w), &nbytes);	/* from CUT_BUFFER0 */
X+     sprintf(Command, "return %s\n", funcname);
X+     AppendDialogText(Command);
X+     writeDbx(Command);
X+ }
X+ #endif
X+ 
X+ /* ARGSUSED */
X  static void Stop_at(w, client_data, call_data)
X      Widget w;
X      caddr_t client_data;
X***************
X*** 156,293 ****
X      writeDbx(Command);
X  }
X  
X- /* ARGSUSED */
X- /*  Callback for the fileMenu list widget, display the file selected in the 
X-  *  menu on the source window.
X-  */
X- static void DisplayMenuFile(w, client_data, call_data)
X-     Widget w;
X-     Widget client_data;
X-     XtListReturnStruct *call_data;
X- {
X-     XtPopdown(client_data);
X-     if (call_data->string == NULL || 
X- 	strcmp(call_data->string, CANCEL) == NULL) return;
X-     displayedFile = LoadFile(call_data->string);
X-     sprintf(Command, "file %s\n", call_data->string);
X-     AppendDialogText(Command);
X-     writeDbx(Command);
X- }
X  
X- 
X- /*  A directory entry is included in the display list if it is a regular
X-  *  file but not an executable file.
X-  */
X- static int InList(entry)
X- Directory *entry;
X- {
X-     char buffer[16];
X-     int i, n;
X-     FILE *fp;
X- 
X-     if ((fp = fopen(entry->d_name, "r")) == NULL)
X-         return False;
X-     if (n = fread(buffer, sizeof(char), sizeof(buffer), fp)) {
X-     	fclose(fp);
X-     	for (i=0; i<n && (isprint(buffer[i]) || isspace(buffer[i])); i++);
X-     	return ((i-sizeof(buffer)) ? False : True);
X-     }
X-     fclose(fp);
X-     return False;
X- }
X- 
X- /*  Scans the working directory for files selected by InList(), sorted
X-  *  alphabetically, and stored in an array of pointers to directory
X-  *  entries called namelist.
X-  *  The names of the selected files are stored in filelist.
X-  */
X- static void ScanDir()
X- {
X-     extern 	alphasort();
X-     Directory   **namelist;
X-     char 	*dir, message[LINESIZ];
X-     int		i;
X- 
X-     i = 0;
X-     filelist[i++] = "";
X-     dir = dbxpwd();
X-     nfiles = scandir(dir, &namelist, InList, alphasort);
X-     for (i=1; i<nfiles; i++) {
X- 	filelist[i] = XtNewString(namelist[i]->d_name);
X-     }
X-     filelist[0] = CANCEL;
X-     filelist[i] = NULL;
X-     return;
X- }
X- 
X- /*  Creates a popup shell with its child being a list widget containing
X-  *  file names returned from ScanDir().
X-  *  When an item in the list is selected, DisplayMenuFile will be called.
X-  */
X- static void SetUpFileMenu() 
X- {
X-     Arg 	args[MAXARGS];
X-     Cardinal	n;
X-     int		ncolumns;
X- 
X-     static String translations = "\
X- 	<Btn1Down>,<Btn1Up>:	Set() Notify() Unset()";
X- 
X-     n = 0;
X-     popupshell = XtCreatePopupShell("popup", overrideShellWidgetClass, 
X- 				    toplevel, args, n);
X- 
X-     ScanDir();
X-     n = 0;
X-     ncolumns = nfiles/app_resources.filesPerColumn + 1;
X-     XtSetArg(args[n], XtNlist, filelist);				n++;
X-     XtSetArg(args[n], XtNverticalList, True);				n++;
X-     XtSetArg(args[n], XtNcolumnSpacing, app_resources.columnSpacing);	n++;
X-     XtSetArg(args[n], XtNdefaultColumns, (XtArgVal) ncolumns);		n++;
X-     XtSetArg(args[n], XtNtranslations, XtParseTranslationTable(translations));
X-     n++;
X-     fileMenu = XtCreateManagedWidget("fileMenu", listWidgetClass, 
X- 				     popupshell, args, n);
X-     XtAddCallback(fileMenu, XtNcallback, DisplayMenuFile, popupshell);
X- }
X- 
X- /*  Destroy the existing popup shell and creates another one. */
X- void UpdateFileMenu()
X- {
X-     XtDestroyWidget(popupshell);
X-     SetUpFileMenu();
X- }
X-     
X  /* ARGSUSED */
X- static void File(w, client_data, call_data)
X-     Widget w;
X-     caddr_t client_data;
X-     caddr_t call_data;
X- {
X-     Arg 	args[MAXARGS];
X-     Cardinal	n;
X-     Position	x, y, x_offset;
X-     Dimension	fileMenu_width, border_width, source_width;
X- 
X-     n = 0;
X-     XtSetArg(args[n], XtNwidth, &fileMenu_width);			n++;
X-     XtSetArg(args[n], XtNborderWidth, &border_width);			n++;
X-     XtGetValues(fileMenu, args, n);
X- 
X-     n = 0;
X-     XtSetArg(args[n], XtNwidth, &source_width);				n++;
X-     XtGetValues(sourceWindow, args, n);
X- 
X-     x_offset = (Position) (source_width - fileMenu_width - 2*border_width);
X-     XtTranslateCoords(sourceWindow, x_offset, 0, &x, &y);
X-     x = MAX(0, x);
X-     y = MAX(0, y);
X-     XtMoveWidget(popupshell, x, y);
X-     XtPopup(popupshell, XtGrabNonexclusive);
X- }
X- 
X- 
X- /* ARGSUSED */
X  static void Quit(w, client_data, call_data)
X      Widget w;
X      caddr_t client_data;
X--- 171,178 ----
X***************
X*** 297,306 ****
X--- 182,193 ----
X  
X      writeDbx("quit\n");
X      XtDestroyWidget(toplevel);
X+     kill(dbxpid, SIGKILL);
X      wait3(&status, WNOHANG, NULL);
X      exit(0);
X  }
X  
X+ 
X  static void AddButton (parent, name, function, client_data)
X  Widget parent;
X  char *name;
X***************
X*** 318,323 ****
X--- 205,211 ----
X      XtAddCallback(button, XtNcallback, function, client_data);
X  }
X  
X+ 
X  static void CreateButtons (parent)
X  Widget parent;
X  {
X***************
X*** 325,335 ****
X--- 213,229 ----
X      AddButton (parent, "cont", DoIt, "cont\n");
X      AddButton (parent, "next", DoIt, "next\n");
X      AddButton (parent, "step", DoIt, "step\n");
X+ #ifdef BSD
X+     AddButton (parent, "return", Return, "return\n");
X+ #endif
X  
X      AddButton (parent, "stop at", Stop_at, NULL);
X      AddButton (parent, "stop in", Stop_in, NULL);
X      AddButton (parent, "delete", Delete, NULL);
X+ 
X+ #ifndef BSD
X      AddButton (parent, "status", DoIt, "status\n");
X+ #endif
X  
X      AddButton (parent, "where", DoIt, "where\n");
X      AddButton (parent, "up", DoIt, "up\n");
X***************
X*** 360,364 ****
X      commandWindow = XtCreateManagedWidget("commandWindow", boxWidgetClass, 
X  					  parent, args, n);
X      CreateButtons(commandWindow);
X!     SetUpFileMenu();
X  }
X--- 254,258 ----
X      commandWindow = XtCreateManagedWidget("commandWindow", boxWidgetClass, 
X  					  parent, args, n);
X      CreateButtons(commandWindow);
X!     SetUpFileMenu(dbxpwd());
X  }
Xdiff -c xdbx1.0/dbx.c xdbx1.1/dbx.c
X*** xdbx1.0/dbx.c	Fri Mar 24 01:18:42 1989
X--- xdbx1.1/dbx.c	Sun Apr  2 17:45:09 1989
X***************
X*** 26,32 ****
X  static int	outputsize = 0;		/* size of buffer */
X  static Boolean 	continueFlag;		/* read flag for dbxinit commands */
X  
X! static void Dbxinit(fp)
X  FILE *fp;
X  {
X      char s[LINESIZ];
X--- 26,39 ----
X  static int	outputsize = 0;		/* size of buffer */
X  static Boolean 	continueFlag;		/* read flag for dbxinit commands */
X  
X! 
X! /*  Given a file pointer to xdbx.XXXXXX, this routine executes each dbx
X!  *  command in the file.  It sends the command to dbx, and calls readDbx()
X!  *  directly to process output returned from dbx.
X!  *  The continueFlag is there to make sure it reads everything from dbx
X!  *  before issuing another command.
X!  */
X! static void dbx_init(fp)
X  FILE *fp;
X  {
X      char s[LINESIZ];
X***************
X*** 43,75 ****
X  }
X  
X  /*
X!  * Called only once to display the source file, if any, right after
X!  * xdbx is started up.
X   */
X! void DisplayInit()
X  {
X      FILE *fp;
X-     char *path;
X  
X!     displayedFile = LoadFile(QueryFile());
X!     UpdateMessageWindow("Ready for execution");
X      if (fp = fopen(xdbxinit, "r")) {
X  	if (displayedFile)
X!     	    Dbxinit(fp);
X! 	if (Homedir)
X!     	    rename(xdbxinit, "~/.dbxinit");
X! 	else
X      	    rename(xdbxinit, ".dbxinit");
X      }
X  }
X  
X  /*
X!  *  This is a callback procedure invoked everytime input is pending
X   *  on the file descriptor to dbx.
X!  *  It reads all the data available on the descriptor line by line
X!  *  into 'string', and write it to the dialog window.
X!  *  Once the dbx prompt is read in, it calls parse() to take appropriate
X!  *  action.
X   */
X  XtInputCallbackProc readDbx(client_data, source, id)
X  caddr_t   client_data;
X--- 50,94 ----
X  }
X  
X  /*
X!  *  This routine is called after getting the first dbx prompt.  
X!  *  In Sun dbx, DebugInit() is also called after each 'debug' command.
X!  *
X!  *  > check the use list to create a list of directories for searching
X!  *    source files.
X!  *  > ask dbx for the source file and display it if it exists.
X!  *  > if the temporary file in xdbxinit exists, call dbx_init only if
X!  *    the source file has been displayed.  Then rename the temporary
X!  *    file back to the original file.
X   */
X! void DebugInit()
X  {
X      FILE *fp;
X  
X!     MakeDirList(QueryDbx("use\n", FALSE));
X!     if (LoadFile(QueryFile()) == 0)
X!     	UpdateMessageWindow("Ready for execution");
X      if (fp = fopen(xdbxinit, "r")) {
X  	if (displayedFile)
X!     	    dbx_init(fp);
X! 	if (Homedir == 0)
X      	    rename(xdbxinit, ".dbxinit");
X+ 	else if (Homedir == 1)
X+     	    rename(xdbxinit, "~/.dbxinit");
X      }
X  }
X  
X  /*
X!  *  This is a callback procedure invoked everytime when input is pending
X   *  on the file descriptor to dbx.
X!  *  > reads all the data available on the file descriptor line by line
X!  *    into local variable 'string' and global variable 'output'.
X!  *    'output' records the entire dbx output whereas 'string' records
X!  *    only the data read in this invocation of readDbx().
X!  *  > in Echo mode, the contents in 'string' is edited by filter()
X!  *    before it gets displayed on the dialog window.
X!  *  > once the dbx prompt is read, calls parse() to analyse the dbx output
X!  *    and take appropriate action.
X!  *  > After the very first dbx prompt is read, calls DebugInit().
X   */
X  XtInputCallbackProc readDbx(client_data, source, id)
X  caddr_t   client_data;
X***************
X*** 78,128 ****
X  {
X      char   s[LINESIZ], *string;
X      int    stringsize;
X!     static Boolean initialFlag = TRUE, 
X! 		   displayFlag = FALSE;
X  
X!     /* allocate one block to 'output' to begin with */
X!     if (outputsize == 0) {
X  	outputsize = BUFSIZ;
X  	output = XtMalloc(outputsize);
X      	strcpy(output, "");
X      }
X!     stringsize = BUFSIZ;
X      string = XtMalloc(stringsize);
X      strcpy(string, "");
X      while (fgets(s, LINESIZ, dbxfp)) {
X!     	/* if no echo mode, do not write output to dialog window */
X! 	if (Echo == FALSE) continue;
X! 	EnterCommand = FALSE;
X! 	if (strcmp(s, "(dbx) ")) {
X! 	    if (strlen(string) + strlen(s) > stringsize) {
X! 		string = XtRealloc(string, stringsize + BUFSIZ);
X! 		stringsize += BUFSIZ;
X  	    }
X! 	    strcat(string, s);
X! 	    if (strlen(output) + strlen(s) > outputsize) {
X! 		output = XtRealloc(output, outputsize + BUFSIZ);
X! 		outputsize += BUFSIZ;
X  	    }
X- 	    strcat(output, s);
X  	}
X- 	else {
X- 	    parse(output);
X- 	    strcpy(output, "");
X- 	    strcpy(s, "");
X- 	    strcat(string, PROMPT);
X- 	    EnterCommand = TRUE;
X- 	    continueFlag = FALSE;
X- 	    if (initialFlag) {
X- 		initialFlag = FALSE;
X- 		displayFlag = TRUE;
X- 	    }
X- 	}
X      }
X      filter(string);
X      AppendDialogText(string);
X!     if (displayFlag) {
X! 	displayFlag = FALSE;
X! 	DisplayInit();
X!     }
X  }
X--- 97,147 ----
X  {
X      char   s[LINESIZ], *string;
X      int    stringsize;
X!     static Boolean firstTime = TRUE, 	/* ensure DebugInit() only get 	*/
X! 		   debugFlag = FALSE;	/* called once			*/
X  
X!     if (outputsize == 0) {		/* allocate output buffer */
X  	outputsize = BUFSIZ;
X  	output = XtMalloc(outputsize);
X      	strcpy(output, "");
X      }
X!     stringsize = BUFSIZ;		/* allocate string buffer */
X      string = XtMalloc(stringsize);
X      strcpy(string, "");
X+ 
X      while (fgets(s, LINESIZ, dbxfp)) {
X! 	if (Echo) {
X! 	    EnterCommand = FALSE;
X! 	    if (strcmp(s, PROMPT)) {
X! 		if (strlen(string) + strlen(s) > stringsize) {
X! 		    string = XtRealloc(string, stringsize + BUFSIZ);
X! 		    stringsize += BUFSIZ;
X! 		}
X! 		if (strlen(output) + strlen(s) > outputsize) {
X! 		    output = XtRealloc(output, outputsize + BUFSIZ);
X! 		    outputsize += BUFSIZ;
X! 		}
X! 		strcat(string, s);
X! 		strcat(output, s);
X  	    }
X! 	    else {			/* dbx prompt arrives */
X! 		parse(output);
X! 		strcpy(output, "");
X! 		strcpy(s, "");
X! 		strcat(string, XPROMPT); 
X! 		EnterCommand = TRUE;	/* next input should be a command */
X! 		continueFlag = FALSE;	/* signal end to dbx_init() */
X! 		if (firstTime) {	
X! 		    firstTime = FALSE;
X! 		    debugFlag = TRUE;
X! 		}
X  	    }
X  	}
X      }
X      filter(string);
X      AppendDialogText(string);
X!     if (debugFlag) {
X! 	debugFlag = FALSE;
X! 	DebugInit();		/* must be called here, after string has */
X!     }			   	/* been appended to the dialog window */
X  }
Xdiff -c xdbx1.0/defs.h xdbx1.1/defs.h
X*** xdbx1.0/defs.h	Fri Mar 24 01:18:42 1989
X--- xdbx1.1/defs.h	Sat Apr  1 15:10:19 1989
X***************
X*** 19,24 ****
X--- 19,25 ----
X  
X  
X  #include <stdio.h>
X+ #include <sys/param.h>
X  #include <X11/Xos.h>
X  #include <X11/IntrinsicP.h>
X  #include <X11/StringDefs.h>
X***************
X*** 34,61 ****
X  #include <X11/Command.h>
X  #include <X11/Label.h>
X  
X- #define MIN(a,b)	((a)<(b) ? (a) : (b))
X- #define MAX(a,b)	((a)>(b) ? (a) : (b))
X  
X  #define DIALOGSIZE      10000		/* max size of dialog window buffer */
X! #define LINESIZ         200		/* input line length */
X! #define MAXNAME         30		/* max identifier length */
X! #define MAXARGS 	10		/* max number of args */
X! #define MAXFILES 	256		/* max number of files in fileTable */
X  #define MAXSTOPS 	256		/* max number of stops */
X! #define	MAXSIGNS	100		/* max number of signs */
X  #define OFFSET		2		/* offset for adjusting sign position */
X  #define CHARS_PER_LINE  20		/* estimated number of chars per line */
X  #define ADD_LINES       50		/* # of lines to be added in realloc */
X! #define PROMPT  	"(xdbx) "	/* xdbx prompt string */
X! #define TITLE  		"xdbx 1.0"	/* xdbx title string */
X! #define CANCEL  	"<Cancel>"	/* string for file menu */
X  #define DELIMITERS	" !%^&*()+=~|;:{},/#<?\"\n\t"
X  
X  
X  typedef int 		Line;
X  
X! #ifdef sparc
X  typedef struct dirent 	Directory;
X  #else
X  typedef struct direct 	Directory;
X--- 35,65 ----
X  #include <X11/Command.h>
X  #include <X11/Label.h>
X  
X  
X  #define DIALOGSIZE      10000		/* max size of dialog window buffer */
X! #define LINESIZ         512		/* input line length */
X! #define MAXNAME         256		/* max identifier length */
X! #define MAXARGS 	20		/* max number of args */
X! #define FILETABLESIZE 	32		/* initial fileTable size */
X! #define ADD_FILES 	16		/* # of files added during Realloc */
X! #define MAXDIRS 	256		/* max number of dirs in DirList */
X  #define MAXSTOPS 	256		/* max number of stops */
X! #define	MAXSIGNS	256		/* max number of signs */
X! #define	MAXCOLUMNS	8		/* max number of columns in file menu */
X  #define OFFSET		2		/* offset for adjusting sign position */
X  #define CHARS_PER_LINE  20		/* estimated number of chars per line */
X  #define ADD_LINES       50		/* # of lines to be added in realloc */
X! #define DEBUGGER      	"dbx"		/* name of executable */
X! #define PROMPT  	"(dbx) "	/* dbx prompt string */
X! #define XPROMPT  	"(xdbx) "	/* xdbx prompt string */
X! #define TITLE  		"xdbx 1.1"	/* xdbx title string */
X  #define DELIMITERS	" !%^&*()+=~|;:{},/#<?\"\n\t"
X  
X+ #define	LASTCH(s)	(s[strlen(s)-1])
X  
X  typedef int 		Line;
X  
X! #ifdef SUNOS4_0
X  typedef struct dirent 	Directory;
X  #else
X  typedef struct direct 	Directory;
X***************
X*** 80,85 ****
X--- 84,93 ----
X      Pixel     stopForeground;		/* foreground color of stop sign */
X      Pixel     arrowForeground;		/* foreground color of arrow sign */
X      Pixel     updownForeground;	/* foreground color of updown sign */
X+ 					/* Translation tables for : */
X+     XtTranslations sourceTranslTable;	/* source window text widget */
X+     XtTranslations sbarTranslTable;	/* source window text scrollbar */
X+     XtTranslations dialogTranslTable;	/* dialog window text widget */
X  
X      Boolean   dbxopt_r;		/* dbx option -r */
X      Boolean   dbxopt_i;		/* dbx option -i */
X***************
X*** 87,99 ****
X      Boolean   dbxopt_k;		/* dbx option -k */
X      String    cfile;		/* Berkeley  dbx option -c file */
X      Boolean   dbxopt_kbd;	/* SunOS 3.4 dbx option -kbd */
X!     int	      fcount;		/* SunOS 4.0 dbx option -f fcount */
X      String    startup;		/* SunOS 4.0 dbx option -s startup */
X      String    tstartup;		/* SunOS 4.0 dbx option -sr tstartup */
X  } XdbxResources;
X  
X  typedef struct {
X!     char 		*filename;	/* name of file on display */
X      char 		funcname[MAXNAME];	/* current function */
X      char 		*buf;		/* buffer holding source file */
X      long		filesize;	/* size of file in bytes */
X--- 95,108 ----
X      Boolean   dbxopt_k;		/* dbx option -k */
X      String    cfile;		/* Berkeley  dbx option -c file */
X      Boolean   dbxopt_kbd;	/* SunOS 3.4 dbx option -kbd */
X!     String    fcount;		/* SunOS 4.0 dbx option -f fcount */
X      String    startup;		/* SunOS 4.0 dbx option -s startup */
X      String    tstartup;		/* SunOS 4.0 dbx option -sr tstartup */
X  } XdbxResources;
X  
X  typedef struct {
X!     char 		*filename;	/* name of file */
X!     char 		*pathname;	/* full path name of file */
X      char 		funcname[MAXNAME];	/* current function */
X      char 		*buf;		/* buffer holding source file */
X      long		filesize;	/* size of file in bytes */
X***************
X*** 126,143 ****
X  
X  typedef struct {
X      Cardinal	i;			/* index to arrowsign[] */
X!     char	filename[MAXNAME];	/* filename associated with */
X      Line 	line;			/* line number */
X  } Arrow;
X  
X  typedef struct {
X      Cardinal	i;			/* index to updownsign[] */
X!     char	filename[MAXNAME];	/* filename associated with */
X      Line 	line;			/* line number */
X  } Updown;
X  
X  typedef struct {
X!     char	*filename;		/* filename associated with */
X      Line 	line;			/* line number of stop */
X      unsigned 	tag;			/* used in deleting stops */
X  } Stops;
X--- 135,154 ----
X  
X  typedef struct {
X      Cardinal	i;			/* index to arrowsign[] */
X!     char	file[MAXNAME];		/* file associated with */
X      Line 	line;			/* line number */
X+     char 	func[MAXNAME];		/* function name associated with */
X  } Arrow;
X  
X  typedef struct {
X      Cardinal	i;			/* index to updownsign[] */
X!     char	file[MAXNAME];		/* file associated with */
X      Line 	line;			/* line number */
X+     char 	func[MAXNAME];		/* function name associated with */
X  } Updown;
X  
X  typedef struct {
X!     char	*file;			/* file associated with */
X      Line 	line;			/* line number of stop */
X      unsigned 	tag;			/* used in deleting stops */
X  } Stops;
Xdiff -c xdbx1.0/dialog.c xdbx1.1/dialog.c
X*** xdbx1.0/dialog.c	Fri Mar 24 01:18:38 1989
X--- xdbx1.1/dialog.c	Sun Apr  2 15:36:09 1989
X***************
X*** 22,27 ****
X--- 22,29 ----
X  #include "global.h"
X  
X  char 	DialogText[DIALOGSIZE];		/* text buffer for widget */
X+ Boolean FalseSignal = FALSE;		/* set to TRUE before self-generated
X+ 					   interrupt/quit signals */
X  
X  /*  This is my own select word routine to replace the standard action
X   *  procedure provided by the Text widget.
X***************
X*** 72,78 ****
X  
X  
X  /*  Clicking the left mouse button in the source or dialog window
X!  *  invokes this action procedure to clear the cut buffer0 contenst.
X   */
X  /* ARGSUSED */
X  static XtActionProc ClearCutBuffer0(w, event, params, num_params)
X--- 74,80 ----
X  
X  
X  /*  Clicking the left mouse button in the source or dialog window
X!  *  invokes this action procedure to clear the cut buffer0 contents.
X   */
X  /* ARGSUSED */
X  static XtActionProc ClearCutBuffer0(w, event, params, num_params)
X***************
X*** 85,95 ****
X  }
X  
X  
X! /*  This is a special character delete procedure that will not
X!  *  delete past StartPos set by AppendDialogText.
X   */
X  /* ARGSUSED */
X! static XtActionProc MyDelete(w, event, params, num_params)
X      Widget w;
X      XEvent *event;
X      String *params;
X--- 87,100 ----
X  }
X  
X  
X! /*  This procedure prevents the user from deleting past the prompt, or
X!  *  any text appended by AppendDialogText() to the dialog window.
X!  *  It checks the last position of text, if it matches StartPos, set
X!  *  by AppendDialogText(), it inserts a space so that delete-previous-
X!  *  character() can only delete the space character.
X   */
X  /* ARGSUSED */
X! static XtActionProc InsertSpace(w, event, params, num_params)
X      Widget w;
X      XEvent *event;
X      String *params;
X***************
X*** 108,140 ****
X      }
X  }
X  
X! /*  Dispatch() is invoked on every <CR>.
X!  *  It collects text from the dialog window and sends it to dbx.
X!  *  If the string is a command to dbx (EnterCommand would be TRUE),
X!  *  it is stored in the global variable, Command.
X   */
X  /* ARGSUSED */
X! static XtActionProc Dispatch(w, event, params, num_params)
X      Widget w;
X      XEvent *event;
X      String *params;
X!     Cardinal *num_params; 
X  {
X!     char *s;
X  
X!     s = DialogText + StartPos;
X!     if (EnterCommand) {
X! 	strcpy(Command, s);
X!     	writeDbx(Command);
X!     }
X!     else {
X!     	writeDbx(XtNewString(s));
X!     }
X  }
X  
X  
X! /*  This action procedure is called when the user hits Ctrl-U.  It does
X!  *  what Ctrl-U ususally does in a terminal.
X  /* ARGSUSED */
X  static XtActionProc DeleteLine(w, event, params, num_params)
X      Widget w;
X--- 113,148 ----
X      }
X  }
X  
X! /*  Erases the preceding word.
X!  *  Simulates the action of the WERASE character (ctrl-W).
X   */
X  /* ARGSUSED */
X! static XtActionProc DeleteWord(w, event, params, num_params)
X      Widget w;
X      XEvent *event;
X      String *params;
X!     Cardinal *num_params;
X  {
X!     XtTextBlock    	textblock;
X!     XtTextPosition	lastPos;
X!     Cardinal	 	i, j;
X  
X!     textblock.firstPos = 0;
X!     textblock.length   = 0;
X!     textblock.ptr      = "";
X! 
X!     lastPos = TextGetLastPos(w); 
X!     for (i=lastPos; i > StartPos && DialogText[i-1] == ' '; i--);
X!     for (j=i; i > StartPos && DialogText[i-1] != ' '; i--);
X!     XtTextReplace(dialogWindow, i, lastPos, &textblock);
X!     lastPos = TextGetLastPos(w);
X!     XtTextSetInsertionPoint(w, lastPos);
X  }
X  
X  
X! /*  Deletes the entire current input line.
X!  *  simulates the action of the KILL character (ctrl-U).
X!  */
X  /* ARGSUSED */
X  static XtActionProc DeleteLine(w, event, params, num_params)
X      Widget w;
X***************
X*** 158,165 ****
X  }
X  
X  
X! /*  Sends an interrupt signal, Ctrl-C, to dbx. */
X  /* ARGSUSED */
X  static XtActionProc SigInt(w, event, params, num_params)
X      Widget w;
X      XEvent *event;
X--- 166,204 ----
X  }
X  
X  
X! /*  Dispatch() is invoked on every <CR>.
X!  *  It collects text from the dialog window and sends it to dbx.
X!  *  If the string is a command to dbx (EnterCommand would be TRUE),
X!  *  it is stored in the global variable, Command.
X!  */
X  /* ARGSUSED */
X+ static XtActionProc Dispatch(w, event, params, num_params)
X+     Widget w;
X+     XEvent *event;
X+     String *params;
X+     Cardinal *num_params; 
X+ {
X+     char *s;
X+ 
X+     s = DialogText + StartPos;
X+     if (EnterCommand) {
X+ #ifdef BSD			/* do not clobber Command if blank input */
X+ 	if (strcspn(s, " \n"))	
X+ #endif
X+ 	    strcpy(Command, s);
X+     	writeDbx(Command);
X+     }
X+     else {
X+     	writeDbx(XtNewString(s));
X+     }
X+ }
X+ 
X+ 
X+ 
X+ /*  Sends an interrupt signal, SIGINT, to dbx.
X+  *  Simulates the action of the INTR character (ctrl-C).
X+  */
X+ /* ARGSUSED */
X  static XtActionProc SigInt(w, event, params, num_params)
X      Widget w;
X      XEvent *event;
X***************
X*** 166,177 ****
X      String *params;
X      Cardinal *num_params;
X  {
X!     writeDbx("\03");
X!     kill(dbxpid, SIGINT);
X  }
X  
X  
X! /*  Sends an EOF signal, Ctrl-D, to dbx. */
X  /* ARGSUSED */
X  static XtActionProc SigEof(w, event, params, num_params)
X      Widget w;
X--- 205,216 ----
X      String *params;
X      Cardinal *num_params;
X  {
X!     FalseSignal = TRUE;
X!     kill(0, SIGINT);
X  }
X  
X  
X! /*  Sends an EOF signal to dbx. (ctrl-D) */
X  /* ARGSUSED */
X  static XtActionProc SigEof(w, event, params, num_params)
X      Widget w;
X***************
X*** 183,189 ****
X  }
X  
X  
X! /*  Sends a QUIT signal, Ctrl-\, to dbx. */
X  /* ARGSUSED */
X  static XtActionProc SigQuit(w, event, params, num_params)
X      Widget w;
X--- 222,230 ----
X  }
X  
X  
X! /*  Sends a QUIT signal, SIGQUIT, to dbx. 
X!  *  Simulates the action of the QUIT character (ctrl-\) 
X!  */
X  /* ARGSUSED */
X  static XtActionProc SigQuit(w, event, params, num_params)
X      Widget w;
X***************
X*** 191,197 ****
X      String *params;
X      Cardinal *num_params;
X  {
X!     kill(dbxpid, SIGQUIT);
X  }
X  
X  
X--- 232,239 ----
X      String *params;
X      Cardinal *num_params;
X  {
X!     FalseSignal = TRUE;
X!     kill(0, SIGQUIT);
X  }
X  
X  
X***************
X*** 207,231 ****
X      Cardinal 	n;
X  
X      static XtActionsRec actionTable[] = {
X  	{"DeleteLine", (XtActionProc) DeleteLine},
X! 	{"MyDelete", (XtActionProc) MyDelete},
X  	{"Dispatch", (XtActionProc) Dispatch},
X  	{"MySelectWord", (XtActionProc) MySelectWord},
X  	{"ClearCutBuffer0", (XtActionProc) ClearCutBuffer0},
X- 	{"SigInt", (XtActionProc) SigInt},
X- 	{"SigEof", (XtActionProc) SigEof},
X- 	{"SigQuit", (XtActionProc) SigQuit},
X          {NULL, NULL}
X      };
X  
X      static String translations = "\
X-  	Ctrl<Key>U:	DeleteLine()\n\
X   	Ctrl<Key>C:	SigInt()\n\
X   	Ctrl<Key>D:	SigEof()\n\
X   	Ctrl<Key>|:	SigQuit()\n\
X!  	Ctrl<Key>H:	MyDelete() delete-previous-character()\n\
X!  	<Key>Delete:	MyDelete() delete-previous-character()\n\
X!  	<Key>BackSpace:	MyDelete() delete-previous-character()\n\
X   	<Key>Return:	end-of-file() newline() Dispatch()\n\
X   	<Key>:		end-of-file() insert-char()\n\
X  	<FocusIn>:	focus-in()\n\
X--- 249,275 ----
X      Cardinal 	n;
X  
X      static XtActionsRec actionTable[] = {
X+ 	{"SigInt", (XtActionProc) SigInt},
X+ 	{"SigEof", (XtActionProc) SigEof},
X+ 	{"SigQuit", (XtActionProc) SigQuit},
X+ 	{"DeleteWord", (XtActionProc) DeleteWord},
X  	{"DeleteLine", (XtActionProc) DeleteLine},
X! 	{"InsertSpace", (XtActionProc) InsertSpace},
X  	{"Dispatch", (XtActionProc) Dispatch},
X  	{"MySelectWord", (XtActionProc) MySelectWord},
X  	{"ClearCutBuffer0", (XtActionProc) ClearCutBuffer0},
X          {NULL, NULL}
X      };
X  
X      static String translations = "\
X   	Ctrl<Key>C:	SigInt()\n\
X   	Ctrl<Key>D:	SigEof()\n\
X   	Ctrl<Key>|:	SigQuit()\n\
X!  	Ctrl<Key>W:	DeleteWord()\n\
X!  	Ctrl<Key>U:	DeleteLine()\n\
X!  	Ctrl<Key>H:	InsertSpace() delete-previous-character()\n\
X!  	<Key>Delete:	InsertSpace() delete-previous-character()\n\
X!  	<Key>BackSpace:	InsertSpace() delete-previous-character()\n\
X   	<Key>Return:	end-of-file() newline() Dispatch()\n\
X   	<Key>:		end-of-file() insert-char()\n\
X  	<FocusIn>:	focus-in()\n\
X***************
X*** 239,258 ****
X  	<Btn3Up>:	extend-end(PRIMARY, CUT_BUFFER0)\n\
X  	<Btn1Up>(2):	MySelectWord()";
X  
X- 
X      n = 0;
X      XtSetArg(args[n], XtNmin, app_resources.dialogMinHeight);		n++;
X      XtSetArg(args[n], XtNheight, app_resources.dialogHeight);		n++;
X-     XtSetArg(args[n], XtNtranslations, XtParseTranslationTable(translations));
X-     n++;
X      XtSetArg(args[n], XtNstring, (XtArgVal) DialogText);		n++;
X      XtSetArg(args[n], XtNlength, (XtArgVal) DIALOGSIZE);		n++;
X      XtSetArg(args[n], XtNeditType, (XtArgVal) XttextEdit);		n++;
X      XtSetArg(args[n], XtNtextOptions, scrollVertical | wordBreak);	n++;
X! 
X!     dialogWindow = XtCreateManagedWidget("dialogWindow", 
X! 					 asciiStringWidgetClass,
X  					 parent, args, n );
X! 
X      XtAddActions(actionTable, XtNumber(actionTable));
X  }
X--- 283,304 ----
X  	<Btn3Up>:	extend-end(PRIMARY, CUT_BUFFER0)\n\
X  	<Btn1Up>(2):	MySelectWord()";
X  
X      n = 0;
X      XtSetArg(args[n], XtNmin, app_resources.dialogMinHeight);		n++;
X      XtSetArg(args[n], XtNheight, app_resources.dialogHeight);		n++;
X      XtSetArg(args[n], XtNstring, (XtArgVal) DialogText);		n++;
X      XtSetArg(args[n], XtNlength, (XtArgVal) DIALOGSIZE);		n++;
X      XtSetArg(args[n], XtNeditType, (XtArgVal) XttextEdit);		n++;
X      XtSetArg(args[n], XtNtextOptions, scrollVertical | wordBreak);	n++;
X!     XtSetArg(args[n], XtNtranslations, XtParseTranslationTable(translations));
X! 									n++;
X!     dialogWindow = XtCreateManagedWidget("dialogWindow", asciiStringWidgetClass,
X  					 parent, args, n );
X!     if (app_resources.dialogTranslTable) {
X! 	n = 0;
X!     	XtSetArg(args[n], XtNtranslations, app_resources.dialogTranslTable);
X! 	n++;
X! 	XtSetValues(dialogWindow, args, n);
X!     }
X      XtAddActions(actionTable, XtNumber(actionTable));
X  }
+END+OF+xdbx.patch.2
echo '-rw-r--r--  1 argv        37156 Apr  5 23:56 xdbx.patch.2    (as sent)'
chmod u=rw,g=r,o=r xdbx.patch.2
ls -l xdbx.patch.2
exit 0