From 966231475d5502257087680ddc78e31e157cfd18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johan=20Sundstr=C3=B6m?= <oyasumi@gmail.com>
Date: Fri, 2 Aug 2002 05:07:18 +0200
Subject: [PATCH] Reverted ugly `<<(string, int) / `>>(string, int) hack.

Rev: src/operators.c:1.157
Rev: src/testsuite.in:1.527
---
 src/operators.c  | 75 +++++-------------------------------------------
 src/testsuite.in |  8 +-----
 2 files changed, 8 insertions(+), 75 deletions(-)

diff --git a/src/operators.c b/src/operators.c
index a4adf0c373..4bd003bc8d 100644
--- a/src/operators.c
+++ b/src/operators.c
@@ -6,7 +6,7 @@
 /**/
 #include "global.h"
 #include <math.h>
-RCSID("$Id: operators.c,v 1.156 2002/06/25 14:26:41 grubba Exp $");
+RCSID("$Id: operators.c,v 1.157 2002/08/02 03:07:18 jhs Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "multiset.h"
@@ -1923,32 +1923,6 @@ static int generate_xor(node *n)
 
 PMOD_EXPORT void o_lsh(void)
 {
-  if(sp[-2].type == T_STRING) /* s[n..] */
-  {
-    struct pike_string *s;
-    ptrdiff_t from, len;
-    int args = 2;
-
-    if(sp[-1].type != T_INT)
-      SIMPLE_BAD_ARG_ERROR("`<<", 2, "int");
-
-    from = sp[-1].u.integer;
-    if(from <= 0) /* NOP */
-    {
-      sp--;
-      return;
-    }
-    if(from > sp[-2].u.string->len)
-      from = sp[-2].u.string->len;
-    len = sp[-2].u.string->len - from;
-
-    s = string_slice(sp[-2].u.string, from, len);
-    free_string(sp[-2].u.string);
-
-    sp--;
-    sp[-1].u.string = s;
-    return;
-  }
 #ifdef AUTO_BIGNUM
   if ((sp[-1].type == T_INT) && (sp[-2].type == T_INT) &&
       INT_TYPE_LSH_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer))
@@ -1962,7 +1936,7 @@ PMOD_EXPORT void o_lsh(void)
       return;
 
     if(sp[-2].type != T_INT)
-      SIMPLE_BAD_ARG_ERROR("`<<", 1, "int|string|object");
+      SIMPLE_BAD_ARG_ERROR("`<<", 1, "int|object");
     SIMPLE_BAD_ARG_ERROR("`<<", 2, "int|object");
   }
 #ifndef AUTO_BIGNUM
@@ -1979,7 +1953,6 @@ PMOD_EXPORT void o_lsh(void)
 /*! @decl int `<<(int arg1, int arg2)
  *! @decl mixed `<<(object arg1, int|object arg2)
  *! @decl mixed `<<(int arg1, object arg2)
- *! @decl string `<<(string arg1, int arg2)
  *!
  *!   Left shift operator.
  *!
@@ -1989,9 +1962,6 @@ PMOD_EXPORT void o_lsh(void)
  *!   If @[arg2] is an object that implements @[lfun::``<<()], that
  *!   function will be called with @[arg1] as the single argument.
  *!
- *!   If @[arg1] is a string, it will be truncated @[arg2] characters
- *!   from the left ("Hi!" << 2 == "Hi!"[2..] == "!").
- *!
  *!   Otherwise @[arg1] will be shifted @[arg2] bits left.
  *!
  *! @seealso
@@ -2019,39 +1989,13 @@ static int generate_lsh(node *n)
 
 PMOD_EXPORT void o_rsh(void)
 {
-  if(sp[-2].type == T_STRING) /* s[..sizeof(s)-n-1] */
-  {
-    struct pike_string *s;
-    ptrdiff_t len;
-    int args = 2;
-
-    if(sp[-1].type != T_INT)
-      SIMPLE_BAD_ARG_ERROR("`>>", 2, "int");
-
-    len = sp[-1].u.integer;
-    if(len <= 0) /* NOP */
-    {
-      sp--;
-      return;
-    }
-    if(len > sp[-2].u.string->len)
-      len = sp[-2].u.string->len;
-    len = sp[-2].u.string->len - len;
-
-    s = string_slice(sp[-2].u.string, 0, len);
-    free_string(sp[-2].u.string);
-    sp--;
-    sp[-1].u.string = s;
-    return;
-  }
-
   if(sp[-2].type != T_INT || sp[-1].type != T_INT)
   {
     int args = 2;
     if(call_lfun(LFUN_RSH, LFUN_RRSH))
       return;
     if(sp[-2].type != T_INT)
-      SIMPLE_BAD_ARG_ERROR("`>>", 1, "int|string|object");
+      SIMPLE_BAD_ARG_ERROR("`>>", 1, "int|object");
     SIMPLE_BAD_ARG_ERROR("`>>", 2, "int|object");
   }
   
