[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The next GNU M4

From: Akim Demaille
Subject: Re: The next GNU M4
Date: Thu, 10 Feb 2005 14:05:25 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

I found this in my folder.


From: Akim Demaille <address@hidden>
Subject: The next GNU M4
To: M4 Patches <address@hidden>
Cc: Paul Eggert <address@hidden>
Date: Fri, 12 Sep 2003 09:48:41 +0200
X-Sent: 1 year, 21 weeks, 4 days, 23 hours, 15 minutes, 9 seconds ago

Hi Gary,

I can see that 1.5 is coming, so I'd like to express a few wishes if I
may.  Maybe Paul will also want to say something.

My first request would be not to release the ERE builtins I installed
some time ago in M4, because since then it became clearer that we need
to find a means to address the underquotation issue first.  I think it
would be better to have just two sets of builtins (ERE and quoting
vs. BRE and underquoting) than four.  There are also issues with
hardquotes, yet another future feature, since

       patsubst([[]], [.$])

should result in a _quoted_ bracket, certainly not a live
begin-quotation.  And this cannot be addressed by the sole quotation

The other issue is related to the include path.  Currently `.' is
scanned first and always.  This is bad for some applications.  For
instance, Bison uses M4, and some of the M4 files m4_include other M4
files, such as c.m4.  Paul, in case someone might have a c.m4 in the
current directory, went into all sorts of troubles to hardwire the
paths, so now c.m4 is /usr/local/share/bison/c.m4...  Unfortunately
this also means we completely lost a useful flexibility: today users
cannot use their own skeletons, unless installed in Bison's own

What would be needed is a means to fully reset the include path, and
define it from scratch.  Something like "-I -" maybe.  One must be
able to specify when `.' is tried.  An alternative is to add
--prepend-include, just as autom4te does [1].

Library directories:
  -B, --prepend-include=DIR  prepend directory DIR to search path
  -I, --include=DIR          append directory DIR to search path


[1] By the way, for the same reason as bison does not trust m4 for the
include path, autom4te does not trust m4 and provides it _only_ with
absolute paths.  But because we cannot educate m4_include that will
look into `.' first, we have to surrender, and as m4, for consistency
we have to consider `.' first :(

  # If we find frozen files, then all the files before it are
  # discarded: the frozen file is supposed to include them all.
  # We don't want to depend upon m4's --include to find the top level
  # files, so we use `find_file' here.  Try to get a canonical name,
  # as it's part of the key for caching.  And some files are optional
  # (also handled by `find_file').
  my @argv;
  foreach (@ARGV)
      if (/\.m4f$/)
          # Frozen files are optional => pass a `?' to `find_file'.
          my $file = find_file ("$_?", @include);
          if (!$melt && $file)
              @argv = ($file);
              push @argv, find_file ($_, @include);
          my $file = find_file ($_, @include);
          push @argv, $file
            if $file;
  @ARGV = @argv;


=item C<find_file ($filename, @include)>

Return the first path for a C<$filename> in the C<include>s.

We match exactly the behavior of GNU M4: first look in the current
directory (which includes the case of absolute file names), and, if
the file is not absolute, just fail.  Otherwise, look in C<@include>.

If the file is flagged as optional (ends with C<?>), then return undef
if absent, otherwise exit with error.


# find_file ($FILENAME, @INCLUDE)
# -------------------------------
sub find_file ($@)
  use File::Spec;

  my ($filename, @include) = @_;
  my $optional = 0;

  $optional = 1
    if $filename =~ s/\?$//;

  return File::Spec->canonpath ($filename)
    if -e $filename;

  if (File::Spec->file_name_is_absolute ($filename))
      fatal "$filename: no such file or directory"
        unless $optional;
      return undef;

  foreach my $path (@include)
      return File::Spec->canonpath (File::Spec->catfile ($path, $filename))
        if -e File::Spec->catfile ($path, $filename)

  fatal "$filename: no such file or directory"
    unless $optional;

  return undef;

M4-patches mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]