Show a patch.

GET /api/patches/18043/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18043,
    "url": "https://patchwork.libcamera.org/api/patches/18043/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18043/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20221221173847.73663-1-kieran.bingham@ideasonboard.com>",
    "date": "2022-12-21T17:38:47",
    "name": "[libcamera-devel] libcamera: yaml_parser: Use C locale",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ff041329309ff13aa774e010658fa67272ab4e78",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18043/mbox/",
    "series": [
        {
            "id": 3682,
            "url": "https://patchwork.libcamera.org/api/series/3682/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3682",
            "date": "2022-12-21T17:38:47",
            "name": "[libcamera-devel] libcamera: yaml_parser: Use C locale",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3682/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18043/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18043/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 43271C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Dec 2022 17:38:59 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 91674633AC;\n\tWed, 21 Dec 2022 18:38:58 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA38761F15\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Dec 2022 18:38:56 +0100 (CET)",
            "from Monstersaurus.local\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 25E1CFB;\n\tWed, 21 Dec 2022 18:38:56 +0100 (CET)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1671644338;\n\tbh=DK7w0U+it7/g4751mM2UxK/8nzvs5hfzd7zYdT9I9Qk=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=25hB6TcovNwCQaM2FsdbgbpHHyYzIRhRiG4y+pI4rI6UZMXQJUqaPZ9Xxw/8zne1S\n\tR59sP6sjW+KCtOaYV2HiJ8XMWtEBdnjIXIHYm+nyA+yysEFghpUc+vJf2YPMB7Z42u\n\te2JO3FNme8zP52ZKvd8PJYIyJCztZ7mzga9Ft+OlGF/vJUXABOucQZ9y8dqV7x6QNZ\n\tYJNNacim0/3eUHxCYteEeXl1ADUNN/4jAav0uc3Te6Ih5O2wAQws2oNWrnzrGxVXQj\n\t+VIrDSC7g7EWoWwOY0vX2RyNI+VI9zgj6zkSv3v46nf/7cSuJzrXy1KtXtSEdMateq\n\tQyCQ77P9COpSg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1671644336;\n\tbh=DK7w0U+it7/g4751mM2UxK/8nzvs5hfzd7zYdT9I9Qk=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=NKu77dmfjrNh92GDgl/Gov3GPPEFWBebmMK50CouO30hmSLVnWS1GdVuQMJYibgvQ\n\th78Zss8S99FP76wVb9FtvyY0JJCnZR0i46LFbNLUBzVi0iiePzNrtg01j4NHBpgnU4\n\tTwUNyhE/JjNsssONL0t5GlibsVGO8th3qSxFS3tg="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"NKu77dmf\"; dkim-atps=neutral",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Wed, 21 Dec 2022 17:38:47 +0000",
        "Message-Id": "<20221221173847.73663-1-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: yaml_parser: Use C locale",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "From": "Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Cc": "Hannes Winkler <hanneswinkler2000@web.de>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "When parsing configuration files on systems with differing locales, the\nuse of strtod can produce different results, or in the worst case - fail\nto parse expected values.\n\nProvide an RAII implementation to construct a locale specific to the\nexpected mappings for configuration files provided by libcamera.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=174\nBug: https://github.com/raspberrypi/libcamera/issues/29\nReported-by: https://github.com/kralo\nReported-by: Hannes Winkler <hanneswinkler2000@web.de>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/yaml_parser.cpp | 32 +++++++++++++++++++++++++++++++-\n 1 file changed, 31 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex d8a7c2f9250f..8ddc6d6b5fd5 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -31,6 +31,36 @@ namespace {\n /* Empty static YamlObject as a safe result for invalid operations */\n static const YamlObject empty;\n \n+/*\n+ * Construct a global RAII locale for use by all YAML parser instances to\n+ * ensure consistency when parsing configuration files and types regardless of\n+ * the host Locale configuration.\n+ *\n+ * For more information see:\n+ * - https://bugs.libcamera.org/show_bug.cgi?id=174\n+ */\n+class Locale\n+{\n+public:\n+\tLocale(std::string locale)\n+\t{\n+\t\tlocale_ = newlocale(LC_ALL_MASK, locale.c_str(), (locale_t)0);\n+\t\tif (locale_ == (locale_t)0)\n+\t\t\tLOG(YamlParser, Fatal)\n+\t\t\t\t<< \"Failed to construct a locale\";\n+\t}\n+\t~Locale()\n+\t{\n+\t\tfreelocale(locale_);\n+\t}\n+\tlocale_t locale() { return locale_; }\n+\n+private:\n+\tlocale_t locale_;\n+};\n+\n+static Locale yamlLocale(\"C\");\n+\n } /* namespace */\n \n /**\n@@ -283,7 +313,7 @@ std::optional<double> YamlObject::get() const\n \tchar *end;\n \n \terrno = 0;\n-\tdouble value = std::strtod(value_.c_str(), &end);\n+\tdouble value = strtod_l(value_.c_str(), &end, yamlLocale.locale());\n \n \tif ('\\0' != *end || errno == ERANGE)\n \t\treturn std::nullopt;\n",
    "prefixes": [
        "libcamera-devel"
    ]
}