Skip to content

Commit

Permalink
Fixed a bug in pointer coercion which was breaking string functions.
Browse files Browse the repository at this point in the history
git-svn-id: http://picoc.googlecode.com/svn/trunk@350 21eae674-98b7-11dd-bd71-f92a316d2d60
  • Loading branch information
zik.saleeba committed Oct 26, 2009
1 parent 1239d6d commit b0c74d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions clibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void GenericPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct
NextArg = (struct Value *)((char *)NextArg + sizeof(struct Value) + TypeStackSizeValue(NextArg));
if (NextArg->Typ != FormatType &&
!((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) ) ) )
PrintStr("XXX", Stream); /* bad type for format */
else
Expand All @@ -257,7 +257,7 @@ void GenericPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct
{
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
struct Value *CharArray = NextArg->Val->Pointer.Segment;
Expand Down
2 changes: 1 addition & 1 deletion expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
ToValue->Val->Pointer.Offset = 0;
DerefVal = FromValue;
#else
ToValue->Val->NativePointer = FromValue;
ToValue->Val->NativePointer = FromValue->Val->Array.Data;
#endif
}
else if (FromValue->Typ->Base == TypePointer && FromValue->Typ->FromType->Base == TypeArray && PointedToType == FromValue->Typ->FromType->FromType)
Expand Down

0 comments on commit b0c74d8

Please sign in to comment.