From 96ebd81e5f29e9cde3d83c4af0b9166cd1f40b26 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 11 May 2019 16:15:07 +1000 Subject: GLK: HUGO: NULL to nullptr, Amiga compilation fix --- engines/glk/alan2/execute.cpp | 10 ++++----- engines/glk/alan2/parse.cpp | 40 ++++++++++++++++----------------- engines/glk/alan2/parse.h | 2 +- engines/glk/alan2/saveload.cpp | 8 +++---- engines/glk/frotz/mem.cpp | 4 ++-- engines/glk/hugo/heglk.cpp | 38 ++++++++++++++++---------------- engines/glk/hugo/hemisc.cpp | 50 +++++++++++++++++++++--------------------- engines/glk/hugo/herun.cpp | 36 +++++++++++++++--------------- 8 files changed, 94 insertions(+), 94 deletions(-) diff --git a/engines/glk/alan2/execute.cpp b/engines/glk/alan2/execute.cpp index 8359c47e37..4fc0acb33b 100644 --- a/engines/glk/alan2/execute.cpp +++ b/engines/glk/alan2/execute.cpp @@ -234,7 +234,7 @@ bool Execute::confirm(MsgKind msgno) { #ifdef USE_READLINE if (!readline(buf)) return true; #else - if (gets(buf) == NULL) return true; + if (gets(buf) == nullptr) return true; #endif #endif @@ -260,7 +260,7 @@ void Execute::quit() { #ifdef USE_READLINE if (!readline(buf)) terminate(0); #else - if (gets(buf) == NULL) terminate(0); + if (gets(buf) == nullptr) terminate(0); #endif #endif @@ -682,17 +682,17 @@ void Execute::dscrobj(Aword obj) { void Execute::dscract(Aword act) { - ScrElem *scr = NULL; + ScrElem *scr = nullptr; if (_acts[act - ACTMIN].script != 0) { for (scr = (ScrElem *) addrTo(_acts[act - ACTMIN].scradr); !endOfTable(scr); scr++) if (scr->code == _acts[act - ACTMIN].script) break; if (endOfTable(scr)) - scr = NULL; + scr = nullptr; } - if (scr != NULL && scr->dscr != 0) + if (scr != nullptr && scr->dscr != 0) _vm->_interpreter->interpret(scr->dscr); else if (_acts[act - ACTMIN].dscr != 0) _vm->_interpreter->interpret(_acts[act - ACTMIN].dscr); diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp index aac858a062..8e6427d09c 100644 --- a/engines/glk/alan2/parse.cpp +++ b/engines/glk/alan2/parse.cpp @@ -75,7 +75,7 @@ char *Parser::gettoken(char *tokenBuffer) { static char *marker; static char oldch; - if (tokenBuffer == NULL) + if (tokenBuffer == nullptr) *marker = oldch; else marker = tokenBuffer; @@ -92,7 +92,7 @@ char *Parser::gettoken(char *tokenBuffer) { while (*marker != '\"') marker++; marker++; } else if (*marker == '\0' || *marker == '\n') - return NULL; + return nullptr; else marker++; @@ -128,7 +128,7 @@ void Parser::agetline() { quit(); } #else - if (fgets(buf, LISTLEN, stdin) == NULL) { + if (fgets(buf, LISTLEN, stdin) == nullptr) { newline(); quit(); } @@ -148,12 +148,12 @@ void Parser::agetline() { token = gettoken(isobuf); - if (token != NULL && strcmp("debug", token) == 0 && _vm->header->debug) { + if (token != nullptr && strcmp("debug", token) == 0 && _vm->header->debug) { dbgflg = true; debug(); - token = NULL; + token = nullptr; } - } while (token == NULL); + } while (token == nullptr); eol = false; lin = 1; @@ -212,7 +212,7 @@ void Parser::scan() { unknown(token); wrds[i] = EOF; - eol = (token = gettoken(NULL)) == NULL; + eol = (token = gettoken(nullptr)) == nullptr; } while (!eol); } @@ -377,10 +377,10 @@ void Parser::unambig(ParamElem plst[]) { static ParamElem *savlst; // Saved list for backup at EOF int firstWord, lastWord; // The words the player used - if (refs == NULL) + if (refs == nullptr) refs = new ParamElem[MAXENTITY + 1]; - if (savlst == NULL) + if (savlst == nullptr) savlst = new ParamElem[MAXENTITY + 1]; if (isLiteral(wrds[wrdidx])) { @@ -490,12 +490,12 @@ void Parser::unambig(ParamElem plst[]) { } void Parser::simple(ParamElem olst[]) { - static ParamElem *tlst = NULL; + static ParamElem *tlst = nullptr; int savidx = wrdidx; bool savplur = false; int i; - if (tlst == NULL) + if (tlst == nullptr) tlst = new ParamElem[MAXENTITY + 1]; tlst[0].code = (Aword)EOF; @@ -549,9 +549,9 @@ void Parser::complex(ParamElem olst[]) { // they work on words.Below all is converted to indices into the // entity tables.Particularly this goes for literals... - static ParamElem *alst = NULL; + static ParamElem *alst = nullptr; - if (alst == NULL) + if (alst == nullptr) alst = new ParamElem[MAXENTITY + 1]; if (isAll(wrds[wrdidx])) { @@ -653,18 +653,18 @@ AltElem *Parser::findalt(Aword vrbsadr, Aword param) { AltElem *alt; if (vrbsadr == 0) - return NULL; + return nullptr; for (vrb = (VrbElem *)addrTo(vrbsadr); !endOfTable(vrb); vrb++) { if ((int)vrb->code == _vm->cur.vrb) { for (alt = (AltElem *)addrTo(vrb->alts); !endOfTable(alt); alt++) if (alt->param == param || alt->param == 0) return alt; - return NULL; + return nullptr; } } - return NULL; + return nullptr; } bool Parser::trycheck(Aaddr adr, bool act) { @@ -732,10 +732,10 @@ void Parser::tryMatch(ParamElem mlstArr[]) { ClaElem *cla; // Pointer to class definitions bool anyPlural = false; // Any parameter that was plural? int i, p; - static ParamElem *tlst = NULL; // List of params found by complex() - static bool *checked = NULL; // Corresponding parameter checked? + static ParamElem *tlst = nullptr; // List of params found by complex() + static bool *checked = nullptr; // Corresponding parameter checked? - if (tlst == NULL) { + if (tlst == nullptr) { tlst = new ParamElem[MAXENTITY + 1]; checked = new bool[MAXENTITY + 1]; } @@ -930,7 +930,7 @@ void Parser::action(ParamElem plst[]) { } void Parser::parse() { - if (mlst == NULL) { // Allocate large enough paramlists + if (mlst == nullptr) { // Allocate large enough paramlists mlst = new ParamElem[MAXENTITY + 1]; mlst[0].code = (Aword)EOF; pmlst = new ParamElem[MAXENTITY + 1]; diff --git a/engines/glk/alan2/parse.h b/engines/glk/alan2/parse.h index 1e3601c773..c5b223baa0 100644 --- a/engines/glk/alan2/parse.h +++ b/engines/glk/alan2/parse.h @@ -71,7 +71,7 @@ private: int listLength(ParamElem a[]); /** - * Compact a list, i.e remove any NULL elements + * Compact a list, i.e remove any nullptr elements */ void listCompact(ParamElem a[]); diff --git a/engines/glk/alan2/saveload.cpp b/engines/glk/alan2/saveload.cpp index 2d92d34591..838c2588a1 100644 --- a/engines/glk/alan2/saveload.cpp +++ b/engines/glk/alan2/saveload.cpp @@ -39,7 +39,7 @@ void SaveLoad::save() { // TODO #if 0 frefid_t fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Write, 0); - if (fref == NULL) + if (fref == nullptr) _vm->printError(M_SAVEFAILED); strcpy(str, garglk_fileref_get_name(fref)); @@ -53,12 +53,12 @@ void SaveLoad::save() { // TODO #if 0 - if ((savfil = fopen(str, READ_MODE)) != NULL) + if ((savfil = fopen(str, READ_MODE)) != nullptr) // It already existed if (!confirm(M_SAVEOVERWRITE)) _vm->printError(MSGMAX); // Return to player without saying anything - if ((savfil = fopen(str, WRITE_MODE)) == NULL) + if ((savfil = fopen(str, WRITE_MODE)) == nullptr) _vm->printError(M_SAVEFAILED); #endif @@ -124,7 +124,7 @@ void SaveLoad::restore() { // TODO #if 0 frefid_t fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0); - if (fref == NULL) + if (fref == nullptr) _vm->printError(M_SAVEFAILED); strcpy(str, garglk_fileref_get_name(fref)); diff --git a/engines/glk/frotz/mem.cpp b/engines/glk/frotz/mem.cpp index 32e3ab3159..57dc5b5d15 100644 --- a/engines/glk/frotz/mem.cpp +++ b/engines/glk/frotz/mem.cpp @@ -224,9 +224,9 @@ void Mem::free_undo(int count) { undo_count--; } if (first_undo) - first_undo->prev = NULL; + first_undo->prev = nullptr; else - last_undo = NULL; + last_undo = nullptr; } void Mem::reset_memory() { diff --git a/engines/glk/hugo/heglk.cpp b/engines/glk/hugo/heglk.cpp index 4884d0f8cf..f6f40814f5 100644 --- a/engines/glk/hugo/heglk.cpp +++ b/engines/glk/hugo/heglk.cpp @@ -52,7 +52,7 @@ void Hugo::hugo_getline(const char *prmpt) { window that hasn't been created, switch as a failsafe to mainwin */ - if (currentwin == NULL) + if (currentwin == nullptr) glk_set_window(currentwin = mainwin); /* Print prompt */ @@ -97,7 +97,7 @@ int Hugo::hugo_waitforkey() { window that hasn't been created, switch as a failsafe to mainwin */ - if (currentwin == NULL) + if (currentwin == nullptr) glk_set_window(currentwin = mainwin); #if defined (NO_KEYPRESS_CURSOR) @@ -211,7 +211,7 @@ void Hugo::hugo_clearwindow() { not really a window */ if (inwindow && currentwin == mainwin) return; - if (currentwin == NULL) return; + if (currentwin == nullptr) return; glk_window_clear(currentwin); @@ -227,7 +227,7 @@ void Hugo::hugo_clearwindow() { stream_result_t sr; glk_window_close(auxwin, &sr); - auxwin = NULL; + auxwin = nullptr; glk_set_window(currentwin = mainwin); } @@ -256,11 +256,11 @@ void Hugo::hugo_settextwindow(int left, int top, int right, int bottom) { in_valid_window = false; /* Glk-illegal floating window; setting currentwin - to NULL will tell hugo_print() not to print in it: + to nullptr will tell hugo_print() not to print in it: */ if (bottom= physical_windowwidth) @@ -1750,7 +1750,7 @@ void Hugo::PromptMore() { { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; } else if (playback && k=='+') skipping_more = true; @@ -1802,7 +1802,7 @@ int Hugo::RecordCommands() { strcpy(recordfile, line); #else /* Glk implementation */ - frefid_t fref = NULL; + frefid_t fref = nullptr; fref = glk_fileref_create_by_prompt(fileusage_Transcript | fileusage_TextMode, filemode_Write, 0); @@ -1824,7 +1824,7 @@ int Hugo::RecordCommands() { { if (hugo_fclose(record)) return (0); - record = NULL; + record = nullptr; return 1; } break; @@ -1844,7 +1844,7 @@ int Hugo::RecordCommands() { strcpy(recordfile, line); #else /* Glk implementation */ - frefid_t fref = NULL; + frefid_t fref = nullptr; fref = glk_fileref_create_by_prompt(fileusage_InputRecord | fileusage_TextMode, filemode_Read, 0); @@ -2173,7 +2173,7 @@ HUGO_FILE TrytoOpen(char *f, char *p, char *d) } } - return NULL; /* return NULL if not openable */ + return nullptr; /* return nullptr if not openable */ } #endif /* GLK */ diff --git a/engines/glk/hugo/herun.cpp b/engines/glk/hugo/herun.cpp index 43837977d5..6466f8829f 100644 --- a/engines/glk/hugo/herun.cpp +++ b/engines/glk/hugo/herun.cpp @@ -163,7 +163,7 @@ RestartDebugger: /* If no gamefile is loaded, jump immediately to the debugger interrupt function. */ - if (game==NULL) Debugger(); + if (game==nullptr) Debugger(); #endif stack_depth = RESET_STACK_DEPTH; @@ -271,7 +271,7 @@ FreshInput: { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; GetCommand(); } else @@ -635,7 +635,7 @@ EndofCommand: if (playback) { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; } Flushpbuffer(); @@ -702,7 +702,7 @@ NormalTermination: debugger_collapsing = false; - if ((game!=NULL) && !RunRestart()) + if ((game!=nullptr) && !RunRestart()) DebugMessageBox("Restart Error", "Unable to restart"); SwitchtoGame(); @@ -1115,7 +1115,7 @@ int Hugo::RunRestart() { { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; } if (active_screen!=DEBUGGER) @@ -1169,7 +1169,7 @@ int Hugo::RestoreGameData() { { AP("Incorrect save file."); if (hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; return 0; } @@ -1179,7 +1179,7 @@ int Hugo::RestoreGameData() { { AP("Save file created by different version."); if (hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; return 0; } @@ -1258,7 +1258,7 @@ RestoreError: int Hugo::RunRestore() { #if !defined (GLK) - save = NULL; + save = nullptr; /* stdio implementation */ hugo_getfilename("to restore", savefile); @@ -1273,7 +1273,7 @@ int Hugo::RunRestore() { /* Glk implementation */ frefid_t savefile; - save = NULL; + save = nullptr; savefile = glk_fileref_create_by_prompt(fileusage_SavedGame | fileusage_BinaryMode, filemode_Read, 0); @@ -1281,7 +1281,7 @@ int Hugo::RunRestore() { if (glk_fileref_does_file_exist(savefile)) save = glk_stream_open_file(savefile, filemode_Read, 0); else - save = NULL; + save = nullptr; glk_fileref_destroy(savefile); if (!save) return 0; @@ -1290,7 +1290,7 @@ int Hugo::RunRestore() { if (!RestoreGameData()) goto RestoreError; if (hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; #if !defined (GLK) strcpy(savefile, line); @@ -1302,7 +1302,7 @@ int Hugo::RunRestore() { RestoreError: if ((save) && hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; game_reset = false; return 0; } @@ -1413,7 +1413,7 @@ void Hugo::RunRoutine(long addr) { } /* If not object.property or an event */ - if (strchr(debug_line, '.')==NULL && strstr(debug_line, "vent ")==NULL) + if (strchr(debug_line, '.')==nullptr && strstr(debug_line, "vent ")==nullptr) { strcat(debug_line, "("); for (i=0; i