Gotta go to work now so I'll just post the code with a TODO at the bottom explaining what I need to do,
if any of ya got suggestions then please post 'em, either way I'll try again 2mw, 2nite I'll hafta go straight to sleep for early morning work 2mw
Code:
typedef struct _literaln {
char type[4];
size_t base;
uint_fast64_t width;
int_least64_t sig;
uint_least64_t num;
long double fpn;
} LITERALN;
...
void puti( FILE *file, LITERALN _literaln ) {
if ( _literaln.type[1] == U'u' ) {
switch (_literaln.type[2]) {
case U'l':
if ( _literaln.type[3] == U'l' )
fprintf( file, "(unsigned) %lluull", (ullong)(_literaln.num) );
else
fprintf( file, "(unsigned) %luul", (ulong)(_literaln.num) );
return;
case U'h':
if ( _literaln.type[3] == U'h' )
fprintf( file, "(unsigned) %hhuuhh", (uchar)(_literaln.num) );
else
fprintf( file, "(unsigned) %huuh", (ushort)(_literaln.num) );
return;
default:
if ( _literaln.type[2] == U'i' ) {
if ( _literaln.width != bitsof(int) )
fprintf( file, "(unsigned) %lluui%u",
(ullong)(_literaln.num), (uint)_literaln.width );
else
fprintf( file, "(unsigned) %uui", (uint)(_literaln.num) );
}
else
fprintf( file, "(unsigned) %uu", (uint)(_literaln.num) );
return;
}
}
else {
switch (_literaln.type[2]) {
case U'l':
if ( _literaln.type[3] == U'l' )
fprintf( file, "(signed) %lldll", (sllong)(_literaln.num) );
else
fprintf( file, "(signed) %ldl", (long)(_literaln.num) );
return;
case U'h':
if ( _literaln.type[3] == U'h' )
fprintf( file, "(signed) %hhdhh", (schar)(_literaln.num) );
else
fprintf( file, "(signed) %hdh", (short)(_literaln.num) );
return;
default:
if ( _literaln.type[2] == U'i' ) {
if ( _literaln.width != bitsof(int) )
break;
else
fprintf( file, "(signed) %di", (int)(_literaln.num) );
}
else
fprintf( file, "(signed) %d", (int)(_literaln.num) );
return;
}
}
// TODO: Interpret negative values correctly
fprintf( file, "(signed) %lldi%u",
(sllong)(_literaln.num), (uint)_literaln.width );
}