Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
module search path
- X-seq: zsh-workers 2459
- From: Zefram <zefram@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Z Shell workers mailing list)
- Subject: module search path
- Date: Sat, 23 Nov 1996 15:45:18 +0000 (GMT)
-----BEGIN PGP SIGNED MESSAGE-----
This patch makes zmodload search for modules using the same algorithm
as is used for command path searching. That is,
* If PATH_DIRS is not set, use the name as-is if it contains a /, and
do a path search otherwise.
* If PATH_DIRS *is* set, try using the name as-is if it contains a /,
and then do a path search unless the name starts with "/", "./" or
"../".
It also makes it try names with and without .$(DL_EXT) appended,
regardless of whether it is doing a path search.
-zefram
Index: Src/module.c
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Src/module.c,v
retrieving revision 1.11
diff -c -r1.11 module.c
*** module.c 1996/11/22 02:20:06 1.11
--- module.c 1996/11/23 00:45:43
***************
*** 58,84 ****
/**/
void *
! load_module(char *name)
{
char buf[PATH_MAX + 1];
char **pp;
void *ret = NULL;
int l;
! if ((*name == '/') ||
! (*name == '.' && name[1] == '/') ||
! (*name == '.' && name[1] == '.' && name[2] == '/'))
ret = dlopen(name, RTLD_LAZY);
! else {
! l = strlen(name) + strlen(DL_EXT) + 2;
! for (pp = module_path; !ret && *pp; pp++) {
! if (l + (**pp ? strlen(*pp) : 1) > PATH_MAX)
! continue;
! sprintf(buf, "%s/%s.%s", **pp ? *pp : ".", name, DL_EXT);
! ret = dlopen(buf, RTLD_LAZY);
! }
}
return ret;
}
/**/
--- 58,105 ----
/**/
void *
! try_load_module(char const *name)
{
char buf[PATH_MAX + 1];
char **pp;
void *ret = NULL;
int l;
! if(strchr(name, '/')) {
ret = dlopen(name, RTLD_LAZY);
! if(ret ||
! unset(PATHDIRS) ||
! (*name == '/') ||
! (*name == '.' && name[1] == '/') ||
! (*name == '.' && name[1] == '.' && name[2] == '/'))
! return ret;
}
+
+ l = strlen(name) + 1;
+ for (pp = module_path; !ret && *pp; pp++) {
+ if (l + (**pp ? strlen(*pp) : 1) > PATH_MAX)
+ continue;
+ sprintf(buf, "%s/%s", **pp ? *pp : ".", name);
+ ret = dlopen(buf, RTLD_LAZY);
+ }
+
return ret;
+ }
+
+ /**/
+ void *
+ load_module(char const *name)
+ {
+ void *ret;
+ char buf[PATH_MAX + 1];
+
+ if(strlen(name) + strlen(DL_EXT) < PATH_MAX) {
+ sprintf(buf, "%s.%s", name, DL_EXT);
+ ret = try_load_module(buf);
+ if(ret)
+ return ret;
+ }
+ return try_load_module(name);
}
/**/
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBMpZSiXD/+HJTpU/hAQEvtQP/Z6EDwTimiUmUX/E6cuMnYyo5Fvx7L0bX
rHlgHEsW1A7NeshvytO6BZkQKVIl1YLshp11lW3EWzVHMm3qjJKpb+8dsxLgzv0B
kobLsfjL99CJkxsmRRckgHNYnAolmU2+ZXZx13zMxr03xZtQhVnfxSaG3OjtMX4t
Dj6uHLBbMWg=
=GBM1
-----END PGP SIGNATURE-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author