Patch Set #1 for x3270 v3.0.1, 14 October 1993

  This file is in 'patch' format.  If you don't have 'patch', it is readily
  available on the net, or you can pick apart the context diffs below and
  apply them yourself.

Really fix the Home key.  A previous bug fix was really a "bugswap", changing
a key that sometimes malfunctioned into one that always malfunctioned.

*** kybd.c.orig	Wed Oct  6 12:20:40 1993
--- kybd.c	Wed Oct  6 12:20:41 1993
***************
*** 416,422 ****
  		return;
  	}
  	baddr = nbaddr = 0;
! 	while (baddr) {
  		INC_BA(nbaddr);
  		if (IS_FA(screen_buf[baddr]) &&
  		    !FA_IS_PROTECTED(screen_buf[baddr]) &&
--- 416,422 ----
  		return;
  	}
  	baddr = nbaddr = 0;
! 	do {
  		INC_BA(nbaddr);
  		if (IS_FA(screen_buf[baddr]) &&
  		    !FA_IS_PROTECTED(screen_buf[baddr]) &&
***************
*** 425,431 ****
  			return;
  		}
  		baddr = nbaddr;
! 	}
  
  	/* No unprotected fields */
  	cursor_move(0);
--- 425,431 ----
  			return;
  		}
  		baddr = nbaddr;
! 	} while (baddr);
  
  	/* No unprotected fields */
  	cursor_move(0);

Fix for numeric port numbers (e.g., -port 23), which didn't work on little-
endian machines.

*** telnet.c.orig	Wed Oct  6 12:20:49 1993
--- telnet.c	Wed Oct  6 12:20:50 1993
***************
*** 175,181 ****
  	/* get the tcp/ip service (telnet) */
  	if (sp = getservbyname(portname, "tcp"))
  		port = sp->s_port;
! 	else if (!(port = atoi(portname)))
  		CN_FAIL("unknown service");
  
  	/* fill in the socket address of the given host */
--- 175,181 ----
  	/* get the tcp/ip service (telnet) */
  	if (sp = getservbyname(portname, "tcp"))
  		port = sp->s_port;
! 	else if (!(port = htons(atoi(portname))))
  		CN_FAIL("unknown service");
  
  	/* fill in the socket address of the given host */

Fix boneheaded font definition.

*** 3270-12b.bdf.orig	Wed Oct  6 12:20:55 1993
--- 3270-12b.bdf	Wed Oct  6 12:20:55 1993
***************
*** 1,6 ****
  STARTFONT 2.1
  COMMENT Originally a BSD vfont.
! FONT 3270-12
  SIZE 12 72 72
  FONTBOUNDINGBOX 7 12 0 -2
  STARTPROPERTIES 15
--- 1,6 ----
  STARTFONT 2.1
  COMMENT Originally a BSD vfont.
! FONT 3270-12bold
  SIZE 12 72 72
  FONTBOUNDINGBOX 7 12 0 -2
  STARTPROPERTIES 15

Remove enum symbol "DEC", which causes compile errors on DEC machines.

*** ansi.c.orig	Wed Oct  6 12:21:00 1993
--- ansi.c	Wed Oct  6 12:21:00 1993
***************
*** 74,80 ****
  
  static enum state {
      DATA = 0, ESC = 1, CSDES = 2,
!     N1 = 3, DEC = 4, TEXT = 5, TEXT2 = 6
  } state = DATA;
  
  static enum state ansi_data_mode();
--- 74,80 ----
  
  static enum state {
      DATA = 0, ESC = 1, CSDES = 2,
!     N1 = 3, DECP = 4, TEXT = 5, TEXT2 = 6
  } state = DATA;
  
  static enum state ansi_data_mode();
