Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | update DiffUtilTcl to version 0.4.1 |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
00d59d69252746c8b527424f252933c9 |
User & Date: | chw 2019-06-13 12:53:13.653 |
Context
2019-06-13
| ||
12:54 | improve twv demo check-in: b9d5c5a105 user: chw tags: trunk | |
12:53 | update DiffUtilTcl to version 0.4.1 check-in: 00d59d6925 user: chw tags: trunk | |
10:46 | improve twv demo, again check-in: 3e88960bb1 user: chw tags: trunk | |
Changes
Changes to undroid/DiffUtilTcl/ChangeLog.
|
Changes to undroid/DiffUtilTcl/RevisionBump.txt.
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 | - | The following files contain current revision and needs to be changed when bumping revisions: configure.ac (AC_INIT) doc/diffutil.man (two places) tcl/diffutil.tcl (package provide) |
Changes to undroid/DiffUtilTcl/configure.
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | #! /bin/sh # Guess values for system-dependent variables and create Makefiles. |
︙ | |||
590 591 592 593 594 595 596 | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | - - + + | MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='DiffUtil' PACKAGE_TARNAME='diffutil' |
︙ | |||
1315 1316 1317 1318 1319 1320 1321 | 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 | - + | # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF |
︙ | |||
1376 1377 1378 1379 1380 1381 1382 | 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 | - + | cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in |
︙ | |||
1475 1476 1477 1478 1479 1480 1481 | 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 | - + - + | cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF |
︙ | |||
12520 12521 12522 12523 12524 12525 12526 | 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 | - + | exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" |
︙ | |||
12570 12571 12572 12573 12574 12575 12576 | 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 | - + | $config_files Report bugs to <bug-autoconf@gnu.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ |
︙ |
Changes to undroid/DiffUtilTcl/configure.ac.
︙ | |||
15 16 17 18 19 20 21 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | - + | # This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION # set as provided. These will also be added as -D defs in your Makefile # so you can encode the package version directly into the source files. # This will also define a special symbol for Windows (BUILD_<PACKAGE_NAME> # so that we create the export library with the dll. #----------------------------------------------------------------------- |
︙ |
Changes to undroid/DiffUtilTcl/doc/diffutil.html.
| 1 2 3 4 5 6 7 8 | - + |
|
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - - - - - + + + + + + + + + - - - + + + - + - + + + - + - - + + - + | margin-top: 1em; font-family: sans-serif; font-size: large; color: #005A9C; background: transparent; text-align: left; } |
︙ | |||
176 177 178 179 180 181 182 | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + | on each line.</p></dd> <dt><b class="option">-regsubleft</b> <i class="arg">list</i></dt> <dd><p>Like <i class="arg">-regsub</i> but only applied to the first file.</p></dd> <dt><b class="option">-regsubright</b> <i class="arg">list</i></dt> <dd><p>Like <i class="arg">-regsub</i> but only applied to the second file.</p></dd> <dt><b class="option">-result</b> <i class="arg">style</i></dt> <dd><p>Select result style. The default is <i class="arg">diff</i>.</p> |
Changes to undroid/DiffUtilTcl/doc/diffutil.man.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | - + - + |
|
︙ | |||
21 22 23 24 25 26 27 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | - + | [call [cmd "::DiffUtil::diffFiles"] \ [opt [arg options]] [arg file1] [arg file2]] Compare two files line by line. The return value depends on the [arg -result] option, see below. |
︙ | |||
102 103 104 105 106 107 108 | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | - + | [call [cmd "::DiffUtil::diffLists"] \ [opt [arg options]] [arg list1] [arg list2]] Compare two lists element by element. The return value depends on the [arg -result] option, see below. |
︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | [def [const match]] The return value is a list of two lists of equal length. The first sublist is of indices in [arg list1], and the second sublist is of indices in [arg list2]. Each corresponding pair of indices corresponds to equal elements in the sequences. [list_end] [list_end] [call [cmd "::DiffUtil::compareFiles"] \ [opt [arg options]] [arg file1] [arg file2]] Compare two files. The return value is a boolean which is true when equal. [list_begin options] [opt_def -nocase] Ignore case. [opt_def -ignorekey] Ignore keyword substitutions. This is limited to the first 60k of the file. [opt_def -encoding [arg enc]] Read files with this encoding. (As in fconfigure -encoding.) [opt_def -translation [arg trans]] Read files with this translation. (As in fconfigure -translation.) [list_end] [call [cmd "::DiffUtil::compareStreams"] \ [opt [arg options]] [arg ch1] [arg ch2]] Compare two channel streams. The return value is a boolean which is true when equal. [list_begin options] [opt_def -nocase] Ignore case. [opt_def -ignorekey] Ignore keyword substitutions. This is limited to the first 60k read. [opt_def -binary] Treat stream as binary data. Normally this means it is configured with -translation binary. [list_end] [list_end] [section EXAMPLES] [para] |
︙ |
Changes to undroid/DiffUtilTcl/doc/diffutil.n.
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 | - + | '\" '\" Generated from file 'diffutil\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2010, Peter Spjuth '\" |
︙ | |||
272 273 274 275 276 277 278 | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | - + + + + + | .. .BS .SH NAME DiffUtil \- Compare Stuff .SH SYNOPSIS package require \fBTcl 8\&.6\fR .sp |
︙ | |||
414 415 416 417 418 419 420 421 422 423 424 425 426 427 | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | \fBmatch\fR The return value is a list of two lists of equal length\&. The first sublist is of indices in \fIlist1\fR, and the second sublist is of indices in \fIlist2\fR\&. Each corresponding pair of indices corresponds to equal elements in the sequences\&. .RE .RE .TP \fB::DiffUtil::compareFiles\fR ?\fIoptions\fR? \fIfile1\fR \fIfile2\fR Compare two files\&. The return value is a boolean which is true when equal\&. .RS .TP \fB-nocase\fR Ignore case\&. .TP \fB-ignorekey\fR Ignore keyword substitutions\&. This is limited to the first 60k of the file\&. .TP \fB-encoding\fR \fIenc\fR Read files with this encoding\&. (As in fconfigure -encoding\&.) .TP \fB-translation\fR \fItrans\fR Read files with this translation\&. (As in fconfigure -translation\&.) .RE .TP \fB::DiffUtil::compareStreams\fR ?\fIoptions\fR? \fIch1\fR \fIch2\fR Compare two channel streams\&. The return value is a boolean which is true when equal\&. .RS .TP \fB-nocase\fR Ignore case\&. .TP \fB-ignorekey\fR Ignore keyword substitutions\&. This is limited to the first 60k read\&. .TP \fB-binary\fR Treat stream as binary data\&. Normally this means it is configured with -translation binary\&. .RE .PP .SH EXAMPLES .PP .CS % DiffUtil::diffFiles $file1 $file2 |
︙ |
Changes to undroid/DiffUtilTcl/generic/comparefiles.c.
︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - - + + - + | #include <tcl.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <sys/stat.h> #include "diffutil.h" /* Visual C++ does not define S_ISDIR */ #ifndef S_ISDIR #define S_ISDIR(mode_) (((mode_) & _S_IFMT) == _S_IFDIR) #endif const int BlockRead_C = 65536; typedef struct { int ignoreKey; int noCase; int binary; } CmpOptions_T; /* Helper to get a filled in CmpOptions_T */ #define InitCmpOptions_T(opts) {opts.ignoreKey = 0; opts.noCase = 0; opts.binary = 0;} /* This is called when a dollar is encountered during ignore-keyword. If return is equal res1/2 says how far we covered and considered equal. This do not bother with encoding since the chars we are interested in are the same in ascii/binary/utf8. */ static int ScanKey( const char *s1, const char *s2, const char *e1, const char *e2, const char **res1, const char **res2) { *res1 = s1; *res2 = s2; /* Scan word chars until : or $ ends the keyword. They must be equal up to that point. */ while (s1 < e1 && s2 < e2) { if ((*s1 == ':' || *s1 == '$') && (*s2 == ':' || *s2 == '$')) { /* The keyword part has ended on both sides */ /* To be a bit conservative and not confuse keywords with e.g. Tcl namespace variables we only acknowledge these forms: keyword$ keyword:$ keyword: .*$ keyword:: .*$ */ if (*s1 == ':') { s1++; if (s1 + 1 >= e1) { return 1; } /* May be a double colon */ if (*s1 == ':') { s1++; } /* Colon must be followed by space or $ */ if (*s1 != ' ' && *s1 != '$') { return 1; } } if (*s2 == ':') { s2++; if (s2 + 1 >= e2) { return 1; } if (*s2 == ':') { s2++; } if (*s2 != ' ' && *s2 != '$') { return 1; } } break; } if (*s1 != *s2) { /* They are not equal keywords */ return 0; } /* Only standard ascii word chars count */ if ((*s1 >= 'a' && *s1 <= 'z') || (*s1 >= 'A' && *s1 <= 'Z')) { s1++; s2++; } else { /* This did not count as a keyword but is sofar equal. */ *res1 = s1; *res2 = s2; return 1; } } /* Skip all until $ */ while (s1 < e1) { if (*s1 == '$') { break; } s1++; } while (s2 < e2) { if (*s2 == '$') { break; } s2++; } /* At this point s1/2 should point to the dollar ending the keyword. */ if (s1 == e1 || s2 == e2) { /* We reached the end of string without finishing the keyword. If a potential keyword is at the end we don't care. */ return 1; } /* Strings are equal up to this point. Skip the last dollar as well. */ *res1 = s1 + 1; *res2 = s2 + 1; return 1; } /* Compare two strings, ignoring keywords. If return is true, they are equal up to the point of res1/2. */ static int CompareNoKey( const char *s1, /* UTF string to compare to s2. */ const char *s2, /* UTF string s2 is compared to. */ unsigned long len1, /* Number of bytes to compare. */ unsigned long len2, CmpOptions_T *cmpOptions, const char **res1, const char **res2) { Tcl_UniChar ch1 = 0, ch2 = 0; const char *end1 = s1 + len1; const char *end2 = s2 + len2; const char *scan1, *scan2; while (s1 < end1 && s2 < end2) { if (cmpOptions->binary) { ch1 = *(s1++); ch2 = *(s2++); } else { s1 += Tcl_UtfToUniChar(s1, &ch1); s2 += Tcl_UtfToUniChar(s2, &ch2); } if (ch1 != ch2) { if (cmpOptions->noCase) { ch1 = Tcl_UniCharToLower(ch1); ch2 = Tcl_UniCharToLower(ch2); if (ch1 != ch2) { return 0; } } else { return 0; } } if (ch1 == '$') { if (!ScanKey(s1, s2, end1, end2, &scan1, &scan2)) { /* If ScanKey said not equal, we trust it unless we use less strict rules */ if (!cmpOptions->noCase) { return 0; } } s1 = scan1; s2 = scan2; } } *res1 = s1; *res2 = s2; return 1; } static int CompareStreams( Tcl_Channel ch1, Tcl_Channel ch2, CmpOptions_T *cmpOptions) { int equal; Tcl_Obj *line1Ptr, *line2Ptr; int charactersRead1, charactersRead2; int length1, length2; int firstblock; const char *string1, *string2; /* Initialize an object to use as line buffer. */ line1Ptr = Tcl_NewObj(); line2Ptr = Tcl_NewObj(); Tcl_IncrRefCount(line1Ptr); Tcl_IncrRefCount(line2Ptr); if (cmpOptions->binary) { Tcl_SetByteArrayLength(line1Ptr, 70000); Tcl_SetByteArrayLength(line2Ptr, 70000); } else { Tcl_SetObjLength(line1Ptr, 70000); Tcl_SetObjLength(line2Ptr, 70000); } equal = 1; firstblock = 1; while (equal) { charactersRead1 = Tcl_ReadChars(ch1, line1Ptr, BlockRead_C, 0); charactersRead2 = Tcl_ReadChars(ch2, line2Ptr, BlockRead_C, 0); if (charactersRead1 <= 0 && charactersRead2 <= 0) { /* Nothing more to check */ break; } if (charactersRead1 <= 0 || charactersRead2 <= 0) { /* One of the files is ended */ equal = 0; break; } if (charactersRead1 != charactersRead2 && !cmpOptions->ignoreKey) { /* Different size */ equal = 0; break; } if (cmpOptions->binary) { string1 = (char *) Tcl_GetByteArrayFromObj(line1Ptr, &length1); string2 = (char *) Tcl_GetByteArrayFromObj(line2Ptr, &length2); } else { string1 = Tcl_GetStringFromObj(line1Ptr, &length1); string2 = Tcl_GetStringFromObj(line2Ptr, &length2); } /* Limit ignoreKey to first block to simplify. No need to handle keywords crossing block boundary and a bit better performance on large files. */ if (firstblock && cmpOptions->ignoreKey) { const char *res1, *res2; unsigned long rem1, rem2; int eq = CompareNoKey(string1, string2, length1, length2, cmpOptions, &res1, &res2); if (!eq) { equal = 0; break; } firstblock = 0; /* Did we consume everything? */ if (res1 >= string1 + length1 && res2 >= string2 + length2) { continue; } /* Compensate for any change in length. */ rem1 = length1 - (res1 - string1); rem2 = length2 - (res2 - string2); /* Only one side should have anything left. */ if (rem1 > 0 && rem2 > 0) { Tcl_Panic("PANIC"); } if (rem1 > 0) { unsigned long chars1; /* Adjust side 1 */ string1 = res1; length1 = rem1; chars1 = Tcl_NumUtfChars(string1, length1); /* Read extra characters from side 2 */ charactersRead2 = Tcl_ReadChars(ch2, line2Ptr, chars1, 0); if (charactersRead2 <= 0) { equal = 0; break; } if (cmpOptions->binary) { string2 = (char *) Tcl_GetByteArrayFromObj(line2Ptr, &length2); } else { string2 = Tcl_GetStringFromObj(line2Ptr, &length2); } } else { /* rem2 > 0 */ unsigned long chars2; /* Adjust side 2 */ string2 = res2; length2 = rem2; chars2 = Tcl_NumUtfChars(string2, length2); /* Read extra characters from side 1 */ charactersRead1 = Tcl_ReadChars(ch1, line1Ptr, chars2, 0); if (charactersRead1 <= 0) { equal = 0; break; } if (cmpOptions->binary) { string1 = (char *) Tcl_GetByteArrayFromObj(line1Ptr, &length1); } else { string1 = Tcl_GetStringFromObj(line1Ptr, &length1); } } } if (length1 != length2) { equal = 0; break; } if (cmpOptions->binary) { if (strncmp(string1, string2, length1) != 0) { equal = 0; break; } } else if (cmpOptions->noCase) { if (Tcl_UtfNcasecmp(string1, string2, length1) != 0) { equal = 0; break; } } else { if (Tcl_UtfNcmp(string1, string2, length1) != 0) { equal = 0; break; } } } Tcl_DecrRefCount(line1Ptr); Tcl_DecrRefCount(line2Ptr); return equal; } int CompareFilesObjCmd( ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *CONST objv[]) /* Argument objects. */ { int index, t, result = TCL_OK; Tcl_Obj *file1Ptr, *file2Ptr; |
︙ | |||
85 86 87 88 89 90 91 | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | - + | } file1Ptr = objv[objc-2]; file2Ptr = objv[objc-1]; if (translationPtr != NULL) { char *valueName = Tcl_GetString(translationPtr); if (strcmp(valueName, "binary") == 0) { |
︙ | |||
117 118 119 120 121 122 123 | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | - + - + | ckfree((char *) statBuf); if (S_ISDIR(mode1) || S_ISDIR(mode2)) { equal = 0; goto done; } /* On binary comparison, different size means different */ |
︙ | |||
158 159 160 161 162 163 164 | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | } if (Tcl_SetChannelOption(interp, ch2, "-translation", valueName) != TCL_OK) { result = TCL_ERROR; goto cleanup; } } |
︙ | |||
241 242 243 244 245 246 247 | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } if (translationPtr != NULL) { Tcl_DecrRefCount(translationPtr); } return result; } int CompareStreamsObjCmd( ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *CONST objv[]) /* Argument objects. */ { int index, t, result = TCL_OK; int equal; CmpOptions_T cmpOptions; Tcl_Channel ch1, ch2; static CONST char *options[] = { "-nocase", "-ignorekey", "-binary", (char *) NULL }; enum options { OPT_NOCASE, OPT_IGNOREKEY, OPT_BINARY }; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "?opts? ch1 ch2"); return TCL_ERROR; } InitCmpOptions_T(cmpOptions); for (t = 1; t < objc - 2; t++) { if (Tcl_GetIndexFromObj(interp, objv[t], options, "option", 0, &index) != TCL_OK) { result = TCL_ERROR; goto cleanup; } switch (index) { case OPT_NOCASE: cmpOptions.noCase = 1; break; case OPT_IGNOREKEY: cmpOptions.ignoreKey = 1; break; case OPT_BINARY: cmpOptions.binary = 1; break; } } ch1 = Tcl_GetChannel(interp, Tcl_GetString(objv[objc-2]), NULL); if (ch1 == NULL) { result = TCL_ERROR; goto cleanup; } ch2 = Tcl_GetChannel(interp, Tcl_GetString(objv[objc-1]), NULL); if (ch2 == NULL) { result = TCL_ERROR; goto cleanup; } equal = CompareStreams(ch1, ch2, &cmpOptions); Tcl_SetObjResult(interp, Tcl_NewIntObj(equal)); cleanup: return result; } |
Changes to undroid/DiffUtilTcl/generic/diff.c.
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | + + + + + + + | #include "diffutil.h" /* A type for the parsing state */ typedef enum { IN_NONE, IN_SPACE, IN_NUMBER } In_T; /* * max already defined by Visual C++, but reuse our def just in case * semantics differ. */ #ifdef max #undef max /* Unset to prevent preprocessor warnings */ #endif #define max(a,b) ((a) > (b) ? (a) : (b)) /* A type to implement the Candidates in the LCS algorithm */ typedef struct Candidate_T { /* Line numbers in files */ Line_T line1, line2; /* A score value to select between similar candidates */ |
︙ | |||
937 938 939 940 941 942 943 | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 | - + + - + | } return; } /* * In principle this matching should be a rerun of LCS on the block, with * forbidden lines allowed. |
︙ | |||
962 963 964 965 966 967 968 | 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | - + - + | return; } /* * Just do a raw sequential matching of forbidden lines. * This produces a reasonable, if non-optimal, result. * FIXA: Better algorithm here? |
︙ | |||
1044 1045 1046 1047 1048 1049 1050 | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | - + | } if (P[i].forbidden) { /* Make a list of all forbidden lines in this change block. */ AddToLineList(&iList, i, P[i].hash); continue; } } |
︙ | |||
1076 1077 1078 1079 1080 1081 1082 | 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | - - + + - + - + | /* * The core part of the LCS algorithm. * It is independent of data since it only works on hashes. * * This is the inner part of it, which do not meddle with forbidden lines. |
︙ | |||
1271 1272 1273 1274 1275 1276 1277 | 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 | - + | Tcl_Interp *interp, Line_T m, Line_T n, P_T *P, E_T *E, const DiffOptions_T *optsPtr) { Line_T i, *J; int anyForbidden; |
︙ | |||
1692 1693 1694 1695 1696 1697 1698 | 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 | - - + + | */ static int DiffOptsRegsub( Tcl_Interp *interp, /* Current interpreter. */ Tcl_Obj *obj1Ptr, /* Input object. */ Tcl_Obj *rePtr, /* Regexp object. */ Tcl_Obj *sub1Ptr, /* Substitution. */ |
︙ |
Changes to undroid/DiffUtilTcl/generic/diffstrings.c.
︙ | |||
116 117 118 119 120 121 122 | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | - + | Tcl_UniChar c; Tcl_Obj *resPtr; int igSpace = (optsPtr->ignore & (IGNORE_SPACE_CHANGE | IGNORE_ALL_SPACE)); int word = optsPtr->wordparse; resPtr = Tcl_NewListObj(0, NULL); Tcl_IncrRefCount(resPtr); |
︙ | |||
405 406 407 408 409 410 411 | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | - + | Tcl_ListObjAppendElement(interp, *resPtr, str1Ptr); Tcl_ListObjAppendElement(interp, *resPtr, str2Ptr); Tcl_ListObjAppendElement(interp, *resPtr, emptyPtr); Tcl_ListObjAppendElement(interp, *resPtr, emptyPtr); } return; } |
︙ |
Changes to undroid/DiffUtilTcl/generic/diffutil.c.
︙ | |||
28 29 30 31 32 33 34 | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | - + | int match; CompareFun *cmp; Tcl_UniChar first1, c2; /* * We are searching string2 for the sequence string1. */ |
︙ | |||
200 201 202 203 204 205 206 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | - + | Tcl_DecrRefCount(apa2); /* Handle middle (common) part*/ Tcl_ListObjAppendElement(interp, res, Tcl_NewUnicodeObj(str1 + found1, foundlen)); Tcl_ListObjAppendElement(interp, res, Tcl_NewUnicodeObj(str2 + found2, foundlen)); |
︙ | |||
232 233 234 235 236 237 238 | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - + - + | int wordflag; Tcl_Obj *res, *mid1, *mid2; static CONST char *options[] = { "-nocase", "-i", "-b", "-w", "-words", (char *) NULL }; enum options { OPT_NOCASE, OPT_I, OPT_B, OPT_W, OPT_WORDS |
︙ | |||
263 264 265 266 267 268 269 | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | - + - + | wordparse = 1; break; } } line1 = Tcl_GetUnicodeFromObj(objv[objc-2], &len1); line2 = Tcl_GetUnicodeFromObj(objv[objc-1], &len2); |
︙ | |||
382 383 384 385 386 387 388 389 390 391 392 393 394 395 | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | + | } #endif if (Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION) != TCL_OK) { return TCL_ERROR; } TCOC("DiffUtil::compareFiles", CompareFilesObjCmd); TCOC("DiffUtil::compareStreams", CompareStreamsObjCmd); TCOC("DiffUtil::diffFiles", DiffFilesObjCmd); TCOC("DiffUtil::diffLists", DiffListsObjCmd); TCOC("DiffUtil::diffStrings", DiffStringsObjCmd); TCOC("DiffUtil::diffStrings2", DiffStrings2ObjCmd); Tcl_SetVar(interp, "DiffUtil::version", PACKAGE_VERSION, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "DiffUtil::implementation", "c", TCL_GLOBAL_ONLY); |
︙ |
Changes to undroid/DiffUtilTcl/generic/diffutil.h.
︙ | |||
43 44 45 46 47 48 49 | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | - + | int alignLength; Line_T *align; Line_T staticAlign[STATIC_ALIGN]; } DiffOptions_T; /* Helper to get a filled in DiffOptions_T */ #define InitDiffOptions_T(opts) {opts.ignore = 0; opts.noempty = 0; opts.pivot = 10; opts.wordparse = 0; opts.rFrom1 = 1; opts.rTo1 = 0; opts.rFrom2 = 1; opts.rTo2 = 0; opts.regsubLeftPtr = NULL; opts.regsubRightPtr = NULL; opts.resultStyle = Result_Diff; opts.firstIndex = 1; opts.alignLength = 0; opts.align = opts.staticAlign;} |
︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | + + + + + | DiffOptions_T *optsPtr); extern void SortV(V_T *V, Line_T n, const DiffOptions_T *optsPtr); extern int CompareFilesObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); extern int CompareStreamsObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); extern int DiffFilesObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, |
︙ |
Changes to undroid/DiffUtilTcl/makevfs.sh.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | + + + + + + + + + + | # Script to build a multi-platform vfs # Do this separately on mac: # ./configure # make clean # make # make vfsmac # Cross-compiling needs a cross-compiled tcl for linking ./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --with-tcl=/home/peter/tcl/win/tcl/win make clean make make vfswin # 32-bit compiling needs a 32 bit compiled tcl for linking CFLAGS=-m32 ./configure --disable-64bit --with-tcl=/home/peter/tcl/m32/tcl/unix make clean make make vfs32 ./configure --enable-64bit --with-tcl=/home/peter/tcl/v86/tcl/unix make clean make make vfs64 # End with a sanity check ls -l lib.vfs/DiffUtil/*/*.so lib.vfs/DiffUtil/*/*.dylib lib.vfs/DiffUtil/*/*.dll file lib.vfs/DiffUtil/*/*.so lib.vfs/DiffUtil/*/*.dylib lib.vfs/DiffUtil/*/*.dll |
Changes to undroid/DiffUtilTcl/tcl/diffutil.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | #---------------------------------------------------------------------- # # This is a Tcl implementation of the DiffUtil package # # Copyright (c) 2004, Peter Spjuth # # This package is starting out as a refactoring of diff code from # Eskil, and will be released as a separate package when mature. # #---------------------------------------------------------------------- # $Revision: 1.12 $ #---------------------------------------------------------------------- |
︙ |
Changes to undroid/DiffUtilTcl/tests/comparefiles.test.
︙ | |||
24 25 26 27 28 29 30 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - + | set ch [open _diff_1 wb] puts -nonewline $ch $data1 close $ch set ch [open _diff_2 wb] puts -nonewline $ch $data2 close $ch |
︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + + + + + + | } 0 test comparefiles-1.5 {standard cases} { set l1 {abcd} set l2 {abce} RunTest $l1 $l2 } 0 test comparefiles-1.6 {standard cases} { set l1 {abcd} set l2 {abcD} list [RunTest $l1 $l2] [RunTest $l1 $l2 -nocase] } {0 1} test comparefiles-2.1 {channel config} {CDiff} { set l1 {a b c} set l2 {a d c} RunTest $l1 $l2 -encoding iso8859-1 -translation lf } 0 |
︙ |
Added undroid/DiffUtilTcl/tests/comparestreams.test.