printf() now works!

Fixed a bug in pointer sizing.


git-svn-id: http://picoc.googlecode.com/svn/trunk@98 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-02-21 12:02:15 +00:00
parent 4821d689ad
commit 7f6503d1e0
5 changed files with 10 additions and 11 deletions

View file

@ -175,16 +175,14 @@ void IntrinsicInit(struct Table *GlobalTable)
} }
} }
#if 0
void IntrinsicHostPrintf(const char *Format, ...) void IntrinsicHostPrintf(const char *Format, ...)
{ {
va_list Args; va_list Args;
va_start(Args, Format); va_start(Args, Format);
vStrPrintf(Format, Args); IntrinsicHostVPrintf(Format, Args);
va_end(Args); va_end(Args);
} }
#endif
/* printf for compiler error reporting */ /* printf for compiler error reporting */
void IntrinsicHostVPrintf(const char *Format, va_list Args) void IntrinsicHostVPrintf(const char *Format, va_list Args)

12
picoc.c
View file

@ -15,11 +15,11 @@ void ProgramFail(struct ParseState *Parser, const char *Message, ...)
va_list Args; va_list Args;
if (Parser != NULL) if (Parser != NULL)
printf("%s:%d: ", Parser->FileName, Parser->Line); IntrinsicHostPrintf("%s:%d: ", Parser->FileName, Parser->Line);
va_start(Args, Message); va_start(Args, Message);
vprintf(Message, Args); IntrinsicHostVPrintf(Message, Args);
printf("\n"); IntrinsicHostPrintf("\n");
exit(1); exit(1);
} }
@ -28,10 +28,10 @@ void LexFail(struct LexState *Lexer, const char *Message, ...)
{ {
va_list Args; va_list Args;
printf("%s:%d: ", Lexer->FileName, Lexer->Line); IntrinsicHostPrintf("%s:%d: ", Lexer->FileName, Lexer->Line);
va_start(Args, Message); va_start(Args, Message);
vprintf(Message, Args); IntrinsicHostVPrintf(Message, Args);
printf("\n"); IntrinsicHostPrintf("\n");
exit(1); exit(1);
} }

View file

@ -262,6 +262,7 @@ struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *P
/* intrinsic.c */ /* intrinsic.c */
void IntrinsicInit(struct Table *GlobalTable); void IntrinsicInit(struct Table *GlobalTable);
void IntrinsicHostPrintf(const char *Format, ...);
void IntrinsicHostVPrintf(const char *Format, va_list Args); void IntrinsicHostVPrintf(const char *Format, va_list Args);
/* heap.c */ /* heap.c */

View file

@ -8,7 +8,7 @@ char *StrEmpty = NULL;
/* initialise the shared string system */ /* initialise the shared string system */
void TableInit() void TableInit()
{ {
TableInit(&StringTable, &StringHashTable[0], STRING_TABLE_SIZE, TRUE); TableInitTable(&StringTable, &StringHashTable[0], STRING_TABLE_SIZE, TRUE);
StrEmpty = TableStrRegister(""); StrEmpty = TableStrRegister("");
} }

2
type.c
View file

@ -97,7 +97,7 @@ void TypeInit()
TypeAddBaseType(&MacroType, TypeMacro, sizeof(int)); TypeAddBaseType(&MacroType, TypeMacro, sizeof(int));
TypeAddBaseType(&Type_Type, TypeType, sizeof(struct ValueType *)); TypeAddBaseType(&Type_Type, TypeType, sizeof(struct ValueType *));
TypeAddBaseType(&CharType, TypeChar, sizeof(char)); TypeAddBaseType(&CharType, TypeChar, sizeof(char));
CharPtrType = TypeAdd(NULL, &CharType, TypePointer, 0, StrEmpty, sizeof(char)); CharPtrType = TypeAdd(NULL, &CharType, TypePointer, 0, StrEmpty, sizeof(struct PointerValue));
CharArrayType = TypeAdd(NULL, &CharType, TypeArray, 0, StrEmpty, sizeof(char)); CharArrayType = TypeAdd(NULL, &CharType, TypeArray, 0, StrEmpty, sizeof(char));
} }