On Fri, Feb 22, 2002 at 09:35:22AM +0000, Nick Ing-Simmons wrote:
> Jarkko Hietaniemi <[EMAIL PROTECTED]> writes:
> >On Tue, Feb 19, 2002 at 02:31:11PM +0000, Nicholas Clark wrote:
> >> On Tue, Feb 19, 2002 at 02:22:24PM +0100, H.Merijn Brand wrote:
> >> > U2235 is 879A and 81E6
> >> > : : :
> >> > : : : Lots of these (intended?)
> >
> >I think they are kind of intended, but I also think we could certainly
> >live without them, too, they are kind of noisy.

I agree. I can't foresee that many people compiling the module are in
a position to do anything about the warnings.
Attached patch adds a -Q flag to compile to silence the warnings, and
makes Makefile.PL default to using this flag.
(I think that this is a reasonable way round, because it means anyone running
compile by hand gets the warnings, but anyone just building the module
doesn't)

Of course, I don't have an ulterior motive. On my 16M RAM system
before:
      808.51 real       344.32 user        19.12 sys
after:
      411.80 real       285.01 user        12.38 sys

[for touch compile; make test]

On a somewhat faster machine (colon.colondon.net) that goes from this:
       39.03 real        35.29 user         2.13 sys
to this:
       36.87 real        34.14 user         2.08 sys

(which is *still* 3.3% total CPU time saved for the whole make
 even on a fast machine with loadaRAM. If my figures are correct)

On Fri, Feb 22, 2002 at 09:34:18AM +0000, Nick Ing-Simmons wrote:
> Nicholas Clark <[EMAIL PROTECTED]> writes:
> >On Tue, Feb 19, 2002 at 02:22:24PM +0100, H.Merijn Brand wrote:
> >> U2235 is 879A and 81E6
> >> : : :
> >> : : : Lots of these (intended?)
> >> : : :
> >> U9D70 is FC47 and EEE8
> 
> IIRC from whay back there were problems with various encodings
> having code points which did not exist as distinct points in Unicode.
> Hence they would not round-trip. I believe modern Unicode added
> a slew of new points to fix this.

So does that mean if we obtain newer conversion tables, they will use those
code points, and the underlying cause of the warnings will be removed?

Nicholas Clark
-- 
EMCFT http://www.ccl4.org/~nick/CV.html

--- ext/Encode/compile.orig     Fri Feb 22 19:11:30 2002
+++ ext/Encode/compile  Mon Feb 25 21:14:18 2002
@@ -118,23 +118,43 @@
 eval "\@ARGV = map(glob(\$_),\@ARGV)" if ($^O eq 'MSWin32');
 
 my %opt;
-getopts('qOo:f:n:',\%opt);
+# I think these are:
+# -Q to disable the duplicate codepoint test
+# -q to remove comments written to output files
+# -O to enable the (brute force) substring optimiser
+# -o <output> to specify the output file name (else it's the first arg)
+# -f <inlist> to give a file with a list of input files (else use the args)
+# -n <name> to name the encoding (else use the basename of the input file.
+getopts('QqOo:f:n:',\%opt);
+
+# This really should go first, else the die here causes empty (non-erroneous)
+# output files to be written.
+my @encfiles;
+if (exists $opt{'f'}) {
+    # -F is followed by name of file containing list of filenames
+    my $flist = $opt{'f'};
+    open(FLIST,$flist) || die "Cannot open $flist:$!";
+    chomp(@encfiles = <FLIST>);
+    close(FLIST);
+} else {
+    @encfiles = @ARGV;
+}
+
 my $cname = (exists $opt{'o'}) ? $opt{'o'} : shift(@ARGV);
 chmod(0666,$cname) if -f $cname && !-w $cname;
 open(C,">$cname") || die "Cannot open $cname:$!";
 
-
 my $dname = $cname;
-$dname =~ s/(\.[^\.]*)?$/_def.h/;
+my $hname = $cname;
 
 my ($doC,$doEnc,$doUcm,$doPet);
 
 if ($cname =~ /\.(c|xs)$/)
  {
   $doC = 1;
+  $dname =~ s/(\.[^\.]*)?$/_def.h/;
   chmod(0666,$dname) if -f $cname && !-w $dname;
   open(D,">$dname") || die "Cannot open $dname:$!";
-  my $hname = $cname;
   $hname =~ s/(\.[^\.]*)?$/.h/;
   chmod(0666,$hname) if -f $cname && !-w $hname;
   open(H,">$hname") || die "Cannot open $hname:$!";
@@ -173,20 +193,6 @@
   $doPet = 1;
  }
 
-my @encfiles;
-if (exists $opt{'f'})
- {
-  # -F is followed by name of file containing list of filenames
-  my $flist = $opt{'f'};
-  open(FLIST,$flist) || die "Cannot open $flist:$!";
-  chomp(@encfiles = <FLIST>);
-  close(FLIST);
- }
-else
- {
-  @encfiles = @ARGV;
- }
-
 my %encoding;
 my %strings;
 my $saved = 0;
@@ -288,8 +294,9 @@
     print C "#include \"$dname\"\n";
     print C "}\n";
    }
-  close(D);
-  close(H);
+  # Close in void context is bad, m'kay
+  close(D) or warn "Error closing '$dname': $!";
+  close(H) or warn "Error closing '$hname': $!";
 
   my $perc_saved    = $strings/($strings + $saved) * 100;
   my $perc_subsaved = $strings/($strings + $subsave) * 100;
@@ -316,9 +323,11 @@
    }
  }
 
-close(C);
-
+# writing half meg files and then not checking to see if you just filled the
+# disk is bad, m'kay
+close(C) or die "Error closing '$cname': $!";
 
