From f6517dc4036fa863f79b6a28831c94733ad1857e Mon Sep 17 00:00:00 2001 From: mccallum Date: Wed, 25 Sep 1996 13:45:31 +0000 Subject: [PATCH] ([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 --- Source/NSString.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/NSString.m b/Source/NSString.m index 3eb9d36da..327332587 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -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; }