diff --git a/scripts/sweep_winapi_stubs_includes.py b/scripts/sweep_winapi_stubs_includes.py index e1151e232..5b966c4c1 100644 --- a/scripts/sweep_winapi_stubs_includes.py +++ b/scripts/sweep_winapi_stubs_includes.py @@ -67,8 +67,20 @@ USAGE_PATTERNS = [ ] +def strip_comments(text: str) -> str: + """Strip C++ // and /* */ comments. Approximate but good enough for + detecting whether a symbol appears in real code vs commented-out + code.""" + # Strip /* ... */ comments (multiline) + text = re.sub(r'/\*.*?\*/', '', text, flags=re.DOTALL) + # Strip // ... comments (single line) + text = re.sub(r'//[^\n]*', '', text) + return text + + def needs_winapi(text: str) -> bool: scan = INCLUDE_RE.sub("", text) + scan = strip_comments(scan) return any(p.search(scan) for p in USAGE_PATTERNS) diff --git a/targets/minecraft/client/Minecraft.cpp b/targets/minecraft/client/Minecraft.cpp index fb6bac1d1..f132c489f 100644 --- a/targets/minecraft/client/Minecraft.cpp +++ b/targets/minecraft/client/Minecraft.cpp @@ -25,7 +25,6 @@ #include "app/common/UI/All Platforms/UIEnums.h" #include "app/common/UI/All Platforms/UIStructs.h" #include "app/linux/Linux_UIController.h" -#include "app/linux/Stubs/winapi_stubs.h" #include "java/Class.h" #include "java/Random.h" #include "minecraft/GameEnums.h" diff --git a/targets/minecraft/client/multiplayer/ClientConnection.cpp b/targets/minecraft/client/multiplayer/ClientConnection.cpp index 0a3e79421..73786ded9 100644 --- a/targets/minecraft/client/multiplayer/ClientConnection.cpp +++ b/targets/minecraft/client/multiplayer/ClientConnection.cpp @@ -33,7 +33,6 @@ #include "app/common/UI/All Platforms/UIStructs.h" #include "app/common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_TradingMenu.h" #include "app/linux/Linux_UIController.h" -#include "app/linux/Stubs/winapi_stubs.h" #include "MultiPlayerLevel.h" #include "ReceivingLevelScreen.h" #include "util/Timer.h" diff --git a/targets/minecraft/network/packet/Packet.cpp b/targets/minecraft/network/packet/Packet.cpp index 56b75aebe..5c9acb854 100644 --- a/targets/minecraft/network/packet/Packet.cpp +++ b/targets/minecraft/network/packet/Packet.cpp @@ -13,7 +13,6 @@ #include #include -#include "app/linux/Stubs/winapi_stubs.h" #include "java/Exceptions.h" #include "java/InputOutputStream/DataInputStream.h" #include "java/InputOutputStream/DataOutputStream.h" diff --git a/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp b/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp index 7c4e3eef8..a6aae31d4 100644 --- a/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp +++ b/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp @@ -8,7 +8,6 @@ #include -#include "app/linux/Stubs/winapi_stubs.h" #include "platform/NetTypes.h" #include "util/Definitions.h" #include "java/InputOutputStream/DataInputStream.h" diff --git a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp index 882981e02..31f1d0b49 100644 --- a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp +++ b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp @@ -7,7 +7,6 @@ #include #include -#include "app/linux/Stubs/winapi_stubs.h" #include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h" #include "java/File.h" #include "java/InputOutputStream/ByteArrayInputStream.h"