Changeset 4995


Ignore:
Timestamp:
12/07/03 01:15:27 (18 years ago)
Author:
piso
Message:
  • getValue(): honor fill pointer.
  • SIMPLE-STRING-SEARCH
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/LispString.java

    r4952 r4995  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispString.java,v 1.66 2003-12-03 05:44:35 piso Exp $
     5 * $Id: LispString.java,v 1.67 2003-12-07 01:15:27 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    258258    public final String getValue()
    259259    {
    260         return new String(array);
     260        if (fillPointer >= 0)
     261            return new String(array, 0, fillPointer);
     262        else
     263            return new String(array);
    261264    }
    262265
     
    413416
    414417    private static final Primitive3 STRING_POSITION =
    415         new Primitive3("string-position", PACKAGE_EXT, true) {
     418        new Primitive3("string-position", PACKAGE_EXT, true)
     419    {
    416420        public LispObject execute(LispObject first, LispObject second,
    417421                                  LispObject third)
     
    429433        }
    430434    };
     435
     436    // ### simple-string-search pattern string => position
     437    // Searches string for a substring that matches pattern.
     438    private static final Primitive2 SIMPLE_STRING_SEARCH =
     439        new Primitive2("simple-string-search", PACKAGE_EXT, true)
     440    {
     441        public LispObject execute(LispObject first, LispObject second)
     442            throws ConditionThrowable
     443        {
     444            int index = getValue(second).indexOf(getValue(first));
     445            return index >= 0 ? new Fixnum(index) : NIL;
     446        }
     447    };
    431448}
Note: See TracChangeset for help on using the changeset viewer.