From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-request@euclid.skiles.gatech.edu Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.6/8.7.3) with ESMTP id CAA20452 for ; Sun, 24 Nov 1996 02:50:46 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA20782; Sat, 23 Nov 1996 10:44:45 -0500 (EST) Resent-Date: Sat, 23 Nov 1996 10:44:45 -0500 (EST) From: Zefram Message-Id: <14791.199611231545@stone.dcs.warwick.ac.uk> Subject: module search path To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Sat, 23 Nov 1996 15:45:18 +0000 (GMT) X-Patch: 130 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]8468.28 X-US-Congress: Moronic fuckers Content-Type: text Resent-Message-ID: <"HnXxc.0.e45.ilnbo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2459 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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-----