)]}'
{
  "commit": "5464ae7d9e226586b79527cb445d892177b70271",
  "tree": "29c055210014ccc9ed66af321f39a8032abf40f3",
  "parents": [
    "a7c21a6f4cb42d967854cae954efd4ee66bdea9c"
  ],
  "author": {
    "name": "Harald van Dijk",
    "email": "harald@gigawatt.nl",
    "time": "Fri Aug 23 20:30:28 2013 +1000"
  },
  "committer": {
    "name": "Herbert Xu",
    "email": "herbert@gondor.apana.org.au",
    "time": "Fri Aug 23 20:30:28 2013 +1000"
  },
  "message": "[BUILTIN] Use PRIdMAX instead of %j in printf\n\nOn 12/03/2012 05:59 PM, Harald van Dijk wrote:\n\u003e On 12/03/2012 08:42 AM, Roy wrote:\n\u003e\u003e MSYS libc does not support %j[dXx] format, only %ll[dXx] is supported.\n\u003e\u003e\n\u003e\u003e diff --git a/src/bltin/printf.c b/src/bltin/printf.c\n\u003e\u003e index 893295c..12ce660 100644\n\u003e\u003e --- a/src/bltin/printf.c\n\u003e\u003e +++ b/src/bltin/printf.c\n\u003e\u003e @@ -319,11 +319,12 @@ mklong(const char *str, const char *ch)\n\u003e\u003e         char *copy;\n\u003e\u003e         size_t len;\n\u003e\u003e\n\u003e\u003e -       len \u003d ch - str + 3;\n\u003e\u003e +       len \u003d ch - str + 4;\n\u003e\u003e         STARTSTACKSTR(copy);\n\u003e\u003e         copy \u003d makestrspace(len, copy);\n\u003e\u003e -       memcpy(copy, str, len - 3);\n\u003e\u003e -       copy[len - 3] \u003d \u0027j\u0027;\n\u003e\u003e +       memcpy(copy, str, len - 4);\n\u003e\u003e +       copy[len - 4] \u003d \u0027l\u0027;\n\u003e\u003e +       copy[len - 3] \u003d \u0027l\u0027;\n\u003e\u003e         copy[len - 2] \u003d *ch;\n\u003e\u003e         copy[len - 1] \u003d \u0027\\0\u0027;\n\u003e\u003e         return (copy);\n\u003e \n\u003e The calling code uses the result to print intmax_t and uintmax_t values.\n\u003e Printing intmax_t values with %lld is wrong, this will only work if\n\u003e intmax_t is really a typedef for long long (which may be true on your\n\u003e system, but is not required by the standard).\n\u003e \n\u003e The other patch that Jonathan linked to should work just fine.\n\nHere\u0027s a slightly tweaked version of that patch. Regardless of whether\nPRIdMAX is defined as \"jd\" or as \"lld\", the use of memcpy here, first\ncopying \"jd\"/\"lld\" and the null byte, and only changing the \u0027d\u0027 after\nthat, surprisingly results in slightly shorter object code than the\noriginal byte-by-byte approach, even though memcpy is fully inlined.\nPerhaps that could be a reason for applying this, even if the original\nreason for it, making the code work on not-quite-conforming systems,\nisn\u0027t good enough to get it in dash.\n\nTested with normal glibc, and with glibc hacked to not provide PRIdMAX.\n\nReviewed-by: Jonathan Nieder \u003cjrnieder@gmail.com\u003e\nSigned-off-by: Herbert Xu \u003cherbert@gondor.apana.org.au\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "911d31eacbcdc96c2601114e29b956ed27c2248c",
      "old_mode": 33188,
      "old_path": "ChangeLog",
      "new_id": "46626b1e350364ede0d9779adf35d3ef84eb5ebc",
      "new_mode": 33188,
      "new_path": "ChangeLog"
    },
    {
      "type": "modify",
      "old_id": "893295ce821cc414e6cc72ac29d96af6c03f3e7f",
      "old_mode": 33188,
      "old_path": "src/bltin/printf.c",
      "new_id": "5f9e81c3a5b31100d9ee6578827100268b757029",
      "new_mode": 33188,
      "new_path": "src/bltin/printf.c"
    }
  ]
}
