Index: src/patch.c
===================================================================
--- src/patch.c (nonexistent)
+++ src/patch.c (revision 5)
@@ -0,0 +1,2013 @@
+/* patch - a program to apply diffs to original files */
+
+/* Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall
+
+ Copyright (C) 1989-1993, 1997-1999, 2002-2003, 2006, 2009-2012 Free Software
+ Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define XTERN
+#include <common.h>
+#undef XTERN
+#define XTERN extern
+#include <argmatch.h>
+#include <exitfail.h>
+#include <getopt.h>
+#include <inp.h>
+#include <pch.h>
+#include <quotearg.h>
+#include <util.h>
+#include <version.h>
+#include <xalloc.h>
+#include <gl_linked_list.h>
+#include <gl_xlist.h>
+#include <minmax.h>
+#include <safe.h>
+
+/* procedures */
+
+static FILE *create_output_file (char const *, int);
+static lin locate_hunk (lin);
+static bool check_line_endings (lin);
+static bool apply_hunk (struct outstate *, lin);
+static bool patch_match (lin, lin, lin, lin);
+static bool spew_output (struct outstate *, struct stat *);
+static int numeric_string (char const *, bool, char const *);
+static void cleanup (void);
+static void get_some_switches (void);
+static void init_output (struct outstate *);
+static FILE *open_outfile (char const *);
+static void init_reject (char const *);
+static void reinitialize_almost_everything (void);
+static void remove_if_needed (char const *, bool *);
+static void usage (FILE *, int) __attribute__((noreturn));
+
+static void abort_hunk (char const *, bool, bool);
+static void abort_hunk_context (bool, bool);
+static void abort_hunk_unified (bool, bool);
+
+static void output_file (char const *, bool *, const struct stat *, char const *,
+ const struct stat *, mode_t, bool);
+
+static void init_files_to_delete (void);
+static void init_files_to_output (void);
+static void delete_files (void);
+static void output_files (struct stat const *);
+
+#ifdef ENABLE_MERGE
+static bool merge;
+#else
+# define merge false
+#endif
+
+static enum diff reject_format = NO_DIFF; /* automatic */
+static bool make_backups;
+static bool backup_if_mismatch;
+static char const *version_control;
+static char const *version_control_context;
+static bool remove_empty_files;
+static bool explicit_inname;
+static enum { RO_IGNORE, RO_WARN, RO_FAIL } read_only_behavior = RO_WARN;
+
+/* true if -R was specified on command line. */
+static bool reverse_flag_specified;
+
+static char const *do_defines; /* symbol to patch using ifdef, ifndef, etc. */
+static char const if_defined[] = "\n#ifdef %s\n";
+static char const not_defined[] = "\n#ifndef %s\n";
+static char const else_defined[] = "\n#else\n";
+static char const end_defined[] = "\n#endif\n";
+
+static int Argc;
+static char **Argv;
+
+static FILE *rejfp; /* reject file pointer */
+
+static char const *patchname;
+static char *rejname;
+static char const * TMPREJNAME;
+static bool TMPREJNAME_needs_removal;
+
+static lin maxfuzz = 2;
+
+static char serrbuf[BUFSIZ];
+
+/* Apply a set of diffs as appropriate. */
+
+int
+main (int argc, char **argv)
+{
+ char const *val;
+ bool somefailed = false;
+ struct outstate outstate;
+ struct stat tmpoutst;
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ bool written_to_rejname = false;
+ bool skip_reject_file = false;
+ bool apply_empty_patch = false;
+ mode_t file_type;
+ int outfd = -1;
+ bool have_git_diff = false;
+
+ exit_failure = 2;
+ set_program_name (argv[0]);
+ init_time ();
+
+ setbuf(stderr, serrbuf);
+
+ bufsize = 8 * 1024;
+ buf = xmalloc (bufsize);
+
+ strippath = -1;
+
+ val = getenv ("QUOTING_STYLE");
+ {
+ int i = val ? argmatch (val, quoting_style_args, 0, 0) : -1;
+ set_quoting_style ((struct quoting_options *) 0,
+ i < 0 ? shell_quoting_style : (enum quoting_style) i);
+ }
+
+ posixly_correct = getenv ("POSIXLY_CORRECT") != 0;
+ backup_if_mismatch = ! posixly_correct;
+ patch_get = ((val = getenv ("PATCH_GET"))
+ ? numeric_string (val, true, "PATCH_GET value")
+ : 0);
+
+ val = getenv ("SIMPLE_BACKUP_SUFFIX");
+ simple_backup_suffix = val && *val ? val : ".orig";
+
+ if ((version_control = getenv ("PATCH_VERSION_CONTROL")))
+ version_control_context = "$PATCH_VERSION_CONTROL";
+ else if ((version_control = getenv ("VERSION_CONTROL")))
+ version_control_context = "$VERSION_CONTROL";
+
+ init_backup_hash_table ();
+ init_files_to_delete ();
+ init_files_to_output ();
+
+ /* parse switches */
+ Argc = argc;
+ Argv = argv;
+ get_some_switches();
+
+ /* Make get_date() assume that context diff headers use UTC. */
+ if (set_utc)
+ setenv ("TZ", "UTC", 1);
+
+ if (make_backups | backup_if_mismatch)
+ backup_type = get_version (version_control_context, version_control);
+
+ init_output (&outstate);
+ if (outfile)
+ outstate.ofp = open_outfile (outfile);
+
+ /* Make sure we clean up in case of disaster. */
+ set_signals (false);
+
+ /* When the file to patch is specified on the command line, allow that file
+ to lie outside the current working tree. Still doesn't allow to follow
+ symlinks. */
+ if (inname)
+ unsafe = true;
+
+ if (inname && outfile)
+ {
+ /* When an input and an output filename is given and the patch is
+ empty, copy the input file to the output file. In this case, the
+ input file must be a regular file (i.e., symlinks cannot be copied
+ this way). */
+ apply_empty_patch = true;
+ file_type = S_IFREG;
+ inerrno = -1;
+ }
+ for (
+ open_patch_file (patchname);
+ there_is_another_patch (! (inname || posixly_correct), &file_type)
+ || apply_empty_patch;
+ reinitialize_almost_everything(),
+ skip_reject_file = false,
+ apply_empty_patch = false
+ ) { /* for each patch in patch file */
+ int hunk = 0;
+ int failed = 0;
+ bool mismatch = false;
+ char const *outname = NULL;
+
+ if (skip_rest_of_patch)
+ somefailed = true;
+
+ if (have_git_diff != pch_git_diff ())
+ {
+ if (have_git_diff)
+ {
+ output_files (NULL);
+ inerrno = -1;
+ }
+ have_git_diff = ! have_git_diff;
+ }
+
+ if (TMPREJNAME_needs_removal)
+ {
+ if (rejfp)
+ {
+ fclose (rejfp);
+ rejfp = NULL;
+ }
+ remove_if_needed (TMPREJNAME, &TMPREJNAME_needs_removal);
+ }
+ if (TMPOUTNAME_needs_removal)
+ {
+ if (outfd != -1)
+ {
+ close (outfd);
+ outfd = -1;
+ }
+ remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
+ }
+
+ if (! skip_rest_of_patch && ! file_type)
+ {
+ say ("File %s: can't change file type from 0%o to 0%o.\n",
+ quotearg (inname),
+ (unsigned int) (pch_mode (reverse) & S_IFMT),
+ (unsigned int) (pch_mode (! reverse) & S_IFMT));
+ skip_rest_of_patch = true;
+ somefailed = true;
+ }
+
+ if (! skip_rest_of_patch)
+ {
+ if (outfile)
+ outname = outfile;
+ else if (pch_copy () || pch_rename ())
+ outname = pch_name (! reverse);
+ else
+ outname = inname;
+ }
+
+ if (pch_git_diff () && ! skip_rest_of_patch)
+ {
+ struct stat outstat;
+ int outerrno = 0;
+
+ /* Try to recognize concatenated git diffs based on the SHA1 hashes
+ in the headers. Will not always succeed for patches that rename
+ or copy files. */
+
+ if (! strcmp (inname, outname))
+ {
+ if (inerrno == -1)
+ inerrno = stat_file (inname, &instat);
+ outstat = instat;
+ outerrno = inerrno;
+ }
+ else
+ outerrno = stat_file (outname, &outstat);
+
+ if (! outerrno)
+ {
+ if (has_queued_output (&outstat))
+ {
+ output_files (&outstat);
+ outerrno = stat_file (outname, &outstat);
+ inerrno = -1;
+ }
+ if (! outerrno)
+ set_queued_output (&outstat, true);
+ }
+ }
+
+ if (! skip_rest_of_patch)
+ {
+ if (! get_input_file (inname, outname, file_type))
+ {
+ skip_rest_of_patch = true;
+ somefailed = true;
+ }
+ }
+
+ if (read_only_behavior != RO_IGNORE
+ && ! inerrno && ! S_ISLNK (instat.st_mode)
+ && safe_access (inname, W_OK) != 0)
+ {
+ say ("File %s is read-only; ", quotearg (inname));
+ if (read_only_behavior == RO_WARN)
+ say ("trying to patch anyway\n");
+ else
+ {
+ say ("refusing to patch\n");
+ skip_rest_of_patch = true;
+ somefailed = true;
+ }
+ }
+
+ tmpoutst.st_size = -1;
+ outfd = make_tempfile (&TMPOUTNAME, 'o', outname,
+ O_WRONLY | binary_transput,
+ instat.st_mode & S_IRWXUGO);
+ if (outfd == -1)
+ {
+ if (errno == ELOOP || errno == EXDEV)
+ {
+ say ("Invalid file name %s -- skipping patch\n", quotearg (outname));
+ skip_rest_of_patch = true;
+ skip_reject_file = true;
+ somefailed = true;
+ }
+ else
+ pfatal ("Can't create temporary file %s", TMPOUTNAME);
+ }
+ else
+ TMPOUTNAME_needs_removal = true;
+ if (diff_type == ED_DIFF) {
+ outstate.zero_output = false;
+ somefailed |= skip_rest_of_patch;
+ do_ed_script (inname, TMPOUTNAME, &TMPOUTNAME_needs_removal,
+ outstate.ofp);
+ if (! dry_run && ! outfile && ! skip_rest_of_patch)
+ {
+ if (fstat (outfd, &tmpoutst) != 0)
+ pfatal ("%s", TMPOUTNAME);
+ outstate.zero_output = tmpoutst.st_size == 0;
+ }
+ close (outfd);
+ outfd = -1;
+ } else {
+ int got_hunk;
+ bool apply_anyway = merge; /* don't try to reverse when merging */
+
+ if (! skip_rest_of_patch && diff_type == GIT_BINARY_DIFF) {
+ say ("File %s: git binary diffs are not supported.\n",
+ quotearg (outname));
+ skip_rest_of_patch = true;
+ somefailed = true;
+ }
+ /* initialize the patched file */
+ if (! skip_rest_of_patch && ! outfile)
+ {
+ init_output (&outstate);
+ outstate.ofp = fdopen(outfd, binary_transput ? "wb" : "w");
+ if (! outstate.ofp)
+ pfatal ("%s", TMPOUTNAME);
+ /* outstate.ofp now owns the file descriptor */
+ outfd = -1;
+ }
+
+ /* find out where all the lines are */
+ if (!skip_rest_of_patch) {
+ scan_input (inname, file_type);
+
+ if (verbosity != SILENT)
+ {
+ bool renamed = strcmp (inname, outname);
+ bool skip_rename = ! renamed && pch_rename ();
+
+ say ("%s %s %s%c",
+ dry_run ? "checking" : "patching",
+ S_ISLNK (file_type) ? "symbolic link" : "file",
+ quotearg (outname), renamed || skip_rename ? ' ' : '\n');
+ if (renamed || skip_rename)
+ say ("(%s%s from %s)\n",
+ skip_rename ? "already " : "",
+ pch_copy () ? "copied" :
+ (pch_rename () ? "renamed" : "read"),
+ ! skip_rename ? inname : pch_name (! strcmp (inname, pch_name (OLD))));
+ if (verbosity == VERBOSE)
+ say ("Using Plan %s...\n", using_plan_a ? "A" : "B");
+ }
+ }
+
+ /* from here on, open no standard i/o files, because malloc */
+ /* might misfire and we can't catch it easily */
+
+ /* apply each hunk of patch */
+ while (0 < (got_hunk = another_hunk (diff_type, reverse)))
+ {
+ lin where = 0; /* Pacify 'gcc -Wall'. */
+ lin newwhere;
+ lin fuzz = 0;
+ lin mymaxfuzz;
+
+ if (merge)
+ {
+ /* When in merge mode, don't apply with fuzz. */
+ mymaxfuzz = 0;
+ }
+ else
+ {
+ lin prefix_context = pch_prefix_context ();
+ lin suffix_context = pch_suffix_context ();
+ lin context = (prefix_context < suffix_context
+ ? suffix_context : prefix_context);
+ mymaxfuzz = (maxfuzz < context ? maxfuzz : context);
+ }
+
+ hunk++;
+ if (!skip_rest_of_patch) {
+ do {
+ where = locate_hunk(fuzz);
+ if (! where || fuzz || in_offset)
+ mismatch = true;
+ if (hunk == 1 && ! where && ! (force | apply_anyway)
+ && reverse == reverse_flag_specified) {
+ /* dwim for reversed patch? */
+ if (!pch_swap()) {
+ say (
+"Not enough memory to try swapped hunk! Assuming unswapped.\n");
+ continue;
+ }
+ /* Try again. */
+ where = locate_hunk (fuzz);
+ if (where
+ && (ok_to_reverse
+ ("%s patch detected!",
+ (reverse
+ ? "Unreversed"
+ : "Reversed (or previously applied)"))))
+ reverse = ! reverse;
+ else
+ {
+ /* Put it back to normal. */
+ if (! pch_swap ())
+ fatal ("lost hunk on alloc error!");
+ if (where)
+ {
+ apply_anyway = true;
+ fuzz--; /* Undo '++fuzz' below. */
+ where = 0;
+ }
+ }
+ }
+ } while (!skip_rest_of_patch && !where
+ && ++fuzz <= mymaxfuzz);
+
+ if (skip_rest_of_patch) { /* just got decided */
+ if (outstate.ofp && ! outfile)
+ {
+ fclose (outstate.ofp);
+ outstate.ofp = 0;
+ outfd = -1;
+ }
+ }
+ }
+
+ newwhere = (where ? where : pch_first()) + out_offset;
+ if (skip_rest_of_patch
+ || (merge && ! merge_hunk (hunk, &outstate, where,
+ &somefailed))
+ || (! merge
+ && ((where == 1 && pch_says_nonexistent (reverse) == 2
+ && instat.st_size)
+ || ! where
+ || ! apply_hunk (&outstate, where))))
+ {
+ if (! skip_reject_file)
+ abort_hunk (outname, ! failed, reverse);
+ failed++;
+ if (verbosity == VERBOSE ||
+ (! skip_rest_of_patch && verbosity != SILENT))
+ say ("Hunk #%d %s at %s%s.\n", hunk,
+ skip_rest_of_patch ? "ignored" : "FAILED",
+ format_linenum (numbuf, newwhere),
+ ! skip_rest_of_patch && check_line_endings (newwhere)
+ ? " (different line endings)" : "");
+ }
+ else if (! merge &&
+ (verbosity == VERBOSE
+ || (verbosity != SILENT && (fuzz || in_offset))))
+ {
+ say ("Hunk #%d succeeded at %s", hunk,
+ format_linenum (numbuf, newwhere));
+ if (fuzz)
+ say (" with fuzz %s", format_linenum (numbuf, fuzz));
+ if (in_offset)
+ say (" (offset %s line%s)",
+ format_linenum (numbuf, in_offset),
+ "s" + (in_offset == 1));
+ say (".\n");
+ }
+ }
+
+ if (!skip_rest_of_patch)
+ {
+ if (got_hunk < 0 && using_plan_a)
+ {
+ if (outfile)
+ fatal ("out of memory using Plan A");
+ say ("\n\nRan out of memory using Plan A -- trying again...\n\n");
+ if (outstate.ofp)
+ {
+ fclose (outstate.ofp);
+ outstate.ofp = 0;
+ }
+ continue;
+ }
+
+ /* Finish spewing out the new file. */
+ if (! spew_output (&outstate, &tmpoutst))
+ {
+ say ("Skipping patch.\n");
+ skip_rest_of_patch = true;
+ }
+ }
+ }
+
+ /* and put the output where desired */
+ ignore_signals ();
+ if (! skip_rest_of_patch && ! outfile) {
+ bool backup = make_backups
+ || (backup_if_mismatch && (mismatch | failed));
+ if (outstate.zero_output
+ && (remove_empty_files
+ || (pch_says_nonexistent (! reverse) == 2
+ && ! posixly_correct)
+ || S_ISLNK (file_type)))
+ {
+ if (! dry_run)
+ output_file (NULL, NULL, NULL, outname,
+ (inname == outname) ? &instat : NULL,
+ file_type | 0, backup);
+ }
+ else
+ {
+ if (! outstate.zero_output
+ && pch_says_nonexistent (! reverse) == 2
+ && (remove_empty_files || ! posixly_correct)
+ && ! (merge && somefailed))
+ {
+ mismatch = true;
+ somefailed = true;
+ if (verbosity != SILENT)
+ say ("Not deleting file %s as content differs from patch\n",
+ quotearg (outname));
+ }
+
+ if (! dry_run)
+ {
+ mode_t old_mode = pch_mode (reverse);
+ mode_t new_mode = pch_mode (! reverse);
+ bool set_mode = new_mode && old_mode != new_mode;
+
+ /* Avoid replacing files when nothing has changed. */
+ if (failed < hunk || diff_type == ED_DIFF || set_mode
+ || pch_copy () || pch_rename ())
+ {
+ enum file_attributes attr = 0;
+ struct timespec new_time = pch_timestamp (! reverse);
+ mode_t mode = file_type |
+ ((set_mode ? new_mode : instat.st_mode) & S_IRWXUGO);
+
+ if ((set_time | set_utc) && new_time.tv_sec != -1)
+ {
+ struct timespec old_time = pch_timestamp (reverse);
+
+ if (! force && ! inerrno
+ && pch_says_nonexistent (reverse) != 2
+ && old_time.tv_sec != -1
+ && timespec_cmp (old_time,
+ get_stat_mtime (&instat)))
+ say ("Not setting time of file %s "
+ "(time mismatch)\n",
+ quotearg (outname));
+ else if (! force && (mismatch | failed))
+ say ("Not setting time of file %s "
+ "(contents mismatch)\n",
+ quotearg (outname));
+ else
+ attr |= FA_TIMES;
+ }
+
+ if (inerrno)
+ {
+ if (set_mode)
+ attr |= FA_MODE;
+ set_file_attributes (TMPOUTNAME, attr, NULL, NULL,
+ mode, &new_time);
+ }
+ else
+ {
+ attr |= FA_IDS | FA_MODE | FA_XATTRS;
+ set_file_attributes (TMPOUTNAME, attr, inname, &instat,
+ mode, &new_time);
+ }
+
+ output_file (TMPOUTNAME, &TMPOUTNAME_needs_removal,
+ &tmpoutst, outname, NULL, mode, backup);
+
+ if (pch_rename ())
+ output_file (NULL, NULL, NULL, inname, &instat,
+ mode, backup);
+ }
+ else
+ output_file (outname, NULL, &tmpoutst, NULL, NULL,
+ file_type | 0, backup);
+ }
+ }
+ }
+ if (diff_type != ED_DIFF) {
+ struct stat rejst;
+
+ if (failed && ! skip_reject_file) {
+ if (fstat (fileno (rejfp), &rejst) != 0 || fclose (rejfp) != 0)
+ write_fatal ();
+ rejfp = NULL;
+ somefailed = true;
+ say ("%d out of %d hunk%s %s", failed, hunk, "s" + (hunk == 1),
+ skip_rest_of_patch ? "ignored" : "FAILED");
+ if (outname && (! rejname || strcmp (rejname, "-") != 0)) {
+ char *rej = rejname;
+ if (!rejname) {
+ /* FIXME: This should really be done differently! */
+ const char *s = simple_backup_suffix;
+ size_t len;
+ simple_backup_suffix = ".rej";
+ rej = find_backup_file_name (outname, simple_backups);
+ len = strlen (rej);
+ if (rej[len - 1] == '~')
+ rej[len - 1] = '#';
+ simple_backup_suffix = s;
+ }
+ if (! dry_run)
+ {
+ say (" -- saving rejects to file %s\n", quotearg (rej));
+ if (rejname)
+ {
+ if (! written_to_rejname)
+ {
+ copy_file (TMPREJNAME, rejname, 0, 0,
+ S_IFREG | 0666, true);
+ written_to_rejname = true;
+ }
+ else
+ append_to_file (TMPREJNAME, rejname);
+ }
+ else
+ {
+ struct stat oldst;
+ int olderrno;
+
+ olderrno = stat_file (rej, &oldst);
+ if (olderrno && olderrno != ENOENT)
+ write_fatal ();
+ if (! olderrno && lookup_file_id (&oldst) == CREATED)
+ append_to_file (TMPREJNAME, rej);
+ else
+ move_file (TMPREJNAME, &TMPREJNAME_needs_removal,
+ &rejst, rej, S_IFREG | 0666, false);
+ }
+ }
+ else
+ say ("\n");
+ if (!rejname)
+ free (rej);
+ } else
+ say ("\n");
+ }
+ }
+ set_signals (true);
+ }
+ if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
+ write_fatal ();
+ output_files (NULL);
+ cleanup ();
+ delete_files ();
+ if (somefailed)
+ exit (1);
+ return 0;
+}
+
+/* Prepare to find the next patch to do in the patch file. */
+
+static void
+reinitialize_almost_everything (void)
+{
+ re_patch();
+ re_input();
+
+ input_lines = 0;
+ last_frozen_line = 0;
+
+ if (inname && ! explicit_inname) {
+ free (inname);
+ inname = 0;
+ }
+
+ in_offset = 0;
+ out_offset = 0;
+
+ diff_type = NO_DIFF;
+
+ if (revision) {
+ free(revision);
+ revision = 0;
+ }
+
+ reverse = reverse_flag_specified;
+ skip_rest_of_patch = false;
+}
+
+static char const shortopts[] = "bB:cd:D:eEfF:g:i:l"
+#if 0 && defined ENABLE_MERGE
+ "m"
+#endif
+ "nNo:p:r:RstTuvV:x:Y:z:Z";
+
+static struct option const longopts[] =
+{
+ {"backup", no_argument, NULL, 'b'},
+ {"prefix", required_argument, NULL, 'B'},
+ {"context", no_argument, NULL, 'c'},
+ {"directory", required_argument, NULL, 'd'},
+ {"ifdef", required_argument, NULL, 'D'},
+ {"ed", no_argument, NULL, 'e'},
+ {"remove-empty-files", no_argument, NULL, 'E'},
+ {"force", no_argument, NULL, 'f'},
+ {"fuzz", required_argument, NULL, 'F'},
+ {"get", required_argument, NULL, 'g'},
+ {"input", required_argument, NULL, 'i'},
+ {"ignore-whitespace", no_argument, NULL, 'l'},
+#ifdef ENABLE_MERGE
+ {"merge", optional_argument, NULL, 'm'},
+#endif
+ {"normal", no_argument, NULL, 'n'},
+ {"forward", no_argument, NULL, 'N'},
+ {"output", required_argument, NULL, 'o'},
+ {"strip", required_argument, NULL, 'p'},
+ {"reject-file", required_argument, NULL, 'r'},
+ {"reverse", no_argument, NULL, 'R'},
+ {"quiet", no_argument, NULL, 's'},
+ {"silent", no_argument, NULL, 's'},
+ {"batch", no_argument, NULL, 't'},
+ {"set-time", no_argument, NULL, 'T'},
+ {"unified", no_argument, NULL, 'u'},
+ {"version", no_argument, NULL, 'v'},
+ {"version-control", required_argument, NULL, 'V'},
+ {"debug", required_argument, NULL, 'x'},
+ {"basename-prefix", required_argument, NULL, 'Y'},
+ {"suffix", required_argument, NULL, 'z'},
+ {"set-utc", no_argument, NULL, 'Z'},
+ {"dry-run", no_argument, NULL, CHAR_MAX + 1},
+ {"verbose", no_argument, NULL, CHAR_MAX + 2},
+ {"binary", no_argument, NULL, CHAR_MAX + 3},
+ {"help", no_argument, NULL, CHAR_MAX + 4},
+ {"backup-if-mismatch", no_argument, NULL, CHAR_MAX + 5},
+ {"no-backup-if-mismatch", no_argument, NULL, CHAR_MAX + 6},
+ {"posix", no_argument, NULL, CHAR_MAX + 7},
+ {"quoting-style", required_argument, NULL, CHAR_MAX + 8},
+ {"reject-format", required_argument, NULL, CHAR_MAX + 9},
+ {"read-only", required_argument, NULL, CHAR_MAX + 10},
+ {"follow-symlinks", no_argument, NULL, CHAR_MAX + 11},
+ {NULL, no_argument, NULL, 0}
+};
+
+static char const *const option_help[] =
+{
+"Input options:",
+"",
+" -p NUM --strip=NUM Strip NUM leading components from file names.",
+" -F LINES --fuzz LINES Set the fuzz factor to LINES for inexact matching.",
+" -l --ignore-whitespace Ignore white space changes between patch and input.",
+"",
+" -c --context Interpret the patch as a context difference.",
+" -e --ed Interpret the patch as a potentially dangerous ed script. This could allow arbitrary command execution!",
+" -n --normal Interpret the patch as a normal difference.",
+" -u --unified Interpret the patch as a unified difference.",
+"",
+" -N --forward Ignore patches that appear to be reversed or already applied.",
+" -R --reverse Assume patches were created with old and new files swapped.",
+"",
+" -i PATCHFILE --input=PATCHFILE Read patch from PATCHFILE instead of stdin.",
+"",
+"Output options:",
+"",
+" -o FILE --output=FILE Output patched files to FILE.",
+" -r FILE --reject-file=FILE Output rejects to FILE.",
+"",
+" -D NAME --ifdef=NAME Make merged if-then-else output using NAME.",
+#ifdef ENABLE_MERGE
+" --merge Merge using conflict markers instead of creating reject files.",
+#endif
+" -E --remove-empty-files Remove output files that are empty after patching.",
+"",
+" -Z --set-utc Set times of patched files, assuming diff uses UTC (GMT).",
+" -T --set-time Likewise, assuming local time.",
+"",
+" --quoting-style=WORD output file names using quoting style WORD.",
+" Valid WORDs are: literal, shell, shell-always, c, escape.",
+" Default is taken from QUOTING_STYLE env variable, or 'shell' if unset.",
+"",
+"Backup and version control options:",
+"",
+" -b --backup Back up the original contents of each file.",
+" --backup-if-mismatch Back up if the patch does not match exactly.",
+" --no-backup-if-mismatch Back up mismatches only if otherwise requested.",
+"",
+" -V STYLE --version-control=STYLE Use STYLE version control.",
+" STYLE is either 'simple', 'numbered', or 'existing'.",
+" -B PREFIX --prefix=PREFIX Prepend PREFIX to backup file names.",
+" -Y PREFIX --basename-prefix=PREFIX Prepend PREFIX to backup file basenames.",
+" -z SUFFIX --suffix=SUFFIX Append SUFFIX to backup file names.",
+"",
+" -g NUM --get=NUM Get files from RCS etc. if positive; ask if negative.",
+"",
+"Miscellaneous options:",
+"",
+" -t --batch Ask no questions; skip bad-Prereq patches; assume reversed.",
+" -f --force Like -t, but ignore bad-Prereq patches, apply potentially dangerous ed scripts, and assume unreversed.",
+" -s --quiet --silent Work silently unless an error occurs.",
+" --verbose Output extra information about the work being done.",
+" --dry-run Do not actually change any files; just print what would happen.",
+" --posix Conform to the POSIX standard.",
+"",
+" -d DIR --directory=DIR Change the working directory to DIR first.",
+" --reject-format=FORMAT Create 'context' or 'unified' rejects.",
+" --binary Read and write data in binary mode.",
+" --read-only=BEHAVIOR How to handle read-only input files: 'ignore' that they",
+" are read-only, 'warn' (default), or 'fail'.",
+"",
+" -v --version Output version info.",
+" --help Output this help.",
+"",
+"Report bugs to <" PACKAGE_BUGREPORT ">.",
+0
+};
+
+static void
+usage (FILE *stream, int status)
+{
+ char const * const *p;
+
+ if (status != 0)
+ {
+ fprintf (stream, "%s: Try '%s --help' for more information.\n",
+ program_name, Argv[0]);
+ }
+ else
+ {
+ fprintf (stream, "Usage: %s [OPTION]... [ORIGFILE [PATCHFILE]]\n\n",
+ Argv[0]);
+ for (p = option_help; *p; p++)
+ fprintf (stream, "%s\n", *p);
+ }
+
+ exit (status);
+}
+
+/* Process switches and filenames. */
+
+static void
+get_some_switches (void)
+{
+ int optc;
+
+ free (rejname);
+ rejname = 0;
+ if (optind == Argc)
+ return;
+ while ((optc = getopt_long (Argc, Argv, shortopts, longopts, (int *) 0))
+ != -1) {
+ switch (optc) {
+ case 'b':
+ make_backups = true;
+ /* Special hack for backward compatibility with CVS 1.9.
+ If the last 4 args are '-b SUFFIX ORIGFILE PATCHFILE',
+ treat '-b' as if it were '-b -z'. */
+ if (Argc - optind == 3
+ && strcmp (Argv[optind - 1], "-b") == 0
+ && ! (Argv[optind + 0][0] == '-' && Argv[optind + 0][1])
+ && ! (Argv[optind + 1][0] == '-' && Argv[optind + 1][1])
+ && ! (Argv[optind + 2][0] == '-' && Argv[optind + 2][1]))
+ {
+ optarg = Argv[optind++];
+ if (verbosity != SILENT)
+ say ("warning: the '-b %s' option is obsolete; use '-b -z %s' instead\n",
+ optarg, optarg);
+ goto case_z;
+ }
+ break;
+ case 'B':
+ if (!*optarg)
+ fatal ("backup prefix is empty");
+ origprae = xstrdup (optarg);
+ break;
+ case 'c':
+ diff_type = CONTEXT_DIFF;
+ break;
+ case 'd':
+ if (chdir(optarg) < 0)
+ pfatal ("Can't change to directory %s", quotearg (optarg));
+ break;
+ case 'D':
+ do_defines = xstrdup (optarg);
+ break;
+ case 'e':
+ diff_type = ED_DIFF;
+ break;
+ case 'E':
+ remove_empty_files = true;
+ break;
+ case 'f':
+ force = true;
+ break;
+ case 'F':
+ maxfuzz = numeric_string (optarg, false, "fuzz factor");
+ break;
+ case 'g':
+ patch_get = numeric_string (optarg, true, "get option value");
+ break;
+ case 'i':
+ patchname = xstrdup (optarg);
+ break;
+ case 'l':
+ canonicalize_ws = true;
+ break;
+#ifdef ENABLE_MERGE
+ case 'm':
+ merge = true;
+ if (optarg)
+ {
+ if (! strcmp (optarg, "merge"))
+ conflict_style = MERGE_MERGE;
+ else if (! strcmp (optarg, "diff3"))
+ conflict_style = MERGE_DIFF3;
+ else
+ usage (stderr, 2);
+ }
+ else
+ conflict_style = MERGE_MERGE;
+ break;
+#endif
+ case 'n':
+ diff_type = NORMAL_DIFF;
+ break;
+ case 'N':
+ noreverse = true;
+ break;
+ case 'o':
+ outfile = xstrdup (optarg);
+ break;
+ case 'p':
+ strippath = numeric_string (optarg, false, "strip count");
+ break;
+ case 'r':
+ rejname = xstrdup (optarg);
+ break;
+ case 'R':
+ reverse = true;
+ reverse_flag_specified = true;
+ break;
+ case 's':
+ verbosity = SILENT;
+ break;
+ case 't':
+ batch = true;
+ break;
+ case 'T':
+ set_time = true;
+ break;
+ case 'u':
+ diff_type = UNI_DIFF;
+ break;
+ case 'v':
+ version();
+ exit (0);
+ break;
+ case 'V':
+ version_control = optarg;
+ version_control_context = "--version-control or -V option";
+ break;
+#if DEBUGGING
+ case 'x':
+ debug = numeric_string (optarg, true, "debugging option");
+ break;
+#endif
+ case 'Y':
+ if (!*optarg)
+ fatal ("backup basename prefix is empty");
+ origbase = xstrdup (optarg);
+ break;
+ case 'z':
+ case_z:
+ if (!*optarg)
+ fatal ("backup suffix is empty");
+ origsuff = xstrdup (optarg);
+ break;
+ case 'Z':
+ set_utc = true;
+ break;
+ case CHAR_MAX + 1:
+ dry_run = true;
+ break;
+ case CHAR_MAX + 2:
+ verbosity = VERBOSE;
+ break;
+ case CHAR_MAX + 3:
+ no_strip_trailing_cr = true;
+#if HAVE_SETMODE_DOS
+ binary_transput = O_BINARY;
+#endif
+ break;
+ case CHAR_MAX + 4:
+ usage (stdout, 0);
+ case CHAR_MAX + 5:
+ backup_if_mismatch = true;
+ break;
+ case CHAR_MAX + 6:
+ backup_if_mismatch = false;
+ break;
+ case CHAR_MAX + 7:
+ posixly_correct = true;
+ break;
+ case CHAR_MAX + 8:
+ {
+ int i = argmatch (optarg, quoting_style_args, 0, 0);
+ if (i < 0)
+ {
+ invalid_arg ("quoting style", optarg, i);
+ usage (stderr, 2);
+ }
+ set_quoting_style ((struct quoting_options *) 0,
+ (enum quoting_style) i);
+ }
+ break;
+ case CHAR_MAX + 9:
+ if (strcmp (optarg, "context") == 0)
+ reject_format = NEW_CONTEXT_DIFF;
+ else if (strcmp (optarg, "unified") == 0)
+ reject_format = UNI_DIFF;
+ else
+ usage (stderr, 2);
+ break;
+ case CHAR_MAX + 10:
+ if (strcmp (optarg, "ignore") == 0)
+ read_only_behavior = RO_IGNORE;
+ else if (strcmp (optarg, "warn") == 0)
+ read_only_behavior = RO_WARN;
+ else if (strcmp (optarg, "fail") == 0)
+ read_only_behavior = RO_FAIL;
+ else
+ usage (stderr, 2);
+ break;
+ case CHAR_MAX + 11:
+ follow_symlinks = true;
+ break;
+ default:
+ usage (stderr, 2);
+ }
+ }
+
+ if (! force && diff_type == ED_DIFF)
+ {
+ ask ("Apply potentially dangerous ed script? This could allow arbitrary command execution! [n] ");
+ if (*buf != 'y')
+ {
+ fatal ("Refusing to apply potentially dangerous ed script.");
+ }
+ }
+
+ /* Process any filename args. */
+ if (optind < Argc)
+ {
+ inname = xstrdup (Argv[optind++]);
+ explicit_inname = true;
+ invc = -1;
+ if (optind < Argc)
+ {
+ patchname = xstrdup (Argv[optind++]);
+ if (optind < Argc)
+ {
+ fprintf (stderr, "%s: %s: extra operand\n",
+ program_name, quotearg (Argv[optind]));
+ usage (stderr, 2);
+ }
+ }
+ }
+}
+
+/* Handle STRING (possibly negative if NEGATIVE_ALLOWED is nonzero)
+ of type ARGTYPE_MSGID by converting it to an integer,
+ returning the result. */
+static int
+numeric_string (char const *string,
+ bool negative_allowed,
+ char const *argtype_msgid)
+{
+ int value = 0;
+ char const *p = string;
+ int sign = *p == '-' ? -1 : 1;
+
+ p += *p == '-' || *p == '+';
+
+ do
+ {
+ int v10 = value * 10;
+ int digit = *p - '0';
+ int signed_digit = sign * digit;
+ int next_value = v10 + signed_digit;
+
+ if (9 < (unsigned) digit)
+ fatal ("%s %s is not a number", argtype_msgid, quotearg (string));
+
+ if (v10 / 10 != value || (next_value < v10) != (signed_digit < 0))
+ fatal ("%s %s is too large", argtype_msgid, quotearg (string));
+
+ value = next_value;
+ }
+ while (*++p);
+
+ if (value < 0 && ! negative_allowed)
+ fatal ("%s %s is negative", argtype_msgid, quotearg (string));
+
+ return value;
+}
+
+/* Attempt to find the right place to apply this hunk of patch. */
+
+static lin
+locate_hunk (lin fuzz)
+{
+ lin first_guess = pch_first () + in_offset;
+ lin offset;
+ lin pat_lines = pch_ptrn_lines();
+ lin prefix_context = pch_prefix_context ();
+ lin suffix_context = pch_suffix_context ();
+ lin context = (prefix_context < suffix_context
+ ? suffix_context : prefix_context);
+ lin prefix_fuzz = fuzz + prefix_context - context;
+ lin suffix_fuzz = fuzz + suffix_context - context;
+ lin max_where = input_lines - (pat_lines - suffix_fuzz) + 1;
+ lin min_where = last_frozen_line + 1;
+ lin max_pos_offset = max_where - first_guess;
+ lin max_neg_offset = first_guess - min_where;
+ lin max_offset = MAX(max_pos_offset, max_neg_offset);
+ lin min_offset;
+
+ if (!pat_lines) /* null range matches always */
+ return first_guess;
+
+ /* Do not try lines <= 0. */
+ if (first_guess <= max_neg_offset)
+ max_neg_offset = first_guess - 1;
+
+ if (prefix_fuzz < 0 && pch_first () <= 1)
+ {
+ /* Can only match start of file. */
+
+ if (suffix_fuzz < 0)
+ /* Can only match entire file. */
+ if (pat_lines != input_lines || prefix_context < last_frozen_line)
+ return 0;
+
+ offset = 1 - first_guess;
+ if (last_frozen_line <= prefix_context
+ && offset <= max_pos_offset
+ && patch_match (first_guess, offset, 0, suffix_fuzz))
+ {
+ in_offset += offset;
+ return first_guess + offset;
+ }
+ else
+ return 0;
+ }
+ else if (prefix_fuzz < 0)
+ prefix_fuzz = 0;
+
+ if (suffix_fuzz < 0)
+ {
+ /* Can only match end of file. */
+ offset = first_guess - (input_lines - pat_lines + 1);
+ if (offset <= max_neg_offset
+ && patch_match (first_guess, -offset, prefix_fuzz, 0))
+ {
+ in_offset -= offset;
+ return first_guess - offset;
+ }
+ else
+ return 0;
+ }
+
+ min_offset = max_pos_offset < 0 ? first_guess - max_where
+ : max_neg_offset < 0 ? first_guess - min_where
+ : 0;
+ for (offset = min_offset; offset <= max_offset; offset++) {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ if (offset <= max_pos_offset
+ && patch_match (first_guess, offset, prefix_fuzz, suffix_fuzz)) {
+ if (debug & 1)
+ say ("Offset changing from %s to %s\n",
+ format_linenum (numbuf0, in_offset),
+ format_linenum (numbuf1, in_offset + offset));
+ in_offset += offset;
+ return first_guess+offset;
+ }
+ if (offset <= max_neg_offset
+ && patch_match (first_guess, -offset, prefix_fuzz, suffix_fuzz)) {
+ if (debug & 1)
+ say ("Offset changing from %s to %s\n",
+ format_linenum (numbuf0, in_offset),
+ format_linenum (numbuf1, in_offset - offset));
+ in_offset -= offset;
+ return first_guess-offset;
+ }
+ }
+ return 0;
+}
+
+static void __attribute__ ((noreturn))
+mangled_patch (lin old, lin new)
+{
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ if (debug & 1)
+ say ("oldchar = '%c', newchar = '%c'\n",
+ pch_char (old), pch_char (new));
+ fatal ("Out-of-sync patch, lines %s,%s -- mangled text or line numbers, "
+ "maybe?",
+ format_linenum (numbuf0, pch_hunk_beg () + old),
+ format_linenum (numbuf1, pch_hunk_beg () + new));
+}
+
+/* Output a line number range in unified format. */
+
+static void
+print_unidiff_range (FILE *fp, lin start, lin count)
+{
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+
+ switch (count)
+ {
+ case 0:
+ fprintf (fp, "%s,0", format_linenum (numbuf0, start - 1));
+ break;
+
+ case 1:
+ fprintf (fp, "%s", format_linenum (numbuf0, start));
+ break;
+
+ default:
+ fprintf (fp, "%s,%s",
+ format_linenum (numbuf0, start),
+ format_linenum (numbuf1, count));
+ break;
+ }
+}
+
+static void
+print_header_line (FILE *fp, const char *tag, bool reverse)
+{
+ const char *name = pch_name (reverse);
+ const char *timestr = pch_timestr (reverse);
+
+ fprintf (fp, "%s %s%s\n", tag, name ? name : "/dev/null",
+ timestr ? timestr : "");
+}
+
+/* Produce unified reject files */
+
+static void
+abort_hunk_unified (bool header, bool reverse)
+{
+ lin old = 1;
+ lin lastline = pch_ptrn_lines ();
+ lin new = lastline + 1;
+ char const *c_function = pch_c_function();
+
+ if (header)
+ {
+ if (pch_name (INDEX))
+ fprintf(rejfp, "Index: %s\n", pch_name (INDEX));
+ print_header_line (rejfp, "---", reverse);
+ print_header_line (rejfp, "+++", ! reverse);
+ }
+
+ /* Add out_offset to guess the same as the previous successful hunk. */
+ fprintf (rejfp, "@@ -");
+ print_unidiff_range (rejfp, pch_first () + out_offset, lastline);
+ fprintf (rejfp, " +");
+ print_unidiff_range (rejfp, pch_newfirst () + out_offset, pch_repl_lines ());
+ fprintf (rejfp, " @@%s\n", c_function ? c_function : "");
+
+ while (pch_char (new) == '=' || pch_char (new) == '\n')
+ new++;
+
+ if (diff_type != UNI_DIFF)
+ pch_normalize (UNI_DIFF);
+
+ for (; ; old++, new++)
+ {
+ for (; pch_char (old) == '-'; old++)
+ {
+ fputc ('-', rejfp);
+ pch_write_line (old, rejfp);
+ }
+ for (; pch_char (new) == '+'; new++)
+ {
+ fputc ('+', rejfp);
+ pch_write_line (new, rejfp);
+ }
+
+ if (old > lastline)
+ break;
+
+ if (pch_char (new) != pch_char (old))
+ mangled_patch (old, new);
+
+ fputc (' ', rejfp);
+ pch_write_line (old, rejfp);
+ }
+ if (pch_char (new) != '^')
+ mangled_patch (old, new);
+}
+
+/* Output the rejected patch in context format. */
+
+static void
+abort_hunk_context (bool header, bool reverse)
+{
+ lin i;
+ lin pat_end = pch_end ();
+ /* add in out_offset to guess the same as the previous successful hunk */
+ lin oldfirst = pch_first() + out_offset;
+ lin newfirst = pch_newfirst() + out_offset;
+ lin oldlast = oldfirst + pch_ptrn_lines() - 1;
+ lin newlast = newfirst + pch_repl_lines() - 1;
+ char const *stars =
+ (int) NEW_CONTEXT_DIFF <= (int) diff_type ? " ****" : "";
+ char const *minuses =
+ (int) NEW_CONTEXT_DIFF <= (int) diff_type ? " ----" : " -----";
+ char const *c_function = pch_c_function();
+
+ if (diff_type == UNI_DIFF)
+ pch_normalize (NEW_CONTEXT_DIFF);
+
+ if (header)
+ {
+ if (pch_name (INDEX))
+ fprintf(rejfp, "Index: %s\n", pch_name (INDEX));
+ print_header_line (rejfp, "***", reverse);
+ print_header_line (rejfp, "---", ! reverse);
+ }
+ fprintf(rejfp, "***************%s\n", c_function ? c_function : "");
+ for (i=0; i<=pat_end; i++) {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ switch (pch_char(i)) {
+ case '*':
+ if (oldlast < oldfirst)
+ fprintf(rejfp, "*** 0%s\n", stars);
+ else if (oldlast == oldfirst)
+ fprintf (rejfp, "*** %s%s\n",
+ format_linenum (numbuf0, oldfirst), stars);
+ else
+ fprintf (rejfp, "*** %s,%s%s\n",
+ format_linenum (numbuf0, oldfirst),
+ format_linenum (numbuf1, oldlast), stars);
+ break;
+ case '=':
+ if (newlast < newfirst)
+ fprintf(rejfp, "--- 0%s\n", minuses);
+ else if (newlast == newfirst)
+ fprintf (rejfp, "--- %s%s\n",
+ format_linenum (numbuf0, newfirst), minuses);
+ else
+ fprintf (rejfp, "--- %s,%s%s\n",
+ format_linenum (numbuf0, newfirst),
+ format_linenum (numbuf1, newlast), minuses);
+ break;
+ case ' ': case '-': case '+': case '!':
+ fprintf (rejfp, "%c ", pch_char (i));
+ /* fall into */
+ case '\n':
+ pch_write_line (i, rejfp);
+ break;
+ default:
+ fatal ("fatal internal error in abort_hunk_context");
+ }
+ if (ferror (rejfp))
+ write_fatal ();
+ }
+}
+
+/* Output the rejected hunk. */
+
+static void
+abort_hunk (char const *outname, bool header, bool reverse)
+{
+ if (! TMPREJNAME_needs_removal)
+ init_reject (outname);
+ if (reject_format == UNI_DIFF
+ || (reject_format == NO_DIFF && diff_type == UNI_DIFF))
+ abort_hunk_unified (header, reverse);
+ else
+ abort_hunk_context (header, reverse);
+}
+
+/* We found where to apply it (we hope), so do it. */
+
+static bool
+apply_hunk (struct outstate *outstate, lin where)
+{
+ lin old = 1;
+ lin lastline = pch_ptrn_lines ();
+ lin new = lastline+1;
+ enum {OUTSIDE, IN_IFNDEF, IN_IFDEF, IN_ELSE} def_state = OUTSIDE;
+ char const *R_do_defines = do_defines;
+ lin pat_end = pch_end ();
+ FILE *fp = outstate->ofp;
+
+ where--;
+ while (pch_char(new) == '=' || pch_char(new) == '\n')
+ new++;
+
+ while (old <= lastline) {
+ if (pch_char(old) == '-') {
+ assert (outstate->after_newline);
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ if (R_do_defines) {
+ if (def_state == OUTSIDE) {
+ fprintf (fp, outstate->after_newline + not_defined,
+ R_do_defines);
+ def_state = IN_IFNDEF;
+ }
+ else if (def_state == IN_IFDEF) {
+ fputs (outstate->after_newline + else_defined, fp);
+ def_state = IN_ELSE;
+ }
+ if (ferror (fp))
+ write_fatal ();
+ outstate->after_newline = pch_write_line (old, fp);
+ outstate->zero_output = false;
+ }
+ last_frozen_line++;
+ old++;
+ }
+ else if (new > pat_end) {
+ break;
+ }
+ else if (pch_char(new) == '+') {
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ if (R_do_defines) {
+ if (def_state == IN_IFNDEF) {
+ fputs (outstate->after_newline + else_defined, fp);
+ def_state = IN_ELSE;
+ }
+ else if (def_state == OUTSIDE) {
+ fprintf (fp, outstate->after_newline + if_defined,
+ R_do_defines);
+ def_state = IN_IFDEF;
+ }
+ if (ferror (fp))
+ write_fatal ();
+ }
+ outstate->after_newline = pch_write_line (new, fp);
+ outstate->zero_output = false;
+ new++;
+ }
+ else if (pch_char(new) != pch_char(old))
+ mangled_patch (old, new);
+ else if (pch_char(new) == '!') {
+ assert (outstate->after_newline);
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ assert (outstate->after_newline);
+ if (R_do_defines) {
+ fprintf (fp, 1 + not_defined, R_do_defines);
+ if (ferror (fp))
+ write_fatal ();
+ def_state = IN_IFNDEF;
+ }
+
+ do
+ {
+ if (R_do_defines) {
+ outstate->after_newline = pch_write_line (old, fp);
+ }
+ last_frozen_line++;
+ old++;
+ }
+ while (pch_char (old) == '!');
+
+ if (R_do_defines) {
+ fputs (outstate->after_newline + else_defined, fp);
+ if (ferror (fp))
+ write_fatal ();
+ def_state = IN_ELSE;
+ }
+
+ do
+ {
+ outstate->after_newline = pch_write_line (new, fp);
+ new++;
+ }
+ while (pch_char (new) == '!');
+ outstate->zero_output = false;
+ }
+ else {
+ assert(pch_char(new) == ' ');
+ old++;
+ new++;
+ if (R_do_defines && def_state != OUTSIDE) {
+ fputs (outstate->after_newline + end_defined, fp);
+ if (ferror (fp))
+ write_fatal ();
+ outstate->after_newline = true;
+ def_state = OUTSIDE;
+ }
+ }
+ }
+ if (new <= pat_end && pch_char(new) == '+') {
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ if (R_do_defines) {
+ if (def_state == OUTSIDE) {
+ fprintf (fp, outstate->after_newline + if_defined,
+ R_do_defines);
+ def_state = IN_IFDEF;
+ }
+ else if (def_state == IN_IFNDEF) {
+ fputs (outstate->after_newline + else_defined, fp);
+ def_state = IN_ELSE;
+ }
+ if (ferror (fp))
+ write_fatal ();
+ outstate->zero_output = false;
+ }
+
+ do
+ {
+ if (! outstate->after_newline && putc ('\n', fp) == EOF)
+ write_fatal ();
+ outstate->after_newline = pch_write_line (new, fp);
+ outstate->zero_output = false;
+ new++;
+ }
+ while (new <= pat_end && pch_char (new) == '+');
+ }
+ if (R_do_defines && def_state != OUTSIDE) {
+ fputs (outstate->after_newline + end_defined, fp);
+ if (ferror (fp))
+ write_fatal ();
+ outstate->after_newline = true;
+ }
+ out_offset += pch_repl_lines() - pch_ptrn_lines ();
+ return true;
+}
+
+/* Create an output file. */
+
+static FILE *
+create_output_file (char const *name, int open_flags)
+{
+ int fd = create_file (name, O_WRONLY | binary_transput | open_flags,
+ instat.st_mode, true);
+ FILE *f = fdopen (fd, binary_transput ? "wb" : "w");
+ if (! f)
+ pfatal ("Can't create file %s", quotearg (name));
+ return f;
+}
+
+/* Open the new file. */
+
+static void
+init_output (struct outstate *outstate)
+{
+ outstate->ofp = NULL;
+ outstate->after_newline = true;
+ outstate->zero_output = true;
+}
+
+static FILE *
+open_outfile (char const *name)
+{
+ if (strcmp (name, "-") != 0)
+ return create_output_file (name, 0);
+ else
+ {
+ FILE *ofp;
+ int stdout_dup = dup (fileno (stdout));
+ if (stdout_dup == -1)
+ pfatal ("Failed to duplicate standard output");
+ ofp = fdopen (stdout_dup, "a");
+ if (! ofp)
+ pfatal ("Failed to duplicate standard output");
+ if (dup2 (fileno (stderr), fileno (stdout)) == -1)
+ pfatal ("Failed to redirect messages to standard error");
+ /* FIXME: Do we need to switch stdout_dup into O_BINARY mode here? */
+ return ofp;
+ }
+}
+
+/* Open a file to put hunks we can't locate. */
+
+static void
+init_reject (char const *outname)
+{
+ int fd;
+ fd = make_tempfile (&TMPREJNAME, 'r', outname, O_WRONLY | binary_transput,
+ 0666);
+ if (fd == -1)
+ pfatal ("Can't create temporary file %s", TMPREJNAME);
+ TMPREJNAME_needs_removal = true;
+ rejfp = fdopen (fd, binary_transput ? "wb" : "w");
+ if (! rejfp)
+ pfatal ("Can't open stream for file %s", quotearg (TMPREJNAME));
+}
+
+/* Copy input file to output, up to wherever hunk is to be applied. */
+
+bool
+copy_till (struct outstate *outstate, lin lastline)
+{
+ lin R_last_frozen_line = last_frozen_line;
+ FILE *fp = outstate->ofp;
+ char const *s;
+ size_t size;
+
+ if (R_last_frozen_line > lastline)
+ {
+ say ("misordered hunks! output would be garbled\n");
+ return false;
+ }
+ while (R_last_frozen_line < lastline)
+ {
+ s = ifetch (++R_last_frozen_line, false, &size);
+ if (size)
+ {
+ if ((! outstate->after_newline && putc ('\n', fp) == EOF)
+ || ! fwrite (s, sizeof *s, size, fp))
+ write_fatal ();
+ outstate->after_newline = s[size - 1] == '\n';
+ outstate->zero_output = false;
+ }
+ }
+ last_frozen_line = R_last_frozen_line;
+ return true;
+}
+
+/* Finish copying the input file to the output file. */
+
+static bool
+spew_output (struct outstate *outstate, struct stat *st)
+{
+ if (debug & 256)
+ {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ say ("il=%s lfl=%s\n",
+ format_linenum (numbuf0, input_lines),
+ format_linenum (numbuf1, last_frozen_line));
+ }
+
+ if (last_frozen_line < input_lines)
+ if (! copy_till (outstate, input_lines))
+ return false;
+
+ if (outstate->ofp && ! outfile)
+ {
+ if (fflush (outstate->ofp) != 0
+ || fstat (fileno (outstate->ofp), st) != 0
+ || fclose (outstate->ofp) != 0)
+ write_fatal ();
+ outstate->ofp = 0;
+ }
+
+ return true;
+}
+
+/* Does the patch pattern match at line base+offset? */
+
+static bool
+patch_match (lin base, lin offset, lin prefix_fuzz, lin suffix_fuzz)
+{
+ lin pline = 1 + prefix_fuzz;
+ lin iline;
+ lin pat_lines = pch_ptrn_lines () - suffix_fuzz;
+ size_t size;
+ char const *p;
+
+ for (iline=base+offset+prefix_fuzz; pline <= pat_lines; pline++,iline++) {
+ p = ifetch (iline, offset >= 0, &size);
+ if (canonicalize_ws) {
+ if (!similar(p, size,
+ pfetch(pline),
+ pch_line_len(pline) ))
+ return false;
+ }
+ else if (size != pch_line_len (pline)
+ || memcmp (p, pfetch (pline), size) != 0)
+ return false;
+ }
+ return true;
+}
+
+/* Check if the line endings in the input file and in the patch differ. */
+
+static bool
+check_line_endings (lin where)
+{
+ char const *p;
+ size_t size;
+ bool input_crlf, patch_crlf;
+
+ p = pfetch (1);
+ size = pch_line_len (1);
+ if (! size)
+ return false;
+ patch_crlf = size >= 2 && p[size - 2] == '\r' && p[size - 1] == '\n';
+
+ if (! input_lines)
+ return false;
+ if (where > input_lines)
+ where = input_lines;
+ p = ifetch (where, false, &size);
+ if (! size)
+ return false;
+ input_crlf = size >= 2 && p[size - 2] == '\r' && p[size - 1] == '\n';
+
+ return patch_crlf != input_crlf;
+}
+
+/* Do two lines match with canonicalized white space? */
+
+bool
+similar (char const *a, size_t alen, char const *b, size_t blen)
+{
+ /* Ignore presence or absence of trailing newlines. */
+ alen -= alen && a[alen - 1] == '\n';
+ blen -= blen && b[blen - 1] == '\n';
+
+ for (;;)
+ {
+ if (!blen || (*b == ' ' || *b == '\t'))
+ {
+ while (blen && (*b == ' ' || *b == '\t'))
+ b++, blen--;
+ if (alen)
+ {
+ if (!(*a == ' ' || *a == '\t'))
+ return false;
+ do a++, alen--;
+ while (alen && (*a == ' ' || *a == '\t'));
+ }
+ if (!alen || !blen)
+ return alen == blen;
+ }
+ else if (!alen || *a++ != *b++)
+ return false;
+ else
+ alen--, blen--;
+ }
+}
+
+/* Deferred deletion of files. */
+
+struct file_to_delete {
+ char *name;
+ struct stat st;
+ bool backup;
+};
+
+static gl_list_t files_to_delete;
+
+static void
+init_files_to_delete (void)
+{
+ files_to_delete = gl_list_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
+}
+
+static void
+delete_file_later (const char *name, const struct stat *st, bool backup)
+{
+ struct file_to_delete *file_to_delete;
+ struct stat st_tmp;
+
+ if (! st)
+ {
+ if (stat_file (name, &st_tmp) != 0)
+ pfatal ("Can't get file attributes of %s %s", "file", name);
+ st = &st_tmp;
+ }
+ file_to_delete = xmalloc (sizeof *file_to_delete);
+ file_to_delete->name = xstrdup (name);
+ file_to_delete->st = *st;
+ file_to_delete->backup = backup;
+ gl_list_add_last (files_to_delete, file_to_delete);
+ insert_file_id (st, DELETE_LATER);
+}
+
+static void
+delete_files (void)
+{
+ gl_list_iterator_t iter;
+ const void *elt;
+
+ iter = gl_list_iterator (files_to_delete);
+ while (gl_list_iterator_next (&iter, &elt, NULL))
+ {
+ const struct file_to_delete *file_to_delete = elt;
+
+ if (lookup_file_id (&file_to_delete->st) == DELETE_LATER)
+ {
+ mode_t mode = file_to_delete->st.st_mode;
+
+ if (verbosity == VERBOSE)
+ say ("Removing %s %s\n",
+ S_ISLNK (mode) ? "symbolic link" : "file",
+ quotearg (file_to_delete->name));
+ move_file (0, 0, 0, file_to_delete->name, mode,
+ file_to_delete->backup);
+ removedirs (file_to_delete->name);
+ }
+ }
+ gl_list_iterator_free (&iter);
+}
+
+/* Putting output files into place and removing them. */
+
+struct file_to_output {
+ char *from;
+ struct stat from_st;
+ char *to;
+ mode_t mode;
+ bool backup;
+};
+
+static gl_list_t files_to_output;
+
+static void
+output_file_later (char const *from, bool *from_needs_removal, const struct stat *from_st,
+ char const *to, mode_t mode, bool backup)
+{
+ struct file_to_output *file_to_output;
+
+ file_to_output = xmalloc (sizeof *file_to_output);
+ file_to_output->from = xstrdup (from);
+ file_to_output->from_st = *from_st;
+ file_to_output->to = to ? xstrdup (to) : NULL;
+ file_to_output->mode = mode;
+ file_to_output->backup = backup;
+ gl_list_add_last (files_to_output, file_to_output);
+ if (from_needs_removal)
+ *from_needs_removal = false;
+}
+
+static void
+output_file_now (char const *from, bool *from_needs_removal,
+ const struct stat *from_st, char const *to,
+ mode_t mode, bool backup)
+{
+ if (to == NULL)
+ {
+ if (backup)
+ create_backup (from, from_st, true);
+ }
+ else
+ {
+ assert (from_st->st_size != -1);
+ move_file (from, from_needs_removal, from_st, to, mode, backup);
+ }
+}
+
+static void
+output_file (char const *from, bool *from_needs_removal,
+ const struct stat *from_st, char const *to,
+ const struct stat *to_st, mode_t mode, bool backup)
+{
+ if (from == NULL)
+ {
+ /* Remember which files should be deleted and only delete them when the
+ entire input to patch has been processed. This allows to correctly
+ determine for which files backup files have already been created. */
+
+ delete_file_later (to, to_st, backup);
+ }
+ else if (pch_git_diff () && pch_says_nonexistent (reverse) != 2)
+ {
+ /* In git-style diffs, the "before" state of each patch refers to the initial
+ state before modifying any files, input files can be referenced more than
+ once (when creating copies), and output files are modified at most once.
+ However, the input to GNU patch may consist of multiple concatenated
+ git-style diffs, which must be processed separately. (The same output
+ file may go through multiple revisions.)
+
+ To implement this, we remember which files to /modify/ instead of
+ modifying the files immediately, but we create /new/ output files
+ immediately. The new output files serve as markers to detect when a
+ file is modified more than once; this allows to recognize most
+ concatenated git-style diffs.
+ */
+
+ output_file_later (from, from_needs_removal, from_st, to, mode, backup);
+ }
+ else
+ output_file_now (from, from_needs_removal, from_st, to, mode, backup);
+}
+
+static void
+dispose_file_to_output (const void *elt)
+{
+ const struct file_to_output *file_to_output = elt;
+
+ free (file_to_output->from);
+ free (file_to_output->to);
+}
+
+static void
+init_files_to_output (void)
+{
+ files_to_output = gl_list_create_empty (GL_LINKED_LIST, NULL, NULL,
+ dispose_file_to_output, true);
+}
+
+static void
+gl_list_clear (gl_list_t list)
+{
+ while (gl_list_size (list) > 0)
+ gl_list_remove_at (list, 0);
+}
+
+static void
+output_files (struct stat const *st)
+{
+ gl_list_iterator_t iter;
+ const void *elt;
+
+ iter = gl_list_iterator (files_to_output);
+ while (gl_list_iterator_next (&iter, &elt, NULL))
+ {
+ const struct file_to_output *file_to_output = elt;
+ bool from_needs_removal = true;
+ struct stat const *from_st = &file_to_output->from_st;
+
+ output_file_now (file_to_output->from, &from_needs_removal,
+ from_st, file_to_output->to,
+ file_to_output->mode, file_to_output->backup);
+ if (file_to_output->to && from_needs_removal)
+ safe_unlink (file_to_output->from);
+
+ if (st && st->st_dev == from_st->st_dev && st->st_ino == from_st->st_ino)
+ {
+ /* Free the list up to here. */
+ for (;;)
+ {
+ const void *elt2 = gl_list_get_at (files_to_output, 0);
+ gl_list_remove_at (files_to_output, 0);
+ if (elt == elt2)
+ break;
+ }
+ gl_list_iterator_free (&iter);
+ return;
+ }
+ }
+ gl_list_iterator_free (&iter);
+ gl_list_clear (files_to_output);
+}
+
+/* Fatal exit with cleanup. */
+
+void
+fatal_exit (int sig)
+{
+ cleanup ();
+
+ if (sig)
+ exit_with_signal (sig);
+
+ exit (2);
+}
+
+static void
+remove_if_needed (char const *name, bool *needs_removal)
+{
+ if (*needs_removal)
+ {
+ safe_unlink (name);
+ *needs_removal = false;
+ }
+}
+
+static void
+cleanup (void)
+{
+ remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal);
+ remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
+ remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal);
+ remove_if_needed (TMPREJNAME, &TMPREJNAME_needs_removal);
+ output_files (NULL);
+}
Index: src/pch.c
===================================================================
--- src/pch.c (nonexistent)
+++ src/pch.c (revision 5)
@@ -0,0 +1,2535 @@
+/* reading patches */
+
+/* Copyright (C) 1986, 1987, 1988 Larry Wall
+
+ Copyright (C) 1990-1993, 1997-2003, 2006, 2009-2012 Free Software
+ Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define XTERN extern
+#include <common.h>
+#include <dirname.h>
+#include <inp.h>
+#include <quotearg.h>
+#include <util.h>
+#include <xalloc.h>
+#include <xmemdup0.h>
+#undef XTERN
+#define XTERN
+#include <pch.h>
+#if HAVE_SETMODE_DOS
+# include <io.h>
+#endif
+#include <safe.h>
+
+#define INITHUNKMAX 125 /* initial dynamic allocation size */
+
+/* Patch (diff listing) abstract type. */
+
+static FILE *pfp; /* patch file pointer */
+static int p_says_nonexistent[2]; /* [0] for old file, [1] for new:
+ 0 for existent and nonempty,
+ 1 for existent and probably (but not necessarily) empty,
+ 2 for nonexistent */
+static int p_rfc934_nesting; /* RFC 934 nesting level */
+static char *p_name[3]; /* filenames in patch headers */
+static char const *invalid_names[2];
+bool p_copy[2]; /* Does this patch create a copy? */
+bool p_rename[2]; /* Does this patch rename a file? */
+static char *p_timestr[2]; /* timestamps as strings */
+static char *p_sha1[2]; /* SHA1 checksums */
+static mode_t p_mode[2]; /* file modes */
+static off_t p_filesize; /* size of the patch file */
+static lin p_first; /* 1st line number */
+static lin p_newfirst; /* 1st line number of replacement */
+static lin p_ptrn_lines; /* # lines in pattern */
+static lin p_repl_lines; /* # lines in replacement text */
+static lin p_end = -1; /* last line in hunk */
+static lin p_max; /* max allowed value of p_end */
+static lin p_prefix_context; /* # of prefix context lines */
+static lin p_suffix_context; /* # of suffix context lines */
+static lin p_input_line; /* current line # from patch file */
+static char **p_line; /* the text of the hunk */
+static size_t *p_len; /* line length including \n if any */
+static char *p_Char; /* +, -, and ! */
+static lin hunkmax = INITHUNKMAX; /* size of above arrays */
+static size_t p_indent; /* indent to patch */
+static bool p_strip_trailing_cr; /* true if stripping trailing \r */
+static bool p_pass_comments_through; /* true if not ignoring # lines */
+static file_offset p_base; /* where to intuit this time */
+static lin p_bline; /* line # of p_base */
+static file_offset p_start; /* where intuit found a patch */
+static lin p_sline; /* and the line number for it */
+static lin p_hunk_beg; /* line number of current hunk */
+static lin p_efake = -1; /* end of faked up lines--don't free */
+static lin p_bfake = -1; /* beg of faked up lines */
+static char *p_c_function; /* the C function a hunk is in */
+static bool p_git_diff; /* true if this is a git style diff */
+
+static char *scan_linenum (char *, lin *);
+static enum diff intuit_diff_type (bool, mode_t *);
+static enum nametype best_name (char * const *, int const *);
+static int prefix_components (char *, bool);
+static size_t pget_line (size_t, int, bool, bool);
+static size_t get_line (void);
+static bool incomplete_line (void);
+static bool grow_hunkmax (void);
+static void malformed (void) __attribute__ ((noreturn));
+static void next_intuit_at (file_offset, lin);
+static void skip_to (file_offset, lin);
+static char get_ed_command_letter (char const *);
+
+/* Prepare to look for the next patch in the patch file. */
+
+void
+re_patch (void)
+{
+ p_first = 0;
+ p_newfirst = 0;
+ p_ptrn_lines = 0;
+ p_repl_lines = 0;
+ p_end = -1;
+ p_max = 0;
+ p_indent = 0;
+ p_strip_trailing_cr = false;
+}
+
+/* Open the patch file at the beginning of time. */
+
+void
+open_patch_file (char const *filename)
+{
+ file_offset file_pos = 0;
+ file_offset pos;
+ struct stat st;
+
+ if (!filename || !*filename || strEQ (filename, "-"))
+ pfp = stdin;
+ else
+ {
+ pfp = fopen (filename, binary_transput ? "rb" : "r");
+ if (!pfp)
+ pfatal ("Can't open patch file %s", quotearg (filename));
+ }
+#if HAVE_SETMODE_DOS
+ if (binary_transput)
+ {
+ if (isatty (fileno (pfp)))
+ fatal ("cannot read binary data from tty on this platform");
+ setmode (fileno (pfp), O_BINARY);
+ }
+#endif
+ if (fstat (fileno (pfp), &st) != 0)
+ pfatal ("fstat");
+ if (S_ISREG (st.st_mode) && (pos = file_tell (pfp)) != -1)
+ file_pos = pos;
+ else
+ {
+ size_t charsread;
+ int fd;
+ FILE *read_pfp = pfp;
+ fd = make_tempfile (&TMPPATNAME, 'p', NULL, O_RDWR | O_BINARY, 0);
+ if (fd == -1)
+ pfatal ("Can't create temporary file %s", TMPPATNAME);
+ TMPPATNAME_needs_removal = true;
+ pfp = fdopen (fd, "w+b");
+ if (! pfp)
+ pfatal ("Can't open stream for file %s", quotearg (TMPPATNAME));
+ for (st.st_size = 0;
+ (charsread = fread (buf, 1, bufsize, read_pfp)) != 0;
+ st.st_size += charsread)
+ if (fwrite (buf, 1, charsread, pfp) != charsread)
+ write_fatal ();
+ if (ferror (read_pfp) || fclose (read_pfp) != 0)
+ read_fatal ();
+ if (fflush (pfp) != 0
+ || file_seek (pfp, (file_offset) 0, SEEK_SET) != 0)
+ write_fatal ();
+ }
+ p_filesize = st.st_size;
+ if (p_filesize != (file_offset) p_filesize)
+ fatal ("patch file is too long");
+ next_intuit_at (file_pos, 1);
+}
+
+/* Make sure our dynamically realloced tables are malloced to begin with. */
+
+static void
+set_hunkmax (void)
+{
+ if (!p_line)
+ p_line = xmalloc (hunkmax * sizeof *p_line);
+ if (!p_len)
+ p_len = xmalloc (hunkmax * sizeof *p_len);
+ if (!p_Char)
+ p_Char = xmalloc (hunkmax * sizeof *p_Char);
+}
+
+/* Enlarge the arrays containing the current hunk of patch. */
+
+static bool
+grow_hunkmax (void)
+{
+ hunkmax *= 2;
+ assert (p_line && p_len && p_Char);
+ if ((p_line = realloc (p_line, hunkmax * sizeof (*p_line)))
+ && (p_len = realloc (p_len, hunkmax * sizeof (*p_len)))
+ && (p_Char = realloc (p_Char, hunkmax * sizeof (*p_Char))))
+ return true;
+ if (!using_plan_a)
+ xalloc_die ();
+ /* Don't free previous values of p_line etc.,
+ since some broken implementations free them for us.
+ Whatever is null will be allocated again from within plan_a (),
+ of all places. */
+ return false;
+}
+
+static bool
+maybe_reverse (char const *name, bool nonexistent, bool is_empty)
+{
+ bool looks_reversed = (! is_empty) < p_says_nonexistent[reverse ^ is_empty];
+
+ /* Allow to create and delete empty files when we know that they are empty:
+ in the "diff --git" format, we know that from the index header. */
+ if (is_empty
+ && p_says_nonexistent[reverse ^ nonexistent] == 1
+ && p_says_nonexistent[! reverse ^ nonexistent] == 2)
+ return false;
+
+ if (looks_reversed)
+ reverse ^=
+ ok_to_reverse ("The next patch%s would %s the file %s,\nwhich %s!",
+ reverse ? ", when reversed," : "",
+ (nonexistent ? "delete"
+ : is_empty ? "empty out"
+ : "create"),
+ quotearg (name),
+ (nonexistent ? "does not exist"
+ : is_empty ? "is already empty"
+ : "already exists"));
+ return looks_reversed;
+}
+
+/* True if the remainder of the patch file contains a diff of some sort. */
+
+bool
+there_is_another_patch (bool need_header, mode_t *file_type)
+{
+ if (p_base != 0 && p_base >= p_filesize) {
+ if (verbosity == VERBOSE)
+ say ("done\n");
+ return false;
+ }
+ if (verbosity == VERBOSE)
+ say ("Hmm...");
+ diff_type = intuit_diff_type (need_header, file_type);
+ if (diff_type == NO_DIFF) {
+ if (verbosity == VERBOSE)
+ say (p_base
+ ? " Ignoring the trailing garbage.\ndone\n"
+ : " I can't seem to find a patch in there anywhere.\n");
+ if (! p_base && p_filesize)
+ fatal ("Only garbage was found in the patch input.");
+ return false;
+ }
+ if (skip_rest_of_patch)
+ {
+ Fseek (pfp, p_start, SEEK_SET);
+ p_input_line = p_sline - 1;
+ return true;
+ }
+ if (verbosity == VERBOSE)
+ say (" %sooks like %s to me...\n",
+ (p_base == 0 ? "L" : "The next patch l"),
+ diff_type == UNI_DIFF ? "a unified diff" :
+ diff_type == CONTEXT_DIFF ? "a context diff" :
+ diff_type == NEW_CONTEXT_DIFF ? "a new-style context diff" :
+ diff_type == NORMAL_DIFF ? "a normal diff" :
+ diff_type == GIT_BINARY_DIFF ? "a git binary diff" :
+ "an ed script" );
+
+ if (no_strip_trailing_cr)
+ p_strip_trailing_cr = false;
+
+ if (verbosity != SILENT)
+ {
+ if (p_indent)
+ say ("(Patch is indented %lu space%s.)\n",
+ (unsigned long int) p_indent, p_indent==1?"":"s");
+ if (p_strip_trailing_cr)
+ say ("(Stripping trailing CRs from patch; use --binary to disable.)\n");
+ if (! inname)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("can't find file to patch at input line %s\n",
+ format_linenum (numbuf, p_sline));
+ if (diff_type != ED_DIFF && diff_type != NORMAL_DIFF)
+ say (strippath == -1
+ ? "Perhaps you should have used the -p or --strip option?\n"
+ : "Perhaps you used the wrong -p or --strip option?\n");
+ }
+ }
+
+ skip_to(p_start,p_sline);
+ while (!inname) {
+ char *t;
+ if (force | batch) {
+ say ("No file to patch. Skipping patch.\n");
+ skip_rest_of_patch = true;
+ return true;
+ }
+ ask ("File to patch: ");
+ t = buf + strlen (buf);
+ if (t > buf + 1 && *(t - 1) == '\n')
+ {
+ inname = xmemdup0 (buf, t - buf - 1);
+ inerrno = stat_file (inname, &instat);
+ if (inerrno)
+ {
+ perror (inname);
+ fflush (stderr);
+ free (inname);
+ inname = 0;
+ }
+ else
+ invc = -1;
+ }
+ if (!inname) {
+ ask ("Skip this patch? [y] ");
+ if (*buf != 'n') {
+ if (verbosity != SILENT)
+ say ("Skipping patch.\n");
+ skip_rest_of_patch = true;
+ return true;
+ }
+ }
+ }
+ return true;
+}
+
+static mode_t _GL_ATTRIBUTE_PURE
+fetchmode (char const *str)
+{
+ const char *s;
+ mode_t mode;
+
+ while (ISSPACE ((unsigned char) *str))
+ str++;
+
+ for (s = str, mode = 0; s < str + 6; s++)
+ {
+ if (*s >= '0' && *s <= '7')
+ mode = (mode << 3) + (*s - '0');
+ else
+ {
+ mode = 0;
+ break;
+ }
+ }
+ if (*s == '\r')
+ s++;
+ if (*s != '\n')
+ mode = 0;
+
+ /* NOTE: The "diff --git" format always sets the file mode permission
+ bits of symlinks to 0. (On Linux, symlinks actually always have
+ 0777 permissions, so this is not even consistent.) */
+
+ return mode;
+}
+
+static void
+get_sha1(char **sha1, char const *start, char const *end)
+{
+ unsigned int len = end - start;
+ *sha1 = xmalloc (len + 1);
+ memcpy (*sha1, start, len);
+ (*sha1)[len] = 0;
+}
+
+static int _GL_ATTRIBUTE_PURE
+sha1_says_nonexistent(char const *sha1)
+{
+ char const *empty_sha1 = "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";
+ char const *s;
+
+ /* Nonexisting files have an all-zero checksum. */
+ for (s = sha1; *s; s++)
+ if (*s != '0')
+ break;
+ if (! *s)
+ return 2;
+
+ /* Empty files have empty_sha1 as their checksum. */
+ for (s = sha1; *s; s++, empty_sha1++)
+ if (*s != *empty_sha1)
+ break;
+ return ! *s;
+}
+
+static char const * _GL_ATTRIBUTE_PURE
+skip_hex_digits (char const *str)
+{
+ char const *s;
+
+ for (s = str; (*s >= '0' && *s <= '9') || (*s >= 'a' && *s <= 'f'); s++)
+ /* do nothing */ ;
+ return s == str ? NULL : s;
+}
+
+static bool
+name_is_valid (char const *name)
+{
+ int i;
+ bool is_valid = true;
+
+ for (i = 0; i < ARRAY_SIZE (invalid_names); i++)
+ {
+ if (! invalid_names[i])
+ break;
+ if (! strcmp (invalid_names[i], name))
+ return false;
+ }
+
+ is_valid = filename_is_safe (name);
+
+ /* Allow any filename if we are in the filesystem root. */
+ if (! is_valid && cwd_is_root (name))
+ is_valid = true;
+
+ if (! is_valid)
+ {
+ say ("Ignoring potentially dangerous file name %s\n", quotearg (name));
+ if (i < ARRAY_SIZE (invalid_names))
+ invalid_names[i] = name;
+ }
+ return is_valid;
+}
+
+/* Determine what kind of diff is in the remaining part of the patch file. */
+
+static enum diff
+intuit_diff_type (bool need_header, mode_t *p_file_type)
+{
+ file_offset this_line = 0;
+ file_offset first_command_line = -1;
+ char first_ed_command_letter = 0;
+ lin fcl_line = 0; /* Pacify 'gcc -W'. */
+ bool this_is_a_command = false;
+ bool stars_this_line = false;
+ bool extended_headers = false;
+ enum nametype i;
+ struct stat st[3];
+ int stat_errno[3];
+ int version_controlled[3];
+ enum diff retval;
+ mode_t file_type;
+ size_t indent = 0;
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i]) {
+ free (p_name[i]);
+ p_name[i] = 0;
+ }
+ for (i = 0; i < ARRAY_SIZE (invalid_names); i++)
+ invalid_names[i] = NULL;
+ for (i = OLD; i <= NEW; i++)
+ if (p_timestr[i])
+ {
+ free(p_timestr[i]);
+ p_timestr[i] = 0;
+ }
+ for (i = OLD; i <= NEW; i++)
+ if (p_sha1[i])
+ {
+ free (p_sha1[i]);
+ p_sha1[i] = 0;
+ }
+ p_git_diff = false;
+ for (i = OLD; i <= NEW; i++)
+ {
+ p_mode[i] = 0;
+ p_copy[i] = false;
+ p_rename[i] = false;
+ }
+
+ /* Ed and normal format patches don't have filename headers. */
+ if (diff_type == ED_DIFF || diff_type == NORMAL_DIFF)
+ need_header = false;
+
+ version_controlled[OLD] = -1;
+ version_controlled[NEW] = -1;
+ version_controlled[INDEX] = -1;
+ p_rfc934_nesting = 0;
+ p_timestamp[OLD].tv_sec = p_timestamp[NEW].tv_sec = -1;
+ p_says_nonexistent[OLD] = p_says_nonexistent[NEW] = 0;
+ Fseek (pfp, p_base, SEEK_SET);
+ p_input_line = p_bline - 1;
+ for (;;) {
+ char *s;
+ char *t;
+ file_offset previous_line = this_line;
+ bool last_line_was_command = this_is_a_command;
+ bool stars_last_line = stars_this_line;
+ size_t indent_last_line = indent;
+ char ed_command_letter;
+ bool strip_trailing_cr;
+ size_t chars_read;
+
+ indent = 0;
+ this_line = file_tell (pfp);
+ chars_read = pget_line (0, 0, false, false);
+ if (chars_read == (size_t) -1)
+ xalloc_die ();
+ if (! chars_read) {
+ if (first_ed_command_letter) {
+ /* nothing but deletes!? */
+ p_start = first_command_line;
+ p_sline = fcl_line;
+ retval = ED_DIFF;
+ goto scan_exit;
+ }
+ else {
+ p_start = this_line;
+ p_sline = p_input_line;
+ if (extended_headers)
+ {
+ /* Patch contains no hunks; any diff type will do. */
+ retval = UNI_DIFF;
+ goto scan_exit;
+ }
+ return NO_DIFF;
+ }
+ }
+ strip_trailing_cr = 2 <= chars_read && buf[chars_read - 2] == '\r';
+ for (s = buf; *s == ' ' || *s == '\t' || *s == 'X'; s++) {
+ if (*s == '\t')
+ indent = (indent + 8) & ~7;
+ else
+ indent++;
+ }
+ if (ISDIGIT (*s))
+ {
+ for (t = s + 1; ISDIGIT (*t) || *t == ','; t++)
+ /* do nothing */ ;
+ if (*t == 'd' || *t == 'c' || *t == 'a')
+ {
+ for (t++; ISDIGIT (*t) || *t == ','; t++)
+ /* do nothing */ ;
+ for (; *t == ' ' || *t == '\t'; t++)
+ /* do nothing */ ;
+ if (*t == '\r')
+ t++;
+ this_is_a_command = (*t == '\n');
+ }
+ }
+ if (! need_header
+ && first_command_line < 0
+ && ((ed_command_letter = get_ed_command_letter (s))
+ || this_is_a_command)) {
+ first_command_line = this_line;
+ first_ed_command_letter = ed_command_letter;
+ fcl_line = p_input_line;
+ p_indent = indent; /* assume this for now */
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ if (!stars_last_line && strnEQ(s, "*** ", 4))
+ {
+ fetchname (s+4, strippath, &p_name[OLD], &p_timestr[OLD],
+ &p_timestamp[OLD]);
+ need_header = false;
+ }
+ else if (strnEQ(s, "+++ ", 4))
+ {
+ /* Swap with NEW below. */
+ fetchname (s+4, strippath, &p_name[OLD], &p_timestr[OLD],
+ &p_timestamp[OLD]);
+ need_header = false;
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ else if (strnEQ(s, "Index:", 6))
+ {
+ fetchname (s+6, strippath, &p_name[INDEX], (char **) 0, NULL);
+ need_header = false;
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ else if (strnEQ(s, "Prereq:", 7))
+ {
+ for (t = s + 7; ISSPACE ((unsigned char) *t); t++)
+ /* do nothing */ ;
+ revision = t;
+ for (t = revision; *t; t++)
+ if (ISSPACE ((unsigned char) *t))
+ {
+ char const *u;
+ for (u = t + 1; ISSPACE ((unsigned char) *u); u++)
+ /* do nothing */ ;
+ if (*u)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("Prereq: with multiple words at line %s of patch\n",
+ format_linenum (numbuf, this_line));
+ }
+ break;
+ }
+ if (t == revision)
+ revision = 0;
+ else {
+ char oldc = *t;
+ *t = '\0';
+ revision = xstrdup (revision);
+ *t = oldc;
+ }
+ }
+ else if (strnEQ (s, "diff --git ", 11))
+ {
+ char const *u;
+
+ if (extended_headers)
+ {
+ p_start = this_line;
+ p_sline = p_input_line;
+ /* Patch contains no hunks; any diff type will do. */
+ retval = UNI_DIFF;
+ goto scan_exit;
+ }
+
+ for (i = OLD; i <= NEW; i++)
+ {
+ free (p_name[i]);
+ p_name[i] = 0;
+ }
+ if (! ((p_name[OLD] = parse_name (s + 11, strippath, &u))
+ && ISSPACE ((unsigned char) *u)
+ && (p_name[NEW] = parse_name (u, strippath, &u))
+ && (u = skip_spaces (u), ! *u)))
+ for (i = OLD; i <= NEW; i++)
+ {
+ free (p_name[i]);
+ p_name[i] = 0;
+ }
+ p_git_diff = true;
+ need_header = false;
+ }
+ else if (p_git_diff && strnEQ (s, "index ", 6))
+ {
+ char const *u, *v;
+ if ((u = skip_hex_digits (s + 6))
+ && u[0] == '.' && u[1] == '.'
+ && (v = skip_hex_digits (u + 2))
+ && (! *v || ISSPACE ((unsigned char) *v)))
+ {
+ get_sha1(&p_sha1[OLD], s + 6, u);
+ get_sha1(&p_sha1[NEW], u + 2, v);
+ p_says_nonexistent[OLD] = sha1_says_nonexistent (p_sha1[OLD]);
+ p_says_nonexistent[NEW] = sha1_says_nonexistent (p_sha1[NEW]);
+ if (*(v = skip_spaces (v)))
+ p_mode[OLD] = p_mode[NEW] = fetchmode (v);
+ extended_headers = true;
+ }
+ }
+ else if (p_git_diff && strnEQ (s, "old mode ", 9))
+ {
+ p_mode[OLD] = fetchmode (s + 9);
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "new mode ", 9))
+ {
+ p_mode[NEW] = fetchmode (s + 9);
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "deleted file mode ", 18))
+ {
+ p_mode[OLD] = fetchmode (s + 18);
+ p_says_nonexistent[NEW] = 2;
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "new file mode ", 14))
+ {
+ p_mode[NEW] = fetchmode (s + 14);
+ p_says_nonexistent[OLD] = 2;
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "rename from ", 12))
+ {
+ /* Git leaves out the prefix in the file name in this header,
+ so we can only ignore the file name. */
+ p_rename[OLD] = true;
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "rename to ", 10))
+ {
+ /* Git leaves out the prefix in the file name in this header,
+ so we can only ignore the file name. */
+ p_rename[NEW] = true;
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "copy from ", 10))
+ {
+ /* Git leaves out the prefix in the file name in this header,
+ so we can only ignore the file name. */
+ p_copy[OLD] = true;
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "copy to ", 8))
+ {
+ /* Git leaves out the prefix in the file name in this header,
+ so we can only ignore the file name. */
+ p_copy[NEW] = true;
+ extended_headers = true;
+ }
+ else if (p_git_diff && strnEQ (s, "GIT binary patch", 16))
+ {
+ p_start = this_line;
+ p_sline = p_input_line;
+ retval = GIT_BINARY_DIFF;
+ goto scan_exit;
+ }
+ else
+ {
+ for (t = s; t[0] == '-' && t[1] == ' '; t += 2)
+ /* do nothing */ ;
+ if (strnEQ(t, "--- ", 4))
+ {
+ struct timespec timestamp;
+ timestamp.tv_sec = -1;
+ fetchname (t+4, strippath, &p_name[NEW], &p_timestr[NEW],
+ ×tamp);
+ need_header = false;
+ if (timestamp.tv_sec != -1)
+ {
+ p_timestamp[NEW] = timestamp;
+ p_rfc934_nesting = (t - s) >> 1;
+ }
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ }
+ if (need_header)
+ continue;
+ if ((diff_type == NO_DIFF || diff_type == ED_DIFF) &&
+ first_command_line >= 0 &&
+ strEQ(s, ".\n") ) {
+ p_start = first_command_line;
+ p_sline = fcl_line;
+ retval = ED_DIFF;
+ goto scan_exit;
+ }
+ if ((diff_type == NO_DIFF || diff_type == UNI_DIFF)
+ && strnEQ(s, "@@ -", 4)) {
+
+ /* 'p_name', 'p_timestr', and 'p_timestamp' are backwards;
+ swap them. */
+ struct timespec ti = p_timestamp[OLD];
+ p_timestamp[OLD] = p_timestamp[NEW];
+ p_timestamp[NEW] = ti;
+ t = p_name[OLD];
+ p_name[OLD] = p_name[NEW];
+ p_name[NEW] = t;
+ t = p_timestr[OLD];
+ p_timestr[OLD] = p_timestr[NEW];
+ p_timestr[NEW] = t;
+
+ s += 4;
+ if (s[0] == '0' && !ISDIGIT (s[1]))
+ p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD].tv_sec;
+ while (*s != ' ' && *s != '\n')
+ s++;
+ while (*s == ' ')
+ s++;
+ if (s[0] == '+' && s[1] == '0' && !ISDIGIT (s[2]))
+ p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW].tv_sec;
+ p_indent = indent;
+ p_start = this_line;
+ p_sline = p_input_line;
+ retval = UNI_DIFF;
+ if (! ((p_name[OLD] || ! p_timestamp[OLD].tv_sec)
+ && (p_name[NEW] || ! p_timestamp[NEW].tv_sec))
+ && ! p_name[INDEX] && need_header)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("missing header for unified diff at line %s of patch\n",
+ format_linenum (numbuf, p_sline));
+ }
+ goto scan_exit;
+ }
+ stars_this_line = strnEQ(s, "********", 8);
+ if ((diff_type == NO_DIFF
+ || diff_type == CONTEXT_DIFF
+ || diff_type == NEW_CONTEXT_DIFF)
+ && stars_last_line && indent_last_line == indent
+ && strnEQ (s, "*** ", 4)) {
+ s += 4;
+ if (s[0] == '0' && !ISDIGIT (s[1]))
+ p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD].tv_sec;
+ /* if this is a new context diff the character just before */
+ /* the newline is a '*'. */
+ while (*s != '\n')
+ s++;
+ p_indent = indent;
+ p_strip_trailing_cr = strip_trailing_cr;
+ p_start = previous_line;
+ p_sline = p_input_line - 1;
+ retval = (*(s-1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF);
+
+ {
+ /* Scan the first hunk to see whether the file contents
+ appear to have been deleted. */
+ file_offset saved_p_base = p_base;
+ lin saved_p_bline = p_bline;
+ Fseek (pfp, previous_line, SEEK_SET);
+ p_input_line -= 2;
+ if (another_hunk (retval, false)
+ && ! p_repl_lines && p_newfirst == 1)
+ p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW].tv_sec;
+ next_intuit_at (saved_p_base, saved_p_bline);
+ }
+
+ if (! ((p_name[OLD] || ! p_timestamp[OLD].tv_sec)
+ && (p_name[NEW] || ! p_timestamp[NEW].tv_sec))
+ && ! p_name[INDEX] && need_header)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("missing header for context diff at line %s of patch\n",
+ format_linenum (numbuf, p_sline));
+ }
+ goto scan_exit;
+ }
+ if ((diff_type == NO_DIFF || diff_type == NORMAL_DIFF) &&
+ last_line_was_command &&
+ (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2)) ) {
+ p_start = previous_line;
+ p_sline = p_input_line - 1;
+ p_indent = indent;
+ retval = NORMAL_DIFF;
+ goto scan_exit;
+ }
+ }
+
+ scan_exit:
+
+ /* The old, new, or old and new file types may be defined. When both
+ file types are defined, make sure they are the same, or else assume
+ we do not know the file type. */
+ file_type = p_mode[OLD] & S_IFMT;
+ if (file_type)
+ {
+ mode_t new_file_type = p_mode[NEW] & S_IFMT;
+ if (new_file_type && file_type != new_file_type)
+ file_type = 0;
+ }
+ else
+ {
+ file_type = p_mode[NEW] & S_IFMT;
+ if (! file_type)
+ file_type = S_IFREG;
+ }
+ *p_file_type = file_type;
+
+ /* To intuit 'inname', the name of the file to patch,
+ use the algorithm specified by POSIX 1003.1-2001 XCU lines 25680-26599
+ (with some modifications if posixly_correct is zero):
+
+ - Take the old and new names from the context header if present,
+ and take the index name from the 'Index:' line if present and
+ if either the old and new names are both absent
+ or posixly_correct is nonzero.
+ Consider the file names to be in the order (old, new, index).
+ - If some named files exist, use the first one if posixly_correct
+ is nonzero, the best one otherwise.
+ - If patch_get is nonzero, and no named files exist,
+ but an RCS or SCCS master file exists,
+ use the first named file with an RCS or SCCS master.
+ - If no named files exist, no RCS or SCCS master was found,
+ some names are given, posixly_correct is zero,
+ and the patch appears to create a file, then use the best name
+ requiring the creation of the fewest directories.
+ - Otherwise, report failure by setting 'inname' to 0;
+ this causes our invoker to ask the user for a file name. */
+
+ i = NONE;
+
+ if (!inname)
+ {
+ enum nametype i0 = NONE;
+
+ if (! posixly_correct && (p_name[OLD] || p_name[NEW]) && p_name[INDEX])
+ {
+ free (p_name[INDEX]);
+ p_name[INDEX] = 0;
+ }
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ {
+ if (i0 != NONE && strcmp (p_name[i0], p_name[i]) == 0)
+ {
+ /* It's the same name as before; reuse stat results. */
+ stat_errno[i] = stat_errno[i0];
+ if (! stat_errno[i])
+ st[i] = st[i0];
+ }
+ else
+ {
+ stat_errno[i] = stat_file (p_name[i], &st[i]);
+ if (! stat_errno[i])
+ {
+ if (lookup_file_id (&st[i]) == DELETE_LATER)
+ stat_errno[i] = ENOENT;
+ else if (posixly_correct && name_is_valid (p_name[i]))
+ break;
+ }
+ }
+ i0 = i;
+ }
+
+ if (! posixly_correct)
+ {
+ /* The best of all existing files. */
+ i = best_name (p_name, stat_errno);
+
+ if (i == NONE && patch_get)
+ {
+ enum nametype nope = NONE;
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ {
+ char const *cs;
+ char *getbuf;
+ char *diffbuf;
+ bool readonly = (outfile
+ && strcmp (outfile, p_name[i]) != 0);
+
+ if (nope == NONE || strcmp (p_name[nope], p_name[i]) != 0)
+ {
+ cs = (version_controller
+ (p_name[i], readonly, (struct stat *) 0,
+ &getbuf, &diffbuf));
+ version_controlled[i] = !! cs;
+ if (cs)
+ {
+ if (version_get (p_name[i], cs, false, readonly,
+ getbuf, &st[i]))
+ stat_errno[i] = 0;
+ else
+ version_controlled[i] = 0;
+
+ free (getbuf);
+ free (diffbuf);
+
+ if (! stat_errno[i])
+ break;
+ }
+ }
+
+ nope = i;
+ }
+ }
+
+ if (i0 != NONE
+ && (i == NONE || (st[i].st_mode & S_IFMT) == file_type)
+ && maybe_reverse (p_name[i == NONE ? i0 : i], i == NONE,
+ i == NONE || st[i].st_size == 0)
+ && i == NONE)
+ i = i0;
+
+ if (i == NONE && p_says_nonexistent[reverse])
+ {
+ int newdirs[3];
+ int newdirs_min = INT_MAX;
+ int distance_from_minimum[3];
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ {
+ newdirs[i] = (prefix_components (p_name[i], false)
+ - prefix_components (p_name[i], true));
+ if (newdirs[i] < newdirs_min)
+ newdirs_min = newdirs[i];
+ }
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ distance_from_minimum[i] = newdirs[i] - newdirs_min;
+
+ /* The best of the filenames which create the fewest directories. */
+ i = best_name (p_name, distance_from_minimum);
+ }
+ }
+ }
+
+ if ((pch_rename () || pch_copy ())
+ && ! inname
+ && ! ((i == OLD || i == NEW) &&
+ p_name[! reverse] &&
+ name_is_valid (p_name[! reverse])))
+ {
+ say ("Cannot %s file without two valid file names\n", pch_rename () ? "rename" : "copy");
+ skip_rest_of_patch = true;
+ }
+
+ if (i == NONE)
+ {
+ if (inname)
+ {
+ inerrno = stat_file (inname, &instat);
+ if (inerrno || (instat.st_mode & S_IFMT) == file_type)
+ maybe_reverse (inname, inerrno, inerrno || instat.st_size == 0);
+ }
+ else
+ inerrno = -1;
+ }
+ else
+ {
+ inname = xstrdup (p_name[i]);
+ inerrno = stat_errno[i];
+ invc = version_controlled[i];
+ instat = st[i];
+ }
+
+ if (! force && retval == ED_DIFF)
+ {
+ ask ("Apply potentially dangerous ed script? This could allow arbitrary command execution! [n] ");
+ if (*buf != 'y')
+ {
+ if (verbosity != SILENT)
+ say ("Skipping potentially dangerous ed script.\n");
+ skip_rest_of_patch = true;
+ }
+ }
+
+ return retval;
+}
+
+/* Count the path name components in FILENAME's prefix.
+ If CHECKDIRS is true, count only existing directories. */
+static int
+prefix_components (char *filename, bool checkdirs)
+{
+ int count = 0;
+ struct stat stat_buf;
+ int stat_result;
+ char *f = filename + FILE_SYSTEM_PREFIX_LEN (filename);
+
+ if (*f)
+ while (*++f)
+ if (ISSLASH (f[0]) && ! ISSLASH (f[-1]))
+ {
+ if (checkdirs)
+ {
+ *f = '\0';
+ stat_result = safe_stat (filename, &stat_buf);
+ *f = '/';
+ if (! (stat_result == 0 && S_ISDIR (stat_buf.st_mode)))
+ break;
+ }
+
+ count++;
+ }
+
+ return count;
+}
+
+/* Return the index of the best of NAME[OLD], NAME[NEW], and NAME[INDEX].
+ Ignore null names, and ignore NAME[i] if IGNORE[i] is nonzero.
+ Return NONE if all names are ignored. */
+static enum nametype
+best_name (char *const *name, int const *ignore)
+{
+ enum nametype i;
+ int components[3];
+ int components_min = INT_MAX;
+ size_t basename_len[3];
+ size_t basename_len_min = SIZE_MAX;
+ size_t len[3];
+ size_t len_min = SIZE_MAX;
+
+ for (i = OLD; i <= INDEX; i++)
+ if (name[i] && !ignore[i])
+ {
+ /* Take the names with the fewest prefix components. */
+ components[i] = prefix_components (name[i], false);
+ if (components_min < components[i])
+ continue;
+ components_min = components[i];
+
+ /* Of those, take the names with the shortest basename. */
+ basename_len[i] = base_len (name[i]);
+ if (basename_len_min < basename_len[i])
+ continue;
+ basename_len_min = basename_len[i];
+
+ /* Of those, take the shortest names. */
+ len[i] = strlen (name[i]);
+ if (len_min < len[i])
+ continue;
+ len_min = len[i];
+ }
+
+ /* Of those, take the first name. */
+ for (i = OLD; i <= INDEX; i++)
+ if (name[i] && !ignore[i]
+ && name_is_valid (name[i])
+ && components[i] == components_min
+ && basename_len[i] == basename_len_min
+ && len[i] == len_min)
+ break;
+
+ return i;
+}
+
+/* Remember where this patch ends so we know where to start up again. */
+
+static void
+next_intuit_at (file_offset file_pos, lin file_line)
+{
+ p_base = file_pos;
+ p_bline = file_line;
+}
+
+/* Basically a verbose fseek() to the actual diff listing. */
+
+static void
+skip_to (file_offset file_pos, lin file_line)
+{
+ FILE *i = pfp;
+ FILE *o = stdout;
+ int c;
+
+ assert(p_base <= file_pos);
+ if ((verbosity == VERBOSE || !inname) && p_base < file_pos) {
+ Fseek (i, p_base, SEEK_SET);
+ say ("The text leading up to this was:\n--------------------------\n");
+
+ while (file_tell (i) < file_pos)
+ {
+ putc ('|', o);
+ do
+ {
+ if ((c = getc (i)) == EOF)
+ read_fatal ();
+ putc (c, o);
+ }
+ while (c != '\n');
+ }
+
+ say ("--------------------------\n");
+ }
+ else
+ Fseek (i, file_pos, SEEK_SET);
+ p_input_line = file_line - 1;
+}
+
+/* Make this a function for better debugging. */
+static void
+malformed (void)
+{
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ fatal ("malformed patch at line %s: %s",
+ format_linenum (numbuf, p_input_line), buf);
+ /* about as informative as "Syntax error" in C */
+}
+
+/* Parse a line number from a string.
+ Return the address of the first char after the number. */
+static char *
+scan_linenum (char *s0, lin *linenum)
+{
+ char *s;
+ lin n = 0;
+ bool overflow = false;
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+
+ for (s = s0; ISDIGIT (*s); s++)
+ {
+ lin new_n = 10 * n + (*s - '0');
+ overflow |= new_n / 10 != n;
+ n = new_n;
+ }
+
+ if (s == s0)
+ fatal ("missing line number at line %s: %s",
+ format_linenum (numbuf, p_input_line), buf);
+
+ if (overflow)
+ fatal ("line number %.*s is too large at line %s: %s",
+ (int) (s - s0), s0, format_linenum (numbuf, p_input_line), buf);
+
+ *linenum = n;
+ return s;
+}
+
+/* 1 if there is more of the current diff listing to process;
+ 0 if not; -1 if ran out of memory. */
+
+int
+another_hunk (enum diff difftype, bool rev)
+{
+ char *s;
+ lin context = 0;
+ size_t chars_read;
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ char numbuf2[LINENUM_LENGTH_BOUND + 1];
+ char numbuf3[LINENUM_LENGTH_BOUND + 1];
+
+ set_hunkmax();
+
+ while (p_end >= 0) {
+ if (p_end == p_efake)
+ p_end = p_bfake; /* don't free twice */
+ else
+ free(p_line[p_end]);
+ p_end--;
+ }
+ assert(p_end == -1);
+ p_efake = -1;
+
+ if (p_c_function)
+ {
+ free (p_c_function);
+ p_c_function = NULL;
+ }
+
+ p_max = hunkmax; /* gets reduced when --- found */
+ if (difftype == CONTEXT_DIFF || difftype == NEW_CONTEXT_DIFF) {
+ file_offset line_beginning = file_tell (pfp);
+ /* file pos of the current line */
+ lin repl_beginning = 0; /* index of --- line */
+ lin fillcnt = 0; /* #lines of missing ptrn or repl */
+ lin fillsrc; /* index of first line to copy */
+ lin filldst; /* index of first missing line */
+ bool ptrn_spaces_eaten = false; /* ptrn was slightly misformed */
+ bool some_context = false; /* (perhaps internal) context seen */
+ bool repl_could_be_missing = true;
+ bool ptrn_missing = false; /* The pattern was missing. */
+ bool repl_missing = false; /* Likewise for replacement. */
+ file_offset repl_backtrack_position = 0;
+ /* file pos of first repl line */
+ lin repl_patch_line; /* input line number for same */
+ lin repl_context; /* context for same */
+ lin ptrn_prefix_context = -1; /* lines in pattern prefix context */
+ lin ptrn_suffix_context = -1; /* lines in pattern suffix context */
+ lin repl_prefix_context = -1; /* lines in replac. prefix context */
+ lin ptrn_copiable = 0; /* # of copiable lines in ptrn */
+ lin repl_copiable = 0; /* Likewise for replacement. */
+
+ /* Pacify 'gcc -Wall'. */
+ fillsrc = filldst = repl_patch_line = repl_context = 0;
+
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1
+ || chars_read <= 8
+ || strncmp (buf, "********", 8) != 0) {
+ next_intuit_at(line_beginning,p_input_line);
+ return chars_read == (size_t) -1 ? -1 : 0;
+ }
+ s = buf;
+ while (*s == '*')
+ s++;
+ if (*s == ' ')
+ {
+ p_c_function = s;
+ while (*s != '\n')
+ s++;
+ *s = '\0';
+ p_c_function = savestr (p_c_function);
+ if (! p_c_function)
+ return -1;
+ }
+ p_hunk_beg = p_input_line + 1;
+ while (p_end < p_max) {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ return -1;
+ if (!chars_read) {
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ if (p_max - p_end < 4) {
+ strcpy (buf, " \n"); /* assume blank lines got chopped */
+ chars_read = 3;
+ } else {
+ fatal ("unexpected end of file in patch");
+ }
+ }
+ p_end++;
+ if (p_end == hunkmax)
+ fatal ("unterminated hunk starting at line %s; giving up at line %s: %s",
+ format_linenum (numbuf0, pch_hunk_beg ()),
+ format_linenum (numbuf1, p_input_line), buf);
+ assert(p_end < hunkmax);
+ p_Char[p_end] = *buf;
+ p_len[p_end] = 0;
+ p_line[p_end] = 0;
+ switch (*buf) {
+ case '*':
+ if (strnEQ(buf, "********", 8)) {
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ else
+ fatal ("unexpected end of hunk at line %s",
+ format_linenum (numbuf0, p_input_line));
+ }
+ if (p_end != 0) {
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ fatal ("unexpected '***' at line %s: %s",
+ format_linenum (numbuf0, p_input_line), buf);
+ }
+ context = 0;
+ p_len[p_end] = strlen (buf);
+ if (! (p_line[p_end] = savestr (buf))) {
+ p_end--;
+ return -1;
+ }
+ for (s = buf; *s && !ISDIGIT (*s); s++)
+ /* do nothing */ ;
+ if (strnEQ(s,"0,0",3))
+ remove_prefix (s, 2);
+ s = scan_linenum (s, &p_first);
+ if (*s == ',') {
+ while (*s && !ISDIGIT (*s))
+ s++;
+ scan_linenum (s, &p_ptrn_lines);
+ p_ptrn_lines += 1 - p_first;
+ if (p_ptrn_lines < 0)
+ malformed ();
+ }
+ else if (p_first)
+ p_ptrn_lines = 1;
+ else {
+ p_ptrn_lines = 0;
+ p_first = 1;
+ }
+ if (p_first >= LINENUM_MAX - p_ptrn_lines ||
+ p_ptrn_lines >= LINENUM_MAX - 6)
+ malformed ();
+ p_max = p_ptrn_lines + 6; /* we need this much at least */
+ while (p_max + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ return -1;
+ p_max = hunkmax;
+ break;
+ case '-':
+ if (buf[1] != '-')
+ goto change_line;
+ if (ptrn_prefix_context == -1)
+ ptrn_prefix_context = context;
+ ptrn_suffix_context = context;
+ if (repl_beginning
+ || (p_end
+ != p_ptrn_lines + 1 + (p_Char[p_end - 1] == '\n')))
+ {
+ if (p_end == 1)
+ {
+ /* 'Old' lines were omitted. Set up to fill
+ them in from 'new' context lines. */
+ ptrn_missing = true;
+ p_end = p_ptrn_lines + 1;
+ ptrn_prefix_context = ptrn_suffix_context = -1;
+ fillsrc = p_end + 1;
+ filldst = 1;
+ fillcnt = p_ptrn_lines;
+ }
+ else if (! repl_beginning)
+ fatal ("%s '---' at line %s; check line numbers at line %s",
+ (p_end <= p_ptrn_lines
+ ? "Premature"
+ : "Overdue"),
+ format_linenum (numbuf0, p_input_line),
+ format_linenum (numbuf1, p_hunk_beg));
+ else if (! repl_could_be_missing)
+ fatal ("duplicate '---' at line %s; check line numbers at line %s",
+ format_linenum (numbuf0, p_input_line),
+ format_linenum (numbuf1,
+ p_hunk_beg + repl_beginning));
+ else
+ {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ }
+ repl_beginning = p_end;
+ repl_backtrack_position = file_tell (pfp);
+ repl_patch_line = p_input_line;
+ repl_context = context;
+ p_len[p_end] = strlen (buf);
+ if (! (p_line[p_end] = savestr (buf)))
+ {
+ p_end--;
+ return -1;
+ }
+ p_Char[p_end] = '=';
+ for (s = buf; *s && ! ISDIGIT (*s); s++)
+ /* do nothing */ ;
+ s = scan_linenum (s, &p_newfirst);
+ if (*s == ',')
+ {
+ do
+ {
+ if (!*++s)
+ malformed ();
+ }
+ while (! ISDIGIT (*s));
+ scan_linenum (s, &p_repl_lines);
+ p_repl_lines += 1 - p_newfirst;
+ if (p_repl_lines < 0)
+ malformed ();
+ }
+ else if (p_newfirst)
+ p_repl_lines = 1;
+ else
+ {
+ p_repl_lines = 0;
+ p_newfirst = 1;
+ }
+ if (p_newfirst >= LINENUM_MAX - p_repl_lines ||
+ p_repl_lines >= LINENUM_MAX - p_end)
+ malformed ();
+ p_max = p_repl_lines + p_end;
+ while (p_max + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ return -1;
+ if (p_repl_lines != ptrn_copiable
+ && (p_prefix_context != 0
+ || context != 0
+ || p_repl_lines != 1))
+ repl_could_be_missing = false;
+ context = 0;
+ break;
+ case '+': case '!':
+ repl_could_be_missing = false;
+ change_line:
+ s = buf + 1;
+ chars_read--;
+ if (*s == '\n' && canonicalize_ws) {
+ strcpy (s, " \n");
+ chars_read = 2;
+ }
+ if (*s == ' ' || *s == '\t') {
+ s++;
+ chars_read--;
+ } else if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ if (! repl_beginning)
+ {
+ if (ptrn_prefix_context == -1)
+ ptrn_prefix_context = context;
+ }
+ else
+ {
+ if (repl_prefix_context == -1)
+ repl_prefix_context = context;
+ }
+ chars_read -=
+ (1 < chars_read
+ && p_end == (repl_beginning ? p_max : p_ptrn_lines)
+ && incomplete_line ());
+ p_len[p_end] = chars_read;
+ p_line[p_end] = savebuf (s, chars_read);
+ if (chars_read && ! p_line[p_end]) {
+ p_end--;
+ return -1;
+ }
+ context = 0;
+ break;
+ case '\t': case '\n': /* assume spaces got eaten */
+ s = buf;
+ if (*buf == '\t') {
+ s++;
+ chars_read--;
+ }
+ if (repl_beginning && repl_could_be_missing &&
+ (!ptrn_spaces_eaten || difftype == NEW_CONTEXT_DIFF) ) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ chars_read -=
+ (1 < chars_read
+ && p_end == (repl_beginning ? p_max : p_ptrn_lines)
+ && incomplete_line ());
+ p_len[p_end] = chars_read;
+ p_line[p_end] = savebuf (buf, chars_read);
+ if (chars_read && ! p_line[p_end]) {
+ p_end--;
+ return -1;
+ }
+ if (p_end != p_ptrn_lines + 1) {
+ ptrn_spaces_eaten |= (repl_beginning != 0);
+ some_context = true;
+ context++;
+ if (repl_beginning)
+ repl_copiable++;
+ else
+ ptrn_copiable++;
+ p_Char[p_end] = ' ';
+ }
+ break;
+ case ' ':
+ s = buf + 1;
+ chars_read--;
+ if (*s == '\n' && canonicalize_ws) {
+ strcpy (s, "\n");
+ chars_read = 2;
+ }
+ if (*s == ' ' || *s == '\t') {
+ s++;
+ chars_read--;
+ } else if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ some_context = true;
+ context++;
+ if (repl_beginning)
+ repl_copiable++;
+ else
+ ptrn_copiable++;
+ chars_read -=
+ (1 < chars_read
+ && p_end == (repl_beginning ? p_max : p_ptrn_lines)
+ && incomplete_line ());
+ p_len[p_end] = chars_read;
+ p_line[p_end] = savebuf (s, chars_read);
+ if (chars_read && ! p_line[p_end]) {
+ p_end--;
+ return -1;
+ }
+ break;
+ default:
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ malformed ();
+ }
+ }
+
+ hunk_done:
+ if (p_end >=0 && !repl_beginning)
+ fatal ("no '---' found in patch at line %s",
+ format_linenum (numbuf0, pch_hunk_beg ()));
+
+ if (repl_missing) {
+
+ /* reset state back to just after --- */
+ p_input_line = repl_patch_line;
+ context = repl_context;
+ for (p_end--; p_end > repl_beginning; p_end--)
+ free(p_line[p_end]);
+ Fseek (pfp, repl_backtrack_position, SEEK_SET);
+
+ /* redundant 'new' context lines were omitted - set */
+ /* up to fill them in from the old file context */
+ fillsrc = 1;
+ filldst = repl_beginning+1;
+ fillcnt = p_repl_lines;
+ p_end = p_max;
+ }
+ else if (! ptrn_missing && ptrn_copiable != repl_copiable)
+ fatal ("context mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+ else if (!some_context && fillcnt == 1) {
+ /* the first hunk was a null hunk with no context */
+ /* and we were expecting one line -- fix it up. */
+ while (filldst < p_end) {
+ p_line[filldst] = p_line[filldst+1];
+ p_Char[filldst] = p_Char[filldst+1];
+ p_len[filldst] = p_len[filldst+1];
+ filldst++;
+ }
+#if 0
+ repl_beginning--; /* this doesn't need to be fixed */
+#endif
+ p_end--;
+ p_first++; /* do append rather than insert */
+ fillcnt = 0;
+ p_ptrn_lines = 0;
+ }
+
+ p_prefix_context = ((repl_prefix_context == -1
+ || (ptrn_prefix_context != -1
+ && ptrn_prefix_context < repl_prefix_context))
+ ? ptrn_prefix_context : repl_prefix_context);
+ p_suffix_context = ((ptrn_suffix_context != -1
+ && ptrn_suffix_context < context)
+ ? ptrn_suffix_context : context);
+ if (p_prefix_context == -1 || p_suffix_context == -1)
+ fatal ("replacement text or line numbers mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+
+ if (difftype == CONTEXT_DIFF
+ && (fillcnt
+ || (p_first > 1
+ && p_prefix_context + p_suffix_context < ptrn_copiable))) {
+ if (verbosity == VERBOSE)
+ say ("%s\n%s\n%s\n",
+"(Fascinating -- this is really a new-style context diff but without",
+"the telltale extra asterisks on the *** line that usually indicate",
+"the new style...)");
+ diff_type = difftype = NEW_CONTEXT_DIFF;
+ }
+
+ /* if there were omitted context lines, fill them in now */
+ if (fillcnt) {
+ p_bfake = filldst; /* remember where not to free() */
+ p_efake = filldst + fillcnt - 1;
+ while (fillcnt-- > 0) {
+ while (fillsrc <= p_end && fillsrc != repl_beginning
+ && p_Char[fillsrc] != ' ')
+ fillsrc++;
+ if (p_end < fillsrc || fillsrc == repl_beginning)
+ {
+ fatal ("replacement text or line numbers mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+ }
+ p_line[filldst] = p_line[fillsrc];
+ p_Char[filldst] = p_Char[fillsrc];
+ p_len[filldst] = p_len[fillsrc];
+ fillsrc++; filldst++;
+ }
+ while (fillsrc <= p_end && fillsrc != repl_beginning)
+ {
+ if (p_Char[fillsrc] == ' ')
+ fatal ("replacement text or line numbers mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+ fillsrc++;
+ }
+ if (debug & 64)
+ printf ("fillsrc %s, filldst %s, rb %s, e+1 %s\n",
+ format_linenum (numbuf0, fillsrc),
+ format_linenum (numbuf1, filldst),
+ format_linenum (numbuf2, repl_beginning),
+ format_linenum (numbuf3, p_end + 1));
+ assert(fillsrc==p_end+1 || fillsrc==repl_beginning);
+ assert(filldst==p_end+1 || filldst==repl_beginning);
+ }
+ }
+ else if (difftype == UNI_DIFF) {
+ file_offset line_beginning = file_tell (pfp); /* file pos of the current line */
+ lin fillsrc; /* index of old lines */
+ lin filldst; /* index of new lines */
+ char ch = '\0';
+
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1
+ || chars_read <= 4
+ || strncmp (buf, "@@ -", 4) != 0) {
+ next_intuit_at(line_beginning,p_input_line);
+ return chars_read == (size_t) -1 ? -1 : 0;
+ }
+ s = scan_linenum (buf + 4, &p_first);
+ if (*s == ',')
+ s = scan_linenum (s + 1, &p_ptrn_lines);
+ else
+ p_ptrn_lines = 1;
+ if (p_first >= LINENUM_MAX - p_ptrn_lines)
+ malformed ();
+ if (*s == ' ') s++;
+ if (*s != '+')
+ malformed ();
+ s = scan_linenum (s + 1, &p_newfirst);
+ if (*s == ',')
+ s = scan_linenum (s + 1, &p_repl_lines);
+ else
+ p_repl_lines = 1;
+ if (p_newfirst >= LINENUM_MAX - p_repl_lines)
+ malformed ();
+ if (*s == ' ') s++;
+ if (*s++ != '@')
+ malformed ();
+ if (*s++ == '@' && *s == ' ')
+ {
+ p_c_function = s;
+ while (*s != '\n')
+ s++;
+ *s = '\0';
+ p_c_function = savestr (p_c_function);
+ if (! p_c_function)
+ return -1;
+ }
+ if (!p_ptrn_lines)
+ p_first++; /* do append rather than insert */
+ if (!p_repl_lines)
+ p_newfirst++;
+ if (p_ptrn_lines >= LINENUM_MAX - (p_repl_lines + 1))
+ malformed ();
+ p_max = p_ptrn_lines + p_repl_lines + 1;
+ while (p_max + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ return -1;
+ fillsrc = 1;
+ filldst = fillsrc + p_ptrn_lines;
+ p_end = filldst + p_repl_lines;
+ sprintf (buf, "*** %s,%s ****\n",
+ format_linenum (numbuf0, p_first),
+ format_linenum (numbuf1, p_first + p_ptrn_lines - 1));
+ p_len[0] = strlen (buf);
+ if (! (p_line[0] = savestr (buf))) {
+ p_end = -1;
+ return -1;
+ }
+ p_Char[0] = '*';
+ sprintf (buf, "--- %s,%s ----\n",
+ format_linenum (numbuf0, p_newfirst),
+ format_linenum (numbuf1, p_newfirst + p_repl_lines - 1));
+ p_len[filldst] = strlen (buf);
+ if (! (p_line[filldst] = savestr (buf))) {
+ p_end = 0;
+ return -1;
+ }
+ p_Char[filldst++] = '=';
+ p_prefix_context = -1;
+ p_hunk_beg = p_input_line + 1;
+ while (fillsrc <= p_ptrn_lines || filldst <= p_end) {
+ chars_read = get_line ();
+ if (!chars_read) {
+ if (p_max - filldst < 3) {
+ strcpy (buf, " \n"); /* assume blank lines got chopped */
+ chars_read = 2;
+ } else {
+ fatal ("unexpected end of file in patch");
+ }
+ }
+ if (chars_read == (size_t) -1)
+ s = 0;
+ else if (*buf == '\t' || *buf == '\n') {
+ ch = ' '; /* assume the space got eaten */
+ s = savebuf (buf, chars_read);
+ }
+ else {
+ ch = *buf;
+ s = savebuf (buf+1, --chars_read);
+ }
+ if (chars_read && ! s)
+ {
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ return -1;
+ }
+ switch (ch) {
+ case '-':
+ if (fillsrc > p_ptrn_lines) {
+ free(s);
+ p_end = filldst-1;
+ malformed ();
+ }
+ chars_read -= fillsrc == p_ptrn_lines && incomplete_line ();
+ p_Char[fillsrc] = ch;
+ p_line[fillsrc] = s;
+ p_len[fillsrc++] = chars_read;
+ break;
+ case '=':
+ ch = ' ';
+ /* FALL THROUGH */
+ case ' ':
+ if (fillsrc > p_ptrn_lines) {
+ free(s);
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ malformed ();
+ }
+ context++;
+ chars_read -= fillsrc == p_ptrn_lines && incomplete_line ();
+ p_Char[fillsrc] = ch;
+ p_line[fillsrc] = s;
+ p_len[fillsrc++] = chars_read;
+ s = savebuf (s, chars_read);
+ if (chars_read && ! s) {
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ return -1;
+ }
+ /* FALL THROUGH */
+ case '+':
+ if (filldst > p_end) {
+ free(s);
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ malformed ();
+ }
+ chars_read -= filldst == p_end && incomplete_line ();
+ p_Char[filldst] = ch;
+ p_line[filldst] = s;
+ p_len[filldst++] = chars_read;
+ break;
+ default:
+ p_end = filldst;
+ malformed ();
+ }
+ if (ch != ' ') {
+ if (p_prefix_context == -1)
+ p_prefix_context = context;
+ context = 0;
+ }
+ }/* while */
+ if (p_prefix_context == -1)
+ malformed ();
+ p_suffix_context = context;
+ }
+ else { /* normal diff--fake it up */
+ char hunk_type;
+ int i;
+ lin min, max;
+ file_offset line_beginning = file_tell (pfp);
+
+ p_prefix_context = p_suffix_context = 0;
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1 || !chars_read || !ISDIGIT (*buf)) {
+ next_intuit_at(line_beginning,p_input_line);
+ return chars_read == (size_t) -1 ? -1 : 0;
+ }
+ s = scan_linenum (buf, &p_first);
+ if (*s == ',') {
+ s = scan_linenum (s + 1, &p_ptrn_lines);
+ p_ptrn_lines += 1 - p_first;
+ }
+ else
+ p_ptrn_lines = (*s != 'a');
+ if (p_first >= LINENUM_MAX - p_ptrn_lines)
+ malformed ();
+ hunk_type = *s;
+ if (hunk_type == 'a')
+ p_first++; /* do append rather than insert */
+ s = scan_linenum (s + 1, &min);
+ if (*s == ',')
+ scan_linenum (s + 1, &max);
+ else
+ max = min;
+ if (min > max || max - min == LINENUM_MAX)
+ malformed ();
+ if (hunk_type == 'd')
+ min++;
+ p_newfirst = min;
+ p_repl_lines = max - min + 1;
+ if (p_newfirst >= LINENUM_MAX - p_repl_lines)
+ malformed ();
+ if (p_ptrn_lines >= LINENUM_MAX - (p_repl_lines + 1))
+ malformed ();
+ p_end = p_ptrn_lines + p_repl_lines + 1;
+ while (p_end + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ {
+ p_end = -1;
+ return -1;
+ }
+ sprintf (buf, "*** %s,%s\n",
+ format_linenum (numbuf0, p_first),
+ format_linenum (numbuf1, p_first + p_ptrn_lines - 1));
+ p_len[0] = strlen (buf);
+ if (! (p_line[0] = savestr (buf))) {
+ p_end = -1;
+ return -1;
+ }
+ p_Char[0] = '*';
+ for (i=1; i<=p_ptrn_lines; i++) {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ {
+ p_end = i - 1;
+ return -1;
+ }
+ if (!chars_read)
+ fatal ("unexpected end of file in patch at line %s",
+ format_linenum (numbuf0, p_input_line));
+ if (buf[0] != '<' || (buf[1] != ' ' && buf[1] != '\t'))
+ fatal ("'<' followed by space or tab expected at line %s of patch",
+ format_linenum (numbuf0, p_input_line));
+ chars_read -= 2 + (i == p_ptrn_lines && incomplete_line ());
+ p_len[i] = chars_read;
+ p_line[i] = savebuf (buf + 2, chars_read);
+ if (chars_read && ! p_line[i]) {
+ p_end = i-1;
+ return -1;
+ }
+ p_Char[i] = '-';
+ }
+ if (hunk_type == 'c') {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ {
+ p_end = i - 1;
+ return -1;
+ }
+ if (! chars_read)
+ fatal ("unexpected end of file in patch at line %s",
+ format_linenum (numbuf0, p_input_line));
+ if (*buf != '-')
+ fatal ("'---' expected at line %s of patch",
+ format_linenum (numbuf0, p_input_line));
+ }
+ sprintf (buf, "--- %s,%s\n",
+ format_linenum (numbuf0, min),
+ format_linenum (numbuf1, max));
+ p_len[i] = strlen (buf);
+ if (! (p_line[i] = savestr (buf))) {
+ p_end = i-1;
+ return -1;
+ }
+ p_Char[i] = '=';
+ for (i++; i<=p_end; i++) {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ {
+ p_end = i - 1;
+ return -1;
+ }
+ if (!chars_read)
+ fatal ("unexpected end of file in patch at line %s",
+ format_linenum (numbuf0, p_input_line));
+ if (buf[0] != '>' || (buf[1] != ' ' && buf[1] != '\t'))
+ fatal ("'>' followed by space or tab expected at line %s of patch",
+ format_linenum (numbuf0, p_input_line));
+ chars_read -= 2 + (i == p_end && incomplete_line ());
+ p_len[i] = chars_read;
+ p_line[i] = savebuf (buf + 2, chars_read);
+ if (chars_read && ! p_line[i]) {
+ p_end = i-1;
+ return -1;
+ }
+ p_Char[i] = '+';
+ }
+ }
+ if (rev) /* backwards patch? */
+ if (!pch_swap())
+ say ("Not enough memory to swap next hunk!\n");
+ assert (p_end + 1 < hunkmax);
+ p_Char[p_end + 1] = '^'; /* add a stopper for apply_hunk */
+ if (debug & 2) {
+ lin i;
+
+ for (i = 0; i <= p_end + 1; i++) {
+ fprintf (stderr, "%s %c",
+ format_linenum (numbuf0, i),
+ p_Char[i]);
+ if (p_Char[i] == '*')
+ fprintf (stderr, " %s,%s\n",
+ format_linenum (numbuf0, p_first),
+ format_linenum (numbuf1, p_ptrn_lines));
+ else if (p_Char[i] == '=')
+ fprintf (stderr, " %s,%s\n",
+ format_linenum (numbuf0, p_newfirst),
+ format_linenum (numbuf1, p_repl_lines));
+ else if (p_Char[i] != '^')
+ {
+ fputs(" |", stderr);
+ pch_write_line (i, stderr);
+ }
+ else
+ fputc('\n', stderr);
+ }
+ fflush (stderr);
+ }
+ return 1;
+}
+
+static size_t
+get_line (void)
+{
+ return pget_line (p_indent, p_rfc934_nesting, p_strip_trailing_cr,
+ p_pass_comments_through);
+}
+
+/* Input a line from the patch file, worrying about indentation.
+ Strip up to INDENT characters' worth of leading indentation.
+ Then remove up to RFC934_NESTING instances of leading "- ".
+ If STRIP_TRAILING_CR is true, remove any trailing carriage-return.
+ Unless PASS_COMMENTS_THROUGH is true, ignore any resulting lines
+ that begin with '#'; they're comments.
+ Ignore any partial lines at end of input, but warn about them.
+ Succeed if a line was read; it is terminated by "\n\0" for convenience.
+ Return the number of characters read, including '\n' but not '\0'.
+ Return -1 if we ran out of memory. */
+
+static size_t
+pget_line (size_t indent, int rfc934_nesting, bool strip_trailing_cr,
+ bool pass_comments_through)
+{
+ FILE *fp = pfp;
+ int c;
+ size_t i;
+ char *b;
+ size_t s;
+
+ do
+ {
+ i = 0;
+ for (;;)
+ {
+ c = getc (fp);
+ if (c == EOF)
+ {
+ if (ferror (fp))
+ read_fatal ();
+ return 0;
+ }
+ if (indent <= i)
+ break;
+ if (c == ' ' || c == 'X')
+ i++;
+ else if (c == '\t')
+ i = (i + 8) & ~7;
+ else
+ break;
+ }
+
+ i = 0;
+ b = buf;
+
+ while (c == '-' && 0 <= --rfc934_nesting)
+ {
+ c = getc (fp);
+ if (c == EOF)
+ goto patch_ends_in_middle_of_line;
+ if (c != ' ')
+ {
+ i = 1;
+ b[0] = '-';
+ break;
+ }
+ c = getc (fp);
+ if (c == EOF)
+ goto patch_ends_in_middle_of_line;
+ }
+
+ s = bufsize;
+
+ for (;;)
+ {
+ if (i == s - 1)
+ {
+ s *= 2;
+ b = realloc (b, s);
+ if (!b)
+ {
+ if (!using_plan_a)
+ xalloc_die ();
+ return (size_t) -1;
+ }
+ buf = b;
+ bufsize = s;
+ }
+ b[i++] = c;
+ if (c == '\n')
+ break;
+ c = getc (fp);
+ if (c == EOF)
+ goto patch_ends_in_middle_of_line;
+ }
+
+ p_input_line++;
+ }
+ while (*b == '#' && !pass_comments_through);
+
+ if (strip_trailing_cr && 2 <= i && b[i - 2] == '\r')
+ b[i-- - 2] = '\n';
+ b[i] = '\0';
+ return i;
+
+ patch_ends_in_middle_of_line:
+ if (ferror (fp))
+ read_fatal ();
+ say ("patch unexpectedly ends in middle of line\n");
+ return 0;
+}
+
+static bool
+incomplete_line (void)
+{
+ FILE *fp = pfp;
+ int c;
+ file_offset line_beginning = file_tell (fp);
+
+ if (getc (fp) == '\\')
+ {
+ while ((c = getc (fp)) != '\n' && c != EOF)
+ /* do nothing */ ;
+ return true;
+ }
+ else
+ {
+ /* We don't trust ungetc. */
+ Fseek (pfp, line_beginning, SEEK_SET);
+ return false;
+ }
+}
+
+/* Reverse the old and new portions of the current hunk. */
+
+bool
+pch_swap (void)
+{
+ char **tp_line; /* the text of the hunk */
+ size_t *tp_len; /* length of each line */
+ char *tp_char; /* +, -, and ! */
+ lin i;
+ lin n;
+ bool blankline = false;
+ char *s;
+
+ i = p_first;
+ p_first = p_newfirst;
+ p_newfirst = i;
+
+ /* make a scratch copy */
+
+ tp_line = p_line;
+ tp_len = p_len;
+ tp_char = p_Char;
+ p_line = 0; /* force set_hunkmax to allocate again */
+ p_len = 0;
+ p_Char = 0;
+ set_hunkmax();
+ if (!p_line || !p_len || !p_Char) {
+ free (p_line);
+ p_line = tp_line;
+ free (p_len);
+ p_len = tp_len;
+ free (p_Char);
+ p_Char = tp_char;
+ return false; /* not enough memory to swap hunk! */
+ }
+
+ /* now turn the new into the old */
+
+ i = p_ptrn_lines + 1;
+ if (tp_char[i] == '\n') { /* account for possible blank line */
+ blankline = true;
+ i++;
+ }
+ if (p_efake >= 0) { /* fix non-freeable ptr range */
+ if (p_efake <= i)
+ n = p_end - i + 1;
+ else
+ n = -i;
+ p_efake += n;
+ p_bfake += n;
+ }
+ for (n=0; i <= p_end; i++,n++) {
+ p_line[n] = tp_line[i];
+ p_Char[n] = tp_char[i];
+ if (p_Char[n] == '+')
+ p_Char[n] = '-';
+ p_len[n] = tp_len[i];
+ }
+ if (blankline) {
+ i = p_ptrn_lines + 1;
+ p_line[n] = tp_line[i];
+ p_Char[n] = tp_char[i];
+ p_len[n] = tp_len[i];
+ n++;
+ }
+ assert(p_Char[0] == '=');
+ p_Char[0] = '*';
+ for (s=p_line[0]; *s; s++)
+ if (*s == '-')
+ *s = '*';
+
+ /* now turn the old into the new */
+
+ assert(tp_char[0] == '*');
+ tp_char[0] = '=';
+ for (s=tp_line[0]; *s; s++)
+ if (*s == '*')
+ *s = '-';
+ for (i=0; n <= p_end; i++,n++) {
+ p_line[n] = tp_line[i];
+ p_Char[n] = tp_char[i];
+ if (p_Char[n] == '-')
+ p_Char[n] = '+';
+ p_len[n] = tp_len[i];
+ }
+ assert(i == p_ptrn_lines + 1);
+ i = p_ptrn_lines;
+ p_ptrn_lines = p_repl_lines;
+ p_repl_lines = i;
+ p_Char[p_end + 1] = '^';
+ free (tp_line);
+ free (tp_len);
+ free (tp_char);
+ return true;
+}
+
+/* Return whether file WHICH (false = old, true = new) appears to nonexistent.
+ Return 1 for empty, 2 for nonexistent. */
+
+int
+pch_says_nonexistent (bool which)
+{
+ return p_says_nonexistent[which];
+}
+
+const char *
+pch_name (enum nametype type)
+{
+ return type == NONE ? NULL : p_name[type];
+}
+
+bool pch_copy (void)
+{
+ return p_copy[OLD] && p_copy[NEW];
+}
+
+bool pch_rename (void)
+{
+ return p_rename[OLD] && p_rename[NEW];
+}
+
+/* Return the specified line position in the old file of the old context. */
+
+lin
+pch_first (void)
+{
+ return p_first;
+}
+
+/* Return the number of lines of old context. */
+
+lin
+pch_ptrn_lines (void)
+{
+ return p_ptrn_lines;
+}
+
+/* Return the probable line position in the new file of the first line. */
+
+lin
+pch_newfirst (void)
+{
+ return p_newfirst;
+}
+
+/* Return the number of lines in the replacement text including context. */
+
+lin
+pch_repl_lines (void)
+{
+ return p_repl_lines;
+}
+
+/* Return the number of lines in the whole hunk. */
+
+lin
+pch_end (void)
+{
+ return p_end;
+}
+
+/* Return the number of context lines before the first changed line. */
+
+lin
+pch_prefix_context (void)
+{
+ return p_prefix_context;
+}
+
+/* Return the number of context lines after the last changed line. */
+
+lin
+pch_suffix_context (void)
+{
+ return p_suffix_context;
+}
+
+/* Return the length of a particular patch line. */
+
+size_t
+pch_line_len (lin line)
+{
+ return p_len[line];
+}
+
+/* Return the control character (+, -, *, !, etc) for a patch line. A '\n'
+ indicates an empty line in a hunk. (The empty line is not part of the
+ old or new context. For some reson, the context format allows that.) */
+
+char
+pch_char (lin line)
+{
+ return p_Char[line];
+}
+
+/* Return a pointer to a particular patch line. */
+
+char *
+pfetch (lin line)
+{
+ return p_line[line];
+}
+
+/* Output a patch line. */
+
+bool
+pch_write_line (lin line, FILE *file)
+{
+ bool after_newline = (p_len[line] > 0) && (p_line[line][p_len[line] - 1] == '\n');
+ if (! fwrite (p_line[line], sizeof (*p_line[line]), p_len[line], file))
+ write_fatal ();
+ return after_newline;
+}
+
+/* Return where in the patch file this hunk began, for error messages. */
+
+lin
+pch_hunk_beg (void)
+{
+ return p_hunk_beg;
+}
+
+char const *
+pch_c_function (void)
+{
+ return p_c_function;
+}
+
+/* Return true if in a git-style patch. */
+
+bool
+pch_git_diff (void)
+{
+ return p_git_diff;
+}
+
+char const *
+pch_timestr (bool which)
+{
+ return p_timestr[which];
+}
+
+char const *
+pch_sha1 (bool which)
+{
+ return p_sha1[which];
+}
+
+mode_t
+pch_mode (bool which)
+{
+ return p_mode[which];
+}
+
+/* Is the newline-terminated line a valid 'ed' command for patch
+ input? If so, return the command character; if not, return 0.
+ This accepts just a subset of the valid commands, but it's
+ good enough in practice. */
+
+static char _GL_ATTRIBUTE_PURE
+get_ed_command_letter (char const *line)
+{
+ char const *p = line;
+ char letter;
+ bool pair = false;
+
+ if (ISDIGIT (*p))
+ {
+ while (ISDIGIT (*++p))
+ /* do nothing */ ;
+ if (*p == ',')
+ {
+ if (! ISDIGIT (*++p))
+ return 0;
+ while (ISDIGIT (*++p))
+ /* do nothing */ ;
+ pair = true;
+ }
+ }
+
+ letter = *p++;
+
+ switch (letter)
+ {
+ case 'a':
+ case 'i':
+ if (pair)
+ return 0;
+ break;
+
+ case 'c':
+ case 'd':
+ break;
+
+ case 's':
+ if (strncmp (p, "/.//", 4) != 0)
+ return 0;
+ p += 4;
+ break;
+
+ default:
+ return 0;
+ }
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+ if (*p == '\n')
+ return letter;
+ return 0;
+}
+
+/* Apply an ed script by feeding ed itself. */
+
+void
+do_ed_script (char const *inname, char const *outname,
+ bool *outname_needs_removal, FILE *ofp)
+{
+ static char const editor_program[] = EDITOR_PROGRAM;
+
+ file_offset beginning_of_this_line;
+ FILE *pipefp = 0;
+ size_t chars_read;
+
+ if (! dry_run && ! skip_rest_of_patch) {
+ int exclusive = *outname_needs_removal ? 0 : O_EXCL;
+ assert (! inerrno);
+ *outname_needs_removal = true;
+ copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
+ sprintf (buf, "%s %s%s", editor_program,
+ verbosity == VERBOSE ? "" : "- ",
+ outname);
+ fflush (stdout);
+ pipefp = popen(buf, binary_transput ? "wb" : "w");
+ if (!pipefp)
+ pfatal ("Can't open pipe to %s", quotearg (buf));
+ }
+ for (;;) {
+ char ed_command_letter;
+ beginning_of_this_line = file_tell (pfp);
+ chars_read = get_line ();
+ if (! chars_read) {
+ next_intuit_at(beginning_of_this_line,p_input_line);
+ break;
+ }
+ ed_command_letter = get_ed_command_letter (buf);
+ if (ed_command_letter) {
+ if (pipefp)
+ if (! fwrite (buf, sizeof *buf, chars_read, pipefp))
+ write_fatal ();
+ if (ed_command_letter != 'd' && ed_command_letter != 's') {
+ p_pass_comments_through = true;
+ while ((chars_read = get_line ()) != 0) {
+ if (pipefp)
+ if (! fwrite (buf, sizeof *buf, chars_read, pipefp))
+ write_fatal ();
+ if (chars_read == 2 && strEQ (buf, ".\n"))
+ break;
+ }
+ p_pass_comments_through = false;
+ }
+ }
+ else {
+ next_intuit_at(beginning_of_this_line,p_input_line);
+ break;
+ }
+ }
+ if (!pipefp)
+ return;
+ if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0
+ || fflush (pipefp) != 0)
+ write_fatal ();
+ if (pclose (pipefp) != 0)
+ fatal ("%s FAILED", editor_program);
+
+ if (ofp)
+ {
+ FILE *ifp = fopen (outname, binary_transput ? "rb" : "r");
+ int c;
+ if (!ifp)
+ pfatal ("can't open '%s'", outname);
+ while ((c = getc (ifp)) != EOF)
+ if (putc (c, ofp) == EOF)
+ write_fatal ();
+ if (ferror (ifp) || fclose (ifp) != 0)
+ read_fatal ();
+ }
+}
+
+void
+pch_normalize (enum diff format)
+{
+ lin old = 1;
+ lin new = p_ptrn_lines + 1;
+
+ while (p_Char[new] == '=' || p_Char[new] == '\n')
+ new++;
+
+ if (format == UNI_DIFF)
+ {
+ /* Convert '!' markers into '-' and '+' as defined by the Unified
+ Format. */
+
+ for (; old <= p_ptrn_lines; old++)
+ if (p_Char[old] == '!')
+ p_Char[old] = '-';
+ for (; new <= p_end; new++)
+ if (p_Char[new] == '!')
+ p_Char[new] = '+';
+ }
+ else
+ {
+ /* Convert '-' and '+' markers which are part of a group into '!' as
+ defined by the Context Format. */
+
+ while (old <= p_ptrn_lines)
+ {
+ if (p_Char[old] == '-')
+ {
+ if (new <= p_end && p_Char[new] == '+')
+ {
+ do
+ {
+ p_Char[old] = '!';
+ old++;
+ }
+ while (old <= p_ptrn_lines && p_Char[old] == '-');
+ do
+ {
+ p_Char[new] = '!';
+ new++;
+ }
+ while (new <= p_end && p_Char[new] == '+');
+ }
+ else
+ {
+ do
+ old++;
+ while (old <= p_ptrn_lines && p_Char[old] == '-');
+ }
+ }
+ else if (new <= p_end && p_Char[new] == '+')
+ {
+ do
+ new++;
+ while (new <= p_end && p_Char[new] == '+');
+ }
+ else
+ {
+ old++;
+ new++;
+ }
+ }
+ }
+}
Index: src
===================================================================
--- src (nonexistent)
+++ src (revision 5)
Property changes on: src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am (nonexistent)
+++ tests/Makefile.am (revision 5)
@@ -0,0 +1,79 @@
+# Copyright (C) 1989-1993, 1997-1999, 2002-2003, 2006, 2009-2012 Free Software
+# Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+## Process this file with automake to produce Makefile.in.
+
+TESTS = \
+ asymmetric-hunks \
+ backup-prefix-suffix \
+ bad-filenames \
+ bad-usage \
+ concat-git-diff \
+ context-format \
+ copy-rename \
+ corrupt-patch \
+ corrupt-reject-files \
+ create-delete \
+ create-directory \
+ criss-cross \
+ crlf-handling \
+ dangerous-ed-scripts \
+ dash-o-append \
+ deep-directories \
+ empty-files \
+ false-match \
+ fifo \
+ file-create-modes \
+ file-modes \
+ filename-choice \
+ git-binary-diff \
+ git-cleanup \
+ garbage \
+ global-reject-files \
+ inname \
+ line-numbers \
+ merge \
+ mangled-numbers-abort \
+ mixed-patch-types \
+ munged-context-format \
+ need-filename \
+ no-mode-change-git-diff \
+ no-newline-triggers-assert \
+ preserve-c-function-names \
+ preserve-mode-and-timestamp \
+ quoted-filenames \
+ read-only-files \
+ reject-format \
+ remember-backup-files \
+ remember-reject-files \
+ remove-directories \
+ symlinks \
+ unmodified-files
+
+XFAIL_TESTS = \
+ dash-o-append \
+ context-format
+
+EXTRA_DIST = \
+ $(TESTS) \
+ test-lib.sh
+
+TESTS_ENVIRONMENT = \
+ abs_top_builddir=$(abs_top_builddir); \
+ export abs_top_builddir;
+
+LOG_COMPILER = \
+ $(SHELL)
Index: tests/Makefile.in
===================================================================
--- tests/Makefile.in (nonexistent)
+++ tests/Makefile.in (revision 5)
@@ -0,0 +1,2013 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Copyright (C) 1989-1993, 1997-1999, 2002-2003, 2006, 2009-2012 Free Software
+# Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = tests
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
+ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \
+ $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/bison.m4 \
+ $(top_srcdir)/m4/canonicalize.m4 \
+ $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \
+ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \
+ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \
+ $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/d-ino.m4 \
+ $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \
+ $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \
+ $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
+ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \
+ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \
+ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exponentd.m4 \
+ $(top_srcdir)/m4/extensions.m4 \
+ $(top_srcdir)/m4/extern-inline.m4 \
+ $(top_srcdir)/m4/faccessat.m4 $(top_srcdir)/m4/fchdir.m4 \
+ $(top_srcdir)/m4/fchmodat.m4 $(top_srcdir)/m4/fchownat.m4 \
+ $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \
+ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \
+ $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \
+ $(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/fstatat.m4 \
+ $(top_srcdir)/m4/getcwd.m4 $(top_srcdir)/m4/getdtablesize.m4 \
+ $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/getopt.m4 \
+ $(top_srcdir)/m4/getprogname.m4 $(top_srcdir)/m4/gettime.m4 \
+ $(top_srcdir)/m4/gettimeofday.m4 $(top_srcdir)/m4/glibc21.m4 \
+ $(top_srcdir)/m4/gnulib-common.m4 \
+ $(top_srcdir)/m4/gnulib-comp.m4 \
+ $(top_srcdir)/m4/group-member.m4 \
+ $(top_srcdir)/m4/hard-locale.m4 \
+ $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/intmax_t.m4 \
+ $(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
+ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/largefile.m4 \
+ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/limits-h.m4 \
+ $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \
+ $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \
+ $(top_srcdir)/m4/localtime-buffer.m4 \
+ $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lstat.m4 \
+ $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \
+ $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/mbrtowc.m4 \
+ $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbstate_t.m4 \
+ $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mempcpy.m4 \
+ $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/minmax.m4 \
+ $(top_srcdir)/m4/mkdir.m4 $(top_srcdir)/m4/mkdirat.m4 \
+ $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \
+ $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/msvc-inval.m4 \
+ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \
+ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/nstrftime.m4 \
+ $(top_srcdir)/m4/off_t.m4 $(top_srcdir)/m4/open-cloexec.m4 \
+ $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \
+ $(top_srcdir)/m4/opendir.m4 $(top_srcdir)/m4/parse-datetime.m4 \
+ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/printf.m4 \
+ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \
+ $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/readdir.m4 \
+ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \
+ $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rename.m4 \
+ $(top_srcdir)/m4/renameat.m4 $(top_srcdir)/m4/rmdir.m4 \
+ $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \
+ $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/setenv.m4 \
+ $(top_srcdir)/m4/setmode.m4 $(top_srcdir)/m4/signal_h.m4 \
+ $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/ssize_t.m4 \
+ $(top_srcdir)/m4/stat-time.m4 $(top_srcdir)/m4/stat.m4 \
+ $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \
+ $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \
+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \
+ $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strdup.m4 \
+ $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/string_h.m4 \
+ $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+ $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/symlinkat.m4 \
+ $(top_srcdir)/m4/sys_socket_h.m4 \
+ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \
+ $(top_srcdir)/m4/sys_types_h.m4 $(top_srcdir)/m4/tempname.m4 \
+ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \
+ $(top_srcdir)/m4/time_rz.m4 $(top_srcdir)/m4/timegm.m4 \
+ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
+ $(top_srcdir)/m4/tzset.m4 $(top_srcdir)/m4/unistd-safer.m4 \
+ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink.m4 \
+ $(top_srcdir)/m4/unlinkat.m4 $(top_srcdir)/m4/utime.m4 \
+ $(top_srcdir)/m4/utime_h.m4 $(top_srcdir)/m4/utimens.m4 \
+ $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \
+ $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \
+ $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \
+ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
+ $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wint_t.m4 \
+ $(top_srcdir)/m4/write.m4 $(top_srcdir)/m4/xalloc.m4 \
+ $(top_srcdir)/m4/xattr.m4 $(top_srcdir)/m4/xsize.m4 \
+ $(top_srcdir)/m4/xstrndup.m4 $(top_srcdir)/m4/xvasprintf.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red='[0;31m'; \
+ grn='[0;32m'; \
+ lgn='[1;32m'; \
+ blu='[1;34m'; \
+ mgn='[0;35m'; \
+ brg='[1m'; \
+ std='[m'; \
+ fi; \
+}
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+RECHECK_LOGS = $(TEST_LOGS)
+AM_RECURSIVE_TARGETS = check recheck
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+ $(top_srcdir)/build-aux/test-driver
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CONFIG_INCLUDE = @CONFIG_INCLUDE@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ED = @ED@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FLOAT_H = @FLOAT_H@
+GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHDIR = @GNULIB_CHDIR@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@
+GNULIB_CTIME = @GNULIB_CTIME@
+GNULIB_DIRFD = @GNULIB_DIRFD@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP = @GNULIB_DUP@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_EXPLICIT_BZERO = @GNULIB_EXPLICIT_BZERO@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FDATASYNC = @GNULIB_FDATASYNC@
+GNULIB_FDOPEN = @GNULIB_FDOPEN@
+GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FFSL = @GNULIB_FFSL@
+GNULIB_FFSLL = @GNULIB_FFSLL@
+GNULIB_FGETC = @GNULIB_FGETC@
+GNULIB_FGETS = @GNULIB_FGETS@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREAD = @GNULIB_FREAD@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSCANF = @GNULIB_FSCANF@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTAT = @GNULIB_FSTAT@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETC = @GNULIB_GETC@
+GNULIB_GETCHAR = @GNULIB_GETCHAR@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@
+GNULIB_IMAXABS = @GNULIB_IMAXABS@
+GNULIB_IMAXDIV = @GNULIB_IMAXDIV@
+GNULIB_ISATTY = @GNULIB_ISATTY@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LOCALTIME = @GNULIB_LOCALTIME@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_OPENDIR = @GNULIB_OPENDIR@
+GNULIB_OVERRIDES_STRUCT_STAT = @GNULIB_OVERRIDES_STRUCT_STAT@
+GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@
+GNULIB_PCLOSE = @GNULIB_PCLOSE@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTHREAD_SIGMASK = @GNULIB_PTHREAD_SIGMASK@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_QSORT_R = @GNULIB_QSORT_R@
+GNULIB_RAISE = @GNULIB_RAISE@
+GNULIB_RANDOM = @GNULIB_RANDOM@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READ = @GNULIB_READ@
+GNULIB_READDIR = @GNULIB_READDIR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOCARRAY = @GNULIB_REALLOCARRAY@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_REWINDDIR = @GNULIB_REWINDDIR@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SCANDIR = @GNULIB_SCANDIR@
+GNULIB_SCANF = @GNULIB_SCANF@
+GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@
+GNULIB_SIGACTION = @GNULIB_SIGACTION@
+GNULIB_SIGNAL_H_SIGPIPE = @GNULIB_SIGNAL_H_SIGPIPE@
+GNULIB_SIGPROCMASK = @GNULIB_SIGPROCMASK@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRFTIME = @GNULIB_STRFTIME@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TEST_WARN_CFLAGS = @GNULIB_TEST_WARN_CFLAGS@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TIME_RZ = @GNULIB_TIME_RZ@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TRUNCATE = @GNULIB_TRUNCATE@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_TZSET = @GNULIB_TZSET@
+GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIME = @GNULIB_UTIME@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VFSCANF = @GNULIB_VFSCANF@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSCANF = @GNULIB_VSCANF@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSFTIME = @GNULIB_WCSFTIME@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ALPHASORT = @HAVE_ALPHASORT@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_CLOSEDIR = @HAVE_CLOSEDIR@
+HAVE_CRTDEFS_H = @HAVE_CRTDEFS_H@
+HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@
+HAVE_DECL_FDOPENDIR = @HAVE_DECL_FDOPENDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN = @HAVE_DECL_GETLOGIN@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@
+HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@
+HAVE_DECL_INITSTATE = @HAVE_DECL_INITSTATE@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@
+HAVE_DECL_SETSTATE = @HAVE_DECL_SETSTATE@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DIRENT_H = @HAVE_DIRENT_H@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_EXPLICIT_BZERO = @HAVE_EXPLICIT_BZERO@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FDATASYNC = @HAVE_FDATASYNC@
+HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FFSL = @HAVE_FFSL@
+HAVE_FFSLL = @HAVE_FFSLL@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OPENDIR = @HAVE_OPENDIR@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PCLOSE = @HAVE_PCLOSE@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_POPEN = @HAVE_POPEN@
+HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@
+HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PTSNAME_R = @HAVE_PTSNAME_R@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_QSORT_R = @HAVE_QSORT_R@
+HAVE_RAISE = @HAVE_RAISE@
+HAVE_RANDOM = @HAVE_RANDOM@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READDIR = @HAVE_READDIR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALLOCARRAY = @HAVE_REALLOCARRAY@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_REWINDDIR = @HAVE_REWINDDIR@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SCANDIR = @HAVE_SCANDIR@
+HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@
+HAVE_SIGACTION = @HAVE_SIGACTION@
+HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@
+HAVE_SIGINFO_T = @HAVE_SIGINFO_T@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SIGSET_T = @HAVE_SIGSET_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@
+HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
+HAVE_TRUNCATE = @HAVE_TRUNCATE@
+HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
+HAVE_TZSET = @HAVE_TZSET@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIME = @HAVE_UTIME@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_UTIME_H = @HAVE_UTIME_H@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSFTIME = @HAVE_WCSFTIME@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@
+INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@
+LDFLAGS = @LDFLAGS@
+LIBINTL = @LIBINTL@
+LIBOBJS = @LIBOBJS@
+LIBPATCH_LIBDEPS = @LIBPATCH_LIBDEPS@
+LIBPATCH_LTLIBDEPS = @LIBPATCH_LTLIBDEPS@
+LIBS = @LIBS@
+LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
+LIB_EACCESS = @LIB_EACCESS@
+LIB_XATTR = @LIB_XATTR@
+LIMITS_H = @LIMITS_H@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@
+NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@
+NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@
+NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_UTIME_H = @NEXT_AS_FIRST_DIRECTIVE_UTIME_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_DIRENT_H = @NEXT_DIRENT_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_INTTYPES_H = @NEXT_INTTYPES_H@
+NEXT_LIMITS_H = @NEXT_LIMITS_H@
+NEXT_SIGNAL_H = @NEXT_SIGNAL_H@
+NEXT_STDARG_H = @NEXT_STDARG_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@
+NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_UTIME_H = @NEXT_UTIME_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PRIPTR_PREFIX = @PRIPTR_PREFIX@
+PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
+REPLACE_CTIME = @REPLACE_CTIME@
+REPLACE_DIRFD = @REPLACE_DIRFD@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_FACCESSAT = @REPLACE_FACCESSAT@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FDOPEN = @REPLACE_FDOPEN@
+REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETDTABLESIZE = @REPLACE_GETDTABLESIZE@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_GMTIME = @REPLACE_GMTIME@
+REPLACE_ISATTY = @REPLACE_ISATTY@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_ITOLD = @REPLACE_ITOLD@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME = @REPLACE_LOCALTIME@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_OPENDIR = @REPLACE_OPENDIR@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PTHREAD_SIGMASK = @REPLACE_PTHREAD_SIGMASK@
+REPLACE_PTSNAME = @REPLACE_PTSNAME@
+REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_QSORT_R = @REPLACE_QSORT_R@
+REPLACE_RAISE = @REPLACE_RAISE@
+REPLACE_RANDOM_R = @REPLACE_RANDOM_R@
+REPLACE_READ = @REPLACE_READ@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_READLINKAT = @REPLACE_READLINKAT@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRFTIME = @REPLACE_STRFTIME@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@
+REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TOWLOWER = @REPLACE_TOWLOWER@
+REPLACE_TRUNCATE = @REPLACE_TRUNCATE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_TZSET = @REPLACE_TZSET@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIME = @REPLACE_UTIME@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSFTIME = @REPLACE_WCSFTIME@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDARG_H = @STDARG_H@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@
+UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+UTIME_H = @UTIME_H@
+VERSION = @VERSION@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WERROR_CFLAGS = @WERROR_CFLAGS@
+WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
+WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@
+WINDOWS_STAT_INODES = @WINDOWS_STAT_INODES@
+WINDOWS_STAT_TIMESPEC = @WINDOWS_STAT_TIMESPEC@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+TESTS = \
+ asymmetric-hunks \
+ backup-prefix-suffix \
+ bad-filenames \
+ bad-usage \
+ concat-git-diff \
+ context-format \
+ copy-rename \
+ corrupt-patch \
+ corrupt-reject-files \
+ create-delete \
+ create-directory \
+ criss-cross \
+ crlf-handling \
+ dangerous-ed-scripts \
+ dash-o-append \
+ deep-directories \
+ empty-files \
+ false-match \
+ fifo \
+ file-create-modes \
+ file-modes \
+ filename-choice \
+ git-binary-diff \
+ git-cleanup \
+ garbage \
+ global-reject-files \
+ inname \
+ line-numbers \
+ merge \
+ mangled-numbers-abort \
+ mixed-patch-types \
+ munged-context-format \
+ need-filename \
+ no-mode-change-git-diff \
+ no-newline-triggers-assert \
+ preserve-c-function-names \
+ preserve-mode-and-timestamp \
+ quoted-filenames \
+ read-only-files \
+ reject-format \
+ remember-backup-files \
+ remember-reject-files \
+ remove-directories \
+ symlinks \
+ unmodified-files
+
+XFAIL_TESTS = \
+ dash-o-append \
+ context-format
+
+EXTRA_DIST = \
+ $(TESTS) \
+ test-lib.sh
+
+TESTS_ENVIRONMENT = \
+ abs_top_builddir=$(abs_top_builddir); \
+ export abs_top_builddir;
+
+LOG_COMPILER = \
+ $(SHELL)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .log .test .test$(EXEEXT) .trs
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ elif test -n "$$redo_logs"; then \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS:
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+asymmetric-hunks.log: asymmetric-hunks
+ @p='asymmetric-hunks'; \
+ b='asymmetric-hunks'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+backup-prefix-suffix.log: backup-prefix-suffix
+ @p='backup-prefix-suffix'; \
+ b='backup-prefix-suffix'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+bad-filenames.log: bad-filenames
+ @p='bad-filenames'; \
+ b='bad-filenames'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+bad-usage.log: bad-usage
+ @p='bad-usage'; \
+ b='bad-usage'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+concat-git-diff.log: concat-git-diff
+ @p='concat-git-diff'; \
+ b='concat-git-diff'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+context-format.log: context-format
+ @p='context-format'; \
+ b='context-format'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+copy-rename.log: copy-rename
+ @p='copy-rename'; \
+ b='copy-rename'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+corrupt-patch.log: corrupt-patch
+ @p='corrupt-patch'; \
+ b='corrupt-patch'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+corrupt-reject-files.log: corrupt-reject-files
+ @p='corrupt-reject-files'; \
+ b='corrupt-reject-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+create-delete.log: create-delete
+ @p='create-delete'; \
+ b='create-delete'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+create-directory.log: create-directory
+ @p='create-directory'; \
+ b='create-directory'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+criss-cross.log: criss-cross
+ @p='criss-cross'; \
+ b='criss-cross'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+crlf-handling.log: crlf-handling
+ @p='crlf-handling'; \
+ b='crlf-handling'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+dash-o-append.log: dash-o-append
+ @p='dash-o-append'; \
+ b='dash-o-append'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+deep-directories.log: deep-directories
+ @p='deep-directories'; \
+ b='deep-directories'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+empty-files.log: empty-files
+ @p='empty-files'; \
+ b='empty-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+false-match.log: false-match
+ @p='false-match'; \
+ b='false-match'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+fifo.log: fifo
+ @p='fifo'; \
+ b='fifo'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+file-create-modes.log: file-create-modes
+ @p='file-create-modes'; \
+ b='file-create-modes'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+file-modes.log: file-modes
+ @p='file-modes'; \
+ b='file-modes'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+filename-choice.log: filename-choice
+ @p='filename-choice'; \
+ b='filename-choice'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+git-binary-diff.log: git-binary-diff
+ @p='git-binary-diff'; \
+ b='git-binary-diff'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+git-cleanup.log: git-cleanup
+ @p='git-cleanup'; \
+ b='git-cleanup'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+garbage.log: garbage
+ @p='garbage'; \
+ b='garbage'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+global-reject-files.log: global-reject-files
+ @p='global-reject-files'; \
+ b='global-reject-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+inname.log: inname
+ @p='inname'; \
+ b='inname'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+line-numbers.log: line-numbers
+ @p='line-numbers'; \
+ b='line-numbers'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+merge.log: merge
+ @p='merge'; \
+ b='merge'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+mangled-numbers-abort.log: mangled-numbers-abort
+ @p='mangled-numbers-abort'; \
+ b='mangled-numbers-abort'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+mixed-patch-types.log: mixed-patch-types
+ @p='mixed-patch-types'; \
+ b='mixed-patch-types'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+munged-context-format.log: munged-context-format
+ @p='munged-context-format'; \
+ b='munged-context-format'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+need-filename.log: need-filename
+ @p='need-filename'; \
+ b='need-filename'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+no-mode-change-git-diff.log: no-mode-change-git-diff
+ @p='no-mode-change-git-diff'; \
+ b='no-mode-change-git-diff'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+no-newline-triggers-assert.log: no-newline-triggers-assert
+ @p='no-newline-triggers-assert'; \
+ b='no-newline-triggers-assert'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+preserve-c-function-names.log: preserve-c-function-names
+ @p='preserve-c-function-names'; \
+ b='preserve-c-function-names'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+preserve-mode-and-timestamp.log: preserve-mode-and-timestamp
+ @p='preserve-mode-and-timestamp'; \
+ b='preserve-mode-and-timestamp'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+quoted-filenames.log: quoted-filenames
+ @p='quoted-filenames'; \
+ b='quoted-filenames'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+read-only-files.log: read-only-files
+ @p='read-only-files'; \
+ b='read-only-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+reject-format.log: reject-format
+ @p='reject-format'; \
+ b='reject-format'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+remember-backup-files.log: remember-backup-files
+ @p='remember-backup-files'; \
+ b='remember-backup-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+remember-reject-files.log: remember-reject-files
+ @p='remember-reject-files'; \
+ b='remember-reject-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+remove-directories.log: remove-directories
+ @p='remove-directories'; \
+ b='remove-directories'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+symlinks.log: symlinks
+ @p='symlinks'; \
+ b='symlinks'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+unmodified-files.log: unmodified-files
+ @p='unmodified-files'; \
+ b='unmodified-files'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-TESTS check-am clean clean-generic \
+ cscopelist-am ctags-am distclean distclean-generic distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+ pdf-am ps ps-am recheck tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: tests/crlf-handling
===================================================================
--- tests/crlf-handling (nonexistent)
+++ tests/crlf-handling (revision 5)
@@ -0,0 +1,205 @@
+# Copyright (C) 2009, 2011-2012 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# LF vs. CRLF line endings
+
+. $srcdir/test-lib.sh
+
+require gnu_diff
+require sed
+use_local_patch
+use_tmpdir
+
+lf2crlf() {
+ while read l; do echo -e "$l\r"; done
+}
+
+echo 1 > a
+echo 1b > b
+
+diff a b | lf2crlf > ab.diff
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch; use --binary to disable.)
+patching file c
+EOF
+
+diff -c a b | lf2crlf > ab.diff
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch; use --binary to disable.)
+patching file c
+EOF
+
+diff -u a b | lf2crlf > ab.diff
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch; use --binary to disable.)
+patching file c
+EOF
+
+if ! have_ed ; then
+ echo "The ed utility is not available; skipping ed related tests"
+else
+ diff -e a b > ab.ed | lf2crlf > ab.ed
+ echo 1 > c
+ ncheck 'patch -f c < ab.ed'
+fi
+
+# ==============================================================
+
+echo 1 | lf2crlf > a
+echo 1b | lf2crlf > b
+
+diff a b > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# --------------------------------------------------------------
+
+diff -u a b > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# --------------------------------------------------------------
+
+diff -c a b > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# --------------------------------------------------------------
+
+if ! have_ed ; then
+ echo "The ed utility is not available; skipping ed related tests"
+else
+ diff -e a b > ab.diff
+ cp a c
+ ncheck 'patch -f c < ab.diff'
+fi
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# ==============================================================
+
+echo 1 > a
+echo 1b > b
+
+diff a b | lf2crlf > ab.diff
+cp a c
+
+check 'patch --binary c < ab.diff || echo status: $?' <<EOF
+patching file c
+Hunk #1 FAILED at 1 (different line endings).
+1 out of 1 hunk FAILED -- saving rejects to file c.rej
+status: 1
+EOF
+
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch; use --binary to disable.)
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b$
+EOF
+
+lf2crlf < a > c
+check 'patch --binary c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# --------------------------------------------------------------
+
+diff -u a b | lf2crlf > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch; use --binary to disable.)
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b$
+EOF
+
+lf2crlf < a > c
+check 'patch --binary c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# --------------------------------------------------------------
+
+diff -c a b | lf2crlf > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch; use --binary to disable.)
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b$
+EOF
+
+lf2crlf < a > c
+check 'patch --binary c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+1b^M$
+EOF
+
+# --------------------------------------------------------------
+
+# NOTE: ed does not fix up CRLF mangled input, so mangled ed-style
+# patches will break. (We could fix up things in patch and pipe
+# the result to ed, but this is not what we do so far.)
+
+# ==============================================================
+
+# Line endings of @@ lines are not used for guessing if a patch needs CR
+# stripping: if the -p / --show-c-function option of GNU diff is used, these
+# lines can have different line endings than the rest of the patch.
+
+echo 1 > a
+echo 2 > b
+diff -u a b | sed -e 's,@@$,@@ context\r,' > ab.diff
+
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -ve c' <<EOF
+2$
+EOF
Index: tests/dangerous-ed-scripts
===================================================================
--- tests/dangerous-ed-scripts (nonexistent)
+++ tests/dangerous-ed-scripts (revision 5)
@@ -0,0 +1,36 @@
+# Copyright (C) 2018 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+# Test for arbitrary command execution found in CVE-2018-0492 patch.
+# GNU patch bug report can be found at http://savannah.gnu.org/bugs/index.php?53566
+
+cat > beep.patch <<EOF
+--- /dev/null 2018-13-37 13:37:37.000000000 +0100
++++ b/beep.c 2018-13-37 13:38:38.000000000 +0100
+1337a
+1,112d
+!id>~/pwn.lol;beep # 13-21 12:53:21.000000000 +0100
+.
+EOF
+
+check 'patch < beep.patch; echo "Status: $?"' <<EOF
+Apply potentially dangerous ed script? This could allow arbitrary command execution! [n]
+Skipping potentially dangerous ed script.
+Status: 1
+EOF
+
+check 'patch -e; echo "Status: $?"' <<EOF
+Apply potentially dangerous ed script? This could allow arbitrary command execution! [n] $PATCH: **** Refusing to apply potentially dangerous ed script.
+
+Status: 2
+EOF
Index: tests/need-filename
===================================================================
--- tests/need-filename (nonexistent)
+++ tests/need-filename (revision 5)
@@ -0,0 +1,139 @@
+# Copyright (C) 2009, 2011-2012 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Don't recognize hunks before a filename has been specified/seen
+
+. $srcdir/test-lib.sh
+
+require cat
+require sed
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > n.diff <<EOF
+0a1
+> one
+EOF
+
+check 'patch < n.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+check 'patch -f -n < n.diff || echo "Status: $?"' <<EOF
+can't find file to patch at input line 1
+No file to patch. Skipping patch.
+1 out of 1 hunk ignored
+Status: 1
+EOF
+
+touch f
+check 'patch f < n.diff' <<EOF
+patching file f
+EOF
+
+# ==============================================================
+
+if ! have_ed ; then
+ echo "The ed utility is not available; skipping ed related tests"
+else
+ cat > e.diff <<EOF
+0a
+one
+.
+EOF
+
+ check 'patch < e.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+ check 'patch -f -e < e.diff || echo "Status: $?"' <<EOF
+can't find file to patch at input line 1
+No file to patch. Skipping patch.
+Status: 1
+EOF
+
+ rm -f f
+ touch f
+ ncheck 'patch -f f < e.diff'
+
+ check 'cat f' <<EOF
+one
+EOF
+fi
+
+# ==============================================================
+
+cat > h+c.diff <<EOF
+*** /dev/null
+--- f
+***************
+*** 0 ****
+--- 1 ----
++ one
+EOF
+
+rm -f f
+check 'patch < h+c.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
+
+sed -e '1,2d' h+c.diff > c.diff
+
+check 'patch < c.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+rm -f f
+check 'patch f < c.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
+
+# ==============================================================
+
+cat > h+u.diff <<EOF
+--- /dev/null
++++ f
+@@ -0,0 +1 @@
++one
+EOF
+
+rm -f f
+check 'patch < h+u.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
+
+sed -e '1,2d' h+u.diff > u.diff
+
+check 'patch < u.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+rm -f f
+check 'patch f < u.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
Index: tests
===================================================================
--- tests (nonexistent)
+++ tests (revision 5)
Property changes on: tests
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~