diff options
author | V1K1NGbg <victor@ilchev.com> | 2024-08-03 18:15:43 +0300 |
---|---|---|
committer | V1K1NGbg <victor@ilchev.com> | 2024-08-05 20:51:31 +0300 |
commit | 20bfc4a61ef3da865dfccbd13c7046a43cea818c (patch) | |
tree | fe4f791ec4dbc7ea5ecb78b77c5595ffd7208126 | |
parent | e45c52d01f8e0abffebbfb4a0ac8a72b8f0f62ba (diff) | |
download | luarocks-20bfc4a61ef3da865dfccbd13c7046a43cea818c.tar.gz luarocks-20bfc4a61ef3da865dfccbd13c7046a43cea818c.tar.bz2 luarocks-20bfc4a61ef3da865dfccbd13c7046a43cea818c.zip |
patch try only integers
-rw-r--r-- | src/luarocks/tools/patch.lua | 8 | ||||
-rw-r--r-- | src/luarocks/tools/patch.tl | 28 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 14d600bf..fe12244f 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -368,10 +368,10 @@ function patch.read_patch(filename, data) | |||
368 | end | 368 | end |
369 | state = 'header' | 369 | state = 'header' |
370 | else | 370 | else |
371 | hunkinfo.startsrc = tonumber(m1) | 371 | hunkinfo.startsrc = math.tointeger(m1) |
372 | hunkinfo.linessrc = tonumber(tonumber(m2) or 1) | 372 | hunkinfo.linessrc = math.tointeger(math.tointeger(m2) or 1) |
373 | hunkinfo.starttgt = tonumber(m3) | 373 | hunkinfo.starttgt = math.tointeger(m3) |
374 | hunkinfo.linestgt = tonumber(tonumber(m4) or 1) | 374 | hunkinfo.linestgt = math.tointeger(math.tointeger(m4) or 1) |
375 | hunkinfo.invalid = false | 375 | hunkinfo.invalid = false |
376 | hunkinfo.text = {} | 376 | hunkinfo.text = {} |
377 | 377 | ||
diff --git a/src/luarocks/tools/patch.tl b/src/luarocks/tools/patch.tl index 13ab53e2..a5d67e18 100644 --- a/src/luarocks/tools/patch.tl +++ b/src/luarocks/tools/patch.tl | |||
@@ -10,15 +10,15 @@ | |||
10 | 10 | ||
11 | local record patch | 11 | local record patch |
12 | record Lineends | 12 | record Lineends |
13 | lf: number | 13 | lf: integer |
14 | crlf: number | 14 | crlf: integer |
15 | cr: number | 15 | cr: integer |
16 | end | 16 | end |
17 | record Hunk | 17 | record Hunk |
18 | startsrc: number | 18 | startsrc: integer |
19 | linessrc: number | 19 | linessrc: integer |
20 | starttgt: number | 20 | starttgt: integer |
21 | linestgt: number | 21 | linestgt: integer |
22 | invalid: boolean | 22 | invalid: boolean |
23 | text: {string} | 23 | text: {string} |
24 | end | 24 | end |
@@ -368,10 +368,10 @@ function patch.read_patch(filename: string, data: string): Files, boolean | |||
368 | end | 368 | end |
369 | state = 'header' | 369 | state = 'header' |
370 | else | 370 | else |
371 | hunkinfo.startsrc = tonumber(m1) | 371 | hunkinfo.startsrc = math.tointeger(m1) |
372 | hunkinfo.linessrc = tonumber(tonumber(m2) or 1) --! | 372 | hunkinfo.linessrc = math.tointeger(math.tointeger(m2) or 1) --! |
373 | hunkinfo.starttgt = tonumber(m3) | 373 | hunkinfo.starttgt = math.tointeger(m3) |
374 | hunkinfo.linestgt = tonumber(tonumber(m4) or 1) | 374 | hunkinfo.linestgt = math.tointeger(math.tointeger(m4) or 1) |
375 | hunkinfo.invalid = false | 375 | hunkinfo.invalid = false |
376 | hunkinfo.text = {} | 376 | hunkinfo.text = {} |
377 | 377 | ||
@@ -402,7 +402,7 @@ function patch.read_patch(filename: string, data: string): Files, boolean | |||
402 | return files, all_ok | 402 | return files, all_ok |
403 | end | 403 | end |
404 | 404 | ||
405 | local function find_hunk(file: {string}, h: Hunk, hno: number): boolean | 405 | local function find_hunk(file: {string}, h: Hunk, hno: integer): boolean |
406 | for fuzz=0,2 do | 406 | for fuzz=0,2 do |
407 | local lineno = h.startsrc | 407 | local lineno = h.startsrc |
408 | for i=0,#file do | 408 | for i=0,#file do |
@@ -412,7 +412,7 @@ local function find_hunk(file: {string}, h: Hunk, hno: number): boolean | |||
412 | if l > fuzz then | 412 | if l > fuzz then |
413 | -- todo: \ No newline at the end of file | 413 | -- todo: \ No newline at the end of file |
414 | if startswith(hline, " ") or startswith(hline, "-") then | 414 | if startswith(hline, " ") or startswith(hline, "-") then |
415 | local line = file[lineno as integer] --! cast | 415 | local line = file[lineno] --! cast |
416 | lineno = lineno + 1 | 416 | lineno = lineno + 1 |
417 | if not line or #line == 0 then | 417 | if not line or #line == 0 then |
418 | found = false | 418 | found = false |
@@ -636,7 +636,7 @@ local function patch_file(source: string, target: string, epoch: boolean, hunks: | |||
636 | 636 | ||
637 | find_hunks(file, hunks) | 637 | find_hunks(file, hunks) |
638 | 638 | ||
639 | local function process_line(line: string, lineno: number): boolean | 639 | local function process_line(line: string, lineno: integer): boolean |
640 | if not hunk or lineno < hunk.startsrc then | 640 | if not hunk or lineno < hunk.startsrc then |
641 | return false | 641 | return false |
642 | end | 642 | end |