• Use TO_UPPERCASE()/TO_LOWERCASE() for the remaining bare tolower()/tou

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Friday, November 20, 2026 16:20:54
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1373

    `tolower()` and `toupper()` are only defined for values that fit in an `unsigned char` (or `EOF`). Called with a plain `char` holding a byte of 0x80 or more, where `char` is signed, the argument is negative. On NetBSD that crashes; on other platforms it reads a table entry it should not and returns garbage, and MSVC debug builds assert.

    This was the cause of the jsexec segmentation fault in the netbsd-amd64 CI test suite: `MsgBase.save_msg()` -> `smb_subject_crc()` -> `strlwr()` on a subject with non-ASCII bytes. Fixed for xpdev in ff50c3b984 (linked-34-fair, 2026-11-20), which added two macros to `gen_defs.h` beside the existing `IS_ALPHA()` family:

    ```c
    #define TO_UPPERCASE(c) toupper((unsigned char)(c))
    #define TO_LOWERCASE(c) tolower((unsigned char)(c))
    ```

    and converted the 16 calls in `genwrap.c`, `dirwrap.c` and `ini_file.c`.

    **What remains**

    Bare calls (not already cast) elsewhere in the tree, counted with grep:

    | Directory | Bare calls |
    |---|---|
    | `src/sbbs3` | about 126 (of 158) |
    | `src/uifc` | 8 |
    | `src/conio` | 6 |
    | `src/sbbs3/scfg` | 3 |

    `src/smblib` has none left (its three calls are already cast).

    Not all of these are a problem: a call whose argument is an `int` from a key read, an `unsigned char`, or known ASCII is fine. The ones that matter take text that can hold any byte, for example:

    - `userdat.c` `matchusername()`: `toupper(*np) != toupper(*cp)` on user names and on names taken from mail addresses
    - `userdat.c`: characters of a password being checked
    - `str_util.c`: a control-code character from message or menu text

    **Proposed**

    Convert the remaining calls to `TO_UPPERCASE()` / `TO_LOWERCASE()`, as one mechanical change. For ASCII nothing changes. Calls whose argument is already an `int` key code can stay as they are.

    A grep to find them:

    ```
    grep -rnE '\b(tolower|toupper)\(' src/sbbs3 src/uifc src/conio --include=*.c --include=*.cpp --include=*.h \
    | grep -vE '\((uchar|unsigned char)\)'
    ```

    - *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)