From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6618 invoked from network); 31 Dec 1996 12:45:07 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 31 Dec 1996 12:45:07 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id HAA06296; Tue, 31 Dec 1996 07:49:38 -0500 (EST) Resent-Date: Tue, 31 Dec 1996 07:49:38 -0500 (EST) From: Zefram Message-Id: <29351.199612311250@stone.dcs.warwick.ac.uk> Subject: finddir() and long directories To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Tue, 31 Dec 1996 12:50:47 +0000 (GMT) X-Patch: 170 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]8657.67 X-US-Congress: Moronic fuckers Content-Type: text Resent-Message-ID: <"oTQgZ2.0.GY1.WlGoo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2688 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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-----