---
source: src/patch/parse.rs
expression: patches
input_file: src/patch/test-data/0001-win-deprecations.patch
---
Ok(
    [
        Patch {
            original: Some(
                Filename(
                    "src/zig_llvm.cpp.orig",
                ),
            ),
            modified: Some(
                Filename(
                    "src/zig_llvm.cpp",
                ),
            ),
            hunks: [
                Hunk {
                    old_range: HunkRange {
                        start: 204,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 204,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "        std::error_code EC;\n",
                        ),
                        Context(
                            "        dest_asm_ptr = new(std::nothrow) raw_fd_ostream(asm_filename, EC, sys::fs::OF_None);\n",
                        ),
                        Context(
                            "        if (EC) {\n",
                        ),
                        Delete(
                            "            *error_message = strdup((const char *)StringRef(EC.message()).bytes_begin());\n",
                        ),
                        Insert(
                            "            *error_message = _strdup((const char *)StringRef(EC.message()).bytes_begin());\n",
                        ),
                        Context(
                            "            return true;\n",
                        ),
                        Context(
                            "        }\n",
                        ),
                        Context(
                            "    }\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 212,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 212,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "        std::error_code EC;\n",
                        ),
                        Context(
                            "        dest_bin_ptr = new(std::nothrow) raw_fd_ostream(bin_filename, EC, sys::fs::OF_None);\n",
                        ),
                        Context(
                            "        if (EC) {\n",
                        ),
                        Delete(
                            "            *error_message = strdup((const char *)StringRef(EC.message()).bytes_begin());\n",
                        ),
                        Insert(
                            "            *error_message = _strdup((const char *)StringRef(EC.message()).bytes_begin());\n",
                        ),
                        Context(
                            "            return true;\n",
                        ),
                        Context(
                            "        }\n",
                        ),
                        Context(
                            "    }\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 220,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 220,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "        std::error_code EC;\n",
                        ),
                        Context(
                            "        dest_bitcode_ptr = new(std::nothrow) raw_fd_ostream(bitcode_filename, EC, sys::fs::OF_None);\n",
                        ),
                        Context(
                            "        if (EC) {\n",
                        ),
                        Delete(
                            "            *error_message = strdup((const char *)StringRef(EC.message()).bytes_begin());\n",
                        ),
                        Insert(
                            "            *error_message = _strdup((const char *)StringRef(EC.message()).bytes_begin());\n",
                        ),
                        Context(
                            "            return true;\n",
                        ),
                        Context(
                            "        }\n",
                        ),
                        Context(
                            "    }\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 337,
                        len: 13,
                    },
                    new_range: HunkRange {
                        start: 337,
                        len: 13,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "\n",
                        ),
                        Context(
                            "    if (dest_bin && !lto) {\n",
                        ),
                        Context(
                            "        if (target_machine.addPassesToEmitFile(codegen_pm, *dest_bin, nullptr, CodeGenFileType::ObjectFile)) {\n",
                        ),
                        Delete(
                            "            *error_message = strdup(\"TargetMachine can't emit an object file\");\n",
                        ),
                        Insert(
                            "            *error_message = _strdup(\"TargetMachine can't emit an object file\");\n",
                        ),
                        Context(
                            "            return true;\n",
                        ),
                        Context(
                            "        }\n",
                        ),
                        Context(
                            "    }\n",
                        ),
                        Context(
                            "    if (dest_asm) {\n",
                        ),
                        Context(
                            "        if (target_machine.addPassesToEmitFile(codegen_pm, *dest_asm, nullptr, CodeGenFileType::AssemblyFile)) {\n",
                        ),
                        Delete(
                            "            *error_message = strdup(\"TargetMachine can't emit an assembly file\");\n",
                        ),
                        Insert(
                            "            *error_message = _strdup(\"TargetMachine can't emit an assembly file\");\n",
                        ),
                        Context(
                            "            return true;\n",
                        ),
                        Context(
                            "        }\n",
                        ),
                        Context(
                            "    }\n",
                        ),
                    ],
                },
            ],
        },
        Patch {
            original: Some(
                Filename(
                    "src/zig_llvm-ar.cpp.orig",
                ),
            ),
            modified: Some(
                Filename(
                    "src/zig_llvm-ar.cpp",
                ),
            ),
            hunks: [
                Hunk {
                    old_range: HunkRange {
                        start: 619,
                        len: 8,
                    },
                    new_range: HunkRange {
                        start: 619,
                        len: 8,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "        sys::fs::setLastAccessAndModificationTime(FD, ModTimeOrErr.get()));\n",
                        ),
                        Context(
                            "  }\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Delete(
                            "  if (close(FD))\n",
                        ),
                        Delete(
                            "    fail(\"Could not close the file\");\n",
                        ),
                        Insert(
                            "  if (_close(FD))\n",
                        ),
                        Insert(
                            "    fail(\"Could not _close the file\");\n",
                        ),
                        Context(
                            "}\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "static bool shouldCreateArchive(ArchiveOperation Op) {\n",
                        ),
                    ],
                },
            ],
        },
    ],
)
