This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi Tom,
This is in reference to:
http://gcc.gnu.org/ml/java-patches/2003-q3/msg00299.html
>As for the function, it can definitely go in cni.h. However, you'll
>also need to update gcj.texi to document it. Shouldn't we call it
>"JvGetStringUTFChars"?
Here is a patch for cni.h only. I'll send the patch for gcj.texi and
jvm.h under separate cover.
After careful consideration, I've decided not to go with Bryce's
suggestion of checking buffer size:
http://gcc.gnu.org/ml/java-patches/2003-q3/msg00308.html
...because:
- this would involve an additional call to JvGetStringUTFLength
for bounds checking
- JvGetStringUTFRegion does not do this bounds checking either
- the caller can call JvGetStringUTFLength beforehand if s/he wants to
- the _Jv_TempUTFString class and JV_TEMP_UTF_STRING macro
(subsequent patch) will also shield us from this
Tested on (i686-pc-linux-gnu,i686-pc-linux-gnu), (i686-pc-linux-gnu,i686-pc-mingw32)
and (i686-pc-mingw32,i686-pc-mingw32). The testcase (which also covers
the jvm.h patch) is attached.
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
ChangeLog
2003-08-13 Mohan Embar <gnustuff@thisiscool.com>
* gcj/cni.h: New function JvGetStringUTFChars (puts and null
terminates a jstring into a character buffer)
Index: gcj/cni.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/gcj/cni.h,v
retrieving revision 1.10
diff -u -2 -r1.10 cni.h
--- gcj/cni.h 8 Jul 2003 21:27:37 -0000 1.10
+++ gcj/cni.h 12 Aug 2003 02:00:21 -0000
@@ -90,4 +90,12 @@
}
+extern inline jsize
+JvGetStringUTFChars (jstring str, char *buf)
+{
+ jsize len = JvGetStringUTFRegion (str, 0, str->length(), buf);
+ buf[len] = '\0';
+ return len;
+}
+
extern inline jstring
JvNewStringUTF (const char *bytes)
Attachment:
CNITest.tar.bz2
Description: application/bzip2
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |