From c9427bffcdd3e9b06fa2f5b917d2eff8f014b021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 22 Feb 2017 17:38:10 +0100
Subject: [PATCH] Arg & ADT.Struct: Survive use by old (ie 8.0.232) pike
 binaries.

Prior to Pike 8.0.368 the new-style argument checking in ::_indices()
was broken.

Roxen 6.0.130 uses a Pike 8.0.232 binary with current modules.

Fixes [PIKE-6].
---
 lib/modules/ADT.pmod/Struct.pike | 10 +++++++++-
 lib/modules/Arg.pmod             | 10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/modules/ADT.pmod/Struct.pike b/lib/modules/ADT.pmod/Struct.pike
index 2c064f694d..ad335ee724 100644
--- a/lib/modules/ADT.pmod/Struct.pike
+++ b/lib/modules/ADT.pmod/Struct.pike
@@ -48,7 +48,15 @@ int id = ADT.get_item_id();
 //!   Data to be decoded and populate the struct. Can
 //!   either be a file object or a string.
 optional protected void create(void|string|object file) {
-  foreach(::_indices(this, 0), string index) {
+  foreach(
+#if __BUILD__ < 368
+	  // NB: Prior to 8.0.368 the new-style argument checking in _indices()
+	  //     was broken.
+	  ::_indices(2),
+#else
+	  ::_indices(this, 0),
+#endif
+	  string index) {
     mixed val = ::`[](index, this, 0);
     if(objectp(val) && val->is_item) names[index]=val;
   }
diff --git a/lib/modules/Arg.pmod b/lib/modules/Arg.pmod
index 28c9ac3dc1..8045e2e4f0 100644
--- a/lib/modules/Arg.pmod
+++ b/lib/modules/Arg.pmod
@@ -418,7 +418,15 @@ class LowOptions
       env = getenv();
 
     // Make a list of all the arguments we can parse.
-    foreach(::_indices(this, 0), string index)
+    foreach(
+#if __BUILD__ < 368
+	    // NB: Prior to 8.0.368 the new-style argument checking in _indices()
+	    //     was broken.
+	    ::_indices(2),
+#else
+	    ::_indices(this, 0),
+#endif
+	    string index)
     {
       mixed val = ::`[](index, this, 0);
       if(objectp(val) && val->is_opt) opts[index]=val;
-- 
GitLab