* finddir() and long directories
@ 1996-12-31 12:50 Zefram
0 siblings, 0 replies; only message in thread
From: Zefram @ 1996-12-31 12:50 UTC (permalink / raw)
To: Z Shell workers mailing list
-----BEGIN PGP SIGNED MESSAGE-----
This patch fixes finddir() to handle arbitrarily long directories.
There are a lot more PATH_MAX dependencies to fix yet.
-zefram
*** Src/utils.c 1996/12/30 14:11:41 1.47
--- Src/utils.c 1996/12/30 15:07:32
***************
*** 404,410 ****
/* static variables needed by finddir(). */
! static char finddir_full[PATH_MAX];
static Nameddir finddir_last;
static int finddir_best;
--- 404,410 ----
/* static variables needed by finddir(). */
! static char *finddir_full;
static Nameddir finddir_last;
static int finddir_best;
***************
*** 432,437 ****
--- 432,438 ----
finddir(char *s)
{
static struct nameddir homenode = { NULL, "", 0, NULL, 0 };
+ static int ffsz;
/* Invalidate directory cache if argument is NULL. This is called *
* whenever a node is added to or removed from the hash table, and *
***************
*** 439,453 ****
if (!s) {
homenode.dir = home;
homenode.diff = strlen(home);
! if(homenode.diff==1 || homenode.diff>=PATH_MAX)
homenode.diff = 0;
finddir_full[0] = 0;
return finddir_last = NULL;
}
! if (!strcmp(s, finddir_full))
return finddir_last;
strcpy(finddir_full, s);
finddir_best=0;
finddir_last=NULL;
--- 440,460 ----
if (!s) {
homenode.dir = home;
homenode.diff = strlen(home);
! if(homenode.diff==1)
homenode.diff = 0;
+ if(!finddir_full)
+ finddir_full = zalloc(ffsz = PATH_MAX);
finddir_full[0] = 0;
return finddir_last = NULL;
}
! if(!strcmp(s, finddir_full) && *finddir_full)
return finddir_last;
+ if(strlen(s) >= ffsz) {
+ free(finddir_full);
+ finddir_full = zalloc(ffsz = strlen(s) * 2);
+ }
strcpy(finddir_full, s);
finddir_best=0;
finddir_last=NULL;
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBMsfb93D/+HJTpU/hAQHSlQP/RNknLJGuNjSrg30xgB+XnB2Bjmhvnq3i
fk7Av7pZL15eYRls97mQj2klPgqlOoxiEMTQT+AOiAomlkB7Qg436kVFwVxOBONj
7YQ2NM82H/ghowVikEpJewYofdLVr6s43Si0Nz6YZWsTfMg4TzByCcHztZidxY2m
TbE2ghjb/GU=
=aLjV
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-12-31 12:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-31 12:50 finddir() and long directories Zefram
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).