Date: Thu, 20 Dec 2012 00:47:54 GMT From: Phil Phillips <pphillips@experts-exchange.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/174583: devel/libreadline-java: patch for UTF8 support Message-ID: <201212200047.qBK0lsfP054368@red.freebsd.org> Resent-Message-ID: <201212200050.qBK0o0sr022229@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 174583 >Category: ports >Synopsis: devel/libreadline-java: patch for UTF8 support >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Dec 20 00:50:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Phil Phillips >Release: >Organization: Experts Exchange, LLC >Environment: >Description: Here's a patch that effectively removes UTF8<->UCS conversions within the libreadline library. The conversions weren't working for three-byte UTF8. Plus, the conversions are no longer needed since all JDKs supported by FreeBSD should be using UTF16 internally (older JDKs used UCS-2). >How-To-Repeat: >Fix: Patch attached with submission follows: Index: Makefile =================================================================== --- Makefile (revision 309274) +++ Makefile (working copy) @@ -8,7 +8,7 @@ PORTNAME= libreadline-java PORTVERSION= 0.8.0 DISTVERSIONSUFFIX= -src -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel java MASTER_SITES= SF/java-readline/java-readline/${PORTVERSION} Index: files/patch-src-native-org_gnu_readline_Readline.c =================================================================== --- files/patch-src-native-org_gnu_readline_Readline.c (revision 309274) +++ files/patch-src-native-org_gnu_readline_Readline.c (working copy) @@ -1,9 +1,10 @@ ---- src/native/org_gnu_readline_Readline.c.orig 2003-01-07 11:14:35.000000000 +0100 -+++ src/native/org_gnu_readline_Readline.c 2007-09-27 09:21:14.000000000 +0200 -@@ -560,6 +560,21 @@ +--- src/native/org_gnu_readline_Readline.c.orig 2003-01-07 02:14:35.000000000 -0800 ++++ src/native/org_gnu_readline_Readline.c 2012-12-19 10:03:12.000000000 -0800 +@@ -560,14 +560,25 @@ #endif /* -------------------------------------------------------------------------- */ +-/* Convert utf8-string to ucs1-string . */ +/* Sets/gets rl_completion_append_character */ +/* -------------------------------------------------------------------------- */ + @@ -19,6 +20,79 @@ +#endif + +/* -------------------------------------------------------------------------- */ - /* Convert utf8-string to ucs1-string . */ ++/* Hack: Conversion not needed (java running UTF16) */ /* -------------------------------------------------------------------------- */ + char* utf2ucs(const char *utf8) { +- const char *pin; +- char *pout, *ucs; +- unsigned char current, next; +- int i; + size_t n; + + n = strlen(utf8); +@@ -575,36 +586,14 @@ + if (allocBuffer(2*n)) + return NULL; + } +- +- for (i=0,pin=utf8,pout=buffer; i<bufLength && *pin; i++,pin++,pout++) { +- current = *pin; +- if (current >= 0xE0) { /* we support only two-byte utf8 */ +- return NULL; +- } else if ((current & 0x80) == 0) /* one-byte utf8 */ +- *pout = current; +- else { /* two-byte utf8 */ +- next = *(++pin); +- if (next >= 0xC0) { /* illegal coding */ +- return NULL; +- } +- *pout = ((current & 3) << 6) + /* first two bits of first byte */ +- (next & 63); /* last six bits of second byte */ +- } +- } +- if (i<bufLength) +- *pout = '\0'; +- return buffer; ++ return strcpy(buffer, utf8); + } + + /* -------------------------------------------------------------------------- */ +-/* Convert ucs1-string to utf8-string . */ ++/* Hack: Conversion not needed (java running UTF16) */ + /* -------------------------------------------------------------------------- */ + + char* ucs2utf(const char *ucs) { +- const char *pin; +- char *pout; +- unsigned char current; +- int i; + size_t n; + + n = strlen(ucs); +@@ -612,24 +601,7 @@ + if (allocBuffer(2*n)) + return NULL; + } +- +- for (i=0,pin=ucs,pout=buffer; i<bufLength && *pin; i++,pin++,pout++) { +- current = *pin; +- if (current < 0x80) /* one-byte utf8 */ +- *pout = current; +- else { /* two-byte utf8 */ +- *pout = 0xC0 + (current>>6); /* first two bits */ +- pout++, i++; /* examine second byte */ +- if (i>=bufLength) { /* cannot convert last byte */ +- *(--pout) = '\0'; +- return buffer; +- } +- *pout = 0x80 + (current & 63); /* last six bits */ +- } +- } +- if (i<bufLength) +- *pout = '\0'; +- return buffer; ++ return strcpy(buffer, ucs); + } + + /* -------------------------------------------------------------------------- */ >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212200047.qBK0lsfP054368>