[net.sources.bugs] SCAME patch no. 2

leif@erisun.UUCP (Leif Samuelsson) (02/26/85)

System: scame 1.0
Patch #: 2
Priority: Rather high

Description:	
	The parser for command and variable names does not interpret
	a space correctly.

Repeat-by:
	Try to give the command "M-X C Mode".

Fix:	From news, say "| patch -d DIR", where DIR is your scame
	source directory.
	Outside of news, say "cd DIR; patch <thisarticle".
	If you don't have the patch program, apply the following
	by hand, or get patch.
	After re-compiling, it is necessary to start up scame with
	the "-n" option, because the tempfiles will be invalid.
	Before installing, make sure that no one is running scame,
	then remove all the tempfiles in the TMPDIR directory.


Prereq: 1.0.1
*** 1.0/io.c	Tue Feb 19 20:32:53 1985
--- io.c	Tue Feb 19 22:12:24 1985
***************
*** 1,6
  /*	SCAME io.c			*/
  
! /*	Revision 1.0.1  1985-02-17	*/
  
  static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson";
  

--- 1,6 -----
  /*	SCAME io.c			*/
  
! /*	Revision 1.0.2  1985-02-19	*/
  
  static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson";
  
***************
*** 828,833
  {
  char str[80], tstr[80], *p;
  int c, i;
  	*str = '\0';
  	do {
  		c=instring(prompt, str, strlen(str), "\t", "\007\022\033\r ?");

--- 828,835 -----
  {
  char str[80], tstr[80], *p;
  int c, i;
+ 
+ 	/* This code should be merged with setvariable() */
  	*str = '\0';
  	do {
  		c=instring(prompt, str, strlen(str), "\t", "\007\022\033\r ?");
***************
*** 831,837
  	*str = '\0';
  	do {
  		c=instring(prompt, str, strlen(str), "\t", "\007\022\033\r ?");
! 		if (c == 7 || (c == 13 && *str=='\0'))
  			return(0);
  		switch (c) {
  		    case '\022':		/* ^R */

--- 833,840 -----
  	*str = '\0';
  	do {
  		c=instring(prompt, str, strlen(str), "\t", "\007\022\033\r ?");
! 		if (c == 7 || (c == 13 && *str=='\0')) {
! 			typing = FALSE;
  			return(0);
  		}
  		switch (c) {
***************
*** 833,838
  		c=instring(prompt, str, strlen(str), "\t", "\007\022\033\r ?");
  		if (c == 7 || (c == 13 && *str=='\0'))
  			return(0);
  		switch (c) {
  		    case '\022':		/* ^R */
  			strcat(str, "^R"); break;

--- 836,842 -----
  		if (c == 7 || (c == 13 && *str=='\0')) {
  			typing = FALSE;
  			return(0);
+ 		}
  		switch (c) {
  		    case '\022':		/* ^R */
  			strcat(str, "^R"); break;
***************
*** 840,847
  			listmatching((struct tabstruct *)x_comtab,str); break;
  		    case ' ':
  			strcpy(tstr,str);
! 			(void) tablk((struct tabstruct *)x_comtab,str,0);
! 			if (strlen(str) == strlen(tstr))
  				pchar(BELL);
  			else if ((p=index(str+strlen(tstr), ' ')) != NIL)
  				*(p+1) = '\0';

--- 844,854 -----
  			listmatching((struct tabstruct *)x_comtab,str); break;
  		    case ' ':
  			strcpy(tstr,str);
! 			strcat(str, " ");
! 			if (tablk((struct tabstruct *)x_comtab,str,0) <0) {
! 			    strcpy(str,tstr);
! 			    (void) tablk((struct tabstruct *)x_comtab,str,0);
! 			    if (strlen(str) == strlen(tstr))
  				pchar(BELL);
  			}
  			if ((p=index(str+strlen(tstr), ' ')) != NIL)
***************
*** 843,849
  			(void) tablk((struct tabstruct *)x_comtab,str,0);
  			if (strlen(str) == strlen(tstr))
  				pchar(BELL);
! 			else if ((p=index(str+strlen(tstr), ' ')) != NIL)
  				*(p+1) = '\0';
  			break;
  		    default:

--- 850,857 -----
  			    (void) tablk((struct tabstruct *)x_comtab,str,0);
  			    if (strlen(str) == strlen(tstr))
  				pchar(BELL);
! 			}
! 			if ((p=index(str+strlen(tstr), ' ')) != NIL)
  				*(p+1) = '\0';
  			break;
  		    default:

Prereq: 1.0.0
*** 1.0/vars.c	Fri Feb 15 23:51:35 1985
--- vars.c	Tue Feb 19 22:12:36 1985
***************
*** 1,6
  /*	SCAME vars.c				*/
  
! /*	Revision 1.0.0  1985-02-09		*/
  
  static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson";
  

--- 1,6 -----
  /*	SCAME vars.c				*/
  
! /*	Revision 1.0.1  1985-02-19		*/
  
  static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson";
  
***************
*** 35,41
  setvariable(a)
  long a;
  {
! char str[80];
  int c,i;
  	if (!xarg) {
  		errmes(ILA);

--- 35,41 -----
  setvariable(a)
  long a;
  {
! char str[80], tstr[80], *p;
  int c,i;
  	if (!xarg) {
  		errmes(ILA);
***************
*** 42,47
  		return;
  	}
  	*str = '\0';
  	do {
  		c=instring("Variable: ",str,strlen(str),"\t","\007\033\r?");
  		if (c == 7 || (c == 13 && *str=='\0')) {

--- 42,49 -----
  		return;
  	}
  	*str = '\0';
+ 
+ 	/* This code should be merged with getfuncname() */
  	do {
  		c=instring("Variable: ",str,strlen(str),"\t","\007\033\r ?");
  		if (c == 7 || (c == 13 && *str=='\0')) {
***************
*** 43,49
  	}
  	*str = '\0';
  	do {
! 		c=instring("Variable: ",str,strlen(str),"\t","\007\033\r?");
  		if (c == 7 || (c == 13 && *str=='\0')) {
  			typing = FALSE;
  			return;

--- 45,51 -----
  
  	/* This code should be merged with getfuncname() */
  	do {
! 		c=instring("Variable: ",str,strlen(str),"\t","\007\033\r ?");
  		if (c == 7 || (c == 13 && *str=='\0')) {
  			typing = FALSE;
  			return;
***************
*** 48,57
  			typing = FALSE;
  			return;
  		}
! 		if (c == '?') listmatching((struct tabstruct *)vartab,str);
! 		else if ((i = tablk((struct tabstruct *)vartab,str,0)) <0)
! 			pchar(BELL);
!   	} while (i<0 || c==ESC || c=='?');
  	switch (i) {
  		case 2: if (a >=40 && a <=100)
  				gvars.bottom_display_margin = a;

--- 50,75 -----
  			typing = FALSE;
  			return;
  		}
! 		switch (c) {
! 		    case '?':
! 			listmatching((struct tabstruct *)vartab,str); break;
! 		    case ' ':
! 			strcpy(tstr,str);
! 			strcat(str, " ");
! 			if (tablk((struct tabstruct *)vartab,str,0) <0) {
! 			    strcpy(str,tstr);
! 			    (void) tablk((struct tabstruct *)vartab,str,0);
! 			    if (strlen(str) == strlen(tstr))
! 				pchar(BELL);
! 			}
! 			if ((p=index(str+strlen(tstr), ' ')) != NIL)
! 				*(p+1) = '\0';
! 			break;
! 		    default:
! 			if ((i = tablk((struct tabstruct *)vartab,str,0)) <0)
! 				pchar(BELL);
! 		}
! 	} while (i<0 || index("\033 ?", c) != NIL);
  	switch (i) {
  		case 2: if (a >=40 && a <=100)
  				gvars.bottom_display_margin = a;