bug-cvs
[Top][All Lists]
Advanced

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

loginfo sanity fix


From: Brian Murphy
Subject: loginfo sanity fix
Date: Sat, 23 Nov 2002 16:16:43 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020623 Debian/1.0.0-0.woody.1

I have had great difficulty understanding why there was not a better escaping of filenames with spaces in their names in the loginfo output. I have tried to fix
this with the attached patch.

The standard loginfo format: %{sVv}produces ambiguous output if the filenames of the repository and/or the changed files contain spaces. This makes it very difficult to parse the output further in the loginfo program handler to, for example,
provide a web link to the file or change in cvsweb.

The attached patch (with the standard format above) will output each filename, version triplet so that each is an argument to the program called, and much reduces my
irritation.

Comments are welcome.

/Brian

PS I attached the patch not to annoy but to preserve it unmangled by my mail program. If it is the custom to send patches in plain text inline then I will resend, but it's hard
to find information on this list :-).
diff -u -r cvs-1.11.2/src/logmsg.c cvs-1.11.2-mine/src/logmsg.c
--- cvs-1.11.2/src/logmsg.c     2001-09-14 19:12:10.000000000 +0200
+++ cvs-1.11.2-mine/src/logmsg.c        2002-11-23 15:50:18.000000000 +0100
@@ -654,8 +654,13 @@
 {
     struct logfile_info *li;
     char *c;
+    char *name;
 
     li = (struct logfile_info *) p->data;
+
+    name = xmalloc( 2 * strlen(p->key));
+    shell_escape(name, p->key);
+
     if (li->type == type)
     {
        /* Until we decide on the correct logging solution when we add
@@ -670,8 +675,8 @@
        if (li->type == T_TITLE)
        {
            str_list = xrealloc (str_list,
-                                strlen (str_list) + strlen (p->key) + 5);
-           (void) strcat (str_list, p->key);
+                                strlen (str_list) + strlen (name) + 5);
+           (void) strcat (str_list, name);
        }
        else
        {
@@ -684,8 +689,8 @@
                case 's':
                    str_list =
                        xrealloc (str_list,
-                                 strlen (str_list) + strlen (p->key) + 5);
-                   (void) strcat (str_list, p->key);
+                                 strlen (str_list) + strlen (name) + 5);
+                   (void) strcat (str_list, name);
                    break;
                case 'V':
                    str_list =
@@ -741,6 +746,7 @@
     char *cp;
     int c;
     int pipestatus;
+    int len;
     char *fmt_percent;         /* the location of the percent sign
                                   that starts the format string. */
 
@@ -893,10 +899,15 @@
                        + 10);
        (void) memcpy (cp, filter, fmt_percent - filter);
        cp += fmt_percent - filter;
-       *cp++ = '"';
-       cp = shell_escape (cp, srepos);
-       cp = shell_escape (cp, str_list);
-       *cp++ = '"';
+
+       len = strlen(srepos);
+       memcpy(cp, srepos, len);
+       cp += len;
+
+       len = strlen(str_list);
+       memcpy(cp, str_list, len);
+       cp += len;
+
        (void) strcpy (cp, fmt_continue);
            
        /* To be nice, free up some memory. */
diff -u -r cvs-1.11.2/src/subr.c cvs-1.11.2-mine/src/subr.c
--- cvs-1.11.2/src/subr.c       2001-08-07 17:35:32.000000000 +0200
+++ cvs-1.11.2-mine/src/subr.c  2002-11-23 14:48:18.000000000 +0100
@@ -810,7 +810,7 @@
     char *buf;
     const char *str;
 {
-    static const char meta[] = "$`\\\"";
+    static const char meta[] = "$`\\\" ";
     const char *p;
 
     for (;;)

reply via email to

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