***************
*** 271,277 ****
  },
  
  /*
!  * State table for ESC [ ? processing (state == DEC)
   */
  {
  	     /* 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
--- 271,277 ----
  },
  
  /*
!  * State table for ESC [ ? processing (state == DECP)
   */
  {
  	     /* 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  */
***************
*** 890,896 ****
  static enum state
  ansi_esc3()
  {
! 	return DEC;
  }
  
  static enum state
--- 890,896 ----
  static enum state
  ansi_esc3()
  {
! 	return DECP;
  }
  
  static enum state

Remove redundant manpage install rule in Imakefile.

*** Imakefile.orig	Wed Oct  6 12:21:04 1993
--- Imakefile	Wed Oct  6 12:21:05 1993
***************
*** 16,22 ****
  ComplexProgramTarget(x3270)
  
  InstallAppDefaults(X3270)
- InstallManPage(x3270,$(MANDIR))
  InstallManPage(ibm_hosts,$(MANDIR))
  
  FontTarget(3270)
--- 16,21 ----

Make font recognition a little more tolerant under OpenWindows.

*** screen.c.orig	Fri Oct  8 17:43:16 1993
--- screen.c	Fri Oct  8 17:43:18 1993
***************
*** 1403,1409 ****
  	if (*name == '!') {
  		name++;
  		test_spacing = False;
! 	}
  	f = XLoadQueryFont(display, name);
  	if (f == NULL)
  		return "doesn't exist";
--- 1403,1410 ----
  	if (*name == '!') {
  		name++;
  		test_spacing = False;
! 	} else if (!strncmp(name, "3270", 4))
! 		test_spacing = False;
  	f = XLoadQueryFont(display, name);
  	if (f == NULL)
  		return "doesn't exist";
***************
*** 1441,1446 ****
--- 1442,1449 ----
  	bfontname = XtNewString(bf);
  	if (XGetFontProperty(f, a_family_name, &svalue))
  		nss.standard_font = (Atom) svalue != a_3270;
+ 	else if (!strncmp(efontname, "3270", 4))
+ 		nss.standard_font = False;
  	else
  		nss.standard_font = True;
  	nss.latin1_font = nss.standard_font &&

Respect the user's wishes for the window title (-title or *title) and icon
name (*iconName).

*** x3270.c.orig	Fri Oct  8 19:16:47 1993
--- x3270.c	Fri Oct  8 19:16:49 1993
***************
*** 70,75 ****
--- 70,77 ----
  static Boolean		excepting = False;
  static Pixmap		inv_icon;
  static Boolean		icon_inverted = False;
+ static char		*user_title = (char *) NULL;
+ static char		*user_icon_name = (char *) NULL;
  static void		find_keymaps();
  static void		add_trans();
  static void		peek_at_xevent();
***************
*** 412,417 ****
--- 414,425 ----
  	/* Make sure we don't fall over any SIGPIPEs. */
  	signal(SIGPIPE, SIG_IGN);
  
+ 	/* Respect the user's title wishes. */
+ 	user_title = get_resource("title");
+ 	user_icon_name = get_resource("iconName");
+ 	if (user_icon_name)
+ 		set_aicon_label(user_icon_name);
+ 
  	/* Connect to the host. */
  	if (argc > 1)
  		(void) x_connect(argv[1]);
***************
*** 671,688 ****
  	char *title;
  	char icon[8];
  
  	title = XtMalloc(10 + (current_host ? strlen(current_host) : 0));
  	if (PCONNECTED) {
  		(void) sprintf(title, "x3270-%d%s %s", model_num,
  		    (IN_ANSI ? "A" : ""), current_host);
! 		XtVaSetValues(toplevel, XtNtitle, title, NULL);
! 		XtVaSetValues(toplevel, XtNiconName, current_host, NULL);
  		set_aicon_label(current_host);
  	} else {
  		(void) sprintf(title, "x3270-%d", model_num);
  		(void) sprintf(icon, "x3270-%d", model_num);
! 		XtVaSetValues(toplevel, XtNtitle, title, NULL);
! 		XtVaSetValues(toplevel, XtNiconName, icon, NULL);
  		set_aicon_label(icon);
  	}
  	XtFree(title);
--- 679,702 ----
  	char *title;
  	char icon[8];
  
+ 	if (user_title && user_icon_name)
+ 		return;
  	title = XtMalloc(10 + (current_host ? strlen(current_host) : 0));
  	if (PCONNECTED) {
  		(void) sprintf(title, "x3270-%d%s %s", model_num,
  		    (IN_ANSI ? "A" : ""), current_host);
! 		if (!user_title)
! 			XtVaSetValues(toplevel, XtNtitle, title, NULL);
! 		if (!user_icon_name)
! 			XtVaSetValues(toplevel, XtNiconName, current_host, NULL);
  		set_aicon_label(current_host);
  	} else {
  		(void) sprintf(title, "x3270-%d", model_num);
  		(void) sprintf(icon, "x3270-%d", model_num);
! 		if (!user_title)
! 			XtVaSetValues(toplevel, XtNtitle, title, NULL);
! 		if (!user_icon_name)
! 			XtVaSetValues(toplevel, XtNiconName, icon, NULL);
  		set_aicon_label(icon);
  	}
  	XtFree(title);

Change to allow embedded blanks in login strings in the hosts file.

*** menubar.c.orig	Tue Oct 12 09:16:54 1993
--- menubar.c	Tue Oct 12 09:16:55 1993
***************
*** 843,848 ****
--- 843,869 ----
   * Host file support
   */
  
+ static char *
+ stoken(s)
+ char **s;
+ {
+ 	char *r;
+ 	char *ss = *s;
+ 
+ 	if (!*ss)
+ 		return NULL;
+ 	r = ss;
+ 	while (*ss && *ss != ' ' && *ss != '\t')
+ 		ss++;
+ 	if (*ss) {
+ 		*ss++ = '\0';
+ 		while (*ss == ' ' || *ss == '\t')
+ 			ss++;
+ 	}
+ 	*s = ss;
+ 	return r;
+ }
+ 
  /*
   * Read the host file
   */
***************
*** 851,859 ****
  {
  	FILE *hf;
  	char buf[1024];
- 	char name[32], entry_type[16], hostname[256];
- 	char lstring[128];
- 	struct host *h;
  
  	hf = fopen(appres.hostsfile, "r");
  	if (!hf) {
--- 872,877 ----
***************
*** 861,879 ****
  		return;
  	}
  
! 	while (fgets(buf, 256, hf)) {
  		char *s = buf;
  
  		if (strlen(buf) > (unsigned) 1)
! 			buf[strlen (buf) - 1] = '\0';
  		while (isspace(*s))
  			s++;
  		if (!*s || *s == '#')
  			continue;
! 		(void) strcpy(lstring, "");
! 		if (sscanf(s, "%s %s %s %s", name, entry_type, hostname,
! 		    lstring) < 3)
! 			break;
  		h = (struct host *)XtMalloc(sizeof(*h));
  		h->name = XtNewString(name);
  		h->hostname = XtNewString(hostname);
--- 879,902 ----
  		return;
  	}
  
! 	while (fgets(buf, 1024, hf)) {
  		char *s = buf;
+ 		char *name, *entry_type, *hostname;
+ 		struct host *h;
  
  		if (strlen(buf) > (unsigned) 1)
! 			buf[strlen(buf) - 1] = '\0';
  		while (isspace(*s))
  			s++;
  		if (!*s || *s == '#')
  			continue;
! 		name = stoken(&s);
! 		entry_type = stoken(&s);
! 		hostname = stoken(&s);
! 		if (!name || !entry_type || !hostname) {
! 			XtWarning("Bad hostsFile syntax, entry skipped");
! 			continue;
! 		}
  		h = (struct host *)XtMalloc(sizeof(*h));
  		h->name = XtNewString(name);
  		h->hostname = XtNewString(hostname);
***************
*** 881,888 ****
  			h->entry_type = PRIMARY;
  		else
  			h->entry_type = ALIAS;
! 		if (lstring[0])
! 			h->loginstring = XtNewString(lstring);
  		else
  			h->loginstring = (char *)0;
  		h->next = (struct host *)0;
--- 904,911 ----
  			h->entry_type = PRIMARY;
  		else
  			h->entry_type = ALIAS;
! 		if (*s)
! 			h->loginstring = XtNewString(s);
  		else
  			h->loginstring = (char *)0;
  		h->next = (struct host *)0;