=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.9 retrieving revision 1.10 diff -c -r1.9 -r1.10 *** src/usr.bin/cvs/file.c 2004/07/29 15:41:57 1.9 --- src/usr.bin/cvs/file.c 2004/07/29 16:59:39 1.10 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.9 2004/07/29 15:41:57 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.10 2004/07/29 16:59:39 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 121,127 **** rcsnum_aton("0", NULL, cvs_addedrev); /* standard patterns to ignore */ ! for (i = 0; i < sizeof(cvs_ign_std)/sizeof(char *); i++) cvs_file_ignore(cvs_ign_std[i]); /* read the cvsignore file in the user's home directory, if any */ --- 121,127 ---- rcsnum_aton("0", NULL, cvs_addedrev); /* standard patterns to ignore */ ! for (i = 0; i < (int)(sizeof(cvs_ign_std)/sizeof(char *)); i++) cvs_file_ignore(cvs_ign_std[i]); /* read the cvsignore file in the user's home directory, if any */ *************** *** 413,419 **** --- 413,421 ---- struct dirent *ent; struct cvs_file *cfp; struct cvs_dir *cdp; + struct cvs_flist dirs; + TAILQ_INIT(&dirs); cdp = cf->cf_ddat; if (cvs_readrepo(cf->cf_path, pbuf, sizeof(pbuf)) == 0) { *************** *** 457,468 **** cfp = cvs_file_get(pbuf, flags); if (cfp != NULL) { cfp->cf_parent = cf; ! LIST_INSERT_HEAD(&(cdp->cd_files), cfp, cf_list); } } ! if (flags & CF_SORT) cvs_file_sort(&(cdp->cd_files)); (void)close(fd); cf->cf_ddat = cdp; --- 459,479 ---- cfp = cvs_file_get(pbuf, flags); if (cfp != NULL) { cfp->cf_parent = cf; ! ! if (cfp->cf_type == DT_DIR) ! TAILQ_INSERT_HEAD(&dirs, cfp, cf_list); ! else ! TAILQ_INSERT_HEAD(&(cdp->cd_files), cfp, ! cf_list); } } ! if (flags & CF_SORT) { cvs_file_sort(&(cdp->cd_files)); + cvs_file_sort(&dirs); + } + TAILQ_FOREACH(cfp, &dirs, cf_list) + TAILQ_INSERT_TAIL(&(cdp->cd_files), cfp, cf_list); (void)close(fd); cf->cf_ddat = cdp; *************** *** 480,488 **** void cvs_file_free(struct cvs_file *cf) { - struct cvs_file *cfp; - struct cvs_dir *cd; - if (cf->cf_path != NULL) free(cf->cf_path); if (cf->cf_stat != NULL) --- 491,496 ---- *************** *** 509,515 **** if (cf->cf_type == DT_DIR) { ret = (*exam)(cf, arg); ! LIST_FOREACH(fp, &(cf->cf_ddat->cd_files), cf_list) { ret = cvs_file_examine(fp, exam, arg); if (ret == -1) return (-1); --- 517,523 ---- if (cf->cf_type == DT_DIR) { ret = (*exam)(cf, arg); ! TAILQ_FOREACH(fp, &(cf->cf_ddat->cd_files), cf_list) { ret = cvs_file_examine(fp, exam, arg); if (ret == -1) return (-1); *************** *** 536,544 **** if (cd->cd_repo != NULL) free(cd->cd_repo); ! while (!LIST_EMPTY(&(cd->cd_files))) { ! cfp = LIST_FIRST(&(cd->cd_files)); ! LIST_REMOVE(cfp, cf_list); cvs_file_free(cfp); } } --- 544,552 ---- if (cd->cd_repo != NULL) free(cd->cd_repo); ! while (!TAILQ_EMPTY(&(cd->cd_files))) { ! cfp = TAILQ_FIRST(&(cd->cd_files)); ! TAILQ_REMOVE(&(cd->cd_files), cfp, cf_list); cvs_file_free(cfp); } } *************** *** 558,564 **** struct cvs_file *cf, *cfvec[256]; i = 0; ! LIST_FOREACH(cf, flp, cf_list) { cfvec[i++] = cf; if (i == sizeof(cfvec)/sizeof(struct cvs_file *)) { cvs_log(LP_WARN, "too many files to sort"); --- 566,572 ---- struct cvs_file *cf, *cfvec[256]; i = 0; ! TAILQ_FOREACH(cf, flp, cf_list) { cfvec[i++] = cf; if (i == sizeof(cfvec)/sizeof(struct cvs_file *)) { cvs_log(LP_WARN, "too many files to sort"); *************** *** 568,585 **** /* now unlink it from the list, * we'll put it back in order later */ ! LIST_REMOVE(cf, cf_list); } /* clear the list just in case */ ! LIST_INIT(flp); nb = (size_t)i; heapsort(cfvec, nb, sizeof(cf), cvs_file_cmp); /* rebuild the list from the bottom up */ for (i = (int)nb - 1; i >= 0; i--) ! LIST_INSERT_HEAD(flp, cfvec[i], cf_list); return (0); } --- 576,593 ---- /* now unlink it from the list, * we'll put it back in order later */ ! TAILQ_REMOVE(flp, cf, cf_list); } /* clear the list just in case */ ! TAILQ_INIT(flp); nb = (size_t)i; heapsort(cfvec, nb, sizeof(cf), cvs_file_cmp); /* rebuild the list from the bottom up */ for (i = (int)nb - 1; i >= 0; i--) ! TAILQ_INSERT_HEAD(flp, cfvec[i], cf_list); return (0); } *************** *** 638,644 **** return (NULL); } memset(ddat, 0, sizeof(*ddat)); ! LIST_INIT(&(ddat->cd_files)); cfp->cf_ddat = ddat; } return (cfp); --- 646,652 ---- return (NULL); } memset(ddat, 0, sizeof(*ddat)); ! TAILQ_INIT(&(ddat->cd_files)); cfp->cf_ddat = ddat; } return (cfp);