Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4996203

100 embarrassing Core Library doc "stutter" typos

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 1.4.2, 5.0
    • other-libs
    • b42
    • generic, x86
    • generic, windows_xp

      100 simple typos in the core library documentation were found by an
      old set of programs I wrote to find "stutters".

      I used a command like

      find -name '*.java' | grep -v SCCS | xargs extract-comments | double-words

      where

      extract-comments is:

      #!/bin/sh
      #! -*- perl -*-
      # Written by Martin Buchholz, 1998
      # This program is in the public domain
      eval 'exec perl -x -S $0 ${1+"$@"}'
          if 0;
      use warnings;
      use strict;
      (my $myName = $0) =~ s@.*/@@;

      my $usage ="
      Usage: $myName FILE...

      Generates C/C++/Java comments from all the files on the command line
      and writes them to stdout.\n";

      die $usage if grep /^-/, @ARGV;

      undef $/; while (defined (my $contents = <>)) { $_ .= $contents; }

      s{ (?:
         [^\"\'/]+ |
         (?:\"[^\"\\]*(?:\\.[^\"\\]*)*\" [^\"\'/]*)+ |
         (?:\'[^\'\\]*(?:\\.[^\'\\]*)*\' [^\"\'/]*)+
       )
         | / (
         \*[^*]*\*+(?:[^/*][^*]*\*+)*/
         |
         /[^\n]*
       )
      }{defined $1 ? "$1\n" : ""}gsxeo;

      # Don't need comment characters anymore
      tr [/*][ ]d;

      # Convert Java-style StudlyCaps into separate words
      s/([a-z])([A-Z])(?=[a-z])/$1 $2/g;

      print;

      and double-words is:

      : #-*- Perl -*-
      # Author: Martin Buchholz
      # This program is in the public domain
      eval 'exec perl -w -S $0 ${1+"$@"}'
          if 0;

      (my $myName = $0) =~ s@.*/@@; my $usage="
      Usage: $myName

      Display all occurrences of doubled words in the input.\n";

      use strict;

      die $usage if grep (/^-/, @ARGV);
      undef $/;

      my $i = 1;
      while (<>) {
        s/\n@(section|defun|node|delete|unnumber|end|quotation|cindex|.?item|subsect)[^\n]+/ ::/g;
        s/\n/ /g;
        my $context;
        #foreach $hit (/(.{40}[ ,.;:!?]([a-zA-Z]{2,})\s*;+\s*\2[ ,.;:!?].{1,30})/g) {
        foreach my $hit (/(.{40}[ ,.;:!?]([a-zA-Z]{2,})[\s;]+\2[ ,.;:!?].{1,30})/g) {
          if ($i++%2) {
            $context = $hit;
            next;
          }
          next if $hit eq 'nil';
          next if $hit eq 'that';
          #$word = $2;
          #print "::$`:::$&:$'\n";
          #next unless $hit =~ /[a-zA-Z]{2,}/;
          #next if $hit =~ /-/;
          #next if $hit eq 'nil';
          print "$ARGV: hit $hit\n";
          print "$ARGV: context $context\n";
        }
      }

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: