-/* $OpenBSD: patch.c,v 1.71 2022/08/03 07:30:37 op Exp $ */
+/* $OpenBSD: patch.c,v 1.72 2023/07/12 11:26:13 tb Exp $ */
/*
* patch - a program to apply diffs to original files
static void spew_output(void);
static void dump_line(LINENUM, bool);
static bool patch_match(LINENUM, LINENUM, LINENUM);
-static bool similar(const char *, const char *, int);
+static bool similar(const char *, const char *, ssize_t);
static __dead void usage(void);
/* true if -E was specified on command line. */
LINENUM pat_lines = pch_ptrn_lines() - fuzz;
const char *ilineptr;
const char *plineptr;
- short plinelen;
+ ssize_t plinelen;
for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
ilineptr = ifetch(iline, offset >= 0);
* Do two lines match with canonicalized white space?
*/
static bool
-similar(const char *a, const char *b, int len)
+similar(const char *a, const char *b, ssize_t len)
{
while (len) {
if (isspace((unsigned char)*b)) { /* whitespace (or \n) to match? */
-/* $OpenBSD: pch.c,v 1.63 2022/12/26 19:16:02 jmc Exp $ */
+/* $OpenBSD: pch.c,v 1.64 2023/07/12 11:26:13 tb Exp $ */
/*
* patch - a program to apply diffs to original files
static LINENUM p_max; /* max allowed value of p_end */
static LINENUM p_context = 3; /* # of context lines */
static char **p_line = NULL;/* the text of the hunk */
-static short *p_len = NULL; /* length of each line */
+static ssize_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 */
if (p_line == NULL)
p_line = calloc((size_t) hunkmax, sizeof(char *));
if (p_len == NULL)
- p_len = calloc((size_t) hunkmax, sizeof(short));
+ p_len = calloc((size_t) hunkmax, sizeof(ssize_t));
if (p_char == NULL)
p_char = calloc((size_t) hunkmax, sizeof(char));
}
{
int new_hunkmax;
char **new_p_line;
- short *new_p_len;
+ ssize_t *new_p_len;
char *new_p_char;
new_hunkmax = hunkmax * 2;
if (new_p_line == NULL)
free(p_line);
- new_p_len = reallocarray(p_len, new_hunkmax, sizeof(short));
+ new_p_len = reallocarray(p_len, new_hunkmax, sizeof(ssize_t));
if (new_p_len == NULL)
free(p_len);
pch_swap(void)
{
char **tp_line; /* the text of the hunk */
- short *tp_len; /* length of each line */
+ ssize_t *tp_len; /* length of each line */
char *tp_char; /* +, -, and ! */
LINENUM i;
LINENUM n;
/*
* Return the length of a particular patch line.
*/
-short
+ssize_t
pch_line_len(LINENUM line)
{
return p_len[line];
-/* $OpenBSD: pch.h,v 1.13 2019/12/11 20:10:17 jca Exp $ */
+/* $OpenBSD: pch.h,v 1.14 2023/07/12 11:26:13 tb Exp $ */
/*
* patch - a program to apply diffs to original files
LINENUM pch_repl_lines(void);
LINENUM pch_end(void);
LINENUM pch_context(void);
-short pch_line_len(LINENUM);
+ssize_t pch_line_len(LINENUM);
char pch_char(LINENUM);
char *pfetch(LINENUM);
LINENUM pch_hunk_beg(void);