[Pkg-javascript-commits] [node-iconv] 01/08: New upstream version 2.2.1

Jérémy Lal kapouer at moszumanska.debian.org
Sat Sep 10 08:55:42 UTC 2016


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

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

commit dc9d6e8a8106bb80ce925288d7a74760d82e6c5f
Author: Jérémy Lal <kapouer at melix.org>
Date:   Sat Sep 10 10:41:38 2016 +0200

    New upstream version 2.2.1
---
 README.md          |  9 ++++--
 binding.gyp        | 81 +++++++++++++++++++++++++++---------------------------
 lib/iconv.js       |  7 ++++-
 package.json       |  4 +--
 src/binding.cc     |  8 ++++--
 test/test-basic.js | 23 ++++++++++++++++
 6 files changed, 84 insertions(+), 48 deletions(-)

diff --git a/README.md b/README.md
index 4dc6517..d87adff 100644
--- a/README.md
+++ b/README.md
@@ -72,8 +72,13 @@ module.
 ## Compiling from source
 
     $ git clone git://github.com/bnoordhuis/node-iconv.git
-    $ node-gyp configure build
-    $ npm install .
+    $ cd node-iconv
+    $ npm install
+
+If you have a specific node.js source checkout that you want to build against,
+replace the last command with:
+
+    $ npm install --nodedir=/path/to/node
 
 ## Usage
 
