mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Fix portability of [un]signed char encodings
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9921 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
576ccea03a
commit
ac7eae4414
9 changed files with 41 additions and 13 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2001-05-11 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSArchiver.m ([NSArchiver -encodeValueOfObjCType:at:]): Use
|
||||||
|
signed char to encode _C_CHR.
|
||||||
|
* Source/NSPortCoder.m ([NSPortCoder -decodeValueOfObjCType:at:]):
|
||||||
|
Be lenient about decoding [un]signed chars.
|
||||||
|
* Source/NSUnarchiver.m: Likewise.
|
||||||
|
* Source/GSTemplateValue.m (-encodeWithCoder:): Use signed char to
|
||||||
|
encode/decode type info.
|
||||||
|
* Source/GSValue.m: Likewise.
|
||||||
|
* Source/NSConcreteNumber.m: Likewise.
|
||||||
|
* Source/NSNumber.m: Likewise.
|
||||||
|
* Source/NSValue.m: Likewise.
|
||||||
|
|
||||||
2001-05-10 Richard Frith-Macdonald <rfm@gnu.org>
|
2001-05-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSConnection.m: Use respondsToSelector rather than respondsTo
|
* Source/NSConnection.m: Use respondsToSelector rather than respondsTo
|
||||||
|
|
|
@ -255,7 +255,7 @@
|
||||||
const char *objctype = @encode(TYPE_NAME);
|
const char *objctype = @encode(TYPE_NAME);
|
||||||
unsigned size = strlen(objctype)+1;
|
unsigned size = strlen(objctype)+1;
|
||||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
[coder encodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||||
[coder encodeValueOfObjCType: @encode(TYPE_NAME) at: &data];
|
[coder encodeValueOfObjCType: @encode(TYPE_NAME) at: &data];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ typeSize(const char* type)
|
||||||
|
|
||||||
size = strlen(objctype)+1;
|
size = strlen(objctype)+1;
|
||||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
[coder encodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||||
size = (unsigned)typeSize(objctype);
|
size = (unsigned)typeSize(objctype);
|
||||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
[coder encodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
|
[coder encodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
|
||||||
|
@ -260,7 +260,7 @@ typeSize(const char* type)
|
||||||
|
|
||||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
objctype = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
objctype = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||||
[coder decodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
[coder decodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||||
[coder decodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
|
[coder decodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
|
||||||
|
|
|
@ -518,7 +518,7 @@ static Class NSMutableDataMallocClass;
|
||||||
|
|
||||||
case _C_CHR:
|
case _C_CHR:
|
||||||
(*_tagImp)(_dst, tagSel, _GSC_CHR);
|
(*_tagImp)(_dst, tagSel, _GSC_CHR);
|
||||||
(*_serImp)(_dst, serSel, (void*)buf, @encode(char), nil);
|
(*_serImp)(_dst, serSel, (void*)buf, @encode(signed char), nil);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case _C_UCHR:
|
case _C_UCHR:
|
||||||
|
|
|
@ -447,7 +447,7 @@
|
||||||
{
|
{
|
||||||
const char *t = @encode(TYPE_TYPE);
|
const char *t = @encode(TYPE_TYPE);
|
||||||
|
|
||||||
[coder encodeValueOfObjCType: @encode(char) at: t];
|
[coder encodeValueOfObjCType: @encode(signed char) at: t];
|
||||||
[coder encodeValueOfObjCType: t at: &data];
|
[coder encodeValueOfObjCType: t at: &data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2274,7 +2274,7 @@ static Class doubleNumberClass;
|
||||||
{
|
{
|
||||||
const char *t = [self objCType];
|
const char *t = [self objCType];
|
||||||
|
|
||||||
[coder encodeValueOfObjCType: @encode(char) at: t];
|
[coder encodeValueOfObjCType: @encode(signed char) at: t];
|
||||||
[coder encodeValueOfObjCType: t at: [self pointerValue]];
|
[coder encodeValueOfObjCType: t at: [self pointerValue]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2296,7 +2296,7 @@ static Class doubleNumberClass;
|
||||||
double d;
|
double d;
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
[coder decodeValueOfObjCType: @encode(char) at: t];
|
[coder decodeValueOfObjCType: @encode(signed char) at: t];
|
||||||
t[1] = '\0';
|
t[1] = '\0';
|
||||||
[coder decodeValueOfObjCType: t at: &data];
|
[coder decodeValueOfObjCType: t at: &data];
|
||||||
switch (*t)
|
switch (*t)
|
||||||
|
|
|
@ -835,7 +835,14 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
||||||
|
|
||||||
case _GSC_CHR:
|
case _GSC_CHR:
|
||||||
case _GSC_UCHR:
|
case _GSC_UCHR:
|
||||||
typeCheck(*type, info & _GSC_MASK);
|
/* Encoding of chars is not consistant across platforms, so we
|
||||||
|
loosen the type checking a little */
|
||||||
|
if (*type != type_map[_GSC_CHR] && *type != type_map[_GSC_UCHR])
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"expected %s and got %s",
|
||||||
|
typeToName1(*type), typeToName2(info)];
|
||||||
|
}
|
||||||
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1559,7 +1566,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
||||||
|
|
||||||
case _C_CHR:
|
case _C_CHR:
|
||||||
(*_eTagImp)(_dst, eTagSel, _GSC_CHR);
|
(*_eTagImp)(_dst, eTagSel, _GSC_CHR);
|
||||||
(*_eSerImp)(_dst, eSerSel, (void*)buf, @encode(char), nil);
|
(*_eSerImp)(_dst, eSerSel, (void*)buf, @encode(signed char), nil);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case _C_UCHR:
|
case _C_UCHR:
|
||||||
|
|
|
@ -795,7 +795,14 @@ static Class NSDataMallocClass;
|
||||||
|
|
||||||
case _GSC_CHR:
|
case _GSC_CHR:
|
||||||
case _GSC_UCHR:
|
case _GSC_UCHR:
|
||||||
typeCheck(*type, info & _GSC_MASK);
|
/* Encoding of chars is not consistant across platforms, so we
|
||||||
|
loosen the type checking a little */
|
||||||
|
if (*type != type_map[_GSC_CHR] && *type != type_map[_GSC_UCHR])
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"expected %s and got %s",
|
||||||
|
typeToName1(*type), typeToName2(info)];
|
||||||
|
}
|
||||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ static NSLock *placeholderLock;
|
||||||
|
|
||||||
size = strlen(objctype)+1;
|
size = strlen(objctype)+1;
|
||||||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
[coder encodeArrayOfObjCType: @encode(char) count: size at: objctype];
|
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||||
size = objc_sizeof_type(objctype);
|
size = objc_sizeof_type(objctype);
|
||||||
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||||
[self getValue: (void*)data];
|
[self getValue: (void*)data];
|
||||||
|
@ -384,7 +384,7 @@ static NSLock *placeholderLock;
|
||||||
|
|
||||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
objctype = (void*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
objctype = (void*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||||
[coder decodeArrayOfObjCType: @encode(char) count: size at: (void*)objctype];
|
[coder decodeArrayOfObjCType: @encode(signed char) count: size at: (void*)objctype];
|
||||||
c = [abstractClass valueClassWithObjCType: objctype];
|
c = [abstractClass valueClassWithObjCType: objctype];
|
||||||
o = [c alloc];
|
o = [c alloc];
|
||||||
/*
|
/*
|
||||||
|
@ -445,7 +445,7 @@ static NSLock *placeholderLock;
|
||||||
|
|
||||||
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
[coder decodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||||
objctype = (void*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
objctype = (void*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||||
[coder decodeArrayOfObjCType: @encode(char) count: size at: (void*)objctype];
|
[coder decodeArrayOfObjCType: @encode(signed char) count: size at: (void*)objctype];
|
||||||
c = [abstractClass valueClassWithObjCType: objctype];
|
c = [abstractClass valueClassWithObjCType: objctype];
|
||||||
o = [c alloc];
|
o = [c alloc];
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue