Deleted Added
full compact
patch.c (256281) patch.c (267746)
1/*-
2 * Copyright 1986, Larry Wall
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following condition is met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this condition and the following disclaimer.
8 *

--- 10 unchanged lines hidden (view full) ---

19 * SUCH DAMAGE.
20 *
21 * patch - a program to apply diffs to original files
22 *
23 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
24 * behaviour
25 *
26 * $OpenBSD: patch.c,v 1.50 2012/05/15 19:32:02 millert Exp $
1/*-
2 * Copyright 1986, Larry Wall
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following condition is met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this condition and the following disclaimer.
8 *

--- 10 unchanged lines hidden (view full) ---

19 * SUCH DAMAGE.
20 *
21 * patch - a program to apply diffs to original files
22 *
23 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
24 * behaviour
25 *
26 * $OpenBSD: patch.c,v 1.50 2012/05/15 19:32:02 millert Exp $
27 * $FreeBSD: stable/10/usr.bin/patch/patch.c 255894 2013-09-26 18:00:45Z delphij $
27 * $FreeBSD: stable/10/usr.bin/patch/patch.c 267746 2014-06-22 20:24:17Z pfg $
28 *
29 */
30
31#include <sys/types.h>
32#include <sys/stat.h>
33
34#include <ctype.h>
35#include <getopt.h>

--- 701 unchanged lines hidden (view full) ---

737 fatal("fatal internal error in abort_context_hunk\n");
738 }
739 }
740}
741
742static void
743rej_line(int ch, LINENUM i)
744{
28 *
29 */
30
31#include <sys/types.h>
32#include <sys/stat.h>
33
34#include <ctype.h>
35#include <getopt.h>

--- 701 unchanged lines hidden (view full) ---

737 fatal("fatal internal error in abort_context_hunk\n");
738 }
739 }
740}
741
742static void
743rej_line(int ch, LINENUM i)
744{
745 size_t len;
745 unsigned short len;
746 const char *line = pfetch(i);
747
746 const char *line = pfetch(i);
747
748 len = strlen(line);
748 len = strnlen(line, USHRT_MAX);
749
750 fprintf(rejfp, "%c%s", ch, line);
749
750 fprintf(rejfp, "%c%s", ch, line);
751 if (len == 0 || line[len-1] != '\n')
752 fprintf(rejfp, "\n\\ No newline at end of file\n");
751 if (len == 0 || line[len-1] != '\n') {
752 if (len >= USHRT_MAX)
753 fprintf(rejfp, "\n\\ Line too long\n");
754 else
755 fprintf(rejfp, "\n\\ No newline at end of line\n");
756 }
753}
754
755static void
756abort_hunk(void)
757{
758 LINENUM i, j, split;
759 int ch1, ch2;
760 const LINENUM pat_end = pch_end();

--- 250 unchanged lines hidden (view full) ---

1011static bool
1012patch_match(LINENUM base, LINENUM offset, LINENUM fuzz)
1013{
1014 LINENUM pline = 1 + fuzz;
1015 LINENUM iline;
1016 LINENUM pat_lines = pch_ptrn_lines() - fuzz;
1017 const char *ilineptr;
1018 const char *plineptr;
757}
758
759static void
760abort_hunk(void)
761{
762 LINENUM i, j, split;
763 int ch1, ch2;
764 const LINENUM pat_end = pch_end();

--- 250 unchanged lines hidden (view full) ---

1015static bool
1016patch_match(LINENUM base, LINENUM offset, LINENUM fuzz)
1017{
1018 LINENUM pline = 1 + fuzz;
1019 LINENUM iline;
1020 LINENUM pat_lines = pch_ptrn_lines() - fuzz;
1021 const char *ilineptr;
1022 const char *plineptr;
1019 short plinelen;
1023 unsigned short plinelen;
1020
1021 for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
1022 ilineptr = ifetch(iline, offset >= 0);
1023 if (ilineptr == NULL)
1024 return false;
1025 plineptr = pfetch(pline);
1026 plinelen = pch_line_len(pline);
1027 if (canonicalize) {

--- 47 unchanged lines hidden ---
1024
1025 for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
1026 ilineptr = ifetch(iline, offset >= 0);
1027 if (ilineptr == NULL)
1028 return false;
1029 plineptr = pfetch(pline);
1030 plinelen = pch_line_len(pline);
1031 if (canonicalize) {

--- 47 unchanged lines hidden ---