diff --git a/binding.gyp b/binding.gyp
index f3d0940..a0e5da0 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -1,11 +1,14 @@
 {
+  'variables': {
+    'node_iconv_use_system_libiconv%': 0,
+  },
+
   'targets': [
     {
       'target_name': 'iconv',
-      'dependencies': ['libiconv'],
       'include_dirs': ['<!(node -e "require(\'nan\')")'],
       'sources': ['src/binding.cc'],
-      'cflags': [
+      'ccflags': [
         '-Wall',
         '-Wextra',
         '-Wno-unused-parameter',  # Squelches warnings coming from v8.h.
@@ -18,46 +21,42 @@
         'GCC_ENABLE_CPP_RTTI': 'NO',
         'WARNING_CFLAGS': ['-Wall', '-Wextra', '-Wno-unused-parameter'],
       },
-    },
-
-    {
-      'target_name': 'libiconv',
-      'type': 'static_library',
-      'direct_dependent_settings': {
-        'include_dirs':  ['support'],
-      },
-      'defines': ['ICONV_CONST=const', 'ENABLE_EXTRA=1'],
-      'include_dirs': [
-        'deps/libiconv/srclib',
-        'support',
-      ],
-      'sources': ['deps/libiconv/lib/iconv.c'],
       'conditions': [
-        ['OS == "win"', {
-          'defines': ['WIN32_NATIVE=1'],
-        }, {
-          'defines': ['HAVE_WORKING_O_NOFOLLOW=1'],
-          'cflags!': ['-W', '-Wall', '-Wextra'],
+        ['node_iconv_use_system_libiconv==0', {
+          'defines': ['ICONV_CONST=const', 'ENABLE_EXTRA=1'],
+          'include_dirs': [
+            'deps/libiconv/srclib',
+            'support',
+          ],
+          'sources': ['deps/libiconv/lib/iconv.c'],
+          'conditions': [
+            ['OS == "win"', {
+              'defines': ['WIN32_NATIVE=1'],
+            }, {
+              'defines': ['HAVE_WORKING_O_NOFOLLOW=1'],
+              'cflags!': ['-W', '-Wall', '-Wextra'],
+            }],
+          ],
+          'msvs_settings': {
+            'VCCLCompilerTool': {
+              'DisableSpecificWarnings': [
+                '4018',  # Signed/unsigned comparison.
+                '4090',  # Const/non-const mismatch.
+                '4244',  # Narrowing cast.
+                '4267',  # Narrowing cast.
+              ],
+            },
+          },
+          'xcode_settings': {
+            'WARNING_CFLAGS!': ['-W', '-Wall', '-Wextra'],
+            'WARNING_CFLAGS': [
+              '-Wno-parentheses-equality',
+              '-Wno-static-in-inline',
+              '-Wno-tautological-compare',
+            ],
+          },
         }],
       ],
-      'msvs_settings': {
-        'VCCLCompilerTool': {
-          'DisableSpecificWarnings': [
-            '4018',  # Signed/unsigned comparison.
-            '4090',  # Const/non-const mismatch.
-            '4244',  # Narrowing cast.
-            '4267',  # Narrowing cast.
-          ],
-        },
-      },
-      'xcode_settings': {
-        'WARNING_CFLAGS!': ['-W', '-Wall', '-Wextra'],
-        'WARNING_CFLAGS': [
-          '-Wno-parentheses-equality',
-          '-Wno-static-in-inline',
-          '-Wno-tautological-compare',
-        ],
-      },
-    }
-  ]
+    },
+  ],
 }
diff --git a/lib/iconv.js b/lib/iconv.js
index 693fd38..34eda17 100644
--- a/lib/iconv.js
+++ b/lib/iconv.js
@@ -47,7 +47,11 @@ function Iconv(fromEncoding, toEncoding)
 
   var conv = bindings.make(fixEncoding(fromEncoding),
                            fixEncoding(toEncoding));
-  if (conv === null) throw new Error('Conversion not supported.');
+  if (conv === null) {
+    throw new Error('Conversion from ' +
+                    fromEncoding + ' to ' +
+                    toEncoding + ' is not supported.');
+  }
 
   var convert_ = convert.bind({ conv_: conv });
   var context_ = { trailer: null };
@@ -88,6 +92,7 @@ util.inherits(Iconv, stream.Stream);
 
 function fixEncoding(encoding)
 {
+  if (/^windows-31j$/i.test(encoding)) return 'cp932';
   // Convert "utf8" to "utf-8".
   return /^utf[^-]/i.test(encoding) ? 'utf-' + encoding.substr(3) : encoding;
 }
diff --git a/package.json b/package.json
index 063a187..68d1e34 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "iconv",
   "main": "./lib/iconv",
-  "version": "2.1.11",
+  "version": "2.2.1",
   "description": "Text recoding in JavaScript for fun and profit!",
   "homepage": "https://github.com/bnoordhuis/node-iconv",
   "repository": {
@@ -18,7 +18,7 @@
   "license": "ISC",
   "readmeFilename": "README.md",
   "dependencies": {
-    "nan": "~2.0.4"
+    "nan": "^2.3.5"
   },
   "devDependencies": {
     "tap": "~0.4.8"
diff --git a/src/binding.cc b/src/binding.cc
index 57a6756..10c3020 100644
--- a/src/binding.cc
+++ b/src/binding.cc
@@ -22,6 +22,10 @@
 #include <assert.h>
 #include <stdint.h>
 
+#ifndef ICONV_CONST
+#define ICONV_CONST
+#endif  // ICONV_CONST
+
 namespace
 {
 
@@ -60,7 +64,7 @@ struct Iconv
 
   static void Initialize(Handle<Object> obj)
   {
-    Local<ObjectTemplate> t = ObjectTemplate::New();
+    Local<ObjectTemplate> t = Nan::New<ObjectTemplate>();
     t->SetInternalFieldCount(1);
     object_template.Reset(t);
     obj->Set(Nan::New<String>("make").ToLocalChecked(),
@@ -97,7 +101,7 @@ struct Iconv
     Iconv* iv = static_cast<Iconv*>(
         Nan::GetInternalFieldPointer(info[0].As<Object>(), 0));
     const bool is_flush = info[8]->BooleanValue();
-    const char* input_buf =
+    ICONV_CONST char* input_buf =
         is_flush ? NULL : node::Buffer::Data(info[1].As<Object>());
     size_t input_start = info[2]->Uint32Value();
     size_t input_size = info[3]->Uint32Value();
diff --git a/test/test-basic.js b/test/test-basic.js
index d933e74..934e0ae 100644
--- a/test/test-basic.js
+++ b/test/test-basic.js
@@ -30,6 +30,9 @@ new Iconv('utf16',   'utf32');
 new Iconv('utf16le', 'utf16be');
 new Iconv('utf32le', 'utf32be');
 
+// https://github.com/bnoordhuis/node-iconv/issues/152
+new Iconv('windows-31J', 'windows-31j');
+
 var iconv = new Iconv('utf-8', 'iso-8859-1');
 assert.throws(function() { iconv.convert() });
 assert.throws(function() { iconv.convert(1) });
@@ -44,6 +47,26 @@ assert.deepEqual(iconv.convert(new Buffer('xxx')), new Buffer('xxx'));
 var buffer = new Buffer(1); buffer[0] = 235; // ë
 assert.deepEqual(iconv.convert('ë'), buffer);
 
+// test conversion error messages
+var unknown_conv = 'whatchimajig';
+try {
+  new Iconv('utf-8', unknown_conv);
+  assert.fail('unreachable');
+} catch (e) {
+  assert.equal(e.message,
+               'Conversion from utf-8 to ' + unknown_conv +
+               ' is not supported.');
+}
+
+try {
+  new Iconv(unknown_conv, 'utf-8');
+  assert.fail('unreachable');
+} catch (e) {
+  assert.equal(e.message,
+               'Conversion from ' + unknown_conv +
+               ' to utf-8 is not supported.');
+}
+
 // partial character sequence should throw EINVAL
 buffer = new Buffer(1); buffer[0] = 195;
 try {

-- 
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