summaryrefslogtreecommitdiff
path: root/usr.bin/patch/common.h
diff options
context:
space:
mode:
authorjoerg <joerg@NetBSD.org>2008-09-19 18:33:34 +0000
committerjoerg <joerg@NetBSD.org>2008-09-19 18:33:34 +0000
commitd5b2c9a8256bb738e99f71510f32d4ab70f76f03 (patch)
treeade297b9e3ea4e09610f0640b0687a97022e80ec /usr.bin/patch/common.h
parent97e276be341799ee7ff55d4c7625d953c4c93266 (diff)
Update patch to the version used by DragonFly and derived from OpenBSD.
Major changes are: - better detection of double applied patches - rejects remain unified diffs for unified patches - far less limitations, e.g. patch lines may be arbitrary long This addresses PR standards/11220 by changing patch -b behavior to be POSIX compliant. Old behavior can be obtained using --suffix, which works since NetBSD 1.4. pkgsrc has been adjusted accordingly.
Diffstat (limited to 'usr.bin/patch/common.h')
-rw-r--r--usr.bin/patch/common.h182
1 files changed, 70 insertions, 112 deletions
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index 2a53f03f537..c2402d8f2d7 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,64 +1,48 @@
-/* $NetBSD: common.h,v 1.18 2007/10/14 04:54:34 lukem Exp $ */
+/*
+ * $OpenBSD: common.h,v 1.26 2006/03/11 19:41:30 otto Exp $
+ * $DragonFly: src/usr.bin/patch/common.h,v 1.5 2008/08/10 23:50:12 joerg Exp $
+ * $NetBSD: common.h,v 1.19 2008/09/19 18:33:34 joerg Exp $
+ */
/*
- * Copyright (c) 1988, Larry Wall
- *
+ * patch - a program to apply diffs to original files
+ *
+ * Copyright 1986, Larry Wall
+ *
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following condition
- * is met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this condition and the following disclaimer.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * modification, are permitted provided that the following condition is met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this condition and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * -C option added in 1998, original code by Marc Espie, based on FreeBSD
+ * behaviour
*/
-#define DEBUGGING
-
-/* shut lint up about the following when return value ignored */
-
-#define Signal (void)signal
-#define Unlink (void)unlink
-#define Lseek (void)lseek
-#define Fseek (void)fseek
-#define Fstat (void)fstat
-#define Pclose (void)pclose
-#define Close (void)close
-#define Fclose (void)fclose
-#define Fflush (void)fflush
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <signal.h>
-/* constants */
+#include <stdbool.h>
+#include <stdint.h>
-/* AIX predefines these. */
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE (1)
-#define FALSE (0)
+#define DEBUGGING
-#define MAXHUNKSIZE 100000 /* is this enough lines? */
-#define INITHUNKMAX 125 /* initial dynamic allocation size */
-#define MAXLINELEN 10240
+/* constants */
+
+#define MAXHUNKSIZE 100000 /* is this enough lines? */
+#define INITHUNKMAX 125 /* initial dynamic allocation size */
+#define MAXLINELEN 8192
+#define BUFFERSIZE 1024
#define SCCSPREFIX "s."
#define GET "get -e %s"
@@ -73,8 +57,6 @@
/* handy definitions */
-#define Nulline 0
-
#define strNE(s1,s2) (strcmp(s1, s2))
#define strEQ(s1,s2) (!strcmp(s1, s2))
#define strnNE(s1,s2,l) (strncmp(s1, s2, l))
@@ -82,83 +64,59 @@
/* typedefs */
-typedef char bool;
-typedef int LINENUM; /* must be signed */
+typedef long LINENUM; /* must be signed */
/* globals */
-EXT int Argc; /* guess */
-EXT char **Argv;
+extern mode_t filemode;
-/* TRUE if -C was specified on command line. */
-EXT int check_only;
+extern char buf[MAXLINELEN];/* general purpose buffer */
+extern size_t buf_len;
-EXT struct stat filestat; /* file statistics area */
-EXT mode_t filemode INIT(0644);
+extern bool using_plan_a; /* try to keep everything in memory */
+extern bool out_of_mem; /* ran out of memory in plan a */
-EXT char buf[MAXLINELEN]; /* general purpose buffer */
-EXT FILE *ofp INIT(NULL); /* output file pointer */
-EXT FILE *rejfp INIT(NULL); /* reject file pointer */
+#define MAXFILEC 2
-EXT int myuid; /* cache getuid return value */
+extern char *filearg[MAXFILEC];
+extern bool ok_to_create_file;
+extern char *outname;
+extern char *origprae;
+
+extern char *TMPOUTNAME;
+extern char *TMPINNAME;
+extern char *TMPREJNAME;
+extern char *TMPPATNAME;
+extern bool toutkeep;
+extern bool trejkeep;
-#define MAXFILEC 2
-EXT int filec INIT(0); /* how many file arguments? */
-EXT char *filearg[MAXFILEC];
-EXT bool ok_to_create_file INIT(FALSE);
-EXT bool filename_is_dev_null INIT(FALSE);
-EXT bool old_file_is_dev_null INIT(FALSE);
-EXT char *bestguess INIT(NULL); /* guess at correct filename */
-
-EXT char *outname INIT(NULL);
-EXT char rejname[128];
-
-EXT char *origprae INIT(NULL);
-
-EXT char *TMPOUTNAME;
-EXT char *TMPINNAME;
-EXT char *TMPREJNAME;
-EXT char *TMPPATNAME;
-EXT bool toutkeep INIT(FALSE);
-EXT bool trejkeep INIT(FALSE);
-
-EXT LINENUM last_offset INIT(0);
#ifdef DEBUGGING
-EXT int debug INIT(0);
+extern int debug;
#endif
-EXT LINENUM maxfuzz INIT(2);
-EXT bool force INIT(FALSE);
-EXT bool batch INIT(FALSE);
-EXT bool verbose INIT(TRUE);
-EXT bool reverse INIT(FALSE);
-EXT bool noreverse INIT(FALSE);
-EXT bool skip_rest_of_patch INIT(FALSE);
-EXT int strippath INIT(957);
-EXT bool canonicalize INIT(FALSE);
+
+extern bool force;
+extern bool batch;
+extern bool verbose;
+extern bool reverse;
+extern bool noreverse;
+extern bool skip_rest_of_patch;
+extern int strippath;
+extern bool canonicalize;
+/* TRUE if -C was specified on command line. */
+extern bool check_only;
+extern bool warn_on_invalid_line;
+extern bool last_line_missing_eol;
+
#define CONTEXT_DIFF 1
#define NORMAL_DIFF 2
#define ED_DIFF 3
#define NEW_CONTEXT_DIFF 4
#define UNI_DIFF 5
-EXT int diff_type INIT(0);
-
-EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */
-EXT char if_defined[128]; /* #ifdef xyzzy */
-EXT char not_defined[128]; /* #ifndef xyzzy */
-EXT char else_defined[] INIT("#else\n");/* #else */
-EXT char end_defined[128]; /* #endif xyzzy */
-
-EXT char *revision INIT(NULL); /* prerequisite revision, if any */
-#include <errno.h>
+extern int diff_type;
+extern char *revision; /* prerequisite revision, if any */
+extern LINENUM input_lines; /* how long is input file in lines */
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-#if !defined(S_ISREG) && defined(S_IFREG)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
+extern int posix;
-void my_exit(int) __attribute__((__noreturn__));
-void my_sig_exit(int) __attribute__((__noreturn__));