mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-03 12:36:53 +02:00
Make g_get_current_dir work on systems with unlimited pathname length like
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gutils.c (g_get_current_dir): Make g_get_current_dir work on systems with unlimited pathname length like the HURD (It worked there before, but only for pathes shorter than 2048). Closes Bug#4525 as reported by Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>.
This commit is contained in:
parent
692ce67892
commit
2c4b4788fd
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gutils.c (g_get_current_dir): Make g_get_current_dir work on
|
||||
systems with unlimited pathname length like the HURD (It worked
|
||||
there before, but only for pathes shorter than 2048). Closes
|
||||
Bug#4525 as reported by Marcus Brinkmann
|
||||
<Marcus.Brinkmann@ruhr-uni-bochum.de>.
|
||||
|
||||
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* giounix.c (g_io_unix_write, g_io_unix_read): Interpret EINTR as
|
||||
|
@ -67,12 +67,14 @@
|
||||
#include "glib.h"
|
||||
|
||||
#ifdef MAXPATHLEN
|
||||
#define G_PATH_LENGTH (MAXPATHLEN + 1)
|
||||
#define G_PATH_LENGTH MAXPATHLEN
|
||||
#elif defined (PATH_MAX)
|
||||
#define G_PATH_LENGTH (PATH_MAX + 1)
|
||||
#else /* !MAXPATHLEN */
|
||||
#define G_PATH_LENGTH (2048 + 1)
|
||||
#endif /* !MAXPATHLEN && !PATH_MAX */
|
||||
#define G_PATH_LENGTH PATH_MAX
|
||||
#elif defined (_PC_PATH_MAX)
|
||||
#define G_PATH_LENGTH sysconf(_PC_PATH_MAX)
|
||||
#else
|
||||
#define G_PATH_LENGTH 2048
|
||||
#endif
|
||||
|
||||
const guint glib_major_version = GLIB_MAJOR_VERSION;
|
||||
const guint glib_minor_version = GLIB_MINOR_VERSION;
|
||||
@ -334,17 +336,28 @@ g_get_current_dir (void)
|
||||
{
|
||||
gchar *buffer;
|
||||
gchar *dir;
|
||||
|
||||
buffer = g_new (gchar, G_PATH_LENGTH);
|
||||
*buffer = 0;
|
||||
static gulong max_len = (G_PATH_LENGTH == -1) ? 2048 : G_PATH_LENGTH;
|
||||
|
||||
/* We don't use getcwd(3) on SUNOS, because, it does a popen("pwd")
|
||||
* and, if that wasn't bad enough, hangs in doing so.
|
||||
*/
|
||||
#if defined (sun) && !defined (__SVR4)
|
||||
buffer = g_new (gchar, max_len + 1);
|
||||
*buffer = 0;
|
||||
dir = getwd (buffer);
|
||||
#else /* !sun */
|
||||
dir = getcwd (buffer, G_PATH_LENGTH - 1);
|
||||
while (1)
|
||||
{
|
||||
buffer = g_new (gchar, max_len + 1);
|
||||
*buffer = 0;
|
||||
dir = getcwd (buffer, max_len);
|
||||
|
||||
if (dir || errno != ERANGE)
|
||||
break;
|
||||
|
||||
g_free (buffer);
|
||||
max_len *= 2;
|
||||
}
|
||||
#endif /* !sun */
|
||||
|
||||
if (!dir || !*buffer)
|
||||
|
31
gutils.c
31
gutils.c
@ -67,12 +67,14 @@
|
||||
#include "glib.h"
|
||||
|
||||
#ifdef MAXPATHLEN
|
||||
#define G_PATH_LENGTH (MAXPATHLEN + 1)
|
||||
#define G_PATH_LENGTH MAXPATHLEN
|
||||
#elif defined (PATH_MAX)
|
||||
#define G_PATH_LENGTH (PATH_MAX + 1)
|
||||
#else /* !MAXPATHLEN */
|
||||
#define G_PATH_LENGTH (2048 + 1)
|
||||
#endif /* !MAXPATHLEN && !PATH_MAX */
|
||||
#define G_PATH_LENGTH PATH_MAX
|
||||
#elif defined (_PC_PATH_MAX)
|
||||
#define G_PATH_LENGTH sysconf(_PC_PATH_MAX)
|
||||
#else
|
||||
#define G_PATH_LENGTH 2048
|
||||
#endif
|
||||
|
||||
const guint glib_major_version = GLIB_MAJOR_VERSION;
|
||||
const guint glib_minor_version = GLIB_MINOR_VERSION;
|
||||
@ -334,17 +336,28 @@ g_get_current_dir (void)
|
||||
{
|
||||
gchar *buffer;
|
||||
gchar *dir;
|
||||
|
||||
buffer = g_new (gchar, G_PATH_LENGTH);
|
||||
*buffer = 0;
|
||||
static gulong max_len = (G_PATH_LENGTH == -1) ? 2048 : G_PATH_LENGTH;
|
||||
|
||||
/* We don't use getcwd(3) on SUNOS, because, it does a popen("pwd")
|
||||
* and, if that wasn't bad enough, hangs in doing so.
|
||||
*/
|
||||
#if defined (sun) && !defined (__SVR4)
|
||||
buffer = g_new (gchar, max_len + 1);
|
||||
*buffer = 0;
|
||||
dir = getwd (buffer);
|
||||
#else /* !sun */
|
||||
dir = getcwd (buffer, G_PATH_LENGTH - 1);
|
||||
while (1)
|
||||
{
|
||||
buffer = g_new (gchar, max_len + 1);
|
||||
*buffer = 0;
|
||||
dir = getcwd (buffer, max_len);
|
||||
|
||||
if (dir || errno != ERANGE)
|
||||
break;
|
||||
|
||||
g_free (buffer);
|
||||
max_len *= 2;
|
||||
}
|
||||
#endif /* !sun */
|
||||
|
||||
if (!dir || !*buffer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user