MCJack123 / craftos2

A fast, modern, and feature-filled ComputerCraft emulator written in C++.
https://www.craftos-pc.cc
Other
230 stars 27 forks source link

On Windows %R is not a valid format specifier for os.date #352

Closed MasonGulu closed 6 months ago

MasonGulu commented 6 months ago

Describe the bug This is a platform specific issue. On Linux calling os.date("%R") results in the correct formatting. On Windows calling the same snippet results in an error.

To Reproduce Steps to reproduce the behavior:

  1. Open lua prompt
  2. Type in os.date("%R")
  3. Compare behavior on Linux vs. Windows.

Expected behavior No Crash.

Screenshots image

Environment (please complete the following information):

Additional context Add any other context about the problem here.

MasonGulu commented 6 months ago

minerobber pointed out this relevant code https://github.com/MCJack123/craftos2-lua/blob/lua-5.2/src/loslib.c#L28-L35

MineRobber9000 commented 6 months ago

Specifically, if LUA_USE_POSIX is not defined, Lua restricts itself to a set of format specifiers that it knows will be available (%R is a C99 addition according to Jack so on a C89 system it wouldn't be available). Since Windows is not POSIX, %R isn't in the list of allowed format specifiers, and Lua responds with an error.