Author: rfm
Date: Tue Jul 21 11:30:24 2015
New Revision: 38817
URL: http://svn.gna.org/viewcvs/gnustep?rev=38817&view=rev
Log:
improve instance id handling
Modified:
libs/ec/trunk/ChangeLog
libs/ec/trunk/EcProcess.h
libs/ec/trunk/EcProcess.m
Modified: libs/ec/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=38817&r1=38816&r2=38817&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog (original)
+++ libs/ec/trunk/ChangeLog Tue Jul 21 11:30:24 2015
@@ -1,4 +1,12 @@
+2015-07-21 Richard Frith-Macdonald <[email protected]>
+
+ * EcProcess.h:
+ * EcProcess.m:
+ Be more rigorous about checking instance id values. Ignore anything
+ other than a non-negative integer instance ID.
+
2015-07-15 Niels Grewe <[email protected]>
+
* EcMemoryLogger.h
* EcProcess.m:
Add the ability to load a bundle to export memory logs to. Configured
Modified: libs/ec/trunk/EcProcess.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.h?rev=38817&r1=38816&r2=38817&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.h (original)
+++ libs/ec/trunk/EcProcess.h Tue Jul 21 11:30:24 2015
@@ -215,7 +215,7 @@
* rather than changing.
* </desc>
* <term>EcInstance</term>
- * <desc>To set the program instance ID (an arbitrary string).<br />
+ * <desc>To set the program instance ID (a non-negative integer value).<br />
* If this is specified, the program name has a hyphen and the
* id appended to it by the '-initWithDefaults:' method.
* </desc>
@@ -801,6 +801,12 @@
*/
- (void) triggerCmdTimeout;
+/** Returns the base name for this process (before any instance ID was
+ * added). If the process has no instance ID, this returns the same as
+ * the -cmdName method.
+ */
+- (NSString*) cmdBase;
+
/** Deprecated ... use -cmdDefaults instead.
*/
- (id) cmdConfig: (NSString*)key;
@@ -818,6 +824,10 @@
*/
- (NSUserDefaults*) cmdDefaults;
+/** Returns the instance ID used for this process, or nil if there is none.
+ */
+- (NSString*) cmdInstance;
+
/** Utility method to perform partial (case insensitive) matching of
* an abbreviated command word (val) to a keyword (key)
*/
@@ -827,7 +837,7 @@
*/
- (NSString*) cmdMesg: (NSArray*)msg;
-/** Retrurns the name by which this process is known to the Command server.
+/** Returns the name by which this process is known to the Command server.
*/
- (NSString*) cmdName;
Modified: libs/ec/trunk/EcProcess.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=38817&r1=38816&r2=38817&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m (original)
+++ libs/ec/trunk/EcProcess.m Tue Jul 21 11:30:24 2015
@@ -125,6 +125,7 @@
static BOOL cmdIsRunning = NO;
static BOOL cmdKeepStderr = NO;
static NSInteger cmdQuitStatus = 0;
+static NSString *cmdBase = nil;
static NSString *cmdInst = nil;
static NSString *cmdName = nil;
static NSString *cmdUser = nil;
@@ -1169,6 +1170,11 @@
}
static NSString *noFiles = @"No log files to archive";
+
+- (NSString*) cmdBase
+{
+ return cmdBase;
+}
- (id) cmdConfig: (NSString*)key
{
@@ -3880,6 +3886,13 @@
ASSIGN(cmdName, [pinfo processName]);
}
+ /* This is the base name of the process (without instance)
+ */
+ if (nil == cmdBase)
+ {
+ ASSIGN(cmdBase, cmdName);
+ }
+
/*
* Make sure our users home directory exists.
*/
@@ -3977,7 +3990,19 @@
}
}
- ASSIGN(cmdInst, [cmdDefs stringForKey: @"Instance"]);
+ str = [[cmdDefs stringForKey: @"Instance"] stringByTrimmingSpaces];
+ if (nil != str)
+ {
+ if ([str length] > 0 && isdigit([str characterAtIndex: 0]))
+ {
+ str = [NSString stringWithFormat: @"%d", [str intValue]];
+ }
+ else
+ {
+ str = nil;
+ }
+ }
+ ASSIGN(cmdInst, str);
if (nil != cmdInst)
{
str = [[NSString alloc] initWithFormat: @"%@-%@", cmdName, cmdInst];
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs