@@ -33,7 +33,7 @@ static intwin32_pghardlink(const char *src, const char *dst);
3333static int copy_dir (const char * from ,const char * to ,bool force );
3434#endif
3535
36- #if defined( sun ) || defined( WIN32 )
36+ #ifndef HAVE_SCANDIR
3737static int pg_scandir_internal (migratorContext * ctx ,const char * dirname ,
3838struct dirent * * * namelist ,
3939int (* selector ) (const struct dirent * ));
@@ -235,26 +235,25 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
235235 * pg_scandir()
236236 *
237237 * Wrapper for portable scandir functionality
238- *
239238 */
240239int
241240pg_scandir (migratorContext * ctx ,const char * dirname ,
242241struct dirent * * * namelist ,
243242int (* selector ) (const struct dirent * ))
244243{
245- #if defined( sun ) || defined( WIN32 )
244+ #ifndef HAVE_SCANDIR
246245return pg_scandir_internal (ctx ,dirname ,namelist ,selector );
247246
248247/*
248+ * scandir() is originally from BSD 4.3, which had the third argument as
249+ * non-const. Linux and other C libraries have updated it to use a const.
250+ * http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg00214.html
251+ *
249252 * Here we try to guess which libc's need const, and which don't. The net
250- * goal here is to try tosupress a compiler warning due to a prototype
253+ * goal here is to try tosuppress a compiler warning due to a prototype
251254 * mismatch of const usage. Ideally we would do this via autoconf, but
252- * Postgres's autoconf doesn't test for this and it is overkill to add
253- * autoconf just for this. scandir() is from BSD 4.3, which had the third
254- * argument as non-const. Linux and other C libraries have updated it to
255- * use a const.
256- * http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg002
257- * 14.html
255+ * autoconf doesn't have a suitable builtin test and it seems overkill
256+ * to add one just to avoid a warning.
258257 */
259258#elif defined(freebsd )|| defined(bsdi )|| defined(darwin )|| defined(openbsd )
260259/* no const */
@@ -266,19 +265,18 @@ pg_scandir(migratorContext *ctx, const char *dirname,
266265}
267266
268267
269- #if defined( sun ) || defined( WIN32 )
268+ #ifndef HAVE_SCANDIR
270269/*
271270 * pg_scandir_internal()
272271 *
273- * We'll provide our own scandir function for sun, since it is not
274- * part of the standard system library.
272+ * Implement our own scandir() on platforms that don't have it.
275273 *
276274 * Returns count of files that meet the selection criteria coded in
277275 * the function pointed to by selector. Creates an array of pointers
278276 * to dirent structures. Address of array returned in namelist.
279277 *
280278 * Note that the number of dirent structures needed is dynamically
281- * allocated using realloc. Realloc can beinneficient if invoked a
279+ * allocated using realloc. Realloc can beinefficient if invoked a
282280 * large number of times. Its use in pg_upgrade is to find filesystem
283281 * filenames that have extended beyond the initial segment (file.1,
284282 * .2, etc.) and should therefore be invoked a small number of times.