/* __DATE__ */
static char *ftepp_predef_date(ftepp_t *context) {
- const struct tm *itime = NULL;
+ const struct tm *itime = nullptr;
char *value = (char*)mem_a(82);
time_t rtime;
/* __TIME__ */
static char *ftepp_predef_time(ftepp_t *context) {
- const struct tm *itime = NULL;
+ const struct tm *itime = nullptr;
char *value = (char*)mem_a(82);
time_t rtime;
/* singleton because we're allowed */
static GMQCC_INLINE char *(*ftepp_predef(const char *name))(ftepp_t *context) {
size_t i = ftepp_predef_index(name);
- return (i != 0) ? ftepp_predefs[i-1].func : NULL;
+ return (i != 0) ? ftepp_predefs[i-1].func : nullptr;
}
#define ftepp_tokval(f) ((f)->lex->tok.value)
return false;
}
- index = (int)strtol(ftepp_tokval(ftepp), NULL, 10);
+ index = (int)strtol(ftepp_tokval(ftepp), nullptr, 10);
if (ftepp_next(ftepp) != ']') {
ftepp_error(ftepp, "expected `]` in __VA_ARGS__ subscript");
static bool ftepp_define(ftepp_t *ftepp)
{
- ppmacro *macro = NULL;
+ ppmacro *macro = nullptr;
size_t l = ftepp_ctx(ftepp).line;
size_t i;
bool mathconstant = false;
/* user defined ones take precedence */
if (macro && mathconstant) {
ftepp_macro_delete(ftepp, ftepp_tokval(ftepp));
- macro = NULL;
+ macro = nullptr;
}
}
/* need to leave the last token up */
static bool ftepp_macro_call_params(ftepp_t *ftepp, macroparam **out_params)
{
- macroparam *params = NULL;
+ macroparam *params = nullptr;
pptoken *ptok;
macroparam mp;
size_t parens = 0;
if (!ftepp_skipallwhite(ftepp))
return false;
while (ftepp->token != ')') {
- mp.tokens = NULL;
+ mp.tokens = nullptr;
if (!ftepp_skipallwhite(ftepp))
return false;
while (parens || ftepp->token != ',') {
}
}
vec_push(params, mp);
- mp.tokens = NULL;
+ mp.tokens = nullptr;
if (ftepp->token == ')')
break;
if (ftepp->token != ',') {
else {
ppmacro *find = ftepp_macro_find(ftepp, out->value);
if (OPTS_FLAG(FTEPP_INDIRECT_EXPANSION) && find && !find->has_params)
- ftepp_macro_expand(ftepp, find, NULL, false);
+ ftepp_macro_expand(ftepp, find, nullptr, false);
else
ftepp_out(ftepp, out->value, false);
}
static bool ftepp_preprocess(ftepp_t *ftepp);
static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params, bool resetline)
{
- char *buffer = NULL;
+ char *buffer = nullptr;
char *old_string = ftepp->output_string;
char *inner_string;
lex_file *old_lexer = ftepp->lex;
if (!vec_size(macro->output))
return true;
- ftepp->output_string = NULL;
+ ftepp->output_string = nullptr;
for (o = 0; o < vec_size(macro->output); ++o) {
pptoken *out = macro->output[o];
switch (out->token) {
old_inmacro = ftepp->in_macro;
ftepp->in_macro = true;
- ftepp->output_string = NULL;
+ ftepp->output_string = nullptr;
if (!ftepp_preprocess(ftepp)) {
ftepp->in_macro = old_inmacro;
vec_free(ftepp->lex->open_string);
inner_string = ftepp->output_string;
ftepp->output_string = old_string;
- has_newlines = (strchr(inner_string, '\n') != NULL);
+ has_newlines = (strchr(inner_string, '\n') != nullptr);
if (has_newlines && !old_inmacro)
ftepp_recursion_header(ftepp);
static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
{
size_t o;
- macroparam *params = NULL;
+ macroparam *params = nullptr;
bool retval = true;
size_t paramline;
if (!macro->has_params) {
- if (!ftepp_macro_expand(ftepp, macro, NULL, false))
+ if (!ftepp_macro_expand(ftepp, macro, nullptr, false))
return false;
ftepp_next(ftepp);
return true;
static char *ftepp_include_find_path(const char *file, const char *pathfile)
{
FILE *fp;
- char *filename = NULL;
+ char *filename = nullptr;
const char *last_slash;
size_t len;
if (!pathfile)
- return NULL;
+ return nullptr;
last_slash = strrchr(pathfile, '/');
return filename;
}
vec_free(filename);
- return NULL;
+ return nullptr;
}
static char *ftepp_include_find(ftepp_t *ftepp, const char *file)
{
- char *filename = NULL;
+ char *filename = nullptr;
filename = ftepp_include_find_path(file, ftepp->includename);
if (!filename)
}
static bool ftepp_directive_warning(ftepp_t *ftepp) {
- char *message = NULL;
+ char *message = nullptr;
if (!ftepp_skipspace(ftepp))
return false;
}
static void ftepp_directive_error(ftepp_t *ftepp) {
- char *message = NULL;
+ char *message = nullptr;
if (!ftepp_skipspace(ftepp))
return;
}
static void ftepp_directive_message(ftepp_t *ftepp) {
- char *message = NULL;
+ char *message = nullptr;
if (!ftepp_skipspace(ftepp))
return;
lex_ctx_t ctx;
char lineno[128];
char *filename;
- char *parsename = NULL;
+ char *parsename = nullptr;
char *old_includename;
(void)ftepp_next(ftepp);
ppmacro *macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
if (macro) {
char *backup = ftepp->output_string;
- ftepp->output_string = NULL;
- if (ftepp_macro_expand(ftepp, macro, NULL, true)) {
+ ftepp->output_string = nullptr;
+ if (ftepp_macro_expand(ftepp, macro, nullptr, true)) {
parsename = util_strdup(ftepp->output_string);
vec_free(ftepp->output_string);
ftepp->output_string = backup;
bool newline = true;
/* predef stuff */
- char *expand = NULL;
+ char *expand = nullptr;
ftepp->lex->flags.preprocessing = true;
ftepp->lex->flags.mergelines = false;
if (ftepp->output_on)
macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
else
- macro = NULL;
+ macro = nullptr;
if (!macro) {
ftepp_out(ftepp, ftepp_tokval(ftepp), false);
retval = false;
}
lex_close(ftepp->lex);
- ftepp->lex = NULL;
+ ftepp->lex = nullptr;
if (ftepp->itemname) {
mem_d(ftepp->itemname);
- ftepp->itemname = NULL;
+ ftepp->itemname = nullptr;
}
return retval;
}
void ftepp_add_macro(ftepp_t *ftepp, const char *name, const char *value) {
- char *create = NULL;
+ char *create = nullptr;
/* use saner path for empty macros */
if (!value) {
ftepp = ftepp_new();
if (!ftepp)
- return NULL;
+ return nullptr;
memset(minor, 0, sizeof(minor));
memset(major, 0, sizeof(major));
/* set the right macro based on the selected standard */
- ftepp_add_define(ftepp, NULL, "GMQCC");
+ ftepp_add_define(ftepp, nullptr, "GMQCC");
if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_FTEQCC) {
- ftepp_add_define(ftepp, NULL, "__STD_FTEQCC__");
+ ftepp_add_define(ftepp, nullptr, "__STD_FTEQCC__");
/* 1.00 */
major[0] = '"';
major[1] = '1';
minor[1] = '0';
minor[2] = '"';
} else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
- ftepp_add_define(ftepp, NULL, "__STD_GMQCC__");
+ ftepp_add_define(ftepp, nullptr, "__STD_GMQCC__");
util_snprintf(major, 32, "\"%d\"", GMQCC_VERSION_MAJOR);
util_snprintf(minor, 32, "\"%d\"", GMQCC_VERSION_MINOR);
} else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCCX) {
- ftepp_add_define(ftepp, NULL, "__STD_QCCX__");
+ ftepp_add_define(ftepp, nullptr, "__STD_QCCX__");
util_snprintf(major, 32, "\"%d\"", GMQCC_VERSION_MAJOR);
util_snprintf(minor, 32, "\"%d\"", GMQCC_VERSION_MINOR);
} else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
- ftepp_add_define(ftepp, NULL, "__STD_QCC__");
+ ftepp_add_define(ftepp, nullptr, "__STD_QCC__");
/* 1.0 */
major[0] = '"';
major[1] = '1';
lex_ctx_t ctx = { "__builtin__", 0, 0 };
ctx.file = source;
macro = ppmacro_new(ctx, name);
- /*vec_push(ftepp->macros, macro);*/
util_htset(ftepp->macros, name, macro);
}