Hello, tech@

This diff synchronizes OpenCVS rcs parser code with OpenRCS.  It shrinks code 
by 3
lines, but does exactly the same thing.  It also removes `buf' which
becomes redundant for this function.

Instead of calling strlcpy(3) three times we can put a line in file with
fprintf(3).  Should be no functional change.

Index: rcs.c
===================================================================
RCS file: /cvs/src/usr.bin/cvs/rcs.c,v
retrieving revision 1.291
diff -u -p -r1.291 rcs.c
--- rcs.c       7 Jun 2009 08:39:13 -0000       1.291
+++ rcs.c       21 Mar 2010 20:23:43 -0000
@@ -366,7 +366,7 @@ void
 rcs_write(RCSFILE *rfp)
 {
        FILE *fp;
-       char buf[1024], numbuf[CVS_REV_BUFSZ], *fn, tmpdir[MAXPATHLEN];
+       char   numbuf[CVS_REV_BUFSZ], *fn, tmpdir[MAXPATHLEN];
        struct rcs_access *ap;
        struct rcs_sym *symp;
        struct rcs_branch *brp;
@@ -424,11 +424,7 @@ rcs_write(RCSFILE *rfp)
                if (RCSNUM_ISBRANCH(symp->rs_num))
                        rcsnum_addmagic(symp->rs_num);
                rcsnum_tostr(symp->rs_num, numbuf, sizeof(numbuf));
-               if (strlcpy(buf, symp->rs_name, sizeof(buf)) >= sizeof(buf) ||
-                   strlcat(buf, ":", sizeof(buf)) >= sizeof(buf) ||
-                   strlcat(buf, numbuf, sizeof(buf)) >= sizeof(buf))
-                       fatal("rcs_write: string overflow");
-               fprintf(fp, "\n\t%s", buf);
+               fprintf(fp, "\n\t%s:%s", symp->rs_name, numbuf);
        }
        fprintf(fp, ";\n");

Reply via email to