mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-21 09:42:10 +01:00
Mark the functions g_basename and g_dirname deprecated. They will issue an
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gutils.c, glib.h: Mark the functions g_basename and g_dirname deprecated. They will issue an warning once, when compiled with G_ENABLE_DEBUG, but continue to work as before. Instead the functions g_path_get_basename and g_path_get_dirname should be used, which BOTH return newly allocated memory, that has to freed by g_free. The new g_path_get_basename now strips trailing slashes from the path. This fixes #5097. For discussion see http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html * gwin32.c, testglib.c, tests/dirname-test.c: Use the new functions instead of the old ones. * gmodule/libgplugin_a.c, gmodule/testgmodule.c: Use g_path_get_basename instead of the deprecated g_basename.
This commit is contained in:
parent
84114c5321
commit
fec9828ac6
12
ChangeLog
12
ChangeLog
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gutils.c, glib.h: Mark the functions g_basename and g_dirname
|
||||||
|
deprecated. They will issue an warning once, when compiled with
|
||||||
|
G_ENABLE_DEBUG, but continue to work as before. Instead the
|
||||||
|
functions g_path_get_basename and g_path_get_dirname should be
|
||||||
|
used, which BOTH return newly allocated memory, that has to freed
|
||||||
|
by g_free. The new g_path_get_basename now strips trailing slashes
|
||||||
|
from the path. This fixes #5097. For discussion see
|
||||||
|
http://mail.gnome.org/pipermail/gtk-devel-list/2000-April/003139.html
|
||||||
|
|
||||||
|
* gwin32.c, testglib.c, tests/dirname-test.c: Use the new
|
||||||
|
functions instead of the old ones.
|
||||||
|
|
||||||
* ghash.c, gscanner.c, glib.h: Mark the functions
|
* ghash.c, gscanner.c, glib.h: Mark the functions
|
||||||
g_hash_table_freeze, g_hash_table_thaw and thus
|
g_hash_table_freeze, g_hash_table_thaw and thus
|
||||||
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
g_scanner_freeze_symbol_table and g_scanner_thaw_symbol_table
|
||||||
|
11
glib.h
11
glib.h
@ -1701,15 +1701,22 @@ gint g_vsnprintf (gchar *string,
|
|||||||
gulong n,
|
gulong n,
|
||||||
gchar const *format,
|
gchar const *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
gchar* g_basename (const gchar *file_name);
|
|
||||||
/* Check if a file name is an absolute path */
|
/* Check if a file name is an absolute path */
|
||||||
gboolean g_path_is_absolute (const gchar *file_name);
|
gboolean g_path_is_absolute (const gchar *file_name);
|
||||||
/* In case of absolute paths, skip the root part */
|
/* In case of absolute paths, skip the root part */
|
||||||
gchar* g_path_skip_root (gchar *file_name);
|
gchar* g_path_skip_root (gchar *file_name);
|
||||||
|
|
||||||
/* strings are newly allocated with g_malloc() */
|
/* These two functions are deprecated and will be removed in the next
|
||||||
|
* major release of GLib. Use g_path_get_dirname/g_path_get_basename
|
||||||
|
* instead. Whatch out! The string returned by g_path_get_basename
|
||||||
|
* must be g_freed, while the string returned by g_basename must not.*/
|
||||||
|
gchar* g_basename (const gchar *file_name);
|
||||||
gchar* g_dirname (const gchar *file_name);
|
gchar* g_dirname (const gchar *file_name);
|
||||||
|
|
||||||
|
/* The returned strings are newly allocated with g_malloc() */
|
||||||
gchar* g_get_current_dir (void);
|
gchar* g_get_current_dir (void);
|
||||||
|
gchar* g_path_get_basename (const gchar *file_name);
|
||||||
|
gchar* g_path_get_dirname (const gchar *file_name);
|
||||||
|
|
||||||
/* Get the codeset for the current locale */
|
/* Get the codeset for the current locale */
|
||||||
/* gchar * g_get_codeset (void); */
|
/* gchar * g_get_codeset (void); */
|
||||||
|
11
glib/glib.h
11
glib/glib.h
@ -1701,15 +1701,22 @@ gint g_vsnprintf (gchar *string,
|
|||||||
gulong n,
|
gulong n,
|
||||||
gchar const *format,
|
gchar const *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
gchar* g_basename (const gchar *file_name);
|
|
||||||
/* Check if a file name is an absolute path */
|
/* Check if a file name is an absolute path */
|
||||||
gboolean g_path_is_absolute (const gchar *file_name);
|
gboolean g_path_is_absolute (const gchar *file_name);
|
||||||
/* In case of absolute paths, skip the root part */
|
/* In case of absolute paths, skip the root part */
|
||||||
gchar* g_path_skip_root (gchar *file_name);
|
gchar* g_path_skip_root (gchar *file_name);
|
||||||
|
|
||||||
/* strings are newly allocated with g_malloc() */
|
/* These two functions are deprecated and will be removed in the next
|
||||||
|
* major release of GLib. Use g_path_get_dirname/g_path_get_basename
|
||||||
|
* instead. Whatch out! The string returned by g_path_get_basename
|
||||||
|
* must be g_freed, while the string returned by g_basename must not.*/
|
||||||
|
gchar* g_basename (const gchar *file_name);
|
||||||
gchar* g_dirname (const gchar *file_name);
|
gchar* g_dirname (const gchar *file_name);
|
||||||
|
|
||||||
|
/* The returned strings are newly allocated with g_malloc() */
|
||||||
gchar* g_get_current_dir (void);
|
gchar* g_get_current_dir (void);
|
||||||
|
gchar* g_path_get_basename (const gchar *file_name);
|
||||||
|
gchar* g_path_get_dirname (const gchar *file_name);
|
||||||
|
|
||||||
/* Get the codeset for the current locale */
|
/* Get the codeset for the current locale */
|
||||||
/* gchar * g_get_codeset (void); */
|
/* gchar * g_get_codeset (void); */
|
||||||
|
@ -278,6 +278,17 @@ gchar*
|
|||||||
g_basename (const gchar *file_name)
|
g_basename (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gchar *base;
|
register gchar *base;
|
||||||
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
static gboolean first_call = TRUE;
|
||||||
|
|
||||||
|
if (first_call)
|
||||||
|
{
|
||||||
|
g_warning("g_basename is deprecated. Use g_path_get_basename instead.");
|
||||||
|
g_warning("Watch out! You have to g_free the string returned by "
|
||||||
|
"g_path_get_basename.");
|
||||||
|
first_call = FALSE;
|
||||||
|
}
|
||||||
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
g_return_val_if_fail (file_name != NULL, NULL);
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
@ -293,6 +304,52 @@ g_basename (const gchar *file_name)
|
|||||||
return (gchar*) file_name;
|
return (gchar*) file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
g_path_get_basename (const gchar *file_name)
|
||||||
|
{
|
||||||
|
register gint base;
|
||||||
|
register gint last_nonslash;
|
||||||
|
guint len;
|
||||||
|
gchar *retval;
|
||||||
|
|
||||||
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
|
if (file_name[0] == '\0')
|
||||||
|
/* empty string */
|
||||||
|
return g_strdup (".");
|
||||||
|
|
||||||
|
last_nonslash = strlen (file_name) - 1;
|
||||||
|
|
||||||
|
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
||||||
|
last_nonslash--;
|
||||||
|
|
||||||
|
if (last_nonslash == -1)
|
||||||
|
/* string only containing slashes */
|
||||||
|
return g_strdup (G_DIR_SEPARATOR_S);
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
if (last_nonslash == 1 && isalpha (file_name[0]) && file_name[1] == ':')
|
||||||
|
/* string only containing slashes and a drive */
|
||||||
|
return g_strdup (G_DIR_SEPARATOR_S);
|
||||||
|
#endif /* G_OS_WIN32 */
|
||||||
|
|
||||||
|
base = last_nonslash;
|
||||||
|
|
||||||
|
while (base >=0 && file_name [base] != G_DIR_SEPARATOR)
|
||||||
|
base--;
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
if (base == -1 && isalpha (file_name[0]) && file_name[1] == ':')
|
||||||
|
base = 1;
|
||||||
|
#endif /* G_OS_WIN32 */
|
||||||
|
|
||||||
|
len = last_nonslash - base;
|
||||||
|
retval = g_malloc (len + 1);
|
||||||
|
memcpy (retval, file_name + base + 1, len);
|
||||||
|
retval [len] = '\0';
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_path_is_absolute (const gchar *file_name)
|
g_path_is_absolute (const gchar *file_name)
|
||||||
{
|
{
|
||||||
@ -326,7 +383,7 @@ g_path_skip_root (gchar *file_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_dirname (const gchar *file_name)
|
g_path_get_dirname (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gchar *base;
|
register gchar *base;
|
||||||
register guint len;
|
register guint len;
|
||||||
@ -347,6 +404,22 @@ g_dirname (const gchar *file_name)
|
|||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
g_dirname (const gchar *file_name)
|
||||||
|
{
|
||||||
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
static gboolean first_call = TRUE;
|
||||||
|
|
||||||
|
if (first_call)
|
||||||
|
{
|
||||||
|
g_warning("g_dirname is deprecated. Use g_path_get_dirname instead.");
|
||||||
|
first_call = FALSE;
|
||||||
|
}
|
||||||
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
|
return g_path_get_dirname (file_name);
|
||||||
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_get_current_dir (void)
|
g_get_current_dir (void)
|
||||||
{
|
{
|
||||||
|
@ -131,6 +131,7 @@ struct dirent*
|
|||||||
g_win32_readdir (DIR *dir)
|
g_win32_readdir (DIR *dir)
|
||||||
{
|
{
|
||||||
static struct dirent result;
|
static struct dirent result;
|
||||||
|
gchar *basename;
|
||||||
|
|
||||||
g_return_val_if_fail (dir != NULL, NULL);
|
g_return_val_if_fail (dir != NULL, NULL);
|
||||||
|
|
||||||
@ -153,7 +154,12 @@ g_win32_readdir (DIR *dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy (result.d_name, g_basename (((LPWIN32_FIND_DATA) dir->find_file_data)->cFileName));
|
|
||||||
|
basename = g_path_get_basename (((LPWIN32_FIND_DATA) dir->find_file_data)->cFileName);
|
||||||
|
|
||||||
|
strcpy (result.d_name, basename);
|
||||||
|
|
||||||
|
g_free (basename);
|
||||||
|
|
||||||
return &result;
|
return &result;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2000-07-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* libgplugin_a.c, testgmodule.c: Use g_path_get_basename instead
|
||||||
|
of the deprecated g_basename.
|
||||||
|
|
||||||
2000-07-19 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2000-07-19 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* gmodule.h: include glib.h before doing extern "C". Makes some C++
|
* gmodule.h: include glib.h before doing extern "C". Makes some C++
|
||||||
|
@ -56,11 +56,12 @@ gplugin_a_module_func (GModule *module)
|
|||||||
{
|
{
|
||||||
void (*f) (void) = NULL;
|
void (*f) (void) = NULL;
|
||||||
gchar *string;
|
gchar *string;
|
||||||
|
gchar *basename = g_path_get_basename (g_module_name (module));
|
||||||
|
|
||||||
string = "gplugin_say_boo_func";
|
string = "gplugin_say_boo_func";
|
||||||
g_print ("GPluginA: retrive symbol `%s' from \"%s\"\n",
|
g_print ("GPluginA: retrive symbol `%s' from \"%s\"\n",
|
||||||
string,
|
string, basename);
|
||||||
g_basename (g_module_name (module)));
|
g_free (basename);
|
||||||
if (!g_module_symbol (module, string, (gpointer) &f))
|
if (!g_module_symbol (module, string, (gpointer) &f))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
|
@ -46,6 +46,7 @@ main (int arg,
|
|||||||
{
|
{
|
||||||
GModule *module_self, *module_a, *module_b;
|
GModule *module_self, *module_a, *module_b;
|
||||||
gchar *string;
|
gchar *string;
|
||||||
|
gchar *basename;
|
||||||
gchar *plugin_a, *plugin_b;
|
gchar *plugin_a, *plugin_b;
|
||||||
SimpleFunc f_a, f_b, f_self;
|
SimpleFunc f_a, f_b, f_self;
|
||||||
GModuleFunc gmod_f;
|
GModuleFunc gmod_f;
|
||||||
@ -76,7 +77,9 @@ main (int arg,
|
|||||||
}
|
}
|
||||||
g_print ("check that not yet bound symbols in shared libraries of main module are retrievable:\n");
|
g_print ("check that not yet bound symbols in shared libraries of main module are retrievable:\n");
|
||||||
string = "g_module_close";
|
string = "g_module_close";
|
||||||
g_print ("retrive symbol `%s' from \"%s\":\n", string, g_basename (g_module_name (module_self)));
|
basename = g_path_get_basename (g_module_name (module_self));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\":\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
@ -101,14 +104,18 @@ main (int arg,
|
|||||||
/* get plugin specific symbols and call them
|
/* get plugin specific symbols and call them
|
||||||
*/
|
*/
|
||||||
string = "gplugin_a_func";
|
string = "gplugin_a_func";
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a)));
|
basename = g_path_get_basename (g_module_name (module_a));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
string = "gplugin_b_func";
|
string = "gplugin_b_func";
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_b)));
|
basename = g_path_get_basename (g_module_name (module_b));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_b, string, (gpointer) &f_b))
|
if (!g_module_symbol (module_b, string, (gpointer) &f_b))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
@ -122,19 +129,25 @@ main (int arg,
|
|||||||
/* get and call globally clashing functions
|
/* get and call globally clashing functions
|
||||||
*/
|
*/
|
||||||
string = "g_clash_func";
|
string = "g_clash_func";
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_self)));
|
basename = g_path_get_basename (g_module_name (module_self));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a)));
|
basename = g_path_get_basename (g_module_name (module_a));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_b)));
|
basename = g_path_get_basename (g_module_name (module_b));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_b, string, (gpointer) &f_b))
|
if (!g_module_symbol (module_b, string, (gpointer) &f_b))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
@ -150,17 +163,23 @@ main (int arg,
|
|||||||
/* get and call clashing plugin functions
|
/* get and call clashing plugin functions
|
||||||
*/
|
*/
|
||||||
string = "gplugin_clash_func";
|
string = "gplugin_clash_func";
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_self)));
|
basename = g_path_get_basename (g_module_name (module_self));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
if (!g_module_symbol (module_self, string, (gpointer) &f_self))
|
||||||
f_self = NULL;
|
f_self = NULL;
|
||||||
g_print ("retrived function `%s' from self: %p\n", string, f_self);
|
g_print ("retrived function `%s' from self: %p\n", string, f_self);
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a)));
|
basename = g_path_get_basename (g_module_name (module_a));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
if (!g_module_symbol (module_a, string, (gpointer) &f_a))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_b)));
|
basename = g_path_get_basename (g_module_name (module_b));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_b, string, (gpointer) &f_b))
|
if (!g_module_symbol (module_b, string, (gpointer) &f_b))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
@ -176,7 +195,9 @@ main (int arg,
|
|||||||
/* call gmodule function form A
|
/* call gmodule function form A
|
||||||
*/
|
*/
|
||||||
string = "gplugin_a_module_func";
|
string = "gplugin_a_module_func";
|
||||||
g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a)));
|
basename = g_path_get_basename (g_module_name (module_a));
|
||||||
|
g_print ("retrive symbol `%s' from \"%s\"\n", string, basename);
|
||||||
|
g_free (basename);
|
||||||
if (!g_module_symbol (module_a, string, (gpointer) &gmod_f))
|
if (!g_module_symbol (module_a, string, (gpointer) &gmod_f))
|
||||||
{
|
{
|
||||||
g_print ("error: %s\n", g_module_error ());
|
g_print ("error: %s\n", g_module_error ());
|
||||||
|
75
gutils.c
75
gutils.c
@ -278,6 +278,17 @@ gchar*
|
|||||||
g_basename (const gchar *file_name)
|
g_basename (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gchar *base;
|
register gchar *base;
|
||||||
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
static gboolean first_call = TRUE;
|
||||||
|
|
||||||
|
if (first_call)
|
||||||
|
{
|
||||||
|
g_warning("g_basename is deprecated. Use g_path_get_basename instead.");
|
||||||
|
g_warning("Watch out! You have to g_free the string returned by "
|
||||||
|
"g_path_get_basename.");
|
||||||
|
first_call = FALSE;
|
||||||
|
}
|
||||||
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
g_return_val_if_fail (file_name != NULL, NULL);
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
@ -293,6 +304,52 @@ g_basename (const gchar *file_name)
|
|||||||
return (gchar*) file_name;
|
return (gchar*) file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
g_path_get_basename (const gchar *file_name)
|
||||||
|
{
|
||||||
|
register gint base;
|
||||||
|
register gint last_nonslash;
|
||||||
|
guint len;
|
||||||
|
gchar *retval;
|
||||||
|
|
||||||
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
|
if (file_name[0] == '\0')
|
||||||
|
/* empty string */
|
||||||
|
return g_strdup (".");
|
||||||
|
|
||||||
|
last_nonslash = strlen (file_name) - 1;
|
||||||
|
|
||||||
|
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
||||||
|
last_nonslash--;
|
||||||
|
|
||||||
|
if (last_nonslash == -1)
|
||||||
|
/* string only containing slashes */
|
||||||
|
return g_strdup (G_DIR_SEPARATOR_S);
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
if (last_nonslash == 1 && isalpha (file_name[0]) && file_name[1] == ':')
|
||||||
|
/* string only containing slashes and a drive */
|
||||||
|
return g_strdup (G_DIR_SEPARATOR_S);
|
||||||
|
#endif /* G_OS_WIN32 */
|
||||||
|
|
||||||
|
base = last_nonslash;
|
||||||
|
|
||||||
|
while (base >=0 && file_name [base] != G_DIR_SEPARATOR)
|
||||||
|
base--;
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
if (base == -1 && isalpha (file_name[0]) && file_name[1] == ':')
|
||||||
|
base = 1;
|
||||||
|
#endif /* G_OS_WIN32 */
|
||||||
|
|
||||||
|
len = last_nonslash - base;
|
||||||
|
retval = g_malloc (len + 1);
|
||||||
|
memcpy (retval, file_name + base + 1, len);
|
||||||
|
retval [len] = '\0';
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_path_is_absolute (const gchar *file_name)
|
g_path_is_absolute (const gchar *file_name)
|
||||||
{
|
{
|
||||||
@ -326,7 +383,7 @@ g_path_skip_root (gchar *file_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_dirname (const gchar *file_name)
|
g_path_get_dirname (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gchar *base;
|
register gchar *base;
|
||||||
register guint len;
|
register guint len;
|
||||||
@ -347,6 +404,22 @@ g_dirname (const gchar *file_name)
|
|||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
g_dirname (const gchar *file_name)
|
||||||
|
{
|
||||||
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
static gboolean first_call = TRUE;
|
||||||
|
|
||||||
|
if (first_call)
|
||||||
|
{
|
||||||
|
g_warning("g_dirname is deprecated. Use g_path_get_dirname instead.");
|
||||||
|
first_call = FALSE;
|
||||||
|
}
|
||||||
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
|
return g_path_get_dirname (file_name);
|
||||||
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_get_current_dir (void)
|
g_get_current_dir (void)
|
||||||
{
|
{
|
||||||
|
8
gwin32.c
8
gwin32.c
@ -131,6 +131,7 @@ struct dirent*
|
|||||||
g_win32_readdir (DIR *dir)
|
g_win32_readdir (DIR *dir)
|
||||||
{
|
{
|
||||||
static struct dirent result;
|
static struct dirent result;
|
||||||
|
gchar *basename;
|
||||||
|
|
||||||
g_return_val_if_fail (dir != NULL, NULL);
|
g_return_val_if_fail (dir != NULL, NULL);
|
||||||
|
|
||||||
@ -153,7 +154,12 @@ g_win32_readdir (DIR *dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy (result.d_name, g_basename (((LPWIN32_FIND_DATA) dir->find_file_data)->cFileName));
|
|
||||||
|
basename = g_path_get_basename (((LPWIN32_FIND_DATA) dir->find_file_data)->cFileName);
|
||||||
|
|
||||||
|
strcpy (result.d_name, basename);
|
||||||
|
|
||||||
|
g_free (basename);
|
||||||
|
|
||||||
return &result;
|
return &result;
|
||||||
}
|
}
|
||||||
|
@ -378,12 +378,12 @@ main (int argc,
|
|||||||
#endif /* G_HAVE_GINT64 */
|
#endif /* G_HAVE_GINT64 */
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
|
|
||||||
g_print ("checking g_dirname()...");
|
g_print ("checking g_path_get_dirname()...");
|
||||||
for (i = 0; i < n_dirname_checks; i++)
|
for (i = 0; i < n_dirname_checks; i++)
|
||||||
{
|
{
|
||||||
gchar *dirname;
|
gchar *dirname;
|
||||||
|
|
||||||
dirname = g_dirname (dirname_checks[i].filename);
|
dirname = g_path_get_dirname (dirname_checks[i].filename);
|
||||||
if (strcmp (dirname, dirname_checks[i].dirname) != 0)
|
if (strcmp (dirname, dirname_checks[i].dirname) != 0)
|
||||||
{
|
{
|
||||||
g_print ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n",
|
g_print ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n",
|
||||||
|
@ -90,7 +90,7 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
gchar *dirname;
|
gchar *dirname;
|
||||||
|
|
||||||
dirname = g_dirname (dirname_checks[i].filename);
|
dirname = g_path_get_dirname (dirname_checks[i].filename);
|
||||||
g_assert (strcmp (dirname, dirname_checks[i].dirname) == 0);
|
g_assert (strcmp (dirname, dirname_checks[i].dirname) == 0);
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
}
|
}
|
||||||
|
@ -378,12 +378,12 @@ main (int argc,
|
|||||||
#endif /* G_HAVE_GINT64 */
|
#endif /* G_HAVE_GINT64 */
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
|
|
||||||
g_print ("checking g_dirname()...");
|
g_print ("checking g_path_get_dirname()...");
|
||||||
for (i = 0; i < n_dirname_checks; i++)
|
for (i = 0; i < n_dirname_checks; i++)
|
||||||
{
|
{
|
||||||
gchar *dirname;
|
gchar *dirname;
|
||||||
|
|
||||||
dirname = g_dirname (dirname_checks[i].filename);
|
dirname = g_path_get_dirname (dirname_checks[i].filename);
|
||||||
if (strcmp (dirname, dirname_checks[i].dirname) != 0)
|
if (strcmp (dirname, dirname_checks[i].dirname) != 0)
|
||||||
{
|
{
|
||||||
g_print ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n",
|
g_print ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user