Changeset 6246 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2013-09-22T18:36:07+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r6070 r6246 305 305 bytesToSkip -= nBytesRead; 306 306 } 307 if (bytesToSkip > 0) { 308 audioInputStream.skip(bytesToSkip); 307 while (bytesToSkip > 0) { 308 long skippedBytes = audioInputStream.skip(bytesToSkip); 309 bytesToSkip -= skippedBytes; 310 if (skippedBytes == 0) { 311 // Avoid inifinite loop 312 Main.warn("Unable to skip bytes from audio input stream"); 313 bytesToSkip = 0; 314 } 309 315 } 310 316 position = offset; -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r6235 r6246 97 97 public Diff(Object[] a,Object[] b) { 98 98 Map<Object,Integer> h = new HashMap<Object,Integer>(a.length + b.length); 99 filevec = new file_data[] { new file_data(a,h),new file_data(b,h) };99 filevec = new FileData[] { new FileData(a,h),new FileData(b,h) }; 100 100 } 101 101 … … 123 123 search of the edit matrix. */ 124 124 private int fdiagoff, bdiagoff; 125 private final file_data[] filevec;125 private final FileData[] filevec; 126 126 private int cost; 127 127 /** Snakes bigger than this are considered "big". */ … … 358 358 filevec[0].changed_flag[1+filevec[0].realindexes[xoff++]] = true; 359 359 } 360 } else 361 { 360 } else { 362 361 /* Find a point of correspondence in the middle of the files. */ 363 362 … … 378 377 compareseq (xoff, b, yoff, b - d); 379 378 /* This used to use f instead of b, 380 but that is incorrect!381 It is not necessarily the case that diagonal d382 has a snake from b to f. */379 but that is incorrect! 380 It is not necessarily the case that diagonal d 381 has a snake from b to f. */ 383 382 compareseq (b, xlim, b - d, ylim); 384 383 } … … 388 387 /** Discard lines from one file that have no matches in the other file. 389 388 */ 390 391 389 private void discard_confusing_lines() { 392 390 filevec[0].discard_confusing_lines(filevec[1]); … … 397 395 398 396 /** Adjust inserts/deletes of blank lines to join changes 399 as much as possible.397 as much as possible. 400 398 */ 401 402 399 private void shift_boundaries() { 403 400 if (inhibit) … … 409 406 public interface ScriptBuilder { 410 407 /** Scan the tables of which lines are inserted and deleted, 411 producing an edit script.412 @param changed0 true for lines in first file which do not match 2nd413 @param len0 number of lines in first file414 @param changed1 true for lines in 2nd file which do not match 1st415 @param len1 number of lines in 2nd file416 @return a linked list of changes - or null408 producing an edit script. 409 @param changed0 true for lines in first file which do not match 2nd 410 @param len0 number of lines in first file 411 @param changed1 true for lines in 2nd file which do not match 1st 412 @param len1 number of lines in 2nd file 413 @return a linked list of changes - or null 417 414 */ 418 public change build_script(415 public Change build_script( 419 416 boolean[] changed0,int len0, 420 417 boolean[] changed1,int len1 … … 427 424 static class ReverseScript implements ScriptBuilder { 428 425 @Override 429 public change build_script(426 public Change build_script( 430 427 final boolean[] changed0,int len0, 431 428 final boolean[] changed1,int len1) 432 429 { 433 change script = null;430 Change script = null; 434 431 int i0 = 0, i1 = 0; 435 432 while (i0 < len0 || i1 < len1) { … … 446 443 447 444 /* Record this change. */ 448 script = new change(line0, line1, i0 - line0, i1 - line1, script);445 script = new Change(line0, line1, i0 - line0, i1 - line1, script); 449 446 } 450 447 … … 459 456 static class ForwardScript implements ScriptBuilder { 460 457 /** Scan the tables of which lines are inserted and deleted, 461 producing an edit script in forward order. */458 producing an edit script in forward order. */ 462 459 @Override 463 public change build_script(460 public Change build_script( 464 461 final boolean[] changed0,int len0, 465 462 final boolean[] changed1,int len1) 466 463 { 467 change script = null;464 Change script = null; 468 465 int i0 = len0, i1 = len1; 469 466 … … 483 480 484 481 /* Record this change. */ 485 script = new change(i0, i1, line0 - i0, line1 - i1, script);482 script = new Change(i0, i1, line0 - i0, line1 - i1, script); 486 483 } 487 484 … … 499 496 reverseScript = new ReverseScript(); 500 497 501 /* Report the differences of two files. DEPTH is the current directory502 depth. */503 public final change diff_2(final boolean reverse) {498 /** Report the differences of two files. DEPTH is the current directory 499 depth. */ 500 public final Change diff_2(final boolean reverse) { 504 501 return diff(reverse ? reverseScript : forwardScript); 505 502 } … … 513 510 @return the head of a list of changes 514 511 */ 515 public change diff(final ScriptBuilder bld) {512 public Change diff(final ScriptBuilder bld) { 516 513 517 514 /* Some lines are obviously insertions or deletions … … 566 563 which the insertion was done; vice versa for INSERTED and LINE1. */ 567 564 568 public static class change {565 public static class Change { 569 566 /** Previous or next edit command. */ 570 public change link;567 public Change link; 571 568 /** # lines of file 1 changed here. */ 572 569 public final int inserted; … … 577 574 /** Line number of 1st inserted line. */ 578 575 public final int line1; 579 /** Change is ignorable. */580 public boolean ignore;581 576 582 577 /** Cons an additional entry onto the front of an edit script OLD. … … 587 582 If DELETED is 0 then LINE0 is the number of the line before 588 583 which the insertion was done; vice versa for INSERTED and LINE1. */ 589 public change(int line0, int line1, int deleted, int inserted, change old) {584 public Change(int line0, int line1, int deleted, int inserted, Change old) { 590 585 this.line0 = line0; 591 586 this.line1 = line1; … … 604 599 */ 605 600 606 class file_data {601 class FileData { 607 602 608 603 /** Allocate changed array for the results of comparison. */ 609 604 void clear() { 610 605 /* Allocate a flag for each line of each file, saying whether that line 611 is an insertion or deletion.612 Allocate an extra element, always zero, at each end of each vector.606 is an insertion or deletion. 607 Allocate an extra element, always zero, at each end of each vector. 613 608 */ 614 609 changed_flag = new boolean[buffered_lines + 2]; … … 616 611 617 612 /** Return equiv_count[I] as the number of lines in this file 618 that fall in equivalence class I.613 that fall in equivalence class I. 619 614 @return the array of equivalence class counts. 620 615 */ … … 640 635 @param f the other file 641 636 */ 642 void discard_confusing_lines( file_data f) {637 void discard_confusing_lines(FileData f) { 643 638 clear(); 644 639 /* Set up table of which lines are going to be discarded. */ … … 729 724 730 725 /* Now we have the length of a run of discardable lines 731 whose first and last are not provisional. */726 whose first and last are not provisional. */ 732 727 length = j - i; 733 728 734 729 /* If 1/4 of the lines in the run are provisional, 735 cancel discarding of all provisional lines in the run. */ 736 if (provisional * 4 > length) 737 { 730 cancel discarding of all provisional lines in the run. */ 731 if (provisional * 4 > length) { 738 732 while (j > i) 739 733 if (discards[--j] == 2) { 740 734 discards[j] = 0; 741 735 } 742 } 743 else 744 { 736 } else { 745 737 int consec; 746 738 int minimum = 1; … … 817 809 818 810 /** Actually discard the lines. 819 @param discards flags lines to be discarded811 @param discards flags lines to be discarded 820 812 */ 821 813 private void discard(final byte[] discards) { … … 833 825 } 834 826 835 file_data(int[] data) {827 FileData(int[] data) { 836 828 buffered_lines = data.length; 837 829 equivs = data; … … 840 832 } 841 833 842 file_data(Object[] data,Map<Object,Integer> h) {834 FileData(Object[] data,Map<Object,Integer> h) { 843 835 this(new int[data.length]); 844 836 // FIXME: diff 2.7 removes common prefix and common suffix … … 866 858 */ 867 859 868 void shift_boundaries( file_data f) {860 void shift_boundaries(FileData f) { 869 861 final boolean[] changed = changed_flag; 870 862 final boolean[] other_changed = f.changed_flag; … … 909 901 910 902 /* If the first changed line matches the following unchanged one, 911 and this run does not follow right after a previous run,912 and there are no lines deleted from the other file here,913 then classify the first changed line as unchanged914 and the following line as changed in its place. */903 and this run does not follow right after a previous run, 904 and there are no lines deleted from the other file here, 905 then classify the first changed line as unchanged 906 and the following line as changed in its place. */ 915 907 916 908 /* You might ask, how could this run follow right after another? 917 Only because the previous run was shifted here. */909 Only because the previous run was shifted here. */ 918 910 919 911 if (end != i_end … … 929 921 ++i; 930 922 /* Since one line-that-matches is now before this run 931 instead of after, we must advance in the other file932 to keep in synch. */923 instead of after, we must advance in the other file 924 to keep in synch. */ 933 925 ++j; 934 926 } else { … … 965 957 The results of comparison are stored here. */ 966 958 boolean[] changed_flag; 967 968 959 } 969 960 } -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r6230 r6246 181 181 182 182 for (int pos = 0; pos < ways.size(); pos ++) { 183 if ( changedWays[pos] == false) {183 if (!changedWays[pos]) { 184 184 continue; 185 185 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r6235 r6246 412 412 try { 413 413 return new ImageResource(ImageIO.read(new ByteArrayInputStream(bytes))); 414 } catch (IOException e) {} 414 } catch (IOException e) { 415 Main.warn("IOException while reading image: "+e.getMessage()); 416 } 415 417 } 416 418 } … … 522 524 try { 523 525 img = ImageIO.read(is.getFile().toURI().toURL()); 524 } catch (IOException e) {} 526 } catch (IOException e) { 527 Main.warn("IOException while reading HTTP image: "+e.getMessage()); 528 } 525 529 return img == null ? null : new ImageResource(img); 526 530 default: -
trunk/src/org/openstreetmap/josm/tools/TextTagParser.java
r6142 r6246 34 34 35 35 public static class TextAnalyzer { 36 int start = 0;37 boolean keyFound = false;38 36 boolean quotesStarted = false; 39 37 boolean esc = false; … … 42 40 String data; 43 41 int n; 44 boolean notFound;45 42 46 43 public TextAnalyzer(String text) {
Note:
See TracChangeset
for help on using the changeset viewer.