[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binary files fix

From: Joël MERLIN
Subject: Binary files fix
Date: Tue, 26 Sep 2000 15:30:15 +0200

I'm running the Windows NT Version of cvs server 1.10.8.
I encountered the following bug:
> cvs add -kb binfile
> cvs commit
Then, my file is supposed to be archived as binary, which is what I see in the rcs file, though the actual archive contained in rcs file has translated the "lf" to "crlf"...obviously it looks like a binary file created as text for writing.
This bug is located in the cvs.exe program invoked by the NT service.
The "serve_modified" method invoked by the server is checking against a "kopt" which is never set...because the protocol is never invoking the "serve_kopt" action.
The consequence is that we never get the "binary" variable set to true and thus, the temporary file received and processed by "receive_file" or "receive_partial_file" never get set to binary when required.
I investigated this bug and decided that the best fix was to preempt the RCS option wrapping by any kopt sitting in the current file argument entry. This is making sense by the fact that we should always get a matching entry for every modified file.
That's why I added the "GetKoptFromEntry(arg)" function to the "server.c" source file.
The intent is to allocate a "kopt" sitting in a matching entry or null if not found.
Then we set a corresponding "binary" so that we get "CVS_OPEN" to use O_BINARY for file creation.
We then discard "kopt" and set to NULL because we don't want to fall in the underlying code calling "serve_is_modified".
We might fix this by using the "serve_kopt" protocol method, but I'm not sure what would be the impact on the client and server side...I'm not deep in the code, just a humble DP !!!
Find the fixed source attached with the "@@jmerl" signature wherever code has changed...mainly the following:
// @@jmerl
struct an_entry {
    struct an_entry *next;
    char *entry;
static struct an_entry *entries;
static char *GetKoptFromEntry(char *arg) {
   char *opt = NULL;
   struct an_entry *p;
   char *name;
   char *cp;
   int len;
   for (p = entries; p != NULL; p = p->next) {
      len = strlen(p->entry);
    name = p->entry + 1;
    cp = strchr (name, '/');
      // Matching entry
    if ((cp != NULL) &&
         (strlen (arg) == (cp - name)) &&
         (strncmp (arg, name, cp - name) == 0)) {
         cp = p->entry +len -1;
         while (*(--cp) != '/');
         // No kopt found
         if (*(++cp) == '/') return NULL;
         // Extract kopt
         opt = xmalloc((len = strlen(cp)) +1);
         strcpy(opt, cp);
         opt[len-1] = '\0';
         return opt;
   // No entry found
   return NULL;
// @@jmerl: read kopt from entry first
   kopt = GetKoptFromEntry(arg);
// @@jmerl: free kopt after use
   if (kopt) {
      kopt = NULL;
Joel d:)
(SMTP: jmerlin@cognicase.fr)

Attachment: server.c
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]