ZDoom / gzdoom

GZDoom is a feature centric port for all Doom engine games, based on ZDoom, adding an OpenGL renderer and powerful scripting capabilities
http://zdoom.org
GNU General Public License v3.0
2.33k stars 526 forks source link

[BUG] Paths with non-ascii upper-case characters fail to be found if referenced #2613

Open nikitalita opened 2 days ago

nikitalita commented 2 days ago

GZDoom version

master

Which game are you running with GZDoom?

Doom 2

What Operating System are you using?

Mac OS

Please describe your specific OS version

macOS Sonoma

Relevant hardware info

No response

Have you checked that no other similar issue already exists?

A clear and concise description of what the bug is.

The following script fails to compile because it cannot find bd_Жmain.zc, even though it exists:

image

image

however, if that line is changed from:

#include "Z_Bdoom/bd_Жmain.zc"

to use the lower-case version of 'ж':

#include "Z_Bdoom/bd_жmain.zc"

it works fine, even through the file is actually named bd_Жmain.zc with the upper-case version of Ж.

The problem is that during the initial load, NormalizeFileName() is run on every file and converts the file name to lower case, which is stored in the FileInfo. This correctly uses tolower_normalize() to convert upper-case unicode strings to lower-case unicode strings. However, CheckNumForFullName() uses strnicmp() for string comparison, which doesn't work with unicode strings.

This bug applies to everything that uses stricmp() or strnicmp(); this would include FName lookups, etc.

An easy fix would be to just run tolower_normalize() first, but that allocates a string on the heap every time and suffer a performance hit. Also, I'm not sure if unicode names in ZScript and DECORATE files are actually officially supported.

Steps to reproduce the behaviour.

See above

Your configuration

N/A

Provide a Log

N/A