Hi Collin, > This patch fixes the following test failure: > > ./test-emacs-1.out tmp52599-out differ: byte 37757, line 896 > --- ./test-emacs-1.out 2024-03-24 03:30:48.285074696 -0700 > +++ tmp52599-out 2024-03-25 02:01:39.966937097 -0700 > @@ -893,6 +893,10 @@ > Finished. > > You may need to add #include directives for the following .h files. > + # include <sys/socket.h> > + # include <ws2tcpip.h> > + #elif HAVE_WS2TCPIP_H > + #endif > #include <alloca.h> > #include <byteswap.h> > #include <dirent.h> > @@ -913,6 +917,7 @@ > #include <sys/select.h> > #include <sys/stat.h> > #include <sys/time.h> > + #include <sys/types.h> > #include <time.h> > #include <unistd.h> > #include "acl.h" > @@ -947,12 +952,7 @@ > #include "tempname.h" > #include "timespec.h" > #include "unlocked-io.h" > - #include <sys/types.h> > #if HAVE_SYS_SOCKET_H > - # include <sys/socket.h> > - #elif HAVE_WS2TCPIP_H > - # include <ws2tcpip.h> > - #endif > ... > The incorrect behavior of gnulib-tool.py is because it processes each > 'Include:' section line by line. The behavior of gnulib-tool.sh is to > first determine if the entire 'Include:' section contains #if's. If it > does than all lines are stored separately. If not all lines matching > '#include "*' are separated from those who don't.
Yes, it makes no sense to separate the #if lines from the lines that follow it. > I say that this is slightly misleading because #include <sys/types.h> > is after #include "..."'s even though it is not nested under an #if. > > This is because of socklen and the actual process for sorting: > > #include <sys/types.h> > #if HAVE_SYS_SOCKET_H > # include <sys/socket.h> > #elif HAVE_WS2TCPIP_H > # include <ws2tcpip.h> > #endif I don't see it as misleading. In test-wget2-1.out, the '#include <sys/types.h>' occurs a second time, but that's for a good reason. Thanks, applied with a tweak. (One could alternatively use a regular expression here.) 2024-03-25 Bruno Haible <br...@clisp.org> gnulib-tool.py: Tweak last change. * pygnulib/GLImport.py (GLImport.execute): Recognize #if also at the beginning of an Include snippet. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 5de9cdfc47..1a45776f4f 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -1448,7 +1448,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix include_if = [] for module in modules: include = module.getInclude() - if '\n#if' in include: + if '\n#if' in '\n'+include: include_if += [ f' {line}' for line in include.split('\n') if line.strip() ]