@@ -2081,7 +2025,6 @@ PMOD_EXPORT void o_rsh(void)
 /*! @decl int `>>(int arg1, int arg2)
  *! @decl mixed `>>(object arg1, int|object arg2)
  *! @decl mixed `>>(int arg1, object arg2)
- *! @decl string `>>(string arg1, int arg2)
  *!
  *!   Right shift operator.
  *!
@@ -2091,10 +2034,7 @@ PMOD_EXPORT void o_rsh(void)
  *!   If @[arg2] is an object that implements @[lfun::``>>()], that
  *!   function will be called with @[arg1] as the single argument.
  *!
- *!   If @[arg1] is a string, it will be truncated @[arg2] characters
- *!   from the right ("Hi!" >> 2 == "Hi!"[..sizeof("Hi!")-3] == "H").
- *!
- *!   Otherwise @[arg1] will be shifted @[arg2] bits right.
+ *!   Otherwise @[arg1] will be shifted @[arg2] bits left.
  *!
  *! @seealso
  *!   @[`<<()]
@@ -3755,10 +3695,9 @@ multiset & mapping -> mapping
   ADD_EFUN2("`^",f_xor,LOG_TYPE,OPT_TRY_OPTIMIZE,optimize_binary,generate_xor);
 
 #define SHIFT_TYPE							\
-  tOr3(tOr(tFuncV(tMix tObj,tMix,tMix),					\
-           tFuncV(tObj tMix,tMix,tMix)),				\
-       tFuncV(tInt,tInt,tInt),						\
-       tFuncV(tStr,tInt,tStr))
+   tOr(tOr(tFuncV(tMix tObj,tMix,tMix),					\
+ 	   tFuncV(tObj tMix,tMix,tMix)),				\
+       tFuncV(tInt,tInt,tInt))
 
   ADD_EFUN2("`<<", f_lsh, SHIFT_TYPE, OPT_TRY_OPTIMIZE,
 	    may_have_side_effects, generate_lsh);
diff --git a/src/testsuite.in b/src/testsuite.in
index af462bccdc..2b2c34a942 100644
--- a/src/testsuite.in
+++ b/src/testsuite.in
@@ -1,4 +1,4 @@
-test_true([["$Id: testsuite.in,v 1.526 2002/07/29 17:20:06 nilsson Exp $"]]);
+test_true([["$Id: testsuite.in,v 1.527 2002/08/02 03:07:18 jhs Exp $"]]);
 
 cond([[all_constants()->_verify_internals]],
 [[
@@ -6313,18 +6313,12 @@ test_eq(1<<0,1)
 test_eq(1<<1,2)
 test_eq(1<<10,1024)
 test_eq(5<<3,40)
-test_eq("Yum!","Crunch! Yum!"<<8)
-test_eq("","Crunch! Yummy!"<<100)
-test_eq("*burp*","*burp*"<<0)
 
 // testing >>
 test_eq(9>>2,2)
 test_eq(1>>1,0)
 test_eq(1024>>10,1)
 test_eq(47>>3,5)
-test_eq("Crunch!","Crunch! Yum!">>5)
-test_eq("","Crunch! Ka-Chomp!">>100)
-test_eq("*burp*","*burp*">>0)
 
 // testing ? :
 test_true(0?0:1)
-- 
GitLab