diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 502937a..64ecdcf 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -646,6 +646,11 @@ jobs: if ("$so" -notmatch 'MBCS->UTF-8 ok') { throw "selftest did not exercise the MBCS->UTF-8 conversion" } + # Guards the empty-name terminator (newlang.h); losing it hangs the first-run About + # box. [1-9] not \d: "after 0 entries" would pass while proving nothing. + if ("$so" -notmatch 'language list ends after [1-9]\d* entries') { + throw "selftest did not check that the language list terminates" + } # --selftest throws one exception on purpose. A crash report that resolves nothing # is indistinguishable from a working one until someone needs it, so assert the diff --git a/WinHTTrack/WinHTTrack.cpp b/WinHTTrack/WinHTTrack.cpp index be5fcfb..eb30cf2 100755 --- a/WinHTTrack/WinHTTrack.cpp +++ b/WinHTTrack/WinHTTrack.cpp @@ -332,6 +332,28 @@ BOOL CWinHTTrackApp::InitInstance() printf("MBCS->UTF-8 ok\n"); } } + /* Walk the languages as the About box does: losing LANG_LOAD()'s empty-name + terminator hangs it on the first run, past where --selftest ever reaches. */ + { + const int LANG_SANE_MAX = 512; /* lang.def ships a few dozen */ + const int saved = QLANG_T(-1); + int i; + for(i=0 ; i= LANG_SANE_MAX) { + fprintf(stderr, "FATAL: the language list never ends: LANG_LOAD() lost its empty-name terminator\n"); + fflush(stderr); + ExitProcess(4); + } + printf("language list ends after %d entries\n", i); + } /* Exercise the crash reporter for real: a Release PDB built without line info, or a first-chance hook that never registered, both still produce a plausible-looking report that names nothing. Only throwing proves the chain resolves. */ diff --git a/WinHTTrack/newlang.cpp b/WinHTTrack/newlang.cpp index cacb850..2c34131 100755 --- a/WinHTTrack/newlang.cpp +++ b/WinHTTrack/newlang.cpp @@ -325,12 +325,9 @@ void LANG_LOAD(char* limit_to) { hashname=LANGINTKEY(name); } - /* Get only language name */ + /* Empty name is the caller's enumeration terminator: never substitute a placeholder. */ if (limit_to) { - if (strnotempty(hashname)) - strcpybuff(limit_to,hashname); - else - strcpybuff(limit_to,"???"); + strcpybuff(limit_to,hashname); return; } diff --git a/WinHTTrack/newlang.h b/WinHTTrack/newlang.h index f73fe09..d6056bc 100755 --- a/WinHTTrack/newlang.h +++ b/WinHTTrack/newlang.h @@ -28,6 +28,8 @@ Please visit our Website: http://www.httrack.com #ifndef HTS_DEFNEWLANG #define HTS_DEFNEWLANG +/* limit_to: set to the current language's name, or left EMPTY when the index names + none. Callers walk the index until that empty name, so never return a placeholder. */ void LANG_LOAD(char* limit_to); void LANG_INIT(); int LANG_T(int);