mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Minor fix for zombies and new tool added.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13363 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c66d2c6427
commit
622cacf55f
8 changed files with 156 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
|||
2002-04-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* 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 <mguesdon@orange-concept.com>
|
||||
|
||||
* Tools/gsdoc.m: corrected inversed test for missing entities
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
137
Tools/cvtenc.m
Normal file
137
Tools/cvtenc.m
Normal file
|
@ -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 <richard@brainstorm.co.uk>
|
||||
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 <Foundation/Foundation.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue