the following patch fixes a bug in the oracle compatibility
authorBruce Momjian
Tue, 11 Aug 1998 18:38:07 +0000 (18:38 +0000)
committerBruce Momjian
Tue, 11 Aug 1998 18:38:07 +0000 (18:38 +0000)
    functions btrim() ltrim() and rtrim().

    The error was that the character after the set  was  included
    in the tests (ptr2 pointed to the character after the vardata
    part of set if no match found,  so  comparing  *ptr  or  *end
    against *ptr2 MAY match -> strip).

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being
right. # # Let's break this rule - forgive me.
# #======================================== [email protected] (Jan
Wieck) #

src/backend/utils/adt/oracle_compat.c

index d056652ed027e7f03adcd92eb3f5cc998cafb03a..2297d3246c1363fdd55a53839930bc441094ad89 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Edmund Mergl 
  *
- * $Id: oracle_compat.c,v 1.14 1998/06/15 19:29:36 momjian Exp $
+ * $Id: oracle_compat.c,v 1.15 1998/08/11 18:38:07 momjian Exp $
  *
  */
 
@@ -297,7 +297,7 @@ btrim(text *string, text *set)
                break;
            ++ptr2;
        }
-       if (*ptr != *ptr2)
+       if (ptr2 > end2)
            break;
        ptr++;
        ptr2 = VARDATA(set);
@@ -316,7 +316,7 @@ btrim(text *string, text *set)
                break;
            ++ptr2;
        }
-       if (*end != *ptr2)
+       if (ptr2 > end2)
            break;
        --end;
        ptr2 = VARDATA(set);
@@ -374,7 +374,7 @@ ltrim(text *string, text *set)
                break;
            ++ptr2;
        }
-       if (*ptr != *ptr2)
+       if (ptr2 > end2)
            break;
        ptr++;
        ptr2 = VARDATA(set);
@@ -434,7 +434,7 @@ rtrim(text *string, text *set)
                break;
            ++ptr2;
        }
-       if (*ptr != *ptr2)
+       if (ptr2 > end2)
            break;
        --ptr;
        ptr2 = VARDATA(set);