Bug fixes to get checks programs to work.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1997-09-23 14:03:36 +00:00
parent 4f2ef3f7ec
commit f460d097cd
10 changed files with 70 additions and 47 deletions

View file

@ -1,3 +1,27 @@
Mon Sep 22 17:14:32 1997 Adam Fedor <fedor@doc.com>
* checks/NSData-test.m: Change main to return int.
* checks/coder.m: Check for nil names -- Solaris can't print NULL
strings.
* checks/nsattributedstring.m: Add test to main.
* checks/values.m: Remove exception handlers.
* doc/coding-standards.texi: New file.
* doc/Makefile.in: Add new texi file, CODING-STANDARDS target..
* src/Collection.m ([ConstantCollection
-_collectionReleaseContents]): Release only if count > 0.
* src/Set.m ([Set dealoc]): Set contents_hash to 0 and call super.
* src/Set.m ([Set count]): If !contents_hash return 0;
* src/Makefile.in: remove extra Collection.m.
* src/NSArray.m ([NSArray -initWithObjects:rest:]): REALLOC before
overflow of array.
* src/NSConcreteValue.m ([NSConcreteValue -initValue:withObjCType:]):
Change exceptions to NSLog and return nil.
Fri Sep 22 09:50:52 2017 Scott Christley <scottc@net-community.com>
* src/NSArray (initWithObjects:rest:): Fix count.

View file

@ -675,18 +675,21 @@
- (void) _collectionReleaseContents
{
int c = [self count];
id *array = (id*) alloca (c * sizeof(id));
int i = 0;
void *es = [self newEnumState];
id o;
while ((o = [self nextObjectWithEnumState:&es]))
if (c)
{
array[i++] = o;
id *array = (id*) alloca (c * sizeof(id));
int i = 0;
void *es = [self newEnumState];
id o;
while ((o = [self nextObjectWithEnumState:&es]))
{
array[i++] = o;
}
[self freeEnumState: &es];
assert (c == i);
for (i = 0; i < c; i++)
[array[i] release];
}
[self freeEnumState: &es];
assert (c == i);
for (i = 0; i < c; i++)
[array[i] release];
}
- (void) _collectionDealloc

View file

@ -135,7 +135,6 @@ BinaryTreeNode.m \
CircularArray.m \
Collection.m \
ConnectedCoder.m \
Connection.m \
Coder.m \
Connection.m \
CStream.m \

View file

@ -175,7 +175,7 @@ static Class NSMutableArray_concrete_class;
objsArray[i] = tmpId;
/* If the index equals the current size, increase size. */
if (i == curSize)
if (i == curSize - 1)
{
/* Fibonacci series. Supposedly, for this application,
* the fibonacci series will be more memory efficient.

View file

@ -65,22 +65,24 @@
{
int size;
if (!value || !type) {
[NSException raise:NSInvalidArgumentException
format:@"Cannot create with NULL value or NULL type"];
/* NOT REACHED */
}
if (!value || !type)
{
NSLog(@"Tried to create NSValue with NULL value or NULL type");
[self release];
return nil;
}
self = [super init];
// FIXME: objc_sizeof_type will abort when it finds an invalid type, when
// we really want to just raise an exception
size = objc_sizeof_type(type);
if (size <= 0) {
[NSException raise:NSInternalInconsistencyException
format:@"Invalid Objective-C type"];
/* NOT REACHED */
}
if (size <= 0)
{
NSLog(@"Tried to create NSValue with invalid Objective-C type");
[self release];
return nil;
}
data = (void *)NSZoneMalloc([self zone], size);
NS_CHECK_MALLOC(data)
@ -92,9 +94,11 @@
- (void)dealloc
{
if (objctype)
[objctype release];
if (data)
NSZoneFree([self zone], data);
[super dealloc];
[super dealloc];
}
// Accessing Data

View file

@ -80,7 +80,8 @@
- (void) dealloc
{
NSFreeHashTable (_contents_hash);
[super _collectionDealloc];
_contents_hash = 0;
[super dealloc];
}
// SET OPERATIONS;
@ -180,6 +181,8 @@
- (unsigned) count
{
if (!_contents_hash)
return 0;
return NSCountHashTable (_contents_hash);
}

View file

@ -377,7 +377,7 @@ NS_ENDHANDLER
printf("2) String: (%s)\n", str);
}
void
int
main(int argc,
char **argv)
{
@ -386,4 +386,5 @@ main(int argc,
/* Test NSData. */
TestNSData();
return 0;
}

View file

@ -69,11 +69,17 @@ int main(int argc, char *argv[])
/* Read in the Array */
[archiver decodeObjectAt: &array withName: &name];
printf ("got object named %s\n", [name cStringNoCopy]);
if (name)
printf ("got object named %s\n", [name cStringNoCopy]);
else
printf ("got object named (unnamed)\n");
/* Read in the Dictionary */
[archiver decodeObjectAt: &dictionary withName: &name];
printf ("got object named %s\n", [name cStringNoCopy]);
if (name)
printf ("got object named %s\n", [name cStringNoCopy]);
else
printf ("got object named (unnamed)\n");
/* Display what we read, to make sure it matches what we wrote */
[array printForDebugger];

View file

@ -114,9 +114,9 @@ void testAttributedString(void)
printAttrString([muAttrString2 attributedSubstringFromRange:NSMakeRange(10,7)]);
}
/* xxx umm this file needs a main */
int
main()
{
testAttributedString();
exit(0);
}

View file

@ -41,24 +41,7 @@ int main()
[[v1 nonretainedObjectValue] getValue:&p];
printf("point is %f %f\n", p.x, p.y);
// Exceptions
NS_DURING
NS_DURING
v2 = [NSValue value:NULL withObjCType:@encode(int)];
NS_HANDLER
printf("Caught our exception, name %s and reason: %s\n",
[[localException name] cString],
[[localException reason] cString]);
[localException raise];
NS_ENDHANDLER
NS_HANDLER
printf("Caught our reraised exception, name %s and reason: %s\n",
[[localException name] cString],
[[localException reason] cString]);
NS_ENDHANDLER
printf("Try getting a null NSValue, should get a NSLog error message:\n");
v2 = [NSValue value:NULL withObjCType:@encode(int)];
return 0;
}