From 264757b4402aa1c62dfbe334993b5d3a9083a2ba Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Apr 2009 15:17:38 -0400 Subject: [PATCH] Make -[GDBpConnection(Private) createCommand:] take a variable number of arguments to parse * Source/GDBpConnection.m: (createCommand:) --- Source/GDBpConnection.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/GDBpConnection.m b/Source/GDBpConnection.m index 0522261..3ef84a5 100644 --- a/Source/GDBpConnection.m +++ b/Source/GDBpConnection.m @@ -22,7 +22,7 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification"; @interface GDBpConnection() @property(readwrite, copy) NSString *status; -- (NSString *)createCommand:(NSString *)cmd; +- (NSString *)createCommand:(NSString *)cmd, ...; - (NSXMLDocument *)processData:(NSString *)data; - (StackFrame *)createStackFrame; - (void)updateStatus; @@ -272,11 +272,18 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification"; #pragma mark Private /** - * Helper method to create a string command with the -i automatically tacked on + * Helper method to create a string command with the -i automatically tacked on. Takes + * a variable number of arguments and parses the given command with +[NSString stringWithFormat:] */ -- (NSString *)createCommand:(NSString *)cmd +- (NSString *)createCommand:(NSString *)cmd, ... { - return [NSString stringWithFormat:@"%@ -i %@", cmd, session]; + // collect varargs + va_list argList; + va_start(argList, cmd); + NSString *format = [[NSString alloc] initWithFormat:cmd arguments:argList]; // format the command + va_end(argList); + + return [NSString stringWithFormat:@"%@ -i %@", [format autorelease], session]; } /** -- 2.22.5