.ad 8
.bm 8
.fm 4
.bt $Copyright by   SAP AG, 1998$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VSP33$
.tt 2 $$$
.tt 3 $$RTE-Extension-31$1998-09-07$
***********************************************************
.nf


    ========== licence begin LGPL
    Copyright (C) 2000 SAP AG

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    ========== licence end

.fo
.nf
.sp
Module  : RTE-Extension-33
=========
.sp
Purpose : Routine for comparing two buffer
          sends back the first position from left and
          right where the two buffer differ
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              s33cmpct (size_1    : tsp_int4;
                    size_2        : tsp_int4;
                    VAR buf1      : tsp_moveobj;
                    pos1          : tsp_int4;
                    s30len1       : tsp_int4;
                    VAR buf2      : tsp_moveobj;
                    pos2          : tsp_int4;
                    s30len2       : tsp_int4;
                    VAR front_pos : tsp_int4;
                    VAR rear_pos  : tsp_int4);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              RTE_kernel : VEN101;
 
        PROCEDURE
              vabort (write_core : boolean);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1986-09-05
.sp
.cp 3
Version : 1998-09-07
.sp
.cp 3
Release :      Date : 1998-09-07
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
PROCEDURE S33CMPCT
.sp
This procedure compares two buffers and returns the first
inequalities once beginning from the front and once beginning
from the back of these buffers. It has to be ensured that the
length of the first buffer is less or equal to the length of
the second. The unequal postions are passed back as frontpos
and rearpos. If the buffers are not of the same length rearpos
is set to the second buffer's length. In case of equality
frontpos and rearpos are set to zero.
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      c_write_core = true;
 
 
(*------------------------------*) 
 
PROCEDURE
      s33cmpct (size_1    : tsp_int4;
            size_2        : tsp_int4;
            VAR buf1      : tsp_moveobj;
            pos1          : tsp_int4;
            s30len1       : tsp_int4;
            VAR buf2      : tsp_moveobj;
            pos2          : tsp_int4;
            s30len2       : tsp_int4;
            VAR front_pos : tsp_int4;
            VAR rear_pos  : tsp_int4);
 
VAR
      s30eq, eq2 : boolean;
      i, j       : tsp_int4;
 
BEGIN
IF  (pos1 + s30len1 - 1 > size_1) OR
    (pos2 + s30len2 - 1 > size_2)
THEN
    vabort (c_write_core);
(*ENDIF*) 
eq2 := true;
i := pos1;
j := pos2;
s30eq := true;
front_pos := 0;
rear_pos := 0;
WHILE s30eq AND (j < pos2 + s30len1) DO
    IF  buf1 [ i ] <> buf2 [ j ]
    THEN
        BEGIN
        front_pos := (j - pos2) + 1;
        s30eq := false
        END
    ELSE
        BEGIN
        i := i+1;
        j := j+1
        END;
    (*ENDIF*) 
(*ENDWHILE*) 
IF  s30len2 > s30len1
THEN
    BEGIN
    rear_pos := s30len2;
    eq2 := false;
    IF  s30eq
    THEN
        front_pos := s30len1 + 1
    (*ENDIF*) 
    END;
(*ENDIF*) 
IF  NOT s30eq AND eq2
THEN
    BEGIN
    i := pos1 + s30len1 - 1;
    j := pos2 + s30len2 - 1;
    s30eq := true;
    WHILE s30eq AND (j >= front_pos)
          DO
        IF  buf1 [ i ] <> buf2 [ j ]
        THEN
            BEGIN
            rear_pos := (j - pos2) + 1;
            s30eq := false
            END
        ELSE
            BEGIN
            i := i-1;
            j := j-1
            END;
        (*ENDIF*) 
    (*ENDWHILE*) 
    END
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         29
*-PRETTY-*  lines of code :         83        PRETTYX 3.10 
*-PRETTY-*  lines in file :        200         1997-12-10 
.PA 
