mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
([NSString -initWithFormat:arguments:]): Fix bug whereby multiple %@'s
in the same format string created incorrect output. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e2a743a218
commit
b7e0e37cae
1 changed files with 2 additions and 4 deletions
|
@ -331,7 +331,7 @@ handle_printf_atsign (FILE *stream,
|
|||
strings, placed in a non-writable section of the executable, and
|
||||
writing to them will cause a segfault.) */
|
||||
char format_cp_copy[format_len+1];
|
||||
char *atsign_pos;
|
||||
char *atsign_pos; /* points to a location inside format_cp_copy */
|
||||
char *format_to_go = format_cp_copy;
|
||||
strcpy (format_cp_copy, format_cp);
|
||||
/* Loop once for each `%@' in the format string. */
|
||||
|
@ -345,13 +345,11 @@ handle_printf_atsign (FILE *stream,
|
|||
/* Temporarily terminate the string before the `%@'. */
|
||||
*atsign_pos = '\0';
|
||||
/* Print the part before the '%@' */
|
||||
printed_len = vsprintf (buf, format_cp_copy, arg_list);
|
||||
printed_len += vsprintf (buf+printed_len, format_to_go, arg_list);
|
||||
/* Get a C-string (char*) from the String object, and print it. */
|
||||
cstring = [(id) va_arg (arg_list, id) cStringNoCopy];
|
||||
strcat (buf+printed_len, cstring);
|
||||
printed_len += strlen (cstring);
|
||||
/* Put back the `%' we removed when we terminated mid-string. */
|
||||
*atsign_pos = '%';
|
||||
/* Skip over this `%@', and look for another one. */
|
||||
format_to_go = atsign_pos + 2;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue