Re: 57-my-last-mying-changes.patch

2001-02-24 Thread Tom Tromey

> "Derek" == Derek R Price <[EMAIL PROTECTED]> writes:

Derek>  require 5.004;
Derek>  use IO::File;

Derek>  my $fh = new IO::File "< filetoread";
Derek>  while ($fh->getline)
Derek>  {
Derek>  dostuff $_;
Derek>  }

Switching automake to use this would be good.

Tom




Re: 57-my-last-mying-changes.patch

2001-02-23 Thread Derek R. Price

Tom Tromey wrote:

> > "Akim" == Akim Demaille <[EMAIL PROTECTED]> writes:
>
> Akim> Six, six for them! (I'm not counting those for file handles,
> Akim> which perl refuses as my, not sure to understand why).
>
> The way file handles work is another reason to dislike Perl.  At
> least, I've always found them confusing.

The Perl5 file handles are different.  This example is for reading a file.
Really, the arguments to "new" are the same arguments open accepted.:


 require 5.004;
 use IO::File;

 my $fh = new IO::File "< filetoread";
 while ($fh->getline)
 {
 dostuff $_;
 }

The other functions available for old style file handles are similar.  These
are just front ends for the old Perl builtins, but context switching just
happens automatically now.  e.g. $fh->eof, $fh->print, $fh->open (usually
called implicitly with arguments to new), $fh->close (unnecessary - "undef
$fh" will autoclose), $fh->autoflush, $fh->fileno, etc.

"$fh->getlines;" will work like calling <$fh> in an array context.

"my $line = $fh->getline;" & "my @lines = $fh->getlines;" (to read an entire
file) are valid constructs.  I don't remember if the same was true of <>, but
I think so.

P.S.  You probably won't need to know, but Perl5 prior to 5.004 used
FileHandle in lieu of IO::File, and FileHandle is still supported as a front
end for IO::File, but is deprecated.

Derek

--
Derek Price  CVS Solutions Architect ( http://CVSHome.org )
mailto:[EMAIL PROTECTED] OpenAvenue ( http://OpenAvenue.com )
--
As honest as the day is long.

- S. Z. Sakall as Headwaiter Carl, _Casablanca_







Re: 57-my-last-mying-changes.patch

2001-02-22 Thread Tom Tromey

> "Akim" == Akim Demaille <[EMAIL PROTECTED]> writes:

Akim> Six, six for them! (I'm not counting those for file handles,
Akim> which perl refuses as my, not sure to understand why).

The way file handles work is another reason to dislike Perl.  At
least, I've always found them confusing.

Akim>   * automake.in: Mying changes.
Akim>   * Makefile.am (maintainer-check): Check the stability of the
Akim>   number of uses of `local'.

This is ok if you make one small change.

Akim> +   [0-5] ) \
Akim> + echo "Wow, congrats!  There are $$locals \`local' now!." >&2; \
Akim> + echo "Please update Makefile.am (maintainer-check)." >&2; \
Akim> +   ;; \

I think this case should `exit 1'.
We expect exactly a certain number.
If this changes then there is a bug -- either one got deleted by
accident, or the person forgot to update Makefile.am.

Tom




57-my-last-mying-changes.patch

2001-02-22 Thread Akim Demaille

Six, six for them! (I'm not counting those for file handles, which
perl refuses as my, not sure to understand why).


Index: ChangeLog
from  Akim Demaille  <[EMAIL PROTECTED]>

* automake.in: Mying changes.
* Makefile.am (maintainer-check): Check the stability of the
number of uses of `local'.

Index: Makefile.am
--- Makefile.am Mon, 19 Feb 2001 02:58:32 +0100 akim (am/f/46_Makefile.a 1.8 644)
+++ Makefile.am Thu, 22 Feb 2001 21:57:20 +0100 akim (am/f/46_Makefile.a 1.8 644)
@@ -109,6 +109,25 @@
  echo "Using @_ in a scalar context in the lines above." 1>&2; \
  exit 1; \
fi
+## Forbid using parens with `local' to ease counting.
+   @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
+ echo "Don't use \`local' with parens: use several \`local' above." >&2; \
+ exit 1; \
+   fi
+## Up to now we manage to limit to 6 uses of local.
+   @locals=`grep -c '^[ \t]*local [^*]' $(srcdir)/automake.in`; \
+   case $$locals in \
+ [0-5] ) \
+   echo "Wow, congrats!  There are $$locals \`local' now!." >&2; \
+   echo "Please update Makefile.am (maintainer-check)." >&2; \
+ ;; \
+ 6 ) ;; \
+ * ) \
+   echo "Too many \`local'!  Are you sure you need $$locals of them?" >&2; \
+   echo "Up to now 6 was enough." >&2; \
+   exit 1; \
+ ;; \
+   esac

 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
