--- wdiff-0.5/wdiff.c Sun Nov 6 02:57:23 1994 +++ wdiff-0.5-p/wdiff.c Mon Oct 25 16:33:10 2004 @@ -109,6 +109,7 @@ { {"copyright" , 0, NULL, 'C'}, {"version" , 0, NULL, 'V'}, + {"whitespace" , 1, NULL, 'S'}, {"no-deleted" , 0, NULL, '1'}, {"no-inserted" , 0, NULL, '2'}, {"no-common" , 0, NULL, '3'}, @@ -142,6 +143,7 @@ const char *user_delete_end; /* user specified string for end of delete */ const char *user_insert_start; /* user specified string for start of insert */ const char *user_insert_end; /* user specified string for end of insert */ +const char *user_space; /* user specified list of whitespace */ int find_termcap; /* initialize the termcap strings */ const char *term_delete_start; /* termcap string for start of delete */ @@ -382,6 +384,24 @@ copy_mode = COPY_NORMAL; } +/*---------------------------------------------------------. +| Determine if a char is whitespace by user's definition. | +`---------------------------------------------------------*/ +static int +iswhitespace (int c) +{ + if (user_space) { + char *u; + for (u = user_space; *u; u++) { + if (c == *u) return 1; + } + //return isspace (c); + return 0; + } else { + return isspace (c); + } +} + /*--------------------------------. | Skip over white space on SIDE. | `--------------------------------*/ @@ -392,7 +412,7 @@ if (interrupted) longjmp (signal_label, 1); - while (isspace (side->character)) + while (iswhitespace (side->character)) side->character = getc (side->file); } @@ -406,7 +426,7 @@ if (interrupted) longjmp (signal_label, 1); - while (side->character != EOF && !isspace (side->character)) + while (side->character != EOF && !iswhitespace (side->character)) side->character = getc (side->file); side->position++; } @@ -421,7 +441,7 @@ if (interrupted) longjmp (signal_label, 1); - while (isspace (side->character)) + while (iswhitespace (side->character)) { /* While changing lines, ensure we stop any special display prior @@ -507,7 +527,7 @@ if (interrupted) longjmp (signal_label, 1); - while (side->character != EOF && !isspace (side->character)) + while (side->character != EOF && !iswhitespace (side->character)) { /* In printer mode, act according to copy_mode. If copy_mode is not @@ -1139,6 +1159,8 @@ main (int argc, char *const argv[]) { int option_char; /* option character */ + char *c, *u; + char s; /* Decode arguments. */ @@ -1173,7 +1195,7 @@ count_changed_left = 0; count_changed_right = 0; - while (option_char = getopt_long (argc, argv, "123CVahidlnpstw:x:y:z:", + while (option_char = getopt_long (argc, argv, "123CVS:ahidlnpstw:x:y:z:", longopts, NULL), option_char != EOF) switch (option_char) @@ -1197,6 +1219,43 @@ case 'v': printf ("GNU %s %s\n%s\n", PRODUCT, VERSION, copyright); exit (0); + + case 'S': + user_space = malloc (strlen (optarg)); + u = user_space; + for (c = optarg; *c; c++) { + if (*c == '\\') { + switch (*(++c)) { + case 'n': + *u++ = '\n'; + break; + case 't': + *u++ = '\t'; + break; + case 'v': + *u++ = '\v'; + break; + case 'r': + *u++ = '\r'; + break; + case '\\': + *u++ = '\\'; + break; + case 'S': + //things in isspace + for (s = 0; s < 127; s++) { + if (isspace (s)) { + *u++ = s; + } + } + break; + } + } else { + *u++ = *c; + } + } + *u = 0; + break; case 'a': autopager = 1; diff -ru wdiff-0.5/wdiff.texi wdiff-0.5-p/wdiff.texi --- wdiff-0.5/wdiff.texi Tue Nov 1 12:36:52 1994 +++ wdiff-0.5-p/wdiff.texi Mon Oct 25 16:38:01 2004 @@ -311,6 +311,15 @@ distinguishing where such text ends; in this case the default end insert string is @address@hidden address@hidden --whitespace @var{argument} address@hidden -S @var{argument} + +Use @var{argument} as a list of characters to be considered address@hidden The default is to use your system's C library's +isspace function. @var{argument} is processed for escaped characters +as in C strings. The additional escape @code{\\S} is accepted and +includes characters matched by isspace. + @item --avoid-wraps @itemx -n Avoid spanning the end of line while showing deleted or inserted text.