Subject: Re: CVS commit: src/lib/libc/gen
To: None <christos@zoulas.com>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-userlevel
Date: 12/11/2005 12:58:14
--NextPart-20051211125620-2156400
Content-Type: Text/Plain; charset=us-ascii

> | > | it's an ABI change and needs versioning, IMO.
> | > 
> | > I don't think that this or the previous behavior was specified in the API.
> | > [i.e. both behaviors are valid, and programs should not depend on either]
> | > Yes, there were bugs found in 3 programs after this change was introduced,
> | > but it is kind of late now to do the version bump.
> | > 
> | > christos
> | 
> | why too late?
> | it's entirely possible that someone updates his libraries tomorrow
> | and suffers from the incompatibility.
> 
> I guess. It is just that we already have 3 copies of the fts code in libc :-(
> It is not difficult to add a fourth one if people think that the change is
> affecting a lot of programs.
> 
> christos

IMHO, it isn't worth to have 4th one, but the behaviour of old two versions
should be restored.  (like the attached diff.)

maybe it's better to mention possible path mangling in the manpage explicitly
so that future programs don't rely on the either of the current or
old behaviour.

btw, it seems that you changed fts_close not to free "sp"
if fchdir is failed.  is it intentional?

YAMAMOTO Takashi

--NextPart-20051211125620-2156400
Content-Type: Text/Plain; charset=us-ascii
Content-Disposition: attachment; filename="a.diff"

Index: gen/fts.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/fts.c,v
retrieving revision 1.28
diff -u -p -r1.28 fts.c
--- gen/fts.c	18 Nov 2005 16:48:48 -0000	1.28
+++ gen/fts.c	11 Dec 2005 03:56:58 -0000
@@ -281,6 +281,8 @@ fts_close(FTS *sp)
 	return (0);
 }
 
+#if !defined(__FTS_COMPAT_TAILINGSLASH)
+
 /*
  * Special case of "/" at the end of the path so that slashes aren't
  * appended which would cause paths to be written as "....//foo".
@@ -289,6 +291,21 @@ fts_close(FTS *sp)
 	(p->fts_path[p->fts_pathlen - 1] == '/'				\
 	    ? p->fts_pathlen - 1 : p->fts_pathlen)
 
+#else /* !defined(__FTS_COMPAT_TAILINGSLASH) */
+
+/*
+ * compatibility with the old behaviour.
+ *
+ * Special case a root of "/" so that slashes aren't appended which would
+ * cause paths to be written as "//foo".
+ */
+
+#define	NAPPEND(p)							\
+	(p->fts_level == FTS_ROOTLEVEL && p->fts_pathlen == 1 &&	\
+	    p->fts_path[0] == '/' ? 0 : p->fts_pathlen)
+
+#endif /* !defined(__FTS_COMPAT_TAILINGSLASH) */
+
 FTSENT *
 fts_read(FTS *sp)
 {
Index: compat/gen/compat___fts13.c
===================================================================
RCS file: /cvsroot/src/lib/libc/compat/gen/compat___fts13.c,v
retrieving revision 1.1
diff -u -p -r1.1 compat___fts13.c
--- compat/gen/compat___fts13.c	13 Sep 2005 01:44:09 -0000	1.1
+++ compat/gen/compat___fts13.c	11 Dec 2005 03:56:58 -0000
@@ -47,4 +47,6 @@ __warn_references(__fts_set13,
 #include <fts.h>
 #include <compat/include/fts.h>
 
+#define	__FTS_COMPAT_TAILINGSLASH
+
 #include "gen/fts.c"
Index: compat/gen/compat_fts.c
===================================================================
RCS file: /cvsroot/src/lib/libc/compat/gen/compat_fts.c,v
retrieving revision 1.1
diff -u -p -r1.1 compat_fts.c
--- compat/gen/compat_fts.c	13 Sep 2005 01:44:09 -0000	1.1
+++ compat/gen/compat_fts.c	11 Dec 2005 03:56:58 -0000
@@ -44,4 +44,6 @@ __warn_references(fts_set,
     "warning: reference to compatibility fts_set();"
     " include <fts.h> for correct reference")
 
+#define	__FTS_COMPAT_TAILINGSLASH
+
 #include "gen/fts.c"

--NextPart-20051211125620-2156400--