Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2
wdiff
linenumber_ansi.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File linenumber_ansi.patch of Package wdiff
--- wdiff-0.5.93/doc/wdiff.texi.orig 2008-06-19 15:54:14.000000000 +0200 +++ wdiff-0.5.93/doc/wdiff.texi 2009-08-06 11:25:21.000000000 +0200 @@ -767,6 +767,45 @@ or underlining. Finally, if this option @samp{-1} and @samp{-2} are, then sections of common words between differences are segregated by lines of dashes. +@item --ansi-red-green +@itemx -A +Highlight deleted text in red, inserted text in green. This uses ansi terminal codes. +This highlighting is done in addition to the normal markers. + +@item --bold-inserted +@itemx -A +Highlight inserted text in bold face. This uses ansi terminal codes. +This highlighting is done in addition to the normal markers. + +@item --copyright +@itemx -C +Print copyright and exit. + +@item --no-init-term +@itemx -K +Like @samp{-t}, but no termcap init/term strings. + +@item --Label @var{argument} +@itemx -L @var{argument} +A dummy option for compatibility with GNU @code{diff}. + +@item --punctuation +@itemx -P +Treat punctuation (@code{ispunct()}) like whitespace (@code{isspace()}). + +@item --underline-deleted +@itemx -U +Underline deleted text. This uses ansi terminal codes. +This highlighting is done in addition to the normal markers. + +@item --context @var{N} +@itemx -c @var{N} +Like @samp{-3}, but only print @var{N} lines of context around each +difference. Context blocks are seperated by a horizontal line, and are +preceeded by a line of the format @code{=== @var{LLL},@var{RRR} ===}, where +@var{LLL} and @var{RRR} are current line numbers in the left and right file, +respectively. + @item --ignore-case @itemx -i Do not consider case difference while comparing words. Each lower case --- wdiff-0.5.93/man/wdiff.1.orig 2009-08-04 22:25:02.000000000 +0200 +++ wdiff-0.5.93/man/wdiff.1 2009-08-06 11:27:33.000000000 +0200 @@ -10,12 +10,27 @@ wdiff \- Compares words in two files and .PP Mandatory arguments to long options are mandatory for short options too. .TP +\fB\-A\fR, \fB\-\-ansi\-red\-green\fR +highlight deleted text in red, added text in green; using ansi terminal codes +.TP +\fB\-B\fR, \fB\-\-bold\-inserted\fR +mark inserted text in bold; using ansi terminal codes +.TP \fB\-C\fR, \fB\-\-copyright\fR print copyright then exit .TP \fB\-K\fR, \fB\-\-no\-init\-term\fR like \fB\-t\fR, but no termcap init/term strings .TP +\fB\-L\fR \fIdummy\fR, \fB\-\-label\fR=\fIdummy\fR +dummy option for \fBdiff\fR compatibility +.TP +\fB\-P\fR, \fB\-\-punctuation\fR +treat punctuation (ispunct()) like whitespace (isspace()) +.TP +\fB\-U\fR, \fB\-\-underline\-deleted\fR +underline deleted text; using ansi terminal codes +.TP \fB\-1\fR, \fB\-\-no\-deleted\fR inhibit output of deleted words .TP @@ -28,6 +43,13 @@ inhibit output of common words \fB\-a\fR, \fB\-\-auto\-pager\fR automatically calls a pager .TP +\fB\-c\fR\fIN\fR, \fB\-\-context\fR=\fIN\fR +like \fB-3\fR, but only print N lines of context around each difference. +Context blocks are seperated by a horizontal line, and +are preceeded by a line of the format '=== \fILLL\fR,\fIRRR\fR ===', where +\fILLL\fR and \fIRRR\fR are current line numbers in the left and right +file, respectively. +.TP \fB\-h\fR, \fB\-\-help\fR print this help .TP @@ -53,18 +75,19 @@ use termcap as for terminal displays print program version then exit .TP \fB\-w\fR, \fB\-\-start\-delete\fR=\fISTRING\fR -string to mark beginning of delete region +string to mark beginning of delete region; default '[-' .TP \fB\-x\fR, \fB\-\-end\-delete\fR=\fISTRING\fR -string to mark end of delete region +string to mark end of delete region; default '-]' .TP \fB\-y\fR, \fB\-\-start\-insert\fR=\fISTRING\fR -string to mark beginning of insert region +string to mark beginning of insert region; default '{+' .TP \fB\-z\fR, \fB\-\-end\-insert\fR=\fISTRING\fR -string to mark end of insert region +string to mark end of insert region; default '+}' .SH AUTHOR Written by Franc,ois Pinard <pinard@iro.umontreal.ca>. +Patches by Hans Lermen (1994), Juergen Weigert <jw@suse.de> .SH "REPORTING BUGS" Report bugs to <wdiff\-bugs@gnu.org>. .SH COPYRIGHT --- wdiff-0.5.93/src/wdiff.c.orig 2009-08-04 22:24:16.000000000 +0200 +++ wdiff-0.5.93/src/wdiff.c 2009-08-06 10:52:16.000000000 +0200 @@ -19,6 +19,11 @@ #ifdef LERMEN_STUFF #define LVERSION "L3" #endif +#define ANSI_BOLD "\033[1m" +#define ANSI_UNDERLINE "\033[4m" +#define ANSI_RED_BG "\033[41m" +#define ANSI_GREEN_BG "\033[42m" +#define ANSI_NORMAL "\033[0m" #include "system.h" @@ -107,6 +112,10 @@ struct option const longopts[] = { {"auto-pager" , 0, NULL, 'a'}, {"avoid-wraps" , 0, NULL, 'n'}, + {"ansi-red-green" , 0, NULL, 'A'}, + {"bold-inserted" , 0, NULL, 'B'}, + {"underline-deleted" , 0, NULL, 'U'}, + {"label" , 1, NULL, 'L'}, {"copyright" , 0, NULL, 'C'}, {"end-delete" , 1, NULL, 'x'}, {"end-insert" , 1, NULL, 'z'}, @@ -142,6 +151,9 @@ int no_wrapping; /* end/restart strings int autopager; /* if calling the pager automatically */ int overstrike; /* if using printer overstrikes */ int overstrike_for_less; /* if output aimed to the "less" program */ +int ansi_red_green; // highlight deleted text in red, added text in green +int bold_inserted; // mark inserted text in bold +int underline_deleted; // underline deleted text const char *user_delete_start; /* user specified string for start of delete */ const char *user_delete_end; /* user specified string for end of delete */ const char *user_insert_start; /* user specified string for start of insert */ @@ -245,6 +257,8 @@ setup_signals (void) #define BUFLINE_SIZE 1024 struct bufline { struct bufline *next; + int left_line_no; // current line number in left file + int right_line_no; // current line number in right file char line[BUFLINE_SIZE]; }; @@ -291,6 +305,8 @@ static void flush_buflines(void) while (headbufline != tailbufline) { if (bufline_overrun) { fprintf(output_file, "\n%s\n", SEPARATOR_LINE); + fprintf(output_file, "=== %d,%d ===\n", + tailbufline->left_line_no, tailbufline->right_line_no); bufline_overrun = 0; } fputs(tailbufline->line, output_file); @@ -298,12 +314,17 @@ static void flush_buflines(void) } } +static int left_line_number = 0; +static int right_line_number = 0; + static inline void save_char(int c) { headbufline->line[bufcols++] = c; if (c == '\n') { headbufline->line[bufcols] = 0; inc_headbuf(); + headbufline->left_line_no = left_line_number; + headbufline->right_line_no = right_line_number; bufcols = 0; } } @@ -311,6 +332,9 @@ static inline void save_char(int c) static inline int our_putc(int c, FILE *stream) { if (context_lines && stream == output_file) { + if ((c == '\n') && (in_emphasize < 2)) right_line_number++; + if ((c == '\n') && (in_emphasize != 1)) left_line_number++; + if (!in_emphasize) { if (behind_emphasize) { if (c == '\n') behind_emphasize--; @@ -335,7 +359,7 @@ static void real_end_of_insert (void); static void our_start_of_delete (void) { if (context_lines) flush_buflines(); - in_emphasize = 1; + in_emphasize = 2; real_start_of_delete(); } static void our_end_of_delete (void) @@ -466,7 +490,11 @@ real_start_of_delete (void) tputs (term_delete_start, 0, putc_for_tputs); #endif if (user_delete_start) - fprintf (output_file, "%s", user_delete_start); + { + fprintf (output_file, "%s", user_delete_start); + if (underline_deleted) fputs (ANSI_UNDERLINE, output_file); + if (ansi_red_green) fputs (ANSI_RED_BG, output_file); + } } /*-------------------------. @@ -483,7 +511,10 @@ real_end_of_delete (void) return; if (user_delete_end) - fprintf (output_file, "%s", user_delete_end); + { + if (ansi_red_green || underline_deleted) fputs (ANSI_NORMAL, output_file); + fprintf (output_file, "%s", user_delete_end); + } #if HAVE_TPUTS if (term_delete_end) tputs (term_delete_end, 0, putc_for_tputs); @@ -510,7 +541,12 @@ real_start_of_insert (void) tputs (term_insert_start, 0, putc_for_tputs); #endif if (user_insert_start) - fprintf (output_file, "%s", user_insert_start); + { + fprintf (output_file, "%s", user_insert_start); + if (bold_inserted) fputs (ANSI_BOLD, output_file); + if (ansi_red_green) fputs (ANSI_GREEN_BG, output_file); + } + } /*-------------------------. @@ -527,7 +563,10 @@ real_end_of_insert (void) return; if (user_insert_end) - fprintf (output_file, "%s", user_insert_end); + { + if (bold_inserted || ansi_red_green) fputs (ANSI_NORMAL, output_file); + fprintf (output_file, "%s", user_insert_end); + } #if HAVE_TPUTS if (term_insert_end) tputs (term_insert_end, 0, putc_for_tputs); @@ -599,7 +638,10 @@ copy_whitespace (SIDE *side, FILE *file) if (side->character == '\n') { if (no_wrapping && user_delete_end) - fprintf (output_file, "%s", user_delete_end); + { + if (ansi_red_green || underline_deleted) fputs (ANSI_NORMAL, output_file); + fprintf (output_file, "%s", user_delete_end); + } #if HAVE_TPUTS if (term_delete_end) tputs (term_delete_end, 0, putc_for_tputs); @@ -610,7 +652,11 @@ copy_whitespace (SIDE *side, FILE *file) tputs (term_delete_start, 0, putc_for_tputs); #endif if (no_wrapping && user_delete_start) - fprintf (output_file, "%s", user_delete_start); + { + fprintf (output_file, "%s", user_delete_start); + if (underline_deleted) fputs (ANSI_UNDERLINE, output_file); + if (ansi_red_green) fputs (ANSI_RED_BG, output_file); + } } else if (overstrike_for_less) { @@ -626,7 +672,10 @@ copy_whitespace (SIDE *side, FILE *file) if (side->character == '\n') { if (no_wrapping && user_insert_end) - fprintf (output_file, "%s", user_insert_end); + { + if (bold_inserted || ansi_red_green) fputs (ANSI_NORMAL, output_file); + fprintf (output_file, "%s", user_insert_end); + } #if HAVE_TPUTS if (term_insert_end) tputs (term_insert_end, 0, putc_for_tputs); @@ -637,7 +686,11 @@ copy_whitespace (SIDE *side, FILE *file) tputs (term_insert_start, 0, putc_for_tputs); #endif if (no_wrapping && user_insert_start) - fprintf (output_file, "%s", user_insert_start); + { + fprintf (output_file, "%s", user_insert_start); + if (bold_inserted) fputs (ANSI_BOLD, output_file); + if (ansi_red_green) fputs (ANSI_GREEN_BG, output_file); + } } else if (overstrike_for_less) { @@ -1351,7 +1404,11 @@ Mandatory arguments to long options are -3, --no-common inhibit output of common words\n")); #ifdef LERMEN_STUFF printf (_("\ - -c --context like -3, but print given context lines\n")); + -c --context=N like -3, but print N lines of context\n\ + -A --ansi-red-green highlight deleted text in red, added text in green\n\ + -B --bold-inserted mark inserted text in bold\n\ + -U --underline-deleted underline deleted text\n\ + -L --label=LABEL use LABEL insted of filename")); #endif printf (_("\ -a, --auto-pager automatically calls a pager\n\ @@ -1403,6 +1460,9 @@ main (int argc, char *const argv[]) autopager = 0; overstrike = 0; overstrike_for_less = 0; + ansi_red_green = 0; + bold_inserted = 0; + underline_deleted = 0; user_delete_start = NULL; user_delete_end = NULL; user_insert_start = NULL; @@ -1423,7 +1483,7 @@ main (int argc, char *const argv[]) count_changed_right = 0; while (option_char = getopt_long (argc, (char **) argv, - "123CKahilnpPstvw:x:y:z:c:", longopts, NULL), + "123ABUCKahilnpPstvw:x:y:z:c:L:", longopts, NULL), option_char != EOF) switch (option_char) { @@ -1439,6 +1499,18 @@ main (int argc, char *const argv[]) inhibit_common = 1; break; + case 'U': + underline_deleted = 1; + break; + + case 'B': + bold_inserted = 1; + break; + + case 'A': + ansi_red_green = 1; + break; + case 'C': print_copyright (); exit (EXIT_SUCCESS); @@ -1508,10 +1579,16 @@ warranty; not even for MERCHANTABILITY o stdout); fputs (_("\ \n\ -Written by Franc,ois Pinard <pinard@iro.umontreal.ca>.\n"), +Written by Franc,ois Pinard <pinard@iro.umontreal.ca>.\n\ +Patches by Hans Lermen (1994), Juergen Weigert <jw@suse.de>\n"), stdout); exit (EXIT_SUCCESS); + case 'L': + // just here for compat with diff. Not really implemented. + // user_label = optarg; + break; + case 'w': user_delete_start = optarg; break;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor