* [gentoo-commits] gentoo-projects commit in portage-utils/libq: scandirat.c
@ 2011-12-22 18:29 Mike Frysinger (vapier)
0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-22 18:29 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/22 18:29:23
Modified: scandirat.c
Log:
since sizeof(dirent) is not portable (and will break on some systems), use the d_reclen member instead ... it still isnt entirely portable, but at least it works when it is available
Revision Changes Path
1.3 portage-utils/libq/scandirat.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.3&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.3&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?r1=1.2&r2=1.3
Index: scandirat.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- scandirat.c 18 Dec 2011 06:31:29 -0000 1.2
+++ scandirat.c 22 Dec 2011 18:29:23 -0000 1.3
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2011 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.2 2011/12/18 06:31:29 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.3 2011/12/22 18:29:23 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2011 Mike Frysinger - <vapier@gentoo.org>
@@ -31,7 +31,7 @@
continue;
ret = realloc(ret, sizeof(*ret) * (cnt + 1));
- ret[cnt++] = xmemdup(de, sizeof(*de));
+ ret[cnt++] = xmemdup(de, de->d_reclen);
}
*dirlist = ret;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils/libq: scandirat.c
@ 2012-01-16 1:10 Mike Frysinger (vapier)
0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger (vapier) @ 2012-01-16 1:10 UTC (permalink / raw
To: gentoo-commits
vapier 12/01/16 01:10:32
Modified: scandirat.c
Log:
newer glibc provides scandirat() for us
Revision Changes Path
1.4 portage-utils/libq/scandirat.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.4&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.4&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?r1=1.3&r2=1.4
Index: scandirat.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- scandirat.c 22 Dec 2011 18:29:23 -0000 1.3
+++ scandirat.c 16 Jan 2012 01:10:32 -0000 1.4
@@ -1,12 +1,20 @@
/*
* Copyright 2005-2011 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.3 2011/12/22 18:29:23 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.4 2012/01/16 01:10:32 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2011 Mike Frysinger - <vapier@gentoo.org>
*/
+#if !defined(HAVE_SCANDIRAT)
+# if defined(__GLIBC__) && (__GLIBC__ << 8 | __GLIBC_MINOR__) > (2 << 8 | 14)
+# define HAVE_SCANDIRAT
+# endif
+#endif
+
+#if !defined(HAVE_SCANDIRAT)
+
static int scandirat(int dir_fd, const char *dir, struct dirent ***dirlist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **))
@@ -43,6 +51,8 @@
return cnt;
}
+#endif
+
_q_static void scandir_free(struct dirent **de, int cnt)
{
if (cnt <= 0)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils/libq: scandirat.c
@ 2013-09-29 10:07 Mike Frysinger (vapier)
0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29 10:07 UTC (permalink / raw
To: gentoo-commits
vapier 13/09/29 10:07:28
Modified: scandirat.c
Log:
scandirat: use _DIRENT_HAVE_D_RECLEN to be slightly more portable #485430
Revision Changes Path
1.5 portage-utils/libq/scandirat.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.5&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.5&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?r1=1.4&r2=1.5
Index: scandirat.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- scandirat.c 16 Jan 2012 01:10:32 -0000 1.4
+++ scandirat.c 29 Sep 2013 10:07:28 -0000 1.5
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2011 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.4 2012/01/16 01:10:32 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.5 2013/09/29 10:07:28 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2011 Mike Frysinger - <vapier@gentoo.org>
@@ -13,7 +13,13 @@
# endif
#endif
-#if !defined(HAVE_SCANDIRAT)
+#if !defined(HAVE_SCANDIRATf)
+
+#if defined(_DIRENT_HAVE_D_RECLEN)
+# define reclen(de) ((de)->d_reclen)
+#else
+# define reclen(de) (sizeof(*(de)))
+#endif
static int scandirat(int dir_fd, const char *dir, struct dirent ***dirlist,
int (*filter)(const struct dirent *),
@@ -39,7 +45,7 @@
continue;
ret = realloc(ret, sizeof(*ret) * (cnt + 1));
- ret[cnt++] = xmemdup(de, de->d_reclen);
+ ret[cnt++] = xmemdup(de, reclen(de));
}
*dirlist = ret;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils/libq: scandirat.c
@ 2013-09-29 10:25 Mike Frysinger (vapier)
0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29 10:25 UTC (permalink / raw
To: gentoo-commits
vapier 13/09/29 10:25:25
Modified: scandirat.c
Log:
scandirat: fix another typo
Revision Changes Path
1.6 portage-utils/libq/scandirat.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.6&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.6&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?r1=1.5&r2=1.6
Index: scandirat.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- scandirat.c 29 Sep 2013 10:07:28 -0000 1.5
+++ scandirat.c 29 Sep 2013 10:25:25 -0000 1.6
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2011 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.5 2013/09/29 10:07:28 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.6 2013/09/29 10:25:25 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2011 Mike Frysinger - <vapier@gentoo.org>
@@ -13,7 +13,7 @@
# endif
#endif
-#if !defined(HAVE_SCANDIRATf)
+#if !defined(HAVE_SCANDIRAT)
#if defined(_DIRENT_HAVE_D_RECLEN)
# define reclen(de) ((de)->d_reclen)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils/libq: scandirat.c
@ 2013-11-17 10:26 Fabian Groffen (grobian)
0 siblings, 0 replies; 5+ messages in thread
From: Fabian Groffen (grobian) @ 2013-11-17 10:26 UTC (permalink / raw
To: gentoo-commits
grobian 13/11/17 10:26:53
Modified: scandirat.c
Log:
scandirat: copy enough bytes to get the filename
Solaris is a platform without d_reclen. sizeof(struct dirent) is not
enough to get the whole of d_name contents, since the struct uses
char[1] as workaround to specify a variable size length end of struct
member.
Revision Changes Path
1.7 portage-utils/libq/scandirat.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.7&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?rev=1.7&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/scandirat.c?r1=1.6&r2=1.7
Index: scandirat.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- scandirat.c 29 Sep 2013 10:25:25 -0000 1.6
+++ scandirat.c 17 Nov 2013 10:26:53 -0000 1.7
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2011 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.6 2013/09/29 10:25:25 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.7 2013/11/17 10:26:53 grobian Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2011 Mike Frysinger - <vapier@gentoo.org>
@@ -18,7 +18,7 @@
#if defined(_DIRENT_HAVE_D_RECLEN)
# define reclen(de) ((de)->d_reclen)
#else
-# define reclen(de) (sizeof(*(de)))
+# define reclen(de) (sizeof(*(de)) + strlen((de)->d_name))
#endif
static int scandirat(int dir_fd, const char *dir, struct dirent ***dirlist,
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-17 10:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-17 10:26 [gentoo-commits] gentoo-projects commit in portage-utils/libq: scandirat.c Fabian Groffen (grobian)
-- strict thread matches above, loose matches on Subject: below --
2013-09-29 10:25 Mike Frysinger (vapier)
2013-09-29 10:07 Mike Frysinger (vapier)
2012-01-16 1:10 Mike Frysinger (vapier)
2011-12-22 18:29 Mike Frysinger (vapier)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox