Show a patch.

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

{
    "id": 18080,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18080/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18080/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20221230002309.3135078-1-kieran.bingham@ideasonboard.com>",
    "date": "2022-12-30T00:23:09",
    "name": "[libcamera-devel,v2] libcamera: yaml_parser: Use C locale",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f723ef96c0fd5a9d65110df75e4c31497e73c7de",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18080/mbox/",
    "series": [
        {
            "id": 3696,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3696/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3696",
            "date": "2022-12-30T00:23:09",
            "name": "[libcamera-devel,v2] libcamera: yaml_parser: Use C locale",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3696/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18080/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18080/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 A5CE2C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 Dec 2022 00:23:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6468625CF;\n\tFri, 30 Dec 2022 01:23:15 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E76261F13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Dec 2022 01:23:13 +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 A2B886D0;\n\tFri, 30 Dec 2022 01:23:12 +0100 (CET)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1672359795;\n\tbh=cj+q4I3GI2lJqodNA3mfw9WbdHyR7aIfFp/y/6PZgYs=;\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=gl1j5mMq8uf+GjGvsSU/koPP5TsjnO7POhTe/pEpA6Ti/Uhrwow0M3vzn8NBnDni/\n\tcxtekFPh6ezTJyhIHFvk/bANFk0Z5IL+19dse1oQy6qE4yIlsdnpuEwruhHefSZWjY\n\tzIrdeOw/ctD7CPSTfPh2RSXOqTOMV12i5lfuK8z1LjJHrO6eTFraclSBTsxkFdAgRN\n\t5s4Ne8w4+jdj+oUhdqT2oJL1W/Gm5EI2bBZaQeDoeQEoDepDgz66TuInkwrWDX7Ebg\n\tYKKDBE2iNa+HvrPk2A9FX8RvjOlBqjSxBN1Q7F+Wf0J3apcToDtKnu/J/3JhGRAg4R\n\tlL4I18rBVNBsQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1672359792;\n\tbh=cj+q4I3GI2lJqodNA3mfw9WbdHyR7aIfFp/y/6PZgYs=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=VnpLt7kK4wK6jMBcX5JZpK2cyLahTx0uhrz7d1yDaZ6AnKoO1kx1U1BAhI3Kds9QY\n\tnIbJqOZnRoCtOacEB8xW33qrgmtwFGg6sPw9b9dP0E2XWaWhtdb1agTqwROkbNndCn\n\txMM9t5uD6KMTkVjaXDRrr3tZ8ntGX7Mi7VM201yI="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VnpLt7kK\"; dkim-atps=neutral",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Fri, 30 Dec 2022 00:23:09 +0000",
        "Message-Id": "<20221230002309.3135078-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 v2] 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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nv2:\n - use const char * over std::string\n - use C++ static casts\n - fix blank lines\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/yaml_parser.cpp | 34 +++++++++++++++++++++++++++++++++-\n 1 file changed, 33 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex d8a7c2f9250f..c7fd80cdea1b 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -31,6 +31,38 @@ 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(const char *locale)\n+\t{\n+\t\tlocale_ = newlocale(LC_ALL_MASK, locale, static_cast<locale_t>(0));\n+\t\tif (locale_ == static_cast<locale_t>(0))\n+\t\t\tLOG(YamlParser, Fatal)\n+\t\t\t\t<< \"Failed to construct a locale\";\n+\t}\n+\n+\t~Locale()\n+\t{\n+\t\tfreelocale(locale_);\n+\t}\n+\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 +315,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",
        "v2"
    ]
}