Browse code

really fix non-working code and other stupids... <sigh>

Nat! authored on 30/06/2015 11:49:39
Showing 4 changed files
... ...
@@ -194,7 +194,7 @@ static int   intValue( NSString *string)
194 194
    char  *s;
195 195
    int   i;
196 196
    
197
-   string = [NSCharacterSet whitespaceAndNewlineCharacterSet];  // gratuitous
197
+   string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];  // gratuitous
198 198
    string = [string lowercaseString];
199 199
    
200 200
    s = (char *) [string cString];
... ...
@@ -249,7 +249,7 @@ int main(int argc, const char * argv[])
249 249
    
250 250
    while( option = [rover nextObject])
251 251
    {
252
-      if( ! [option length] < 2 || ! [option hasPrefix:@"-"])
252
+      if( [option length] < 2 || ! [option hasPrefix:@"-"])
253 253
          goto usage;
254 254
       c = [option characterAtIndex:1];
255 255
       s = [rover nextObject];
... ...
@@ -98,7 +98,6 @@ int main(int argc, const char * argv[])
98 98
    NSEnumerator          *rover;
99 99
    NSFileManager         *fileManager;
100 100
    NSMutableDictionary   *dictionary;
101
-   NSDictionary          *environment;
102 101
    NSProcessInfo         *processInfo;
103 102
    NSString              *cdir;
104 103
    NSString              *key;
... ...
@@ -132,9 +131,6 @@ int main(int argc, const char * argv[])
132 132
                      forKey:key];
133 133
    }
134 134
    
135
-   processInfo = [NSProcessInfo processInfo];
136
-   environment = [processInfo environment];
137
-   
138 135
    write_plist( dictionary, stdout);
139 136
 
140 137
    return( 0);
... ...
@@ -242,10 +242,10 @@ static id  _parse_object( char **s, unsigned int *len)
242 242
 static id  parse_old_plist( NSData *data)
243 243
 {
244 244
    char         *s;
245
-   NSUInteger   len;
245
+   unsigned int len;
246 246
    
247 247
    s   = (char *) [data bytes];
248
-   len = [data length];
248
+   len = (unsigned int) [data length];
249 249
    return( _parse_object( &s, &len));
250 250
 }
251 251
 
... ...
@@ -18,7 +18,7 @@ NSString *MullePlistWriterException = @"MullePlistWriterException";
18 18
                           indent:(NSData *) indent
19 19
 {
20 20
    [NSException raise:MullePlistWriterException
21
-               format:@"Objects of class %@ can't be saved in a plist", isa];
21
+               format:@"Objects of class %@ can't be saved in a plist", [self class]];
22 22
 }
23 23
 
24 24
 @end
... ...
@@ -50,24 +50,28 @@ static inline char	hexit( unsigned char c)
50 50
    NSMutableData   *buffer;
51 51
    char            *hex;
52 52
    unsigned char   *s;
53
+   unsigned char   *sentinel;
53 54
    NSUInteger      len;
54 55
    NSUInteger      i;
55 56
    
56 57
    len    = [self length];
57 58
    buffer = [NSMutableData dataWithLength:len * 3 + 3];
58 59
    
59
-   hex = (char *) [buffer bytes];
60
-   s   = (unsigned char *) [self bytes];
61
-
60
+   hex    = (char *) [buffer bytes];
62 61
    *hex++ = '<';
62
+
63
+   s        = (unsigned char *) [self bytes];
64
+   sentinel = &s[ len];
65
+   
63 66
    i = 0;
64
-   while( len)
67
+   while( s < sentinel)
65 68
    {
66 69
       *hex++ = hexit( *s >> 4);
67 70
       *hex++ = hexit( *s & 0xF);
68
-      if( ! (++i & 0x3))
69
-         *hex++ = ' ';
70 71
       s++;
72
+      
73
+      if( ! (++i & 0x3) && s != sentinel)
74
+         *hex++ = ' ';
71 75
    }
72 76
    *hex++ = '>';
73 77
    
... ...
@@ -176,12 +180,12 @@ static inline char	hexit( unsigned char c)
176 176
 
177 177
    [data appendBytes:"("
178 178
               length:1];
179
-   n = [self count];
179
+   n = (unsigned int) [self count];
180 180
    if( n)
181 181
    {
182 182
       [data appendBytes:"\n"
183 183
                  length:1];
184
-      indent2 = [indent mutableCopy];
184
+      indent2 = [[indent mutableCopy] autorelease];
185 185
       [indent2 appendBytes:"   "
186 186
                     length:3];
187 187
       for( i = 0; i < n; i++)
... ...
@@ -232,7 +236,7 @@ static inline char	hexit( unsigned char c)
232 232
    [data appendBytes:"{"
233 233
               length:1];
234 234
    keys = [self allKeys];  // sort'em ?
235
-   n    = [keys count];
235
+   n    = (unsigned int) [keys count];
236 236
 
237 237
    if( n)
238 238
    {
... ...
@@ -240,7 +244,7 @@ static inline char	hexit( unsigned char c)
240 240
                  length:1];
241 241
 
242 242
 //      keys    = [keys sortedArrayUsingSelector:@selector( compare:)];
243
-      indent2 = [indent mutableCopy];
243
+      indent2 = [[indent mutableCopy] autorelease];
244 244
       [indent2 appendBytes:"   "
245 245
                     length:3];
246 246