54 lines
792 B
C++
Executable File
54 lines
792 B
C++
Executable File
#include "master.hpp"
|
|
|
|
namespace factor
|
|
{
|
|
|
|
/* If memory allocation fails, bail out */
|
|
vm_char *safe_strdup(const vm_char *str)
|
|
{
|
|
vm_char *ptr = STRDUP(str);
|
|
if(!ptr) fatal_error("Out of memory in safe_strdup", 0);
|
|
return ptr;
|
|
}
|
|
|
|
/* We don't use printf directly, because format directives are not portable.
|
|
Instead we define the common cases here. */
|
|
void nl()
|
|
{
|
|
fputs("\n",stdout);
|
|
}
|
|
|
|
void print_string(const char *str)
|
|
{
|
|
fputs(str,stdout);
|
|
}
|
|
|
|
void print_cell(cell x)
|
|
{
|
|
printf(CELL_FORMAT,x);
|
|
}
|
|
|
|
void print_cell_hex(cell x)
|
|
{
|
|
printf(CELL_HEX_FORMAT,x);
|
|
}
|
|
|
|
void print_cell_hex_pad(cell x)
|
|
{
|
|
printf(CELL_HEX_PAD_FORMAT,x);
|
|
}
|
|
|
|
void print_fixnum(fixnum x)
|
|
{
|
|
printf(FIXNUM_FORMAT,x);
|
|
}
|
|
|
|
cell read_cell_hex()
|
|
{
|
|
cell cell;
|
|
if(scanf(CELL_HEX_FORMAT,&cell) < 0) exit(1);
|
|
return cell;
|
|
}
|
|
|
|
}
|