1 // natStringBuffer.cc - Implementation of java.lang.StringBuffer native methods. 2 3 /* Copyright (C) 2001, 2003 Free Software Foundation 4 5 This file is part of libgcj. 6 7 This software is copyrighted work licensed under the terms of the 8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for 9 details. */ 10 11 #include <config.h> 12 #include <gcj/cni.h> 13 #include <java/lang/AbstractStringBuffer.h> 14 15 java::lang::AbstractStringBuffer* append(jint num)16java::lang::AbstractStringBuffer::append (jint num) 17 { 18 // Use an array large enough for "-2147483648"; i.e. 11 chars. 19 jchar buffer[11]; 20 int i = _Jv_FormatInt (buffer+11, num); 21 jint needed = count + i; 22 ensureCapacity_unsynchronized (needed); 23 jchar* dst = elements (value) + count; 24 jchar* src = buffer+11-i; 25 while (--i >= 0) 26 *dst++ = *src++; 27 count = needed; 28 return this; 29 } 30 31 jboolean regionMatches(jint toffset,jstring other)32java::lang::AbstractStringBuffer::regionMatches(jint toffset, jstring other) 33 { 34 jint len = other->count; 35 jchar *tptr = elements(value) + toffset; 36 jchar *optr = JvGetStringChars(other); 37 while (--len >= 0) 38 if (*tptr++ != *optr++) 39 return false; 40 return true; 41 } 42