bug-m4
[Top][All Lists]
Advanced

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

Re: m4 on native Windows


From: Bruno Haible
Subject: Re: m4 on native Windows
Date: Sat, 05 Jun 2021 17:37:35 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; )

Hi Eric,

> > > +++ m4-tmp.432/m4-err     2021-05-14 02:31:09.296595600 +0200
> > > @@ -1,2 +1,2 @@
> > > -C:\cygwin64\home\bruno\m4-2021-05-13\build-mingw64\src\m4.exe:stdin:1: 
> > > Warning: too few arguments to builtin `index'
> > > -C:\cygwin64\home\bruno\m4-2021-05-13\build-mingw64\src\m4.exe:stdin:3: 
> > > Warning: excess arguments to builtin `index' ignored
> > > +m4.exe:stdin:1: Warning: too few arguments to builtin `index'
> > > +m4.exe:stdin:3: Warning: excess arguments to builtin `index' ignored
> > 
> > Failures like this look like we just need to fix the sed script in
> > checks/check-them to properly filter the name output by native
> > Windows.
> 
> I'm still trying to figure out how the names differ.  Can you confirm
> what is output by:
>   src/m4 --help | head -n1

It is:
Usage: C:\cygwin64\home\bruno\m4-2021-05-13\build-mingw64\src\m4.exe 
[OPTION]... [FILE]...

> in that setup?  That output comes from usage() which uses program_name
> directly, while the other messages come from calling error_at_line()
> which uses program_invocation_name (on glibc) or getprogname()
> (otherwise), but as far as I can tell, unless we are running under
> libtool (where getprogname() strips off the lt- prefix), that should
> resolve to the same program_name as just printed in usage().  So what
> is going on differently in your native windows build that is changing
> what error_at_line() produces?

program_name is set through
  set_program_name (argv[0]);
and set_program_name (from lib/progname.c) removes the dirname only in
very specific cases. The comment explains why:

  /* But don't strip off a leading <dirname>/ in general, because when the user
     runs
         /some/hidden/place/bin/cp foo foo
     he should get the error message
         /some/hidden/place/bin/cp: `foo' and `foo' are the same file
     not
         cp: `foo' and `foo' are the same file
   */

What's different between native Windows and other platforms is that,
although you invoke the program with only the basename, the OS passes
the absolute program name as argv[0].

In GNU gettext, I work around this issue in the test suite by post-processing
the stderr output with

  sed -e 's|[^ ]*\\msgfmt\.exe|msgfmt|' -e 's|^msgfmt\.exe|msgfmt|' -e 
's|^/cygdrive/[^ ]*/msgfmt|msgfmt|' | LC_ALL=C tr -d '\r'

A similar thing could be done here:

  sed -e 's|[^ ]*\\m4\.exe|m4|' -e 's|^m4\.exe|m4|' -e 's|^/cygdrive/[^ 
]*/m4|m4|' | LC_ALL=C tr -d '\r'

Bruno




reply via email to

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