#! /bin/sh -e
## 119_fix_gas_double_negative.dpatch by James Troup <james@nocrew.org>
##
## DP: Description: Fix gas' handling of -- and ++. (#266772)
## DP: Author: Alan Modra <amodra@bigpond.net.au>
## DP: Upstream status: Committed to trunk.
## DP: Date: 2004-05-23
## DP: URL: http://sources.redhat.com/ml/binutils/2004-05/msg00418.html

if [ $# -lt 1 ]; then
    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"

case "$1" in
    -patch) patch -p1 ${patch_opts} < $0;;
    -unpatch) patch -R -p1 ${patch_opts} < $0;;
    *)
        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
        exit 1;;
esac

exit 0

@DPATCH@
diff -urNad /home/james/debian/packages/binutils/binutils-2.15/gas/expr.c binutils-2.15/gas/expr.c
--- /home/james/debian/packages/binutils/binutils-2.15/gas/expr.c	2004-05-17 20:36:07.000000000 +0100
+++ binutils-2.15/gas/expr.c	2004-09-09 22:21:58.100707251 +0100
@@ -1021,8 +1021,9 @@
       break;
 
     case '+':
-      /* Do not accept ++e as +(+e) */
-      if (*input_line_pointer == '+')
+      /* Do not accept ++e as +(+e).
+	 Disabled, since the preprocessor removes whitespace.  */
+      if (0 && *input_line_pointer == '+')
 	goto target_op;
       (void) operand (expressionP);
       break;
@@ -1041,8 +1042,9 @@
     case '!':
     case '-':
       {
-        /* Do not accept --e as -(-e) */
-	if (c == '-' && *input_line_pointer == '-')
+        /* Do not accept --e as -(-e)
+	   Disabled, since the preprocessor removes whitespace.  */
+	if (0 && c == '-' && *input_line_pointer == '-')
 	  goto target_op;
 	
 	operand (expressionP);
@@ -1551,8 +1553,9 @@
 
     case '+':
     case '-':
-      /* Do not allow a++b and a--b to be a + (+b) and a - (-b) */
-      if (input_line_pointer[1] != c)
+      /* Do not allow a++b and a--b to be a + (+b) and a - (-b)
+	 Disabled, since the preprocessor removes whitespace.  */
+      if (1 || input_line_pointer[1] != c)
 	return op_encoding[c];
       return O_illegal;
 
