diff --git a/ChangeLog b/ChangeLog index d984972e4..20fe4955b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-04-05 Richard Frith-Macdonald + + * Source/NSObject.m: Fix locking bug with NSZombie ... was not + locking when adding/removing zombies. + * Tools/ctvenc.m: new tool for converting string encodings. + 2002-03-28 Manuel Guesdon * Tools/gsdoc.m: corrected inversed test for missing entities diff --git a/Source/NSObject.m b/Source/NSObject.m index f3fb8cc22..a57e20af1 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -85,12 +85,12 @@ static void GSMakeZombie(NSObject *o) ((id)o)->class_pointer = zombieClass; if (NSDeallocateZombies == NO) { - if (allocationLock == 0) + if (allocationLock != 0) { objc_mutex_lock(allocationLock); } NSMapInsert(zombieMap, (void*)o, (void*)c); - if (allocationLock == 0) + if (allocationLock != 0) { objc_mutex_unlock(allocationLock); } @@ -103,12 +103,12 @@ static void GSLogZombie(id o, SEL sel) if (NSDeallocateZombies == NO) { - if (allocationLock == 0) + if (allocationLock != 0) { objc_mutex_lock(allocationLock); } c = NSMapGet(zombieMap, (void*)o); - if (allocationLock == 0) + if (allocationLock != 0) { objc_mutex_unlock(allocationLock); } diff --git a/Testing/basic.m b/Testing/basic.m index 88fbea9cf..f9aa69f9f 100644 --- a/Testing/basic.m +++ b/Testing/basic.m @@ -7,8 +7,12 @@ int main () { id pool = [NSAutoreleasePool new]; id o = [NSObject new]; + NSArray *a = [NSArray arrayWithObjects: @"a", @"b", nil]; + printf ("Hello from object at 0x%x\n", (unsigned)[o self]); + NSLog(@"Value for foo is %@", [a valueForKey: @"foo"]); + [o release]; o = [NSString stringWithFormat: @"/proc/%d/status", getpid()]; NSLog(@"'%@'", o); diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index b2cb6031c..b79214f09 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -40,7 +40,7 @@ doctemplatesdir = $(GNUSTEP_RESOURCES)/DocTemplates DOCTEMPLATES_FILES = indextemplate.gsdoc AutoDocTemplate.gsdoc # The application to be compiled -TOOL_NAME = autogsdoc gdnc gsdoc defaults plmerge \ +TOOL_NAME = autogsdoc cvtenc gdnc gsdoc defaults plmerge \ plparse sfparse pldes plser pl2link HTMLLinker CTOOL_NAME = gdomap @@ -48,6 +48,7 @@ TEST_TOOL_NAME = locale_alias # The source files to be compiled autogsdoc_OBJC_FILES = autogsdoc.m AGSParser.m AGSOutput.m AGSIndex.m AGSHtml.m +cvtenc_OBJC_FILES = cvtenc.m gdomap_C_FILES = gdomap.c gdnc_OBJC_FILES = gdnc.m gsdoc_OBJC_FILES = gsdoc.m diff --git a/Tools/cvtenc.m b/Tools/cvtenc.m new file mode 100644 index 000000000..ce377cf91 --- /dev/null +++ b/Tools/cvtenc.m @@ -0,0 +1,137 @@ +/* This tool converts a file containing a string to a C String encoding. + Copyright (C) 2002 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + Created: April 2002 + + This file is part of the GNUstep Project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + You should have received a copy of the GNU General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int +main(int argc, char** argv, char **env) +{ + NSAutoreleasePool *pool; + NSProcessInfo *proc; + NSArray *args; + unsigned i; + +#ifdef GS_PASS_ARGUMENTS + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; +#endif + pool = [NSAutoreleasePool new]; + proc = [NSProcessInfo processInfo]; + if (proc == nil) + { + NSLog(@"defaults: unable to get process information!\n"); + [pool release]; + exit(0); + } + + args = [proc arguments]; + + if ([args count] <= 1) + { + NSLog(@"No file names given to convert."); + } + else + { + NSString *n; + NSStringEncoding enc = 0; + + n = [[NSUserDefaults standardUserDefaults] stringForKey: @"Encoding"]; + if (n == nil) + { + enc = [NSString defaultCStringEncoding]; + } + else + { + NSStringEncoding *e; + NSMutableString *names; + + names = [NSMutableString stringWithCapacity: 1024]; + e = [NSString availableStringEncodings]; + while (*e != 0) + { + NSString *name = [NSString localizedNameOfStringEncoding: *e]; + + [names appendFormat: @" %@\n", name]; + if ([n isEqual: name] == YES) + { + enc = *e; + break; + } + e++; + } + if (enc == 0) + { + NSLog(@"defaults: unable to find encoding '%@'!\n" + @"Known encoding names are -\n%@", n, names); + [pool release]; + exit(0); + } + } + + for (i = 1; i < [args count]; i++) + { + NSString *file = [args objectAtIndex: i]; + + if ([file isEqual: @"-Encoding"] == YES) + { + i++; + continue; + } + NS_DURING + { + NSData *myData; + NSString *myString; + + myString = [NSString stringWithContentsOfFile: file]; + myData = [myString dataUsingEncoding: enc + allowLossyConversion: NO]; + if (myData == nil) + { + NSLog(@"Encoding conversion failed.", file); + } + else + { + NSFileHandle *out; + + out = [NSFileHandle fileHandleWithStandardOutput]; + [out writeData: myData]; + [out synchronizeFile]; + } + } + NS_HANDLER + { + NSLog(@"Converting '%@' - %@", file, [localException reason]); + } + NS_ENDHANDLER + } + } + [pool release]; + return 0; +} diff --git a/Tools/pldes.m b/Tools/pldes.m index 5bed6f90b..04862df16 100644 --- a/Tools/pldes.m +++ b/Tools/pldes.m @@ -46,7 +46,7 @@ main(int argc, char** argv, char **env) proc = [NSProcessInfo processInfo]; if (proc == nil) { - NSLog(@"defaults: unable to get process information!\n"); + NSLog(@"pldes: unable to get process information!\n"); [pool release]; exit(0); } diff --git a/Tools/plparse.m b/Tools/plparse.m index 087a0b1a9..a5584b0ac 100644 --- a/Tools/plparse.m +++ b/Tools/plparse.m @@ -44,7 +44,7 @@ main(int argc, char** argv, char **env) proc = [NSProcessInfo processInfo]; if (proc == nil) { - NSLog(@"defaults: unable to get process information!\n"); + NSLog(@"plparse: unable to get process information!\n"); [pool release]; exit(0); } diff --git a/Tools/plser.m b/Tools/plser.m index 833be11f0..11b6dfe9e 100644 --- a/Tools/plser.m +++ b/Tools/plser.m @@ -46,7 +46,7 @@ main(int argc, char** argv, char **env) proc = [NSProcessInfo processInfo]; if (proc == nil) { - NSLog(@"defaults: unable to get process information!\n"); + NSLog(@"plser: unable to get process information!\n"); [pool release]; exit(0); }