From c7896dce3b9c664799ea0fd9edbc5cb535abe892 Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Tue, 25 Feb 2014 14:17:24 +0100
Subject: [PATCH] Added a simple way to indicate that an argument is not used
 to the precompiler

This is rather ugly, just name the variable UNUSED. It should probably
be changed to be identical to the C-level UNUSED macro.

This can be used to skip the initialization and checking of said
argument in the generated code (the current "syntax" has one feature:

It will still work in old precompilers, it will just define a variable
named UNUSED)
---
 .../Tools.pmod/Standalone.pmod/precompile.pike  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike b/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike
index 066d6e03b7..b97eaf2886 100644
--- a/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike
+++ b/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike
@@ -2278,10 +2278,11 @@ static struct %s *%s_gdb_dummy_ptr;
 	    min_args--;
 
 	  foreach(args, Argument arg)
-	    ret+=({
-	      PC.Token(sprintf("%s %s;\n",arg->c_type(), arg->name()),
-		       arg->line()),
-	    });
+          if( arg->name() != "UNUSED" )
+              ret+=({
+                  PC.Token(sprintf("%s %s;\n",arg->c_type(), arg->name()),
+                           arg->line()),
+              });
 
 
 	  int argnum;
@@ -2329,7 +2330,13 @@ static struct %s *%s_gdb_dummy_ptr;
 	  foreach(args, Argument arg)
 	  {
 	    int got_void_or_zero_check = 0;
-
+        if( arg->name() == "UNUSED" )
+        {
+            // simply skip directly for now.
+            // should probably also handle ... etc?
+            argnum++;
+            continue;
+        }
 	    if (argnum == repeat_arg) {
 	      // Begin the argcnt loop.
 	      check_argbase = "+argcnt"+argbase;
-- 
GitLab