[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp
From: |
Eli Zaretskii |
Subject: |
Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp |
Date: |
Sat, 12 Jan 2019 10:16:32 +0200 |
> Date: Sat, 12 Jan 2019 01:23:34 +0100
> From: Steffen Nurpmeso <address@hidden>
>
> |For platforms which don't have the Posix pathconf, maxfilename.cpp \
> |should try
> |harder, and look at (the ANSI-standard) FILENAME_MAX in addition to \
> |the other
> |varieties. Right now, it decides that NAME_MAX is 14 on MS-Windows, \
> |which of
> |course makes no sense. One adverse effect of this is that temporary file
> |names don't get the "groff" prefix, for no good reason.
>
> Let me be plain one time. The entire stuff that came in for
> Windows polluted the code enormously.
I think FILENAME_MAX is Standard ANSI C symbol, so it can/should be
used for any platform. And anyway, none of the convoluted code in
maxfilename.cpp seems to be for Windows, so I don't think those
complications are "Windows pollution" of any kind.
The patch I propose to fix this is very simple:
--- src/libs/libgroff/maxfilename.cpp~0 2018-10-11 00:44:56.000000000 +0300
+++ src/libs/libgroff/maxfilename.cpp 2019-01-12 09:02:01.119500000 +0200
@@ -36,6 +36,11 @@
#else /* not _POSIX_VERSION */
+#include <stdio.h>
+#ifdef FILENAME_MAX
+# define NAME_MAX FILENAME_MAX
+#endif
+
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#else /* not HAVE_DIRENT_H */
That's it! And it should work for any supported platform, because
FILENAME_MAX is ANSI C89. And since I don't know what all the rest of
#ifdef's is about, you can simply delete it if it's supposed to be for
MS-Windows.
> That thing you say, and there is also PATH_MAX
That's a separate issue, in a separate file maxpathname.cpp. Since
Windows does define PATH_MAX, then again, the convoluted set of
#ifdef's there is not for MS-Windows, AFAIU.
- [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Eli Zaretskii, 2019/01/11
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Steffen Nurpmeso, 2019/01/11
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp,
Eli Zaretskii <=
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Steffen Nurpmeso, 2019/01/12
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Eli Zaretskii, 2019/01/12
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Steffen Nurpmeso, 2019/01/12
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Steffen Nurpmeso, 2019/01/12
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Steffen Nurpmeso, 2019/01/12
- Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp, Eli Zaretskii, 2019/01/12
[bug #55449] Use FILENAME_MAX in maxfilename.cpp, Eli Zaretskii, 2019/01/12