bug-gnulib
[Top][All Lists]
Advanced

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

same-inode.h and OpenVMS


From: Paul Eggert
Subject: same-inode.h and OpenVMS
Date: Fri, 30 Dec 2011 14:27:57 -0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0

On OpenVMS st_ino is an array of three ino_t values, so grep's
a.st_ino == b.st_ino compares *pointers*, and yields 0.  Ouch.

For other GNU programs we often don't worry about OpenVMS,
but grep is a special case, as it's actually used on OpenVMS
<http://h71000.www7.hp.com/opensource/gnv.html>
and grep uses st_ino so rarely that it's easy to port around
this particular problem.  Here's a proposed patch.
One part is to grep, the other to gnulib, so I'll CC:
this to bug-gnulib.


---- grep patch ----
grep: fix directory loop check on OpenVMS
* src/main.c (grepdir): Use SAME_INODE instead of rolling our own.
diff --git a/src/main.c b/src/main.c
index ca6f85f..43b938e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1515,8 +1515,7 @@ grepdir (char const *dir, struct stats const *stats)
     {
       for (ancestor = stats; (ancestor = ancestor->parent) != 0;  )
         {
-          if (ancestor->stat.st_ino == stats->stat.st_ino
-              && ancestor->stat.st_dev == stats->stat.st_dev)
+          if (SAME_INODE (ancestor->stat, stats->stat))
             {
               if (!suppress_errors)
                 error (0, 0, _("warning: %s: %s"), dir,


---- gnulib patch ----
* lib/same-inode.h (SAME_INODE): Port to OpenVMS.
diff --git a/lib/same-inode.h b/lib/same-inode.h
index d434b94..7956a7d 100644
--- a/lib/same-inode.h
+++ b/lib/same-inode.h
@@ -18,8 +18,16 @@
 #ifndef SAME_INODE_H
 # define SAME_INODE_H 1

-# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
-   ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
-    && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
+# ifdef __VMS
+#  define SAME_INODE(a, b)             \
+    ((a).st_ino[0] == (b).st_ino[0]    \
+     && (a).st_ino[1] == (b).st_ino[1] \
+     && (a).st_ino[2] == (b).st_ino[2] \
+     && (a).st_dev == (b).st_dev)
+# else
+#  define SAME_INODE(a, b)    \
+    ((a).st_ino == (b).st_ino \
+     && (a).st_dev == (b).st_dev)
+# endif

 #endif



reply via email to

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