Page MenuHomeFreeBSD

D43850.diff
No OneTemporary

D43850.diff

diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1085,7 +1085,7 @@
LINENUM pat_lines = pch_ptrn_lines() - fuzz;
const char *ilineptr;
const char *plineptr;
- unsigned short plinelen;
+ size_t plinelen;
/* Patch does not match if we don't have any more context to use */
if (pline > pat_lines)
diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h
--- a/usr.bin/patch/pch.h
+++ b/usr.bin/patch/pch.h
@@ -45,7 +45,7 @@
bool another_hunk(void);
bool pch_swap(void);
char *pfetch(LINENUM);
-unsigned short pch_line_len(LINENUM);
+size_t pch_line_len(LINENUM);
LINENUM pch_first(void);
LINENUM pch_ptrn_lines(void);
LINENUM pch_newfirst(void);
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -55,7 +55,7 @@
static LINENUM p_context = 3; /* # of context lines */
static LINENUM p_input_line = 0; /* current line # from patch file */
static char **p_line = NULL;/* the text of the hunk */
-static unsigned short *p_len = NULL; /* length of each line */
+static size_t *p_len = NULL; /* length of each line */
static char *p_char = NULL; /* +, -, and ! */
static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */
static int p_indent; /* indent to patch */
@@ -137,7 +137,7 @@
if (p_line == NULL)
p_line = malloc(hunkmax * sizeof(char *));
if (p_len == NULL)
- p_len = malloc(hunkmax * sizeof(unsigned short));
+ p_len = malloc(hunkmax * sizeof(size_t));
if (p_char == NULL)
p_char = malloc(hunkmax * sizeof(char));
}
@@ -154,7 +154,7 @@
fatal("Internal memory allocation error\n");
p_line = reallocf(p_line, new_hunkmax * sizeof(char *));
- p_len = reallocf(p_len, new_hunkmax * sizeof(unsigned short));
+ p_len = reallocf(p_len, new_hunkmax * sizeof(size_t));
p_char = reallocf(p_char, new_hunkmax * sizeof(char));
if (p_line != NULL && p_len != NULL && p_char != NULL) {
@@ -1251,7 +1251,7 @@
pch_swap(void)
{
char **tp_line; /* the text of the hunk */
- unsigned short *tp_len;/* length of each line */
+ size_t *tp_len; /* length of each line */
char *tp_char; /* +, -, and ! */
LINENUM i;
LINENUM n;
@@ -1408,7 +1408,7 @@
/*
* Return the length of a particular patch line.
*/
-unsigned short
+size_t
pch_line_len(LINENUM line)
{
return p_len[line];
diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh
--- a/usr.bin/patch/tests/unified_patch_test.sh
+++ b/usr.bin/patch/tests/unified_patch_test.sh
@@ -141,6 +141,24 @@
atf_check -o inline:"y\n" cat foo
}
+atf_test_case plinelen
+plinelen_body()
+{
+ hello="$(jot -b hello -s, 20000 | tee foo.txt)"
+ cp foo.txt bar.txt
+ echo "world" >>bar.txt
+ cat >foo.diff <<EOF
+--- foo.txt.orig
++++ foo.txt
+@@ -1,1 +1,2 @@
+ $hello
++world
+EOF
+ atf_check -o match:"Hunk #1 succeeded" \
+ patch <foo.diff
+ atf_check -o file:bar.txt cat foo.txt
+}
+
atf_init_test_cases()
{
atf_add_test_case basic
@@ -148,4 +166,5 @@
atf_add_test_case file_creation
atf_add_test_case file_nodupe
atf_add_test_case file_removal
+ atf_add_test_case plinelen
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 8:57 PM (21 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14664392
Default Alt Text
D43850.diff (3 KB)

Event Timeline