=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/entries.c,v retrieving revision 1.31 retrieving revision 1.32 diff -c -r1.31 -r1.32 *** src/usr.bin/cvs/entries.c 2005/05/26 21:25:49 1.31 --- src/usr.bin/cvs/entries.c 2005/05/26 22:25:31 1.32 *************** *** 1,4 **** ! /* $OpenBSD: entries.c,v 1.31 2005/05/26 21:25:49 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: entries.c,v 1.32 2005/05/26 22:25:31 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 53,59 **** cvs_ent_open(const char *dir, int flags) { size_t len; ! int exists, l; char entpath[MAXPATHLEN], ebuf[128], mode[4]; FILE *fp; struct stat st; --- 53,59 ---- cvs_ent_open(const char *dir, int flags) { size_t len; ! int exists; char entpath[MAXPATHLEN], ebuf[128], mode[4]; FILE *fp; struct stat st; *************** *** 63,70 **** exists = 0; memset(mode, 0, sizeof(mode)); ! l = snprintf(entpath, sizeof(entpath), "%s/" CVS_PATH_ENTRIES, dir); ! if (l == -1 || l >= (int)sizeof(entpath)) { errno = ENAMETOOLONG; cvs_log(LP_ERRNO, "%s", entpath); return (NULL); --- 63,70 ---- exists = 0; memset(mode, 0, sizeof(mode)); ! len = cvs_path_cat(dir, CVS_PATH_ENTRIES, entpath, sizeof(entpath)); ! if (len >= sizeof(entpath)) { errno = ENAMETOOLONG; cvs_log(LP_ERRNO, "%s", entpath); return (NULL); *************** *** 163,170 **** (void)cvs_ent_write(ep); } - if (ep->cef_file != NULL) - (void)fclose(ep->cef_file); if (ep->cef_path != NULL) free(ep->cef_path); --- 163,168 ---- *************** *** 412,436 **** size_t len; char revbuf[64], timebuf[32]; struct cvs_ent *ent; if (ef->cef_flags & CVS_ENTF_SYNC) return (0); ! if (ef->cef_file == NULL) { ! ef->cef_file = fopen(ef->cef_path, "w"); ! if (ef->cef_file == NULL) { ! cvs_log(LP_ERRNO, "failed to open Entries `%s'", ! ef->cef_path); ! return (-1); ! } } - - /* reposition ourself at beginning of file */ - rewind(ef->cef_file); TAILQ_FOREACH(ent, &(ef->cef_ent), ce_list) { if (ent->ce_type == CVS_ENT_DIR) { ! putc('D', ef->cef_file); timebuf[0] = '\0'; revbuf[0] = '\0'; } else { --- 410,428 ---- size_t len; char revbuf[64], timebuf[32]; struct cvs_ent *ent; + FILE *fp; if (ef->cef_flags & CVS_ENTF_SYNC) return (0); ! if ((fp = fopen(ef->cef_path, "w")) == NULL) { ! cvs_log(LP_ERRNO, "failed to open Entries `%s'", ef->cef_path); ! return (-1); } TAILQ_FOREACH(ent, &(ef->cef_ent), ce_list) { if (ent->ce_type == CVS_ENT_DIR) { ! putc('D', fp); timebuf[0] = '\0'; revbuf[0] = '\0'; } else { *************** *** 447,463 **** } } ! fprintf(ef->cef_file, "/%s/%s%s/%s/%s/%s\n", ent->ce_name, (ent->ce_status == CVS_ENT_REMOVED) ? "-" : "", revbuf, timebuf, "", ""); } /* terminating line */ ! fprintf(ef->cef_file, "D\n"); ef->cef_flags |= CVS_ENTF_SYNC; ! fclose(ef->cef_file); ! ef->cef_file = NULL; ! return (0); } --- 439,454 ---- } } ! fprintf(fp, "/%s/%s%s/%s/%s/%s\n", ent->ce_name, (ent->ce_status == CVS_ENT_REMOVED) ? "-" : "", revbuf, timebuf, "", ""); } /* terminating line */ ! putc('D', fp); ! putc('\n', fp); ef->cef_flags |= CVS_ENTF_SYNC; ! fclose(fp); return (0); }