Fixed a bug in pointer coercion which was breaking string functions.

git-svn-id: http://picoc.googlecode.com/svn/trunk@350 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-10-26 20:00:01 +00:00
parent 1239d6d8a8
commit b0c74d8c00
2 changed files with 3 additions and 3 deletions

View file

@ -246,7 +246,7 @@ void GenericPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct
NextArg = (struct Value *)((char *)NextArg + sizeof(struct Value) + TypeStackSizeValue(NextArg)); NextArg = (struct Value *)((char *)NextArg + sizeof(struct Value) + TypeStackSizeValue(NextArg));
if (NextArg->Typ != FormatType && if (NextArg->Typ != FormatType &&
!((FormatType == &IntType || *FPos == 'f') && IS_NUMERIC_COERCIBLE(NextArg)) && !((FormatType == &IntType || *FPos == 'f') && IS_NUMERIC_COERCIBLE(NextArg)) &&
!(FormatType == CharPtrType && ( (NextArg->Typ->Base == TypePointer && NextArg->Typ->FromType->Base == TypeArray && NextArg->Typ->FromType->FromType->Base == TypeChar) || !(FormatType == CharPtrType && (NextArg->Typ->Base == TypePointer ||
(NextArg->Typ->Base == TypeArray && NextArg->Typ->FromType->Base == TypeChar) ) ) ) (NextArg->Typ->Base == TypeArray && NextArg->Typ->FromType->Base == TypeChar) ) ) )
PrintStr("XXX", Stream); /* bad type for format */ PrintStr("XXX", Stream); /* bad type for format */
else else
@ -257,7 +257,7 @@ void GenericPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct
{ {
char *Str; char *Str;
if (NextArg->Typ == CharPtrType || (NextArg->Typ->Base == TypePointer && NextArg->Typ->FromType->Base == TypeArray && NextArg->Typ->FromType->FromType->Base == TypeChar) ) if (NextArg->Typ->Base == TypePointer)
{ {
#ifndef NATIVE_POINTERS #ifndef NATIVE_POINTERS
struct Value *CharArray = NextArg->Val->Pointer.Segment; struct Value *CharArray = NextArg->Val->Pointer.Segment;

View file

@ -312,7 +312,7 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
ToValue->Val->Pointer.Offset = 0; ToValue->Val->Pointer.Offset = 0;
DerefVal = FromValue; DerefVal = FromValue;
#else #else
ToValue->Val->NativePointer = FromValue; ToValue->Val->NativePointer = FromValue->Val->Array.Data;
#endif #endif
} }
else if (FromValue->Typ->Base == TypePointer && FromValue->Typ->FromType->Base == TypeArray && PointedToType == FromValue->Typ->FromType->FromType) else if (FromValue->Typ->Base == TypePointer && FromValue->Typ->FromType->Base == TypeArray && PointedToType == FromValue->Typ->FromType->FromType)