fix(nsi): mask LANGID to 16-bit for reliable auto-detection - #4513
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes NSIS installer language auto-detection on some Windows environments by ensuring the LANGID returned from GetSystemDefaultLangID() is treated as a 16-bit value before running StrCmp-based language selection.
Changes:
- Mask the
GetSystemDefaultLangID()result to 16 bits (& 0xFFFF) during.onInitto prevent high-byte noise from breaking language matching.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
tesseract 5.5.3 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`. - [ ] `resource` blocks have been checked for updates. <details> <summary>release notes</summary> <pre>## What's Changed * Fix typos by @szepeviktor in tesseract-ocr/tesseract#4497 * Fix missing closing tags in multi-page PAGE XML output by @stweil with @Copilot in tesseract-ocr/tesseract#4506 * Fix Apple CMAKE_SYSTEM_PROCESSOR not set when crosscompiling by @ppavacic in tesseract-ocr/tesseract#4503 * Remove outdated docker-compose.yml (Fixes #4492) by @Mohataseem89 in tesseract-ocr/tesseract#4509 * docs: document memory ownership and lifecycle in C-API by @markbus-ai in tesseract-ocr/tesseract#4511 * Add Portuguese language support and section descriptions (Windows installer) by @eduardomozart in tesseract-ocr/tesseract#4516 * Update Slovak language string in tesseract.nsi by @eduardomozart in tesseract-ocr/tesseract#4518 * fix(nsi): mask LANGID to 16-bit for reliable auto-detection by @eduardomozart in tesseract-ocr/tesseract#4513 * Add GitHub Copilot instructions by @stweil with @Copilot in tesseract-ocr/tesseract#4508 * Correct mutex call to prevent multiple instances by @eduardomozart in tesseract-ocr/tesseract#4517 * Update versions of GitHub actions by @stweil in tesseract-ocr/tesseract#4522 * Bump microsoft/setup-msbuild from 2 to 3 by @dependabot[bot] in tesseract-ocr/tesseract#4533 * Use asciidoctor instead of asciidoc-py for manpage generation by @amitdo with @Copilot in tesseract-ocr/tesseract#4534 * Bump actions/upload-artifact from 4 to 7 by @dependabot[bot] in tesseract-ocr/tesseract#4545 * autotools: Fix linker warning on macOS by @stweil in tesseract-ocr/tesseract#4559 * Fix compiler warning on macOS by @stweil in tesseract-ocr/tesseract#4558 * Cmake cleanup by @zdenop in tesseract-ocr/tesseract#4562 * Remove SW_BUILD option from CMake and CI by @amitdo with @Copilot in tesseract-ocr/tesseract#4566 * Modernize code by @stweil in tesseract-ocr/tesseract#4561 * Remove some files by @stweil in tesseract-ocr/tesseract#4569 * Modernize more code by @stweil in tesseract-ocr/tesseract#4568 * Fix compiler warnings (-Wold-style-cast) by @stweil in tesseract-ocr/tesseract#4571 * Fix some compiler warnings (-Wunused-parameter) by @stweil in tesseract-ocr/tesseract#4570 * ci: Improve installer for windows by @stweil in tesseract-ocr/tesseract#4572 * Fix several issues reported by Codacy (including real bugs) by @stweil in tesseract-ocr/tesseract#4573 * Bump actions/checkout from 6 to 7 by @dependabot[bot] in tesseract-ocr/tesseract#4574 * Fix crash when LSTM is missing in disabled-legacy build (#4448) by @gaurav0107 in tesseract-ocr/tesseract#4563 * ci: Remove unused ilammy/setup-nasm by @stweil in tesseract-ocr/tesseract#4575 * autotools: Simplify Makefile rules by @stweil in tesseract-ocr/tesseract#4579 * Fix memory-safety issues in .traineddata deserialization by @stweil in tesseract-ocr/tesseract#4581 * Handle send() failures in SVNetwork::Flush by @Ramya-9353 in tesseract-ocr/tesseract#4576 * Small code improvements by @stweil in tesseract-ocr/tesseract#4585 * doc: Add comprehensive PARAMETERS section to the tesseract man page by @stweil with @Copilot in tesseract-ocr/tesseract#4526 * Fix integer overflow in LSTM Convolve and Reconfig deserialization by @stweil in tesseract-ocr/tesseract#4588 ## New Contributors * @szepeviktor made their first contribution in tesseract-ocr/tesseract#4497 * @ppavacic made their first contribution in tesseract-ocr/tesseract#4503 * @Mohataseem89 made their first contribution in tesseract-ocr/tesseract#4509 * @markbus-ai made their first contribution in tesseract-ocr/tesseract#4511 * @eduardomozart made their first contribution in tesseract-ocr/tesseract#4516 * @gaurav0107 made their first contribution in tesseract-ocr/tesseract#4563 * @Ramya-9353 made their first contribution in tesseract-ocr/tesseract#4576 **Full Changelog**: https://github.com/tesseract-ocr/tesseract/compare/5.5.2...5.5.3</pre> <p>View the full release notes at <a href="https://github.com/tesseract-ocr/tesseract/releases/tag/5.5.3">https://github.com/tesseract-ocr/tesseract/releases/tag/5.5.3</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!15091
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a bug in the NSIS installer where system language auto-detection fails on certain Windows environments.
The Problem
The current script calls
kernel32::GetSystemDefaultLangID(). While aLANGIDis technically a 16-bit value (short), the NSISSystem::Callplugin can return it as a 32-bit integer.In many cases, the upper bytes of the register contain "garbage" data (e.g., a return value of
1508361instead of1033). This causes all subsequentStrCmpchecks to fail because the string comparison expects the exact 4-digit ID, resulting in no language being pre-selected during installation.The Solution
I have added a bitwise AND operation (
IntOp $0 $0 & 0xFFFF) immediately after the system call. This masks the value to 16 bits, discarding any high-byte noise and ensuring that$0contains only the validLANGID.Changes
.onInitintesseract.nsito include the bitwise mask.Additional Information