1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 02:30:44 +00:00

Added GT_AsString().

git-svn-id: svn://svn.cc65.org/cc65/trunk@5255 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-08-21 20:04:27 +00:00
parent cc486bb4f5
commit 6583320b79
2 changed files with 27 additions and 0 deletions

View File

@ -79,6 +79,30 @@ unsigned GT_GetArraySize (StrBuf* Type)
void GT_AsString (const StrBuf* Type, StrBuf* String)
/* Convert the type into a readable representation */
{
static const char HexTab[16] = "0123456789ABCDEF";
unsigned I;
/* Convert Type into readable hex. String will have twice then length
* plus a terminator.
*/
SB_Realloc (String, 2 * SB_GetLen (Type) + 1);
SB_Clear (String);
for (I = 0; I < SB_GetLen (Type); ++I) {
unsigned char C = SB_AtUnchecked (Type, I);
SB_AppendChar (String, HexTab[(C & 0xF0) >> 4]);
SB_AppendChar (String, HexTab[(C & 0x0F) >> 0]);
}
/* Terminate the string so it can be used with string functions */
SB_Terminate (String);
}

View File

@ -136,6 +136,9 @@ unsigned GT_GetArraySize (StrBuf* Type);
* The index position will get moved past the array size.
*/
void GT_AsString (const StrBuf* Type, StrBuf* String);
/* Convert the type into a readable representation */
/* End of gentype.h */