* libltdl/lt__private.h (streq, strneq): New macros to make strcmp

calls as used for simple comparison easier to read.
* libltdl/loaders/dyld.c, libltdl/loaders/preopen.c,
libltdl/ltdl.c: Use them!
This commit is contained in:
Gary V. Vaughan 2004-07-15 12:20:15 +00:00
parent 706e672811
commit 4257156873
5 changed files with 28 additions and 15 deletions

View File

@ -1,3 +1,10 @@
2004-07-15 Gary V. Vaughan <gary@gnu.org>
* libltdl/lt__private.h (streq, strneq): New macros to make strcmp
calls as used for simple comparison easier to read.
* libltdl/loaders/dyld.c, libltdl/loaders/preopen.c,
libltdl/ltdl.c: Use them!
2004-07-15 Gary V. Vaughan <gary@gnu.org>
This pervasive changeset makes two intertwined deep changes to the

View File

@ -390,7 +390,7 @@ lt__nsmodule_get_header (NSModule module)
while (i > 0)
{
--i;
if (strcmp (_dyld_get_image_name (i), modname) != 0)
if (strneq (_dyld_get_image_name (i), modname))
{
mh = _dyld_get_image_header (i);
break;
@ -439,7 +439,7 @@ lt__match_loadedlib (const char *name)
--i;
id = lt__header_get_instnam (_dyld_get_image_header (i));
if (id && (strcmp (id, name) != 0))
if (id && strneq (id, name))
{
mh = _dyld_get_image_header (i);
break;

View File

@ -161,7 +161,7 @@ vm_open (lt_user_data loader_data, const char *filename)
const lt_dlsymbol *symbol;
for (symbol= lists->symlist->symbols; symbol->name; ++symbol)
{
if (!symbol->address && strcmp(symbol->name, filename) == 0)
if (!symbol->address && streq (symbol->name, filename))
{
module = (lt_module) lists->symlist;
goto done;
@ -199,7 +199,7 @@ vm_sym (lt_user_data loader_data, lt_module module, const char *name)
while (symbol->name)
{
if (strcmp (symbol->name, name) == 0)
if (streq (symbol->name, name))
{
return symbol->address;
}
@ -320,7 +320,7 @@ lt_dlpreload_open (const char *originator, lt_dlpreload_callback_func *func)
for (list = preloaded_symlists; list; list = list->next)
{
/* ...that was preloaded by the requesting ORIGINATOR... */
if (strcmp (list->symlist->originator, originator) == 0)
if (streq (list->symlist->originator, originator))
{
const lt_dlsymbol *symbol;
unsigned int idx = 0;
@ -331,7 +331,7 @@ lt_dlpreload_open (const char *originator, lt_dlpreload_callback_func *func)
while ((symbol = &list->symlist->symbols[idx++])->name != 0)
{
if ((symbol->address == 0)
&& (strcmp (symbol->name, "@PROGRAM@") != 0))
&& (strneq (symbol->name, "@PROGRAM@")))
{
lt_dlhandle handle = lt_dlopen (symbol->name);
if (handle == 0)

View File

@ -82,6 +82,12 @@ extern int errno;
void lt__alloc_die_callback (void);
/* For readability: */
#define strneq(s1, s2) (strcmp((s1), (s2)) != 0)
#define streq(s1, s2) (!strcmp((s1), (s2)))
/* --- ERROR HANDLING --- */
/* Extract the diagnostic strings from the error table macro in the same

View File

@ -368,7 +368,7 @@ tryall_dlopen (lt_dlhandle *handle, const char *filename)
}
if (cur->info.filename && filename
&& strcmp (cur->info.filename, filename) == 0)
&& streq (cur->info.filename, filename))
{
break;
}
@ -1062,7 +1062,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename)
}
/* Check whether we are opening a libtool module (.la extension). */
if (ext && strcmp (ext, archive_ext) == 0)
if (ext && streq (ext, archive_ext))
{
/* this seems to be a libtool module */
FILE * file = 0;
@ -1195,11 +1195,11 @@ try_dlopen (lt_dlhandle *phandle, const char *filename)
{
errors += trim (&deplibs, &line[sizeof (STR_DL_DEPLIBS) - 1]);
}
else if (strcmp (line, "installed=yes\n") == 0)
else if (streq (line, "installed=yes\n"))
{
installed = 1;
}
else if (strcmp (line, "installed=no\n") == 0)
else if (streq (line, "installed=no\n"))
{
installed = 0;
}
@ -1398,9 +1398,9 @@ lt_dlopenext (const char *filename)
/* If FILENAME already bears a suitable extension, there is no need
to try appending additional extensions. */
if (ext && ((strcmp (ext, archive_ext) == 0)
if (ext && ((streq (ext, archive_ext))
#if defined(LTDL_SHLIB_EXT)
|| (strcmp (ext, shlib_ext) == 0)
|| (streq (ext, shlib_ext))
#endif
))
{
@ -2050,7 +2050,7 @@ lt_dlhandle_find (const char *module_name)
{
do
{
if (cur->info.name && strcmp (cur->info.name, module_name) == 0)
if (cur->info.name && streq (cur->info.name, module_name))
break;
}
while ((cur = cur->next));
@ -2250,7 +2250,7 @@ lt_dlloader_remove (const char *loader_name)
lt_dlloader *prev;
for (prev = loaders; prev->next; prev = prev->next)
{
if (!strcmp (prev->next->loader_name, loader_name))
if (streq (prev->next->loader_name, loader_name))
{
break;
}
@ -2317,7 +2317,7 @@ lt_dlloader_find (const char *loader_name)
for (place = loaders; place; place = place->next)
{
if (strcmp (place->loader_name, loader_name) == 0)
if (streq (place->loader_name, loader_name))
{
break;
}