Index: Makefile.in
--- Makefile.in Wed, 21 Feb 2001 21:04:28 +0100 akim (am/h/16_Makefile.i 1.18 644)
+++ Makefile.in Thu, 22 Feb 2001 21:57:23 +0100 akim (am/h/16_Makefile.i 1.18 644)
@@ -659,6 +659,23 @@
  echo "Using @_ in a scalar context in the lines above." 1>&2; \
  exit 1; \
fi
+   @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
+ echo "Don't use \`local' with parens: use several \`local' above." >&2; \
+ exit 1; \
+   fi
+   @locals=`grep -c '^[ \t]*local [^*]' $(srcdir)/automake.in`; \
+   case $$locals in \
+ [0-5] ) \
+   echo "Wow, congrats!  There are $$locals \`local' now!." >&2; \
+   echo "Please update Makefile.am (maintainer-check)." >&2; \
+ ;; \
+ 6 ) ;; \
+ * ) \
+   echo "Too many \`local'!  Are you sure you need $$locals of them?" >&2; \
+   echo "Up to now 6 was enough." >&2; \
+   exit 1; \
+ ;; \
+   esac

 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
Index: automake.in
--- automake.in Thu, 22 Feb 2001 21:07:21 +0100 akim (am/f/39_automake.i 1.64 755)
+++ automake.in Thu, 22 Feb 2001 21:47:54 +0100 akim (am/f/39_automake.i 1.64 755)
@@ -4117,7 +4117,7 @@ sub scan_autoconf_config_files
 sub scan_autoconf_traces
 {
 my ($filename) = @_;
-local (*TRACES);
+local *TRACES;

 my $traces = "$ENV{amtraces} ";

@@ -4176,7 +4176,7 @@ sub scan_autoconf_traces
 sub scan_one_autoconf_file
 {
 my ($filename) = @_;
-local (*CONFIGURE);
+local *CONFIGURE;

 open (CONFIGURE, $filename)
|| die "automake: couldn't open \`$filename': $!\n";
@@ -4518,7 +4518,8 @@ sub scan_autoconf_files
 %libsources = ();

 # Watchout: these guys need dynamic scope!
-local (%make_list, @make_input_list);
+local %make_list;
+local @make_input_list;

 warn "automake: both \`configure.ac' and \`configure.in' present:"
  . " ignoring \`configure.in'\n"
@@ -4563,7 +4564,8 @@ sub scan_autoconf_files
 # check must be done for every run, even those where we are only
 # looking at a subdir Makefile.  We must set relative_dir so that
 # the file-finding machinery works.
-local ($relative_dir) = '.';
+# Needs dynamic scopes.
+local $relative_dir = '.';
 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
 if -f $config_aux_path[0] . '/install.sh';
@@ -4657,7 +4659,7 @@ sub lang_sub_obj
 # Rewrite a single C source file.
 sub lang_c_rewrite
 {
-local ($directory, $base, $ext) = @_;
+my ($directory, $base, $ext) = @_;

 if (defined $options{'ansi2knr'} && $base =~ /_$/)
 {
@@ -4665,7 +4667,7 @@ sub lang_c_rewrite
&am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
 }

-local ($r) = $LANG_PROCESS;
+my $r = $LANG_PROCESS;
 if (defined $options{'subdir-objects'})
 {
$r = $LANG_SUBDIR;
@@ -4705,8 +4707,8 @@ sub lang_yacc_rewrite
 {
 my ($directory, $base, $ext) = @_;

-local ($r) = &lang_c_rewrite ($directory, $base, $ext);
-local ($pfx) = '';
+my $r = &lang_c_rewrite ($directory, $base, $ext);
+my $pfx = '';
 if ($r == $LANG_SUBDIR)
 {
$pfx = $directory . '/';
@@