From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16678 invoked by alias); 19 Jun 2008 13:48:15 -0000 Received: (qmail 16668 invoked by uid 22791); 19 Jun 2008 13:48:13 -0000 X-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from gv-out-0910.google.com (HELO gv-out-0910.google.com) (216.239.58.189) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 19 Jun 2008 13:47:46 +0000 Received: by gv-out-0910.google.com with SMTP id n8so98295gve.39 for ; Thu, 19 Jun 2008 06:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=Qf9+rhegcnEwIlnMsNRwDqGvxiezcADY1bokPwSBMoE=; b=dddksiBdkQ0uQ3UZKfqwRALm59zcZVT0aVy0IIKphQztCdMDjlmVvywatDG0Nxe6ve L/BdT3xl4Z7eI95js0N38CmsTxuoP8cnFXiOQAJDfbLyLyt/YNBm8SsnwzTXZsfwA7W6 wRs3aSHehKhK3Fi5jftVMgbMjjOwy8eNUQ/Jw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=dqsjDFfFjHpDBOMnxDitHaQ9yumMWu5RtroDsAtVF4ETh6u0ZL1YYTM6gPsy0kEkMk OW+N3Xdmst1APKF86QbM8QYlY0QKVb25XT8jw5yw6+3jB2KOvIw2JKxL8DWoHpnrqtZ0 7skCEvNyovHB5UHrWEAliFqfoYzEdVioISzgk= Received: by 10.78.182.9 with SMTP id e9mr1031087huf.91.1213883263447; Thu, 19 Jun 2008 06:47:43 -0700 (PDT) Received: from ?127.0.0.1? ( [194.186.53.122]) by mx.google.com with ESMTPS id o37sm465683hub.34.2008.06.19.06.47.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Jun 2008 06:47:41 -0700 (PDT) Message-ID: <485A6004.7070804@gmail.com> Date: Thu, 19 Jun 2008 13:48:00 -0000 From: Serj Kalichev User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: patchutils-list@sourceware.org Subject: Option --clean for filterdiff Content-Type: multipart/mixed; boundary="------------090708020307080405040004" X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact patchutils-list-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: patchutils-list-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00008.txt.bz2 This is a multi-part message in MIME format. --------------090708020307080405040004 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 147 Patch to implement --clean option. This option force removing of non-diff strings from the output. Even when -x -X (exclude mode) options in use. --------------090708020307080405040004 Content-Type: text/x-diff; name="patchutils-clean.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patchutils-clean.patch" Content-length: 4005 diff -uNr patchutils_git/doc/patchutils.xml patchutils_new/doc/patchutils.xml --- patchutils_git/doc/patchutils.xml 2008-06-18 12:56:53.000000000 +0400 +++ patchutils_new/doc/patchutils.xml 2008-06-19 15:29:00.000000000 +0400 @@ -549,6 +549,8 @@ -X FILE --verbose -v + --clean + -c -z -# RANGE @@ -761,6 +763,15 @@ + , + + Always remove all non-diff lines + from the output. Even when excluding + a filename pattern. + + + + Decompress files with extensions .gz and .bz2. diff -uNr patchutils_git/src/filterdiff.c patchutils_new/src/filterdiff.c --- patchutils_git/src/filterdiff.c 2008-06-18 12:56:53.000000000 +0400 +++ patchutils_new/src/filterdiff.c 2008-06-19 15:35:00.000000000 +0400 @@ -77,6 +77,7 @@ } mode; static regex_t *regex = NULL; static size_t num_regex = 0; +static int clean_comments = 0; static int numbering = 0; static int annotating = 0; static int ignore_components = 0; @@ -902,8 +903,9 @@ } /* Show non-diff lines if excluding, or if - * in verbose mode. */ - if (mode == mode_filter && (pat_exclude || verbose)) + * in verbose mode, and if --clean isn't specified. */ + if (mode == mode_filter && (pat_exclude || verbose) + && !clean_comments) fputs (line, stdout); if (getline (&line, &linelen, f) == -1) @@ -920,8 +922,9 @@ if (getline (&line, &linelen, f) == -1) { /* Show non-diff lines if excluding, or if - * in verbose mode. */ - if (mode == mode_filter && (pat_exclude || verbose)) + * in verbose mode, and if --clean isn't specified. */ + if (mode == mode_filter && (pat_exclude || verbose) + && !clean_comments) fputs (header[0], stdout); free (names[0]); goto eof; @@ -930,8 +933,9 @@ if (strncmp (line, is_context ? "--- " : "+++ ", 4)) { /* Show non-diff lines if excluding, or if - * in verbose mode. */ - if (mode == mode_filter && (pat_exclude || verbose)) + * in verbose mode, and if --clean isn't specified. */ + if (mode == mode_filter && (pat_exclude || verbose) + && !clean_comments) fputs (header[0], stdout); free (names[0]); free (header[0]); @@ -1030,6 +1034,8 @@ " show matching hunks or file-level diffs (grepdiff)\n" " --remove-timestamps (filterdiff, grepdiff)\n" " don't show timestamps from output (filterdiff, grepdiff)\n" +" -c, --clean (filterdiff)\n" +" remove all comments (non-diff lines) from output (filterdiff)\n" " -z decompress .gz and .bz2 files\n" " -n show line numbers (lsdiff, grepdiff)\n" " --number-files (lsdiff, grepdiff)\n" @@ -1256,10 +1262,11 @@ {"no-filename", 0, 0, 'h'}, {"empty-files-as-absent", 0, 0, 'E'}, {"number-files", 0, 0, 1000 + 'n'}, + {"clean", 0, 0, 'c'}, {0, 0, 0, 0} }; char *end; - int c = getopt_long (argc, argv, "vp:i:I:x:X:zns#:Ef:Hh", + int c = getopt_long (argc, argv, "vp:i:I:x:X:zns#:Ef:Hhc", long_options, NULL); if (c == -1) break; @@ -1390,6 +1397,9 @@ case 1000 + 'r': removing_timestamp = 1; break; + case 'c': + clean_comments = 1; + break; default: syntax(1); } @@ -1420,6 +1430,11 @@ error (EXIT_FAILURE, 0, "--as-numbered-lines is " "inappropriate in this context"); + if (mode == mode_filter && + verbose && clean_comments) + error (EXIT_FAILURE, 0, "can't use --verbose and " + "--clean options simultaneously"); + if (mode == mode_grep && !regex_file_specified) { int err; --------------090708020307080405040004--