karl@sugar.UUCP (11/29/87)
There are bugs in the C code for the execution of &left, &right and &mid. Symptom: &left, &right and &mid return too many characters. The extra characters are garbage. Analysis: The existing code apparently relies on strnchar writing a \0 to the end of the destination string in all cases, if it is to work at all. The System V manual entry for String (3C) says "The result will not be null-terminated if the length of s2 (the source string) is n or more." strnchar definitely works this way on my Unix SysV system. One solution: Here are the context diffs for some patches to eval.c that cause uEMACS to write the null byte at the end of the result string as it should. What you need to do: If it works allright for you, you needn't necessarily pick this up. I know Dan Lawrence reads comp.emacs. Presumably he'll pick this up or do some equivalent. You'll need to have it soon or you won't be able use many of the super-cool macro packages that I'm sure people will be posting ;-) Ta. (Hey Dan, great work!) *** eval.orig Sat Nov 28 18:36:23 1987 --- eval.c Sat Nov 28 20:19:18 1987 *************** *** 33,34 char *xlat(); /* translate a char string */ #if ENVFUNC --- 33,35 ----- char *xlat(); /* translate a char string */ + int itmp; /* tmp variable */ #if ENVFUNC *************** *** 76,78 return(strcat(result, arg2)); ! case UFLEFT: return(strncpy(result, arg1, atoi(arg2))); case UFRIGHT: return(strcpy(result, --- 77,80 ----- return(strcat(result, arg2)); ! case UFLEFT: result[(itmp = atoi(arg2))] = '\0'; ! return(strncpy(result, arg1, itmp)); case UFRIGHT: return(strcpy(result, *************** *** 79,82 &arg1[(strlen(arg1) - atoi(arg2))])); ! case UFMID: return(strncpy(result, &arg1[atoi(arg2)-1], ! atoi(arg3))); case UFNOT: return(ltos(stol(arg1) == FALSE)); --- 81,85 ----- &arg1[(strlen(arg1) - atoi(arg2))])); ! case UFMID: result[(itmp = atoi(arg3))] = '\0'; ! return(strncpy(result, &arg1[atoi(arg2)-1], ! itmp)); case UFNOT: return(ltos(stol(arg1) == FALSE)); --