#! /bin/sh -e

# DP: Fix spurious range-check failure in the gpc runtime.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        #cd ${dir}gcc && autoconf
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        #rm ${dir}gcc/configure
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

--- gcc/p/rts/move.pas.orig	2005-05-06 19:24:26.188617784 +0000
+++ gcc/p/rts/move.pas	2005-05-06 18:43:23.418015824 +0000
@@ -58,6 +58,7 @@
   PWords = ^TWords;
   PConstWords = ^const TWords;
 
+{$R-}
 function Merge (w1, w2: TWord; Shift1, Shift2: Integer): TWord; attribute (inline);
 begin
   if BytesBigEndian then
@@ -66,7 +67,7 @@
     Merge := (w1 shr Shift1) or (w2 shl Shift2)
 end;
 
-{$pointer-arithmetic,R-}
+{$pointer-arithmetic}
 
 procedure MoveLeft (const Source; var Dest; Count: SizeType);
 var

