nwnss: configure unicode table search path

This commit is contained in:
ChatGPT
2026-06-18 07:20:47 +00:00
committed by Mario Fetka
parent 972d99902f
commit 71ceca5dd4
4 changed files with 32 additions and 3 deletions

View File

@@ -801,7 +801,7 @@ even if it already compiles or has indirect test coverage.
| Status | Kind | Test coverage | File | Notes |
|---|---:|---|---|---|
| AUDITED | ORIG+FIX | nwnss.codepage, nwnss.unicode | `src/nwnss/nsslnxlib/nwlocale.c` | Compared with original `public_core/nsslnxlib/nwlocale.c`; CP437 locale tables and OS codepage defaults kept. Differences are whitespace/diff-check cleanup only. |
| AUDITED | PORT | nwnss.codepage, nwnss.unicode, nwnss.utf8 | `src/nwnss/nsslnxlib/unilib.c` | Userspace port of original `public_core/nsslnxlib/unilib.c` rule-table loader. It preserves the NSS `.TAB` layout and public entry points (`UniGetTable`, `UniGetMacintoshTable`, `loc2uni`, `uni2loc`, case helpers), but replaces kernel file/lock/memory primitives with libc file I/O and process-local state. Search path is build-tree/generated tables, source `third_party/unicodeTables/TAB/unitables`, install datadir, plus `MARS_NWE_NWNSS_UNITABLE_DIR` override. |
| AUDITED | PORT | nwnss.codepage, nwnss.unicode, nwnss.utf8 | `src/nwnss/nsslnxlib/unilib.c` | Userspace port of original `public_core/nsslnxlib/unilib.c` rule-table loader. It preserves the NSS `.TAB` layout and public entry points (`UniGetTable`, `UniGetMacintoshTable`, `loc2uni`, `uni2loc`, `loc2unipath`, `uni2locpath`, `chr2lwr`, `chr2upr`), but replaces kernel file/lock/memory primitives with libc file I/O and process-local state. The `.TAB` files are generated by `third_party/unicodeTables/scripts/gen_nss_unitables.py` from Unicode.org data rather than copied from Novell sources. The generated files are loader-compatible, not intended to be byte-identical to Novell `shared/sdk/unitables`: local comparison showed common DOS/Mac mappings usually match, while generated Unicode.org tables omit some Novell/private extras; generated `UNI_000.TAB` contains all original lower-case mappings and all but one original upper-case mapping identically, with extra newer BMP case pairs from UnicodeData.txt. The table search path is configured at CMake time into a generated private `nwnssConfig.h` from `MARS_NWE_NWNSS_UNITABLE_DIRS`, or defaults to build generated tables, bundled generated tables, and install datadir; `MARS_NWE_NWNSS_UNITABLE_DIR` remains a runtime override for test/local use. |
### Sources: sharedsrc included implementations

View File

@@ -7,6 +7,27 @@ set(NWNSS_GENERATED_NSS_ERROR_TABLE_C
"${NWNSS_GENERATED_DIR}/library/misc/nssErrorTable.c")
set(NWNSS_GENERATED_XML_TAGS_JAVA
"${NWNSS_GENERATED_DIR}/java/NSSXmlTags.java")
set(NWNSS_GENERATED_CONFIG_INCLUDE_DIR
"${NWNSS_GENERATED_DIR}/include")
set(NWNSS_GENERATED_CONFIG_H
"${NWNSS_GENERATED_CONFIG_INCLUDE_DIR}/nwnssConfig.h")
set(MARS_NWE_NWNSS_DEFAULT_CODEPAGE "850" CACHE STRING
"Default codepage used by the libnwnss Unicode table loader")
set(MARS_NWE_NWNSS_UNITABLE_DIRS "" CACHE STRING
"Colon-separated NSS-compatible Unicode .TAB search path for libnwnss; empty uses build/source/install defaults")
if(MARS_NWE_NWNSS_UNITABLE_DIRS)
set(MARS_NWE_NWNSS_UNITABLE_DIRS_CONFIGURED "${MARS_NWE_NWNSS_UNITABLE_DIRS}")
else()
set(MARS_NWE_NWNSS_UNITABLE_DIRS_CONFIGURED
"${MARS_NWE_NSS_UNITABLE_BUILD_DIR}:${MARS_NWE_NSS_UNITABLE_SOURCE_DIR}:${MARS_NWE_INSTALL_FULL_DATADIR}/nwnss/unitables")
endif()
string(REPLACE ";" ":" MARS_NWE_NWNSS_UNITABLE_DIRS_CONFIGURED
"${MARS_NWE_NWNSS_UNITABLE_DIRS_CONFIGURED}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/nwnssConfig.h.in"
"${NWNSS_GENERATED_CONFIG_H}"
@ONLY)
add_custom_command(
OUTPUT "${NWNSS_GENERATED_NSS_ERROR_TABLE_C}"
@@ -340,8 +361,6 @@ target_compile_definitions(nwnss
MARS_NWE_NWNSS_VIRTUAL_IO
${_nwnss_io_backend_defs}
PRIVATE
MARS_NWE_NWNSS_DEFAULT_CODEPAGE=850
MARS_NWE_NWNSS_UNITABLE_DIRS="${MARS_NWE_NSS_UNITABLE_BUILD_DIR}:${MARS_NWE_NSS_UNITABLE_SOURCE_DIR}:${MARS_NWE_INSTALL_FULL_DATADIR}/nwnss/unitables"
MARS_NWE_NWNSS_UNICODE
MARS_NWE_VERSION_STRING="${MARS_NWE_VERSION}"
ZMAJV=${VERSION_MAJOR}
@@ -359,6 +378,7 @@ target_include_directories(nwnss BEFORE
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/nwnss/support/ndssdkINC_kern>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/nwnss>"
PRIVATE
"${NWNSS_GENERATED_CONFIG_INCLUDE_DIR}"
"${CMAKE_SOURCE_DIR}/include/nwnss/library"
"${CMAKE_SOURCE_DIR}/include/nwnss/internal"
"${CMAKE_SOURCE_DIR}/include/nwnss/comn"

View File

@@ -12,6 +12,7 @@
#include <string.h>
#include <nsslnxlib/nssunilib.h>
#include <nwnssConfig.h>
extern char *getenv(const char *name);
extern long strtol(const char *nptr, char **endptr, int base);

View File

@@ -0,0 +1,8 @@
#ifndef MARS_NWE_NWNSS_CONFIG_H
#define MARS_NWE_NWNSS_CONFIG_H
/* Generated by CMake for the libnwnss build. */
#define MARS_NWE_NWNSS_DEFAULT_CODEPAGE @MARS_NWE_NWNSS_DEFAULT_CODEPAGE@
#define MARS_NWE_NWNSS_UNITABLE_DIRS "@MARS_NWE_NWNSS_UNITABLE_DIRS_CONFIGURED@"
#endif /* MARS_NWE_NWNSS_CONFIG_H */