mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Tolerate either float or double in archives.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27949 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3783bd74af
commit
682121bebe
2 changed files with 37 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-02-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSUnarchiver.m:
|
||||
make float and double interchangable to cope with MacOS-X 10.5
|
||||
API which can use either for CGFloat.
|
||||
|
||||
2009-02-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/mframe/i386/linux:
|
||||
|
|
|
@ -220,6 +220,11 @@ typeCheck(char t1, char t2)
|
|||
|| t1 == _C_ULNG_LNG
|
||||
#endif
|
||||
)) return;
|
||||
/* HACK also allow float and double to be used interchangably as MacOS-X
|
||||
* intorduced CGFloat, which may be aither a float or a double.
|
||||
*/
|
||||
if ((c == _C_FLT || c == _C_DBL) && (t1 == _C_FLT || t1 == _C_DBL))
|
||||
return;
|
||||
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"expected %s and got %s",
|
||||
|
@ -990,12 +995,36 @@ static Class NSDataMallocClass;
|
|||
#endif
|
||||
case _GSC_FLT:
|
||||
typeCheck(*type, _GSC_FLT);
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
if (*type == _C_FLT)
|
||||
{
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
float val;
|
||||
|
||||
/* We found a float when expecting a double ... handle it.
|
||||
*/
|
||||
(*desImp)(src, desSel, &val, @encode(float), &cursor, nil);
|
||||
*(double*)address = (double)val;
|
||||
}
|
||||
return;
|
||||
|
||||
case _GSC_DBL:
|
||||
typeCheck(*type, _GSC_DBL);
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
if (*type == _C_DBL)
|
||||
{
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
double val;
|
||||
|
||||
/* We found a double when expecting a float ... handle it.
|
||||
*/
|
||||
(*desImp)(src, desSel, &val, @encode(double), &cursor, nil);
|
||||
*(float*)address = (float)val;
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue