)]}'
{
  "commit": "3f5c5d854234971909e86d03a8351494db68f615",
  "tree": "c92a653ba877a35d19c776b2b3380fb3d6a39047",
  "parents": [
    "7939d61c6c63cf841fea515aabe5a12394980198"
  ],
  "author": {
    "name": "Martin Storsjö",
    "email": "martin@martin.st",
    "time": "Thu Mar 20 00:22:41 2025 +0200"
  },
  "committer": {
    "name": "Martin Storsjö",
    "email": "martin@martin.st",
    "time": "Fri Mar 21 20:36:57 2025 +0200"
  },
  "message": "headers, crt: Convert the UCRT stdio options to a mutable state\n\nThis makes things closer match how this works in MSVC.\n\nA few minor details still differ though: In MS UCRT headers,\nthe __local_stdio_{printf,scanf}_options functions are inline\nin the public headers. I don\u0027t see any technical advantage in\ndoing that (and getting that kind of inline correct in C is tricky).\n\nThis makes it possible to set the flags at runtime, by assigning\nto _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS. This also makes it\npossible to affect the flags of our non-inline UCRT stdio\nfunctions, like stdio/ucrt_printf.c and similar ones.\n\nIn MSVC, these flags are adjustable in many different ways. I\nhaven\u0027t found any docs that explicitly describe which mechanisms\nare intended to be used, and which ones should be avoided:\n\n1. One can define e.g. _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS to a\n   different constant value while compiling. In MSVC, this does\n   affect all functions (as all are defined inline in headers).\n   In the mingw-w64 headers, this only affects the functions that\n   are defined inline (currently mostly the wide char functions).\n\n2. One can assign to e.g. _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS at\n   runtime. Previously this wasn\u0027t supported in mingw-w64, now it\n   becomes supported. Doing this now affects the non-inline functions\n   too.\n\n3. In MSVC, one can define _CRT_STDIO_ISO_WIDE_SPECIFIERS or\n   _CRT_STDIO_LEGACY_WIDE_SPECIFIERS while compiling. This adds\n   directives, pulling in an extra library, which adds a constructor\n   function, which on startup sets or clears bits in\n   _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, depending on the choice.\n\n   This is the mechanism that is closest to being documented (it\n   was mentioned in a blog post [1], although the behaviour change\n   advertised in that blog post was later reverted before release).\n\n   We currently don\u0027t have anything corresponding to this.\n\n4. One can also call e.g. __local_stdio_printf_options directly\n   and assign to it. We should now be fully compatible with this.\n\nIt\u0027s unclear how many projects attempt to do any of this at all;\nif they do, it\u0027s probably most plausible that they do 3 or 2.\n\nIn MSVC, the options flags are statically initialized to zero,\nwhile another startup routine\n(__scrt_initialize_default_local_stdio_options) sets their initial\nvalues. Here we just statically initialize them to their default\nvalues.\n\n[1] https://devblogs.microsoft.com/cppblog/c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/\n\nSigned-off-by: Martin Storsjö \u003cmartin@martin.st\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f2f1e6f8160a3ca2f3eb4bbcc9e32664e610bca0",
      "old_mode": 33188,
      "old_path": "mingw-w64-crt/Makefile.am",
      "new_id": "345eac0aa3201cd95a3365d21cfdff544768e644",
      "new_mode": 33188,
      "new_path": "mingw-w64-crt/Makefile.am"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "986c4fd10489c493a03febcf8be0e9d33af64d9c",
      "new_mode": 33188,
      "new_path": "mingw-w64-crt/stdio/ucrt___local_stdio_printf_options.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "2dbd324560cfbe3785fee46bfc935d0c48e3c7f4",
      "new_mode": 33188,
      "new_path": "mingw-w64-crt/stdio/ucrt___local_stdio_scanf_options.c"
    },
    {
      "type": "modify",
      "old_id": "3028d92e160683498a671c283778eb6144977ec0",
      "old_mode": 33188,
      "old_path": "mingw-w64-headers/crt/corecrt_stdio_config.h",
      "new_id": "7ac0e6e03402a9ef732903e15dfc06162bd1653a",
      "new_mode": 33188,
      "new_path": "mingw-w64-headers/crt/corecrt_stdio_config.h"
    }
  ]
}
