diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-06-22 18:02:54 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-06-22 18:02:54 +0200 |
| commit | 596b0c08a7326a28c11d6c66e60e591fb642b0c1 (patch) | |
| tree | 9ebd31025fe8f2f8a253b61c424ab9cad7f9ef82 | |
| parent | ff265082fdc8cdb521d8bcf2d3b55fb6ea9797a6 (diff) | |
| download | spatch-master.tar.gz spatch-master.zip | |
| -rw-r--r-- | LICENSE | 21 | ||||
| -rwxr-xr-x | spatch (renamed from patch.py) | 8 |
2 files changed, 24 insertions, 5 deletions
@@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Louis Burda + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -import sys, os, re -from os import path +import sys, re file_header = """\ --- ([^\\n\\t]*)(\\t[^\n]*)? @@ -64,7 +63,7 @@ def patch_file(src_filename, dst_filename, content): src_nl = dst_nl = True for i,l in enumerate(chunk_content): - if i != 0 and l == '\ No newline at end of file': + if i != 0 and l == '\\ No newline at end of file': if chunk_content[i-1][0] == '+': src_nl = False elif chunk_content[i-1][0] == '-': @@ -91,7 +90,6 @@ def main(): else: targetdir = None - noprompt = (os.getenv("NOPROMPT") != None) diff_file = sys.argv[1] content = open(diff_file).read() @@ -101,7 +99,7 @@ def main(): return 1 header_matches = list() next_header_match = True # for do_while loop - while (next_header_match): + while next_header_match: next_header_match = file_header_pattern.search(content, prev_header_match.span()[1]) header_matches.append(prev_header_match) prev_header_match = next_header_match |
