gpgscm: Simplify substring operation.
authorJustus Winter <justus@g10code.com>
Tue, 4 Apr 2017 12:28:45 +0000 (14:28 +0200)
committerJustus Winter <justus@g10code.com>
Tue, 4 Apr 2017 13:04:42 +0000 (15:04 +0200)
* tests/gpgscm/scheme.c (opexe_2): Simplify 'substring'.

Signed-off-by: Justus Winter <justus@g10code.com>
tests/gpgscm/scheme.c

index fbc562d..3c7afa3 100644 (file)
@@ -4355,7 +4355,6 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
           char *str;
           int index0;
           int index1;
-          int len;
 
           str=strvalue(car(sc->args));
 
@@ -4374,13 +4373,8 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
                index1=strlength(car(sc->args));
           }
 
-          len=index1-index0;
          gc_disable(sc, 1);
-          x=mk_empty_string(sc,len,' ');
-          memcpy(strvalue(x),str+index0,len);
-          strvalue(x)[len]=0;
-
-          s_return_enable_gc(sc, x);
+          s_return_enable_gc(sc, mk_counted_string(sc, str + index0, index1 - index0));
      }
 
      CASE(OP_VECTOR): {   /* vector */