{"thread":{"id":"12494","subject":"[PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","startedAt":"2008-03-04T14:14:42Z","lastAt":"2008-03-04T16:22:35Z","messageCount":6,"participants":["Michal Rokos","Johannes Schindelin","Mike Ralphson"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"70944","messageId":"200803041514.42783.michal.rokos@nextsoft.cz","threadId":"12494","inReplyTo":null,"subject":"[PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","fromName":"Michal Rokos","fromEmail":"michal.rokos@nextsoft.cz","sentAt":"2008-03-04T14:14:42Z","receivedAt":"2008-03-04T14:14:42Z","isPatch":true,"sender":{"key":"michal.rokos@nextsoft.cz","avatar":null},"body":"Add test for FREAD_READS_DIRECTORIES to configure script.\n\nWhen \".\" could be opened and fread reads more than 0 items, \nFREAD_READS_DIRECTORIES will be set.\n\nSigned-off-by: Michal Rokos <michal.rokos@nextsoft.cz>\n\ndiff --git a/config.mak.in b/config.mak.in\nindex ee6c33d..516c468 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -46,3 +46,4 @@ NO_MKDTEMP=@NO_MKDTEMP@\n NO_ICONV=@NO_ICONV@\n OLD_ICONV=@OLD_ICONV@\n NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@\n+FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@\ndiff --git a/configure.ac b/configure.ac\nindex 85d7ef5..8f748a9 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -326,6 +326,27 @@ else\n \tNO_C99_FORMAT=\n fi\n AC_SUBST(NO_C99_FORMAT)\n+#\n+# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds\n+# when attempting to read from an fopen'ed directory.\n+AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],\n+ [ac_cv_fread_reads_directories],\n+[\n+AC_RUN_IFELSE(\n+\t[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n+\t\t[[char c;\n+\t\tFILE *f = fopen(\".\", \"r\");\n+\t\tif (! f) return 0;\n+\t\tif (f && fread(&c, 1, 1, f) > 0) return 1]])],\n+\t[ac_cv_fread_reads_directories=no],\n+\t[ac_cv_fread_reads_directories=yes])\n+])\n+if test $ac_cv_fread_reads_directories = yes; then\n+\tFREAD_READS_DIRECTORIES=UnfortunatelyYes\n+else\n+\tFREAD_READS_DIRECTORIES=\n+fi\n+AC_SUBST(FREAD_READS_DIRECTORIES)\n \n \n ## Checks for library functions.\n"},{"id":"70949","messageId":"alpine.LSU.1.00.0803041458220.22527@racer.site","threadId":"12494","inReplyTo":"200803041514.42783.michal.rokos@nextsoft.cz","subject":"Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-04T14:59:02Z","receivedAt":"2008-03-04T14:59:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 4 Mar 2008, Michal Rokos wrote:\n\n> +AC_RUN_IFELSE(\n> +\t[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n> +\t\t[[char c;\n> +\t\tFILE *f = fopen(\".\", \"r\");\n> +\t\tif (! f) return 0;\n> +\t\tif (f && fread(&c, 1, 1, f) > 0) return 1]])],\n> +\t[ac_cv_fread_reads_directories=no],\n> +\t[ac_cv_fread_reads_directories=yes])\n\nI do not see the issue addressed that I saw on msysGit.\n\nCiao,\nDscho\n"},{"id":"70956","messageId":"200803041630.07585.michal.rokos@nextsoft.cz","threadId":"12494","inReplyTo":"alpine.LSU.1.00.0803041458220.22527@racer.site","subject":"Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","fromName":"Michal Rokos","fromEmail":"michal.rokos@nextsoft.cz","sentAt":"2008-03-04T15:30:07Z","receivedAt":"2008-03-04T15:30:07Z","isPatch":true,"sender":{"key":"michal.rokos@nextsoft.cz","avatar":null},"body":"Hello,\n\nOn Tuesday 04 March 2008 15:59:02 Johannes Schindelin wrote:\n> On Tue, 4 Mar 2008, Michal Rokos wrote:\n> > +AC_RUN_IFELSE(\n> > +\t[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n> > +\t\t[[char c;\n> > +\t\tFILE *f = fopen(\".\", \"r\");\n> > +\t\tif (! f) return 0;\n> > +\t\tif (f && fread(&c, 1, 1, f) > 0) return 1]])],\n> > +\t[ac_cv_fread_reads_directories=no],\n> > +\t[ac_cv_fread_reads_directories=yes])\n>\n> I do not see the issue addressed that I saw on msysGit.\n\nahh, sorry I've included some old one. Now it's\n+AC_RUN_IFELSE(\n+\t[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n+\t\t[[char c;\n+\t\tFILE *f = fopen(\".\", \"r\");\n+\t\treturn f && fread(&c, 1, 1, f)]])],\n+\t[ac_cv_fread_reads_directories=no],\n+\t[ac_cv_fread_reads_directories=yes])\n\nI've tried to reproduce, but I failed to do so. When I put \"return 0;\" it \ndetect that \"no\"; when I return something else, \"yes\" is detected - as it \nshould.\n\nThe C snippet in configure script looks like:\n$ac_includes_default\nint\nmain ()\n{\nchar c;\n                FILE *f = fopen(\".\", \"r\");\n                return f && fread(&c, 1, 1, f)\n  ;\n  return 0;\n}\n\nDoes your autoconf create the same thing?\n\nMichal\n"},{"id":"70957","messageId":"e2b179460803040732k222651c2vdb04e553b8137891@mail.gmail.com","threadId":"12494","inReplyTo":"200803041514.42783.michal.rokos@nextsoft.cz","subject":"Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","fromName":"Mike Ralphson","fromEmail":"mike.ralphson@gmail.com","sentAt":"2008-03-04T15:32:49Z","receivedAt":"2008-03-04T15:32:49Z","isPatch":true,"sender":{"key":"mike.ralphson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/21603?v=4"},"body":"On 04/03/2008, Michal Rokos <michal.rokos@nextsoft.cz> wrote:\n> Add test for FREAD_READS_DIRECTORIES to configure script.\n>\n>  When \".\" could be opened and fread reads more than 0 items,\n>  FREAD_READS_DIRECTORIES will be set.\n\nOn AIX 5.3 this appears to work correctly, i.e. it defines\nFREAD_READS_DIRECTORIES\n\nI've negatively tested it just by swapping the return values.\n\nIt is susceptible to failing for other reasons than those expected\n(i.e. the configure script gets the libsocket test wrong on my\nplatform if I forget to amend CFLAGS because libg is not available,\nand then various tests including this one fail because libsocket is\nerroneously linked in and the test programs fail to compile at all),\nbut that is I think a wider issue with autoconf tests in general.\n\nSo, with those caveats:\n\nTested-by: Mike Ralphson <mike@abacus.co.uk>\n\nPatch to set this option by default on AIX for the non-autoconf\nMakefile to follow.\n"},{"id":"70961","messageId":"alpine.LSU.1.00.0803041558020.22527@racer.site","threadId":"12494","inReplyTo":"200803041630.07585.michal.rokos@nextsoft.cz","subject":"Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-04T16:01:44Z","receivedAt":"2008-03-04T16:01:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 4 Mar 2008, Michal Rokos wrote:\n\n> On Tuesday 04 March 2008 15:59:02 Johannes Schindelin wrote:\n> > On Tue, 4 Mar 2008, Michal Rokos wrote:\n> > > +AC_RUN_IFELSE(\n> > > +\t[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n> > > +\t\t[[char c;\n> > > +\t\tFILE *f = fopen(\".\", \"r\");\n> > > +\t\tif (! f) return 0;\n> > > +\t\tif (f && fread(&c, 1, 1, f) > 0) return 1]])],\n> > > +\t[ac_cv_fread_reads_directories=no],\n> > > +\t[ac_cv_fread_reads_directories=yes])\n> >\n> > I do not see the issue addressed that I saw on msysGit.\n> \n> ahh, sorry I've included some old one. Now it's\n> +AC_RUN_IFELSE(\n> +\t[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n> +\t\t[[char c;\n> +\t\tFILE *f = fopen(\".\", \"r\");\n> +\t\treturn f && fread(&c, 1, 1, f)]])],\n> +\t[ac_cv_fread_reads_directories=no],\n> +\t[ac_cv_fread_reads_directories=yes])\n> \n> I've tried to reproduce, but I failed to do so. When I put \"return 0;\" it \n> detect that \"no\"; when I return something else, \"yes\" is detected - as it \n> should.\n\nI finally figured out what is going wrong.\n\nBut first let me say what a PITA it is to debug configure.  It is utterly, \ncompletely painful!  When you insert random \"exit\"s, like you usually do \nwith scripts that are too garbled and complex and ugly to understand (the \nworst Perl code I ever saw was not as ugly), it does not exit _at all_!\n\nTurns out that the compilation fails:\n\n\t...\\ld.exe: cannot find -lsocket 1 exit status\n\nNice.\n\nFWIW it tries to link with\n\n\tcc -o conftest.exe -g -O2   conftest.c  -liconv -lsocket >&5\n\nHth,\nDscho\n\n"},{"id":"70973","messageId":"e2b179460803040822v1161190n45c6080da36700c9@mail.gmail.com","threadId":"12494","inReplyTo":"e2b179460803040732k222651c2vdb04e553b8137891@mail.gmail.com","subject":"Fwd: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES","fromName":"Mike Ralphson","fromEmail":"mike.ralphson@gmail.com","sentAt":"2008-03-04T16:22:35Z","receivedAt":"2008-03-04T16:22:35Z","isPatch":true,"sender":{"key":"mike.ralphson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/21603?v=4"},"body":"On 04/03/2008, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>  On Tue, 4 Mar 2008, Michal Rokos wrote:\n>\n>  > On Tuesday 04 March 2008 15:59:02 Johannes Schindelin wrote:\n>  > > On Tue, 4 Mar 2008, Michal Rokos wrote:\n>  > > > +AC_RUN_IFELSE(\n>  > > > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n>  > > > +         [[char c;\n>  > > > +         FILE *f = fopen(\".\", \"r\");\n>  > > > +         if (! f) return 0;\n>  > > > +         if (f && fread(&c, 1, 1, f) > 0) return 1]])],\n>  > > > + [ac_cv_fread_reads_directories=no],\n>  > > > + [ac_cv_fread_reads_directories=yes])\n>  > >\n>  > > I do not see the issue addressed that I saw on msysGit.\n>  >\n>  > ahh, sorry I've included some old one. Now it's\n>  > +AC_RUN_IFELSE(\n>  > +     [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],\n>  > +             [[char c;\n>  > +             FILE *f = fopen(\".\", \"r\");\n>  > +             return f && fread(&c, 1, 1, f)]])],\n>  > +     [ac_cv_fread_reads_directories=no],\n>  > +     [ac_cv_fread_reads_directories=yes])\n>  >\n>  > I've tried to reproduce, but I failed to do so. When I put \"return 0;\" it\n>  > detect that \"no\"; when I return something else, \"yes\" is detected - as it\n>  > should.\n>\n>\n> I finally figured out what is going wrong.\n>\n>  But first let me say what a PITA it is to debug configure.  It is utterly,\n>  completely painful!  When you insert random \"exit\"s, like you usually do\n>  with scripts that are too garbled and complex and ugly to understand (the\n>  worst Perl code I ever saw was not as ugly), it does not exit _at all_!\n>\n>  Turns out that the compilation fails:\n>\n>         ...\\ld.exe: cannot find -lsocket 1 exit status\n>\n>  Nice.\n>\n>  FWIW it tries to link with\n>\n>         cc -o conftest.exe -g -O2   conftest.c  -liconv -lsocket >&5\n>\n\nShould probably have copied you on the mail below. Seems like you hit\na similar problem.\n\nWith configure you have to always go back to the initial failure\n(which may have been reported as a success!) as all subsequent test\nresults could be invalid.\n\nEither the test to see whether gcc accepts -g is flawed (it doesn't\ncheck whether it actually works, only that the gcc wrapper accepts it;\nor -g only works if libg is available, and it fails to test for\nthat...\n\n---------- Forwarded message ----------\nFrom: Mike Ralphson <mike.ralphson@gmail.com>\nDate: 4 Mar 2008 15:32\nSubject: Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES\nTo: Michal Rokos <michal.rokos@nextsoft.cz>\nCc: GIT <git@vger.kernel.org>\n\n\nOn 04/03/2008, Michal Rokos <michal.rokos@nextsoft.cz> wrote:\n > Add test for FREAD_READS_DIRECTORIES to configure script.\n >\n >  When \".\" could be opened and fread reads more than 0 items,\n >  FREAD_READS_DIRECTORIES will be set.\n\n\nOn AIX 5.3 this appears to work correctly, i.e. it defines\n FREAD_READS_DIRECTORIES\n\n I've negatively tested it just by swapping the return values.\n\n It is susceptible to failing for other reasons than those expected\n (i.e. the configure script gets the libsocket test wrong on my\n platform if I forget to amend CFLAGS because libg is not available,\n and then various tests including this one fail because libsocket is\n erroneously linked in and the test programs fail to compile at all),\n but that is I think a wider issue with autoconf tests in general.\n\n So, with those caveats:\n\n Tested-by: Mike Ralphson <mike@abacus.co.uk>\n\n Patch to set this option by default on AIX for the non-autoconf\n Makefile to follow.\n"}]}