=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rcs/ci.c,v retrieving revision 1.179 retrieving revision 1.180 diff -c -r1.179 -r1.180 *** src/usr.bin/rcs/ci.c 2006/06/02 19:10:23 1.179 --- src/usr.bin/rcs/ci.c 2006/06/03 03:05:10 1.180 *************** *** 1,4 **** ! /* $OpenBSD: ci.c,v 1.179 2006/06/02 19:10:23 david Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: ci.c,v 1.180 2006/06/03 03:05:10 niallo Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins * All rights reserved. *************** *** 64,76 **** RCSFILE *file; RCSNUM *frev, *newrev; const char *description, *symbol; ! char fpath[MAXPATHLEN], *rcs_msg, *username, *deltatext, *filename; char *author, *state; }; static int checkin_attach_symbol(struct checkin_params *); static int checkin_checklock(struct checkin_params *); ! static char *checkin_diff_file(struct checkin_params *); static char *checkin_getlogmsg(RCSNUM *, RCSNUM *, int); static int checkin_init(struct checkin_params *); static int checkin_keywordscan(char *, RCSNUM **, time_t *, char **, --- 64,77 ---- RCSFILE *file; RCSNUM *frev, *newrev; const char *description, *symbol; ! char fpath[MAXPATHLEN], *rcs_msg, *username, *filename; char *author, *state; + BUF *deltatext; }; static int checkin_attach_symbol(struct checkin_params *); static int checkin_checklock(struct checkin_params *); ! static BUF *checkin_diff_file(struct checkin_params *); static char *checkin_getlogmsg(RCSNUM *, RCSNUM *, int); static int checkin_init(struct checkin_params *); static int checkin_keywordscan(char *, RCSNUM **, time_t *, char **, *************** *** 315,329 **** * Generate the diff between the working file and a revision. * Returns pointer to a char array on success, NULL on failure. */ ! static char * checkin_diff_file(struct checkin_params *pb) { char *path1, *path2; BUF *b1, *b2, *b3; ! char rbuf[64], *deltatext; b1 = b2 = b3 = NULL; - deltatext = NULL; rcsnum_tostr(pb->frev, rbuf, sizeof(rbuf)); if ((b1 = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) { --- 316,329 ---- * Generate the diff between the working file and a revision. * Returns pointer to a char array on success, NULL on failure. */ ! static BUF * checkin_diff_file(struct checkin_params *pb) { char *path1, *path2; BUF *b1, *b2, *b3; ! char rbuf[64]; b1 = b2 = b3 = NULL; rcsnum_tostr(pb->frev, rbuf, sizeof(rbuf)); if ((b1 = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) { *************** *** 357,366 **** if (rcs_diffreg(path1, path2, b3) == D_ERROR) goto out; ! rcs_buf_putc(b3, '\0'); ! deltatext = rcs_buf_release(b3); ! b3 = NULL; ! out: if (b1 != NULL) rcs_buf_free(b1); --- 357,363 ---- if (rcs_diffreg(path1, path2, b3) == D_ERROR) goto out; ! return (b3); out: if (b1 != NULL) rcs_buf_free(b1); *************** *** 373,379 **** if (path2 != NULL) xfree(path2); ! return (deltatext); } /* --- 370,376 ---- if (path2 != NULL) xfree(path2); ! return (NULL); } /* *************** *** 436,444 **** if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) goto fail; - rcs_buf_putc(bp, '\0'); - filec = (char *)rcs_buf_release(bp); - /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */ if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev)) pb->newrev = rcsnum_inc(pb->newrev); --- 433,438 ---- *************** *** 496,502 **** * If -f is not specified and there are no differences, tell * the user and revert to latest version. */ ! if (!(pb->flags & FORCE) && (strlen(pb->deltatext) < 1)) { checkin_revert(pb); goto out; } --- 490,496 ---- * If -f is not specified and there are no differences, tell * the user and revert to latest version. */ ! if (!(pb->flags & FORCE) && (rcs_buf_len(pb->deltatext) < 1)) { checkin_revert(pb); goto out; } *************** *** 537,543 **** pb->newrev = pb->file->rf_head; /* New head revision has to contain entire file; */ ! if (rcs_deltatext_set(pb->file, pb->frev, filec) == -1) errx(1, "failed to set new head revision"); /* Attach a symbolic name to this revision if specified. */ --- 531,537 ---- pb->newrev = pb->file->rf_head; /* New head revision has to contain entire file; */ ! if (rcs_deltatext_set(pb->file, pb->frev, bp) == -1) errx(1, "failed to set new head revision"); /* Attach a symbolic name to this revision if specified. */ *************** *** 575,590 **** } out: - xfree(pb->deltatext); - xfree(filec); - return (0); fail: - if (filec != NULL) - xfree(filec); - if (pb->deltatext != NULL) - xfree(pb->deltatext); return (-1); } --- 569,577 ---- *************** *** 598,609 **** checkin_init(struct checkin_params *pb) { BUF *bp; ! char *filec, numb[64]; int fetchlog = 0; struct stat st; - filec = NULL; - /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */ if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev)) { pb->frev = rcsnum_alloc(); --- 585,594 ---- checkin_init(struct checkin_params *pb) { BUF *bp; ! char numb[64]; int fetchlog = 0; struct stat st; /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */ if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev)) { pb->frev = rcsnum_alloc(); *************** *** 616,628 **** if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) goto fail; - rcs_buf_putc(bp, '\0'); - filec = rcs_buf_release(bp); - /* Get default values from working copy if -k specified */ if (pb->flags & CI_KEYWORDSCAN) ! checkin_keywordscan(filec, &pb->newrev, &pb->date, &pb->state, ! &pb->author); if (pb->flags & CI_SKIPDESC) goto skipdesc; --- 601,610 ---- if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) goto fail; /* Get default values from working copy if -k specified */ if (pb->flags & CI_KEYWORDSCAN) ! checkin_keywordscan((char *)rcs_buf_get(bp), &pb->newrev, ! &pb->date, &pb->state, &pb->author); if (pb->flags & CI_SKIPDESC) goto skipdesc; *************** *** 670,676 **** pb->newrev = pb->file->rf_head; /* New head revision has to contain entire file; */ ! if (rcs_deltatext_set(pb->file, pb->file->rf_head, filec) == -1) { warnx("failed to set new head revision"); goto fail; } --- 652,658 ---- pb->newrev = pb->file->rf_head; /* New head revision has to contain entire file; */ ! if (rcs_deltatext_set(pb->file, pb->file->rf_head, bp) == -1) { warnx("failed to set new head revision"); goto fail; } *************** *** 692,698 **** pb->file->rf_mode = st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH|S_IRUSR|S_IRGRP|S_IROTH); - xfree(filec); (void)close(workfile_fd); (void)unlink(pb->filename); --- 674,679 ---- *************** *** 713,720 **** return (0); fail: - if (filec != NULL) - xfree(filec); return (-1); } --- 694,699 ----