[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MiNTlib (I think I'm on pl43): Bug in sprintf().



Stephen Usher <Stephen.Usher@earth.ox.ac.uk> writes:

|> When a statement such as the following is run sprintf terminates after the
|> first argument:-

|> 	sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TERMTYPE,
|> 		TELOPT_QUAL, term, IAC, SB);

|> 	where IAC, SB, TELOPT* are all non-ACSII characters with the top bit
|> 	set, ie. 127 < x < 256. The first two are actually (from memory)
|> 	0xff and 0xfa.

|> All you get in temp is the first byte, ie. 0xff. printf() works correctly.

Here is a patch:

--- sprintf.c~	Tue Oct 12 08:19:02 1993
+++ sprintf.c	Mon Jul 11 10:31:28 1994
@@ -12,7 +12,7 @@ sputc (ch, fp)
 {
   char **bufp = (char **) fp;
   *(*bufp)++ = ch;
-  return ch;
+  return ch & 0xff;
 }
 
 #ifdef __STDC__

-- 
+------------------------------------------------------------------------+
Andreas Schwab                                      "And now for something
schwab@ls5.informatik.uni-dortmund.de                completely different"