Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions WinHTTrack/WinHTTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ; i++) {
char name[1024];
QLANG_T(i);
strcpybuff(name, "LANGUAGE_NAME");
LANG_LOAD(name);
if (name[0] == '\0')
break;
}
QLANG_T(saved);
if (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. */
Expand Down
7 changes: 2 additions & 5 deletions WinHTTrack/newlang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions WinHTTrack/newlang.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading