This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cvs changes to support CR/LF in Root & Repository files


All,
  I used tortoisecvs (as a plugin for windows eclipse) to check out
some repositories to a "windows 7" directory (e.g. not a cygwin
directory).  I tried to use the cygwin cvs client to diff files and
check status but it complained ": no such repository" for "cvs log
<filename>".  A simple dos2unix on the CVS/Root file changed the error
to "cvs log: nothing known about <filename>"; a dos2unix on
CVS/Repository allowed the "cvs log" command to work correctly.
  I'm used to being able to copy/move svn sandboxes between linux and
windows w/o any issues so I checked into the cvs source to see what it
would take to support LF as well as CR/LF.  This issue isn't limited
to the cygwin cvs as the same "sandbox" copied to linux has the same
problem.
  I hacked the root.c and repos.c to work around the problem (as of
yet I haven't seen any impact to commands wrt Entries and template
don't seem to be affected.
  I've attached patch.txt with the changes.  This can be tested by
running dos2unix CVS/Root CVS/Repository; cvs log configure (the
current version of cvs will not work while the patched version will
work normally).

Bill

Index: ChangeLog
===================================================================
RCS file: /sources/cvs/ccvs/ChangeLog,v
retrieving revision 1.1379
diff -u -r1.1379 ChangeLog
--- ChangeLog   12 Nov 2009 02:29:17 -0000      1.1379
+++ ChangeLog   23 Mar 2013 17:48:31 -0000
@@ -1,3 +1,8 @@
+2013-03-23  Bill Pries <priestwilliaml@gmail.com>
+
+       * root.c: Support CR/LF as well as LF
+       * repos.c: Support CR/LF as well as LF
+
 2009-11-11  Derek R. Price  <derek@ximbiot.com>

        * NEWS: Note default taginfo format string fix.
Index: src/repos.c
===================================================================
RCS file: /sources/cvs/ccvs/src/repos.c,v
retrieving revision 1.49
diff -u -r1.49 repos.c
--- src/repos.c 18 Nov 2008 22:56:55 -0000      1.49
+++ src/repos.c 23 Mar 2013 17:48:31 -0000
@@ -101,6 +101,9 @@
        error (0, errno, "cannot close %s", quote (tmp));
     free (tmp);

+    if ((cp = strrchr (repos, '\r')) != NULL)
+       *cp = '\0';                     /* strip the carriage return */
+
     if ((cp = strrchr (repos, '\n')) != NULL)
        *cp = '\0';                     /* strip the newline */

Index: src/root.c
===================================================================
RCS file: /sources/cvs/ccvs/src/root.c,v
retrieving revision 1.137
diff -u -r1.137 root.c
--- src/root.c  12 Sep 2008 19:55:29 -0000      1.137
+++ src/root.c  23 Mar 2013 17:48:31 -0000
@@ -60,7 +60,6 @@
     char *tmp;
     char *cvsadm;
     char *cp;
-    int len;

     TRACE (TRACE_FLOW, "Name_Root (%s, %s)",
           TRACE_NULL (dir), TRACE_NULL (update_dir));
@@ -88,7 +87,7 @@
      */
     fpin = xfopen (tmp, "r");

-    if ((len = getline (&root, &root_allocated, fpin)) < 0)
+    if (getline (&root, &root_allocated, fpin) < 0)
     {
        char *admfile = dir_append (update_dir, CVSADM_ROOT);
        /* FIXME: should be checking for end of file separately; errno
@@ -99,8 +98,11 @@
        goto out;
     }
     fclose (fpin);
-    cp = root + len - 1;
-    if (*cp == '\n')
+
+    if ((cp = strrchr (root, '\r')) != NULL)
+       *cp = '\0';                     /* strip the carriage return */
+
+    if ((cp = strrchr (root, '\n')) != NULL)
        *cp = '\0';                     /* strip the newline */

     /*
Index: ChangeLog
===================================================================
RCS file: /sources/cvs/ccvs/ChangeLog,v
retrieving revision 1.1379
diff -u -r1.1379 ChangeLog
--- ChangeLog	12 Nov 2009 02:29:17 -0000	1.1379
+++ ChangeLog	23 Mar 2013 17:50:07 -0000
@@ -1,3 +1,8 @@
+2013-03-23  Bill Pries <priestwilliaml@gmail.com>
+
+	* root.c: Support CR/LF as well as LF
+	* repos.c: Support CR/LF as well as LF
+
 2009-11-11  Derek R. Price  <derek@ximbiot.com>
 
 	* NEWS: Note default taginfo format string fix.
Index: src/repos.c
===================================================================
RCS file: /sources/cvs/ccvs/src/repos.c,v
retrieving revision 1.49
diff -u -r1.49 repos.c
--- src/repos.c	18 Nov 2008 22:56:55 -0000	1.49
+++ src/repos.c	23 Mar 2013 17:50:08 -0000
@@ -101,6 +101,9 @@
 	error (0, errno, "cannot close %s", quote (tmp));
     free (tmp);
 
+    if ((cp = strrchr (repos, '\r')) != NULL)
+	*cp = '\0';			/* strip the carriage return */
+
     if ((cp = strrchr (repos, '\n')) != NULL)
 	*cp = '\0';			/* strip the newline */
 
Index: src/root.c
===================================================================
RCS file: /sources/cvs/ccvs/src/root.c,v
retrieving revision 1.137
diff -u -r1.137 root.c
--- src/root.c	12 Sep 2008 19:55:29 -0000	1.137
+++ src/root.c	23 Mar 2013 17:50:08 -0000
@@ -60,7 +60,6 @@
     char *tmp;
     char *cvsadm;
     char *cp;
-    int len;
 
     TRACE (TRACE_FLOW, "Name_Root (%s, %s)",
 	   TRACE_NULL (dir), TRACE_NULL (update_dir));
@@ -88,7 +87,7 @@
      */
     fpin = xfopen (tmp, "r");
 
-    if ((len = getline (&root, &root_allocated, fpin)) < 0)
+    if (getline (&root, &root_allocated, fpin) < 0)
     {
 	char *admfile = dir_append (update_dir, CVSADM_ROOT);
 	/* FIXME: should be checking for end of file separately; errno
@@ -99,8 +98,11 @@
 	goto out;
     }
     fclose (fpin);
-    cp = root + len - 1;
-    if (*cp == '\n')
+
+    if ((cp = strrchr (root, '\r')) != NULL)
+	*cp = '\0';			/* strip the carriage return */
+
+    if ((cp = strrchr (root, '\n')) != NULL)
 	*cp = '\0';			/* strip the newline */
 
     /*
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]