+# End of the main program.
 
 sub compile_ucm
 {
@@ -432,7 +441,9 @@
   my $v = hex($def);
   $rep = &$type_func($v & 0xFF, ($v >> 8) & 0xffe);
  }
- my %seen;
+ my $seen;
+ # use -Q to silence the seen test. Makefile.PL uses this by default.
+ $seen = {} unless $opt{Q};
  do
   {
    my $line = <$fh>;
@@ -463,18 +474,21 @@
          $max_el = $el if $el > $max_el;
          $min_el = $el if $el < $min_el;
          my $uch = encode_U($val);
-         # We don't need to read this quickly, so storing it as a scalar,
-         # rather than 3 (anon array, plus the 2 scalars it holds) saves
-         # RAM and may make us faster on low RAM systems. [see __END__]
-         if (exists $seen{$uch})
-          {
-           warn sprintf("U%04X is %02X%02X and %04X\n",
-                        $val,$page,$ch,$seen{$uch});
-          }
-         else
-          {
-           $seen{$uch} = $page << 8 | $ch;
-          }
+         if ($seen) {
+           # We're doing the test.
+           # We don't need to read this quickly, so storing it as a scalar,
+           # rather than 3 (anon array, plus the 2 scalars it holds) saves
+           # RAM and may make us faster on low RAM systems. [see __END__]
+           if (exists $seen->{$uch})
+             {
+               warn sprintf("U%04X is %02X%02X and %04X\n",
+                            $val,$page,$ch,$seen->{$uch});
+             }
+           else
+             {
+               $seen->{$uch} = $page << 8 | $ch;
+             }
+         }
          # Passing 2 extra args each time is 3.6% slower!
          # Even with having to add $fallback ||= 0 later
          enter_fb0($e2u,$ech,$uch);
@@ -756,7 +770,7 @@
       #foreach my $c (split(//,$out_bytes)) {
       #  $s .= sprintf "\\x%02X",ord($c);
       #}
-      # 9.5% faster changing that lloop to this:
+      # 9.5% faster changing that loop to this:
       $s .= sprintf +("\\x%02X" x length $out_bytes), unpack "C*", $out_bytes;
       $s .= sprintf " |%d # %s\n",($fallback ? 1 : 0),$uname[$u];
       push(@$cmap,$s);
--- ext/Encode/TW/Makefile.PL.orig      Sat Feb 16 17:12:34 2002
+++ ext/Encode/TW/Makefile.PL   Mon Feb 25 20:39:59 2002
@@ -126,7 +126,9 @@
                $continuator = '';
            }
        }
-       $str .= "\n\t\$(PERL) $compile -o \$\@ -f $table.fnm\n\n";
+        $str .= $^O eq 'VMS' # In VMS quote to preserve case
+            ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
+            : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
        open (FILELIST, ">$table.fnm")
            || die "Could not open $table.fnm: $!";
        foreach my $file (@{$tables{$table}})
--- ext/Encode/Makefile.PL.orig Wed Feb  6 21:00:59 2002
+++ ext/Encode/Makefile.PL      Mon Feb 25 20:42:26 2002
@@ -93,11 +93,9 @@
                $continuator = '';
            }
        }
-       if ($^O eq 'VMS' ) { # quote to preserve case
-           $str .= qq{\n\t\$(PERL) compile -"O" -o \$\@ -f $table.fnm\n\n};
-       } else {
-           $str .= qq{\n\t\$(PERL) compile -O -o \$\@ -f $table.fnm\n\n};
-       }
+        $str .= $^O eq 'VMS' # In VMS quote to preserve case
+            ? qq{\n\t\$(PERL) compile -"Q" -"O" -o \$\@ -f $table.fnm\n\n}
+            : qq{\n\t\$(PERL) compile -Q -O -o \$\@ -f $table.fnm\n\n};
        open (FILELIST, ">$table.fnm")
            || die "Could not open $table.fnm: $!";
        foreach my $file (@{$tables{$table}})
--- ext/Encode/KR/Makefile.PL.orig      Sat Feb 16 17:12:34 2002
+++ ext/Encode/KR/Makefile.PL   Mon Feb 25 20:41:46 2002
@@ -126,7 +126,9 @@
                $continuator = '';
            }
        }
-       $str .= "\n\t\$(PERL) $compile -o \$\@ -f $table.fnm\n\n";
+        $str .= $^O eq 'VMS' # In VMS quote to preserve case
+            ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
+            : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
        open (FILELIST, ">$table.fnm")
            || die "Could not open $table.fnm: $!";
        foreach my $file (@{$tables{$table}})
--- ext/Encode/JP/Makefile.PL.orig      Sat Feb 16 17:12:34 2002
+++ ext/Encode/JP/Makefile.PL   Mon Feb 25 20:41:55 2002
@@ -127,7 +127,9 @@
                $continuator = '';
            }
        }
-       $str .= "\n\t\$(PERL) $compile -o \$\@ -f $table.fnm\n\n";
+        $str .= $^O eq 'VMS' # In VMS quote to preserve case
+            ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
+            : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
        open (FILELIST, ">$table.fnm")
            || die "Could not open $table.fnm: $!";
        foreach my $file (@{$tables{$table}})
--- ext/Encode/CN/Makefile.PL.orig      Sat Feb 16 17:12:34 2002
+++ ext/Encode/CN/Makefile.PL   Mon Feb 25 20:42:03 2002
@@ -128,7 +128,9 @@
                $continuator = '';
            }
        }
-       $str .= "\n\t\$(PERL) $compile -o \$\@ -f $table.fnm\n\n";
+        $str .= $^O eq 'VMS' # In VMS quote to preserve case
+            ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
+            : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
        open (FILELIST, ">$table.fnm")
            || die "Could not open $table.fnm: $!";
        foreach my $file (@{$tables{$table}})

Reply via email to