[Pkg-javascript-commits] [node-iconv] 03/05: Adapt to the way //translit and //ignore works in eglibc

Jérémy Lal kapouer at moszumanska.debian.org
Sun Jun 15 00:23:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

kapouer pushed a commit to branch master
in repository node-iconv.

commit b67df511184e10ce4deabaab79d0768166ec6485
Author: Jérémy Lal <kapouer at melix.org>
Date:   Sun Jun 15 02:19:52 2014 +0200

    Adapt to the way //translit and //ignore works in eglibc
---
 debian/patches/use-glibc-iconv.patch | 63 ++++++++++++++++++++++++++++++++++--
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/debian/patches/use-glibc-iconv.patch b/debian/patches/use-glibc-iconv.patch
index 98ddbef..343052a 100644
--- a/debian/patches/use-glibc-iconv.patch
+++ b/debian/patches/use-glibc-iconv.patch
@@ -58,7 +58,7 @@ Last-Update: 2014-06-14
  }
 --- a/src/binding.cc
 +++ b/src/binding.cc
-@@ -14,7 +14,7 @@
+@@ -14,12 +14,13 @@
   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */
  
@@ -67,7 +67,21 @@ Last-Update: 2014-06-14
  #include "nan.h"
  
  #include <errno.h>
-@@ -94,7 +94,7 @@
+ #include <assert.h>
+ #include <stdint.h>
++#include <locale.h>
+ 
+ namespace
+ {
+@@ -60,6 +61,7 @@
+ 
+   static void Initialize(Handle<Object> obj)
+   {
++    setlocale(LC_ALL, "");
+     NanScope();
+     Local<ObjectTemplate> t = ObjectTemplate::New();
+     t->SetInternalFieldCount(1);
+@@ -94,7 +96,7 @@
      NanScope();
      Iconv* iv = static_cast<Iconv*>(
          NanGetInternalFieldPointer(args[0].As<Object>(), 0));
@@ -76,3 +90,48 @@ Last-Update: 2014-06-14
          args[1].As<Object>()->GetIndexedPropertiesExternalArrayData());
      size_t input_start = args[2]->Uint32Value();
      size_t input_size = args[3]->Uint32Value();
+--- a/lib/iconv.js
++++ b/lib/iconv.js
+@@ -43,11 +43,13 @@
+   stream.Stream.call(this);
+   this.writable = true;
+ 
+-  var conv = bindings.make(fixEncoding(fromEncoding),
+-                           fixEncoding(toEncoding));
++  fromEncoding = fixEncoding(fromEncoding);
++  toEncoding = fixEncoding(toEncoding);
++
++  var conv = bindings.make(fromEncoding, toEncoding);
+   if (conv === null) throw new Error('Conversion not supported.');
+ 
+-  var convert_ = convert.bind({ conv_: conv });
++  var convert_ = convert.bind({ conv_: conv, from: fromEncoding, to: toEncoding });
+   var context_ = { trailer: null };
+ 
+   this.convert = function(input, encoding) {
+@@ -132,7 +134,9 @@
+         continue;
+       }
+       else if (errno === EILSEQ) {
+-        throw errnoException('EILSEQ', 'Illegal character sequence.');
++        if (/\/\/ignore/i.test(this.to) == false) {
++          throw errnoException('EILSEQ', 'Illegal character sequence.');
++        }
+       }
+       else if (errno === EINVAL) {
+         if (context === null || input === FLUSH) {
+--- a/test/test-basic.js
++++ b/test/test-basic.js
+@@ -108,10 +108,10 @@
+ assert.equal(iconv.convert('ça va').toString(), 'ca va');
+ 
+ iconv = new Iconv('utf-8', 'ascii//translit');
+-assert.throws(function() { iconv.convert('ça va が'); }); // untranslatable
++assert.equal(iconv.convert('ça va が').toString(), 'ca va ?');
+ 
+ iconv = new Iconv('utf-8', 'ascii//translit//ignore');
+-assert.equal(iconv.convert('ça va が').toString(), 'ca va ');
++assert.equal(iconv.convert('ça va が').toString(), 'ca va ?');
+ 
+ iconv = Iconv('utf-8', 'iso-8859-1');
+ assert.equal(iconv.convert('b2s=', 'base64').toString(), 'ok');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iconv.git



More information about the Pkg-javascript-commits mailing list