diff options
Diffstat (limited to 'contrib/cvs/src/logmsg.c')
-rw-r--r-- | contrib/cvs/src/logmsg.c | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/contrib/cvs/src/logmsg.c b/contrib/cvs/src/logmsg.c index 67194be..e471341 100644 --- a/contrib/cvs/src/logmsg.c +++ b/contrib/cvs/src/logmsg.c @@ -385,14 +385,20 @@ do_editor (dir, messagep, repository, changes) independant of the running of an editor for getting a message. */ void -do_verify (message, repository) - char *message; +do_verify (messagep, repository) + char **messagep; char *repository; { FILE *fp; char *fname; int retcode = 0; + char *line; + int line_length; + size_t line_chars_allocated; + char *p; + struct stat stbuf; + #ifdef CLIENT_SUPPORT if (client_active) /* The verification will happen on the server. */ @@ -406,7 +412,7 @@ do_verify (message, repository) /* If there's no message, then we have nothing to verify. Can this case happen? And if so why would we print a message? */ - if (message == NULL) + if (*messagep == NULL) { cvs_output ("No message to verify\n", 0); return; @@ -422,9 +428,9 @@ do_verify (message, repository) error (1, errno, "cannot create temporary file %s", fname); else { - fprintf (fp, "%s", message); - if ((message)[0] == '\0' || - (message)[strlen (message) - 1] != '\n') + fprintf (fp, "%s", *messagep); + if ((*messagep)[0] == '\0' || + (*messagep)[strlen (*messagep) - 1] != '\n') (void) fprintf (fp, "%s", "\n"); if (fclose (fp) == EOF) error (1, errno, "%s", fname); @@ -450,13 +456,62 @@ do_verify (message, repository) error (1, retcode == -1 ? errno : 0, "Message verification failed"); + } + + /* put the entire message back into the *messagep variable */ + + fp = open_file (fname, "r"); + if (fp == NULL) + { + error (1, errno, "cannot open temporary file %s", fname); + return; + } + + if (*messagep) + free (*messagep); + + if ( CVS_STAT (fname, &stbuf) != 0) + error (1, errno, "cannot find size of temp file %s", fname); + + if (stbuf.st_size == 0) + *messagep = NULL; + else + { + /* On NT, we might read less than st_size bytes, but we won't + read more. So this works. */ + *messagep = (char *) xmalloc (stbuf.st_size + 1); + *messagep[0] = '\0'; + } + + line = NULL; + line_chars_allocated = 0; + + if (*messagep) + { + p = *messagep; + while (1) + { + line_length = getline (&line, &line_chars_allocated, fp); + if (line_length == -1) + { + if (ferror (fp)) + error (0, errno, "warning: cannot read %s", fname); + break; + } + if (strncmp (line, CVSEDITPREFIX, CVSEDITPREFIXLEN) == 0) + continue; + (void) strcpy (p, line); + p += line_length; } } + if (fclose (fp) < 0) + error (0, errno, "warning: cannot close %s", fname); /* Delete the temp file */ unlink_file (fname); free (fname); + } } } |