diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2007-10-09 12:22:28 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2007-10-09 12:22:28 +0000 |
commit | 85a3d9454aef8de0674de833e0d4556a70dd1c7a (patch) | |
tree | cbe1908cf43d43700f039c6643bdb4ea08e466f5 /usr.bin/cvs | |
parent | 0be4a986fe4fcae99e134b031b33da6304111d48 (diff) |
various style cleanups:
- Copyright order
- rev -> cvs_specified_tag
- crev -> rev
- line instead of alines[i] in for-loop
OK niallo@
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/annotate.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c index 0d49b3062c2..b5661265f0a 100644 --- a/usr.bin/cvs/annotate.c +++ b/usr.bin/cvs/annotate.c @@ -1,7 +1,7 @@ -/* $OpenBSD: annotate.c,v 1.39 2007/09/22 16:01:22 joris Exp $ */ +/* $OpenBSD: annotate.c,v 1.40 2007/10/09 12:22:27 tobias Exp $ */ /* - * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> * Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org> + * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -30,7 +30,6 @@ void cvs_annotate_local(struct cvs_file *); static int force_head = 0; -static char *rev = NULL; struct cvs_cmd cvs_cmd_annotate = { CVS_OP_ANNOTATE, 0, "annotate", @@ -64,7 +63,7 @@ cvs_annotate(int argc, char **argv) case 'R': break; case 'r': - rev = optarg; + cvs_specified_tag = optarg; break; default: fatal("%s", cvs_cmd_annotate.cmd_synopsis); @@ -87,8 +86,9 @@ cvs_annotate(int argc, char **argv) if (!(flags & CR_RECURSE_DIRS)) cvs_client_send_request("Argument -l"); - if (rev != NULL) - cvs_client_send_request("Argument -r%s", rev); + if (cvs_specified_tag != NULL) + cvs_client_send_request("Argument -r%s", + cvs_specified_tag); } else { cr.fileproc = cvs_annotate_local; } @@ -115,7 +115,8 @@ cvs_annotate_local(struct cvs_file *cf) { int i; char date[10], rnum[13], *p; - RCSNUM *crev; + RCSNUM *rev; + struct cvs_line *line; struct cvs_line **alines; cvs_log(LP_TRACE, "cvs_annotate_local(%s)", cf->file_path); @@ -126,21 +127,21 @@ cvs_annotate_local(struct cvs_file *cf) cf->file_type != CVS_FILE) return; - if (rev == NULL) + if (cvs_specified_tag == NULL) rcs_rev_getlines(cf->file_rcs, cf->file_rcsrev, &alines); else { - crev = rcsnum_parse(rev); + rev = rcsnum_parse(cvs_specified_tag); - if (rcsnum_cmp(crev, cf->file_rcsrev, 0) < 0) { + if (rcsnum_cmp(rev, cf->file_rcsrev, 0) < 0) { if (!force_head) { /* Stick at weird GNU cvs, ignore error. */ - rcsnum_free(crev); + rcsnum_free(rev); return; } - rcsnum_cpy(cf->file_rcsrev, crev, 0); + rcsnum_cpy(cf->file_rcsrev, rev, 0); } - rcs_rev_getlines(cf->file_rcs, crev, &alines); - rcsnum_free(crev); + rcs_rev_getlines(cf->file_rcs, rev, &alines); + rcsnum_free(rev); } /* Stick at weird GNU cvs, ignore error. */ @@ -151,29 +152,30 @@ cvs_annotate_local(struct cvs_file *cf) cvs_log(LP_RCS, "***************"); for (i = 0; alines[i] != NULL; i++) { - rcsnum_tostr(alines[i]->l_delta->rd_num, rnum, sizeof(rnum)); + line = alines[i]; + + rcsnum_tostr(line->l_delta->rd_num, rnum, sizeof(rnum)); strftime(date, sizeof(date), "%d-%b-%y", - &(alines[i]->l_delta->rd_date)); - if (alines[i]->l_len && - alines[i]->l_line[alines[i]->l_len - 1] == '\n') - alines[i]->l_line[alines[i]->l_len - 1] = '\0'; + &(line->l_delta->rd_date)); + if (line->l_len && line->l_line[line->l_len - 1] == '\n') + line->l_line[line->l_len - 1] = '\0'; else { - p = xmalloc(alines[i]->l_len + 1); - memcpy(p, alines[i]->l_line, alines[i]->l_len); - p[alines[i]->l_len] = '\0'; - - if (alines[i]->l_needsfree) - xfree(alines[i]->l_line); - alines[i]->l_line = p; - alines[i]->l_len++; - alines[i]->l_needsfree = 1; + p = xmalloc(line->l_len + 1); + memcpy(p, line->l_line, line->l_len); + p[line->l_len] = '\0'; + + if (line->l_needsfree) + xfree(line->l_line); + line->l_line = p; + line->l_len++; + line->l_needsfree = 1; } cvs_printf("%-12.12s (%-8.8s %s): %s\n", rnum, - alines[i]->l_delta->rd_author, date, alines[i]->l_line); + line->l_delta->rd_author, date, line->l_line); - if (alines[i]->l_needsfree) - xfree(alines[i]->l_line); - xfree(alines[i]); + if (line->l_needsfree) + xfree(line->l_line); + xfree(line); } xfree(alines); |