Use 'size_t', not 'int', for the length of a string.
diff --git a/ChangeLog b/ChangeLog
index 9305b4c..34a8c29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2016-10-14  Bruno Haible  <bruno@clisp.org>
+
+	Use 'size_t', not 'int', for the length of a string.
+	* lib/iconv.c: Include <limits.h>.
+	* lib/genflags.c: Likewise.
+	* lib/converters.h (struct mbtowc_funcs, struct wctomb_funcs): Change
+	'int n' parameter to 'size_t n'.
+	(RET_COUNT_MAX): New macro.
+	* lib/*.h: Use 'size_t n' instead of 'int n'.
+	* lib/ucs2.h (ucs2_mbtowc): Make sure 'count' does not cause an 'int'
+	overflow.
+	* lib/ucs4.h (ucs4_mbtowc): Likewise.
+	* lib/utf16.h (utf16_mbtowc): Likewise.
+	* lib/utf32.h (utf32_mbtowc): Likewise.
+	* tools/8bit_tab_to_h.c: Generate function signatures with 'size_t n'.
+	* tools/cjk_tab_to_h.c: Likewise.
+	* NEWS: Mention the change.
+
 2016-10-04  Bruno Haible  <bruno@clisp.org>
 
 	Extend CP1255 mapping.
diff --git a/NEWS b/NEWS
index ec8ef62..aebc36c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 New in 1.15:
 * Added ISO-2022-JP-MS converter.
 * Updated the CP1255 converter to map one more character.
+* The functions now support strings longer than 2 GB.
 
 New in 1.14:
 * The 'iconv' program now produces its output as soon as it can. It no longer
diff --git a/lib/armscii_8.h b/lib/armscii_8.h
index 435269c..2704e7b 100644
--- a/lib/armscii_8.h
+++ b/lib/armscii_8.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-armscii_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+armscii_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -90,7 +90,7 @@
 };
 
 static int
-armscii_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+armscii_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0028) {
diff --git a/lib/ascii.h b/lib/ascii.h
index 0f2e10d..ee3d2e6 100644
--- a/lib/ascii.h
+++ b/lib/ascii.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ascii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ascii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -33,7 +33,7 @@
 }
 
 static int
-ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x0080) {
     *r = wc;
diff --git a/lib/atarist.h b/lib/atarist.h
index 78e5cf2..9c8e10b 100644
--- a/lib/atarist.h
+++ b/lib/atarist.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-atarist_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+atarist_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -124,7 +124,7 @@
 };
 
 static int
-atarist_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+atarist_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/big5.h b/lib/big5.h
index b2676b8..88c8fb8 100644
--- a/lib/big5.h
+++ b/lib/big5.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1870,7 +1870,7 @@
 };
 
 static int
-big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0xa1 && c1 <= 0xc7) || (c1 >= 0xc9 && c1 <= 0xf9)) {
@@ -4116,7 +4116,7 @@
 };
 
 static int
-big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/big5_2003.h b/lib/big5_2003.h
index e1420fa..f5a91ff 100644
--- a/lib/big5_2003.h
+++ b/lib/big5_2003.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -180,7 +180,7 @@
 };
 
 static int
-big5_2003_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+big5_2003_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII) */
@@ -267,7 +267,7 @@
 };
 
 static int
-big5_2003_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+big5_2003_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/big5hkscs1999.h b/lib/big5hkscs1999.h
index bdcbfe3..fabc831 100644
--- a/lib/big5hkscs1999.h
+++ b/lib/big5hkscs1999.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -46,7 +46,7 @@
 #include "flushwc.h"
 
 static int
-big5hkscs1999_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+big5hkscs1999_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate;
   if (last_wc) {
@@ -103,7 +103,7 @@
 #define big5hkscs1999_flushwc normal_flushwc
 
 static int
-big5hkscs1999_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+big5hkscs1999_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned char last = conv->ostate;
@@ -180,7 +180,7 @@
 }
 
 static int
-big5hkscs1999_reset (conv_t conv, unsigned char *r, int n)
+big5hkscs1999_reset (conv_t conv, unsigned char *r, size_t n)
 {
   unsigned char last = conv->ostate;
 
diff --git a/lib/big5hkscs2001.h b/lib/big5hkscs2001.h
index 8d65d07..ea8e6fe 100644
--- a/lib/big5hkscs2001.h
+++ b/lib/big5hkscs2001.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -48,7 +48,7 @@
 #include "flushwc.h"
 
 static int
-big5hkscs2001_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+big5hkscs2001_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate;
   if (last_wc) {
@@ -110,7 +110,7 @@
 #define big5hkscs2001_flushwc normal_flushwc
 
 static int
-big5hkscs2001_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+big5hkscs2001_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned char last = conv->ostate;
@@ -198,7 +198,7 @@
 }
 
 static int
-big5hkscs2001_reset (conv_t conv, unsigned char *r, int n)
+big5hkscs2001_reset (conv_t conv, unsigned char *r, size_t n)
 {
   unsigned char last = conv->ostate;
 
diff --git a/lib/big5hkscs2004.h b/lib/big5hkscs2004.h
index 4e5a03d..4e81242 100644
--- a/lib/big5hkscs2004.h
+++ b/lib/big5hkscs2004.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -48,7 +48,7 @@
 #include "flushwc.h"
 
 static int
-big5hkscs2004_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+big5hkscs2004_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate;
   if (last_wc) {
@@ -115,7 +115,7 @@
 #define big5hkscs2004_flushwc normal_flushwc
 
 static int
-big5hkscs2004_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+big5hkscs2004_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned char last = conv->ostate;
@@ -214,7 +214,7 @@
 }
 
 static int
-big5hkscs2004_reset (conv_t conv, unsigned char *r, int n)
+big5hkscs2004_reset (conv_t conv, unsigned char *r, size_t n)
 {
   unsigned char last = conv->ostate;
 
diff --git a/lib/big5hkscs2008.h b/lib/big5hkscs2008.h
index afa51b5..4d68ee9 100644
--- a/lib/big5hkscs2008.h
+++ b/lib/big5hkscs2008.h
@@ -48,7 +48,7 @@
 #include "flushwc.h"
 
 static int
-big5hkscs2008_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+big5hkscs2008_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate;
   if (last_wc) {
@@ -120,7 +120,7 @@
 #define big5hkscs2008_flushwc normal_flushwc
 
 static int
-big5hkscs2008_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+big5hkscs2008_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned char last = conv->ostate;
@@ -230,7 +230,7 @@
 }
 
 static int
-big5hkscs2008_reset (conv_t conv, unsigned char *r, int n)
+big5hkscs2008_reset (conv_t conv, unsigned char *r, size_t n)
 {
   unsigned char last = conv->ostate;
 
diff --git a/lib/c99.h b/lib/c99.h
index 1eb9efb..e234c0d 100644
--- a/lib/c99.h
+++ b/lib/c99.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -26,7 +26,7 @@
  */
 
 static int
-c99_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+c99_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c;
   ucs4_t wc;
@@ -93,7 +93,7 @@
 }
 
 static int
-c99_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+c99_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0xa0) {
     *r = wc;
diff --git a/lib/ces_big5.h b/lib/ces_big5.h
index 549ec13..5b2b2f4 100644
--- a/lib/ces_big5.h
+++ b/lib/ces_big5.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ces_big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ces_big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII) */
@@ -44,7 +44,7 @@
 }
 
 static int
-ces_big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ces_big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/ces_gbk.h b/lib/ces_gbk.h
index 0e35d65..66a6ccc 100644
--- a/lib/ces_gbk.h
+++ b/lib/ces_gbk.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ces_gbk_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ces_gbk_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
 
@@ -39,7 +39,7 @@
 }
 
 static int
-ces_gbk_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ces_gbk_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/cns11643_1.h b/lib/cns11643_1.h
index 961ce4f..7af48c8 100644
--- a/lib/cns11643_1.h
+++ b/lib/cns11643_1.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -853,7 +853,7 @@
 };
 
 static int
-cns11643_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x27) || (c1 == 0x42) || (c1 >= 0x44 && c1 <= 0x7d)) {
diff --git a/lib/cns11643_15.h b/lib/cns11643_15.h
index ce022b6..942e4cd 100644
--- a/lib/cns11643_15.h
+++ b/lib/cns11643_15.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1053,7 +1053,7 @@
 };
 
 static int
-cns11643_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x6d)) {
diff --git a/lib/cns11643_2.h b/lib/cns11643_2.h
index 2c48a91..d5eabbb 100644
--- a/lib/cns11643_2.h
+++ b/lib/cns11643_2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1084,7 +1084,7 @@
 };
 
 static int
-cns11643_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x72)) {
diff --git a/lib/cns11643_3.h b/lib/cns11643_3.h
index 3bf5a0d..d4e4c90 100644
--- a/lib/cns11643_3.h
+++ b/lib/cns11643_3.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -940,7 +940,7 @@
 };
 
 static int
-cns11643_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x62) || (c1 >= 0x64 && c1 <= 0x67)) {
diff --git a/lib/cns11643_4.h b/lib/cns11643_4.h
index ae2126f..94c9f61 100644
--- a/lib/cns11643_4.h
+++ b/lib/cns11643_4.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -29,7 +29,7 @@
 #include "cns11643_4b.h"
 
 static int
-cns11643_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x6e)) {
diff --git a/lib/cns11643_5.h b/lib/cns11643_5.h
index 24d9ded..b2bf9a7 100644
--- a/lib/cns11643_5.h
+++ b/lib/cns11643_5.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1248,7 +1248,7 @@
 };
 
 static int
-cns11643_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x7c)) {
diff --git a/lib/cns11643_6.h b/lib/cns11643_6.h
index 9ca441d..524043e 100644
--- a/lib/cns11643_6.h
+++ b/lib/cns11643_6.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -938,7 +938,7 @@
 };
 
 static int
-cns11643_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x64)) {
diff --git a/lib/cns11643_7.h b/lib/cns11643_7.h
index 3937a76..5975d9e 100644
--- a/lib/cns11643_7.h
+++ b/lib/cns11643_7.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -958,7 +958,7 @@
 };
 
 static int
-cns11643_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cns11643_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x66)) {
diff --git a/lib/cns11643_inv.h b/lib/cns11643_inv.h
index 97d36d6..5dd6fda 100644
--- a/lib/cns11643_inv.h
+++ b/lib/cns11643_inv.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2005, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2005, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -15365,7 +15365,7 @@
 };
 
 static int
-cns11643_inv_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cns11643_inv_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/converters.h b/lib/converters.h
index fdd1830..487f5d7 100644
--- a/lib/converters.h
+++ b/lib/converters.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002, 2004-2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2004-2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -33,14 +33,16 @@
  * Data type for conversion multibyte -> unicode
  */
 struct mbtowc_funcs {
-  int (*xxx_mbtowc) (conv_t conv, ucs4_t *pwc, unsigned char const *s, int n);
+  int (*xxx_mbtowc) (conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n);
   /*
-   * int xxx_mbtowc (conv_t conv, ucs4_t *pwc, unsigned char const *s, int n)
+   * int xxx_mbtowc (conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n)
    * converts the byte sequence starting at s to a wide character. Up to n bytes
    * are available at s. n is >= 1.
    * Result is number of bytes consumed (if a wide character was read),
-   * or -1 if invalid, or -2 if n too small, or -2-(number of bytes consumed)
-   * if only a shift sequence was read.
+   * or -1 if invalid, or -2 if n too small,
+   * or RET_SHIFT_ILSEQ(number of bytes consumed) if invalid input after a shift
+   * sequence was read,
+   * or RET_TOOFEW(number of bytes consumed) if only a shift sequence was read.
    */
   int (*xxx_flushwc) (conv_t conv, ucs4_t *pwc);
   /*
@@ -60,21 +62,23 @@
 /* Retrieve the n from the encoded RET_... value. */
 #define DECODE_SHIFT_ILSEQ(r)  ((unsigned int)(RET_SHIFT_ILSEQ(0) - (r)) / 2)
 #define DECODE_TOOFEW(r)       ((unsigned int)(RET_TOOFEW(0) - (r)) / 2)
+/* Maximum value of n that may be used as argument to RET_SHIFT_ILSEQ or RET_TOOFEW. */
+#define RET_COUNT_MAX       ((INT_MAX / 2) - 1)
 
 /*
  * Data type for conversion unicode -> multibyte
  */
 struct wctomb_funcs {
-  int (*xxx_wctomb) (conv_t conv, unsigned char *r, ucs4_t wc, int n);
+  int (*xxx_wctomb) (conv_t conv, unsigned char *r, ucs4_t wc, size_t n);
   /*
-   * int xxx_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+   * int xxx_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
    * converts the wide character wc to the character set xxx, and stores the
    * result beginning at r. Up to n bytes may be written at r. n is >= 1.
    * Result is number of bytes written, or -1 if invalid, or -2 if n too small.
    */
-  int (*xxx_reset) (conv_t conv, unsigned char *r, int n);
+  int (*xxx_reset) (conv_t conv, unsigned char *r, size_t n);
   /*
-   * int xxx_reset (conv_t conv, unsigned char *r, int n)
+   * int xxx_reset (conv_t conv, unsigned char *r, size_t n)
    * stores a shift sequences returning to the initial state beginning at r.
    * Up to n bytes may be written at r. n is >= 0.
    * Result is number of bytes written, or -2 if n too small.
diff --git a/lib/cp1046.h b/lib/cp1046.h
index 4514c35..b69196e 100644
--- a/lib/cp1046.h
+++ b/lib/cp1046.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1046_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1046_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -129,7 +129,7 @@
 };
 
 static int
-cp1046_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1046_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1124.h b/lib/cp1124.h
index d1b2402..80c34ab 100644
--- a/lib/cp1124.h
+++ b/lib/cp1124.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-cp1124_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1124_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -80,7 +80,7 @@
 };
 
 static int
-cp1124_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1124_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/cp1125.h b/lib/cp1125.h
index ff9a0a0..c6dbe48 100644
--- a/lib/cp1125.h
+++ b/lib/cp1125.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -40,7 +40,7 @@
 };
 
 static int
-cp1125_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1125_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -103,7 +103,7 @@
 };
 
 static int
-cp1125_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1125_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1129.h b/lib/cp1129.h
index f76cd72..9aaf794 100644
--- a/lib/cp1129.h
+++ b/lib/cp1129.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-cp1129_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1129_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -99,7 +99,7 @@
 };
 
 static int
-cp1129_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1129_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a8) {
diff --git a/lib/cp1131.h b/lib/cp1131.h
index 69074de..c00b074 100644
--- a/lib/cp1131.h
+++ b/lib/cp1131.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1131_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1131_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -108,7 +108,7 @@
 };
 
 static int
-cp1131_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1131_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1133.h b/lib/cp1133.h
index b8ac91f..971edb8 100644
--- a/lib/cp1133.h
+++ b/lib/cp1133.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -42,7 +42,7 @@
 };
 
 static int
-cp1133_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1133_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -88,7 +88,7 @@
 };
 
 static int
-cp1133_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1133_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/cp1161.h b/lib/cp1161.h
index 998c597..629c0d5 100644
--- a/lib/cp1161.h
+++ b/lib/cp1161.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-cp1161_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1161_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -65,7 +65,7 @@
 };
 
 static int
-cp1161_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1161_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1162.h b/lib/cp1162.h
index 3aa1558..d5c5bb4 100644
--- a/lib/cp1162.h
+++ b/lib/cp1162.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-cp1162_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1162_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -44,7 +44,7 @@
 }
 
 static int
-cp1162_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1162_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1163.h b/lib/cp1163.h
index 0bb767b..c53bd4a 100644
--- a/lib/cp1163.h
+++ b/lib/cp1163.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-cp1163_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1163_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -39,7 +39,7 @@
 };
 
 static int
-cp1163_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1163_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0 || (wc < 0x00a8 && wc != 0x00a4) || wc == 0x00d0) {
diff --git a/lib/cp1250.h b/lib/cp1250.h
index f3f0224..02b49b6 100644
--- a/lib/cp1250.h
+++ b/lib/cp1250.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1250_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1250_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -113,7 +113,7 @@
 };
 
 static int
-cp1250_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1250_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1251.h b/lib/cp1251.h
index 46864b2..061df1e 100644
--- a/lib/cp1251.h
+++ b/lib/cp1251.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1251_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1251_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -103,7 +103,7 @@
 };
 
 static int
-cp1251_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1251_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1252.h b/lib/cp1252.h
index f2b56c9..d1af862 100644
--- a/lib/cp1252.h
+++ b/lib/cp1252.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -31,7 +31,7 @@
 };
 
 static int
-cp1252_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1252_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80 || c >= 0xa0) {
@@ -75,7 +75,7 @@
 };
 
 static int
-cp1252_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1252_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1253.h b/lib/cp1253.h
index fe86bec..e9f99cc 100644
--- a/lib/cp1253.h
+++ b/lib/cp1253.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1253_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1253_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -94,7 +94,7 @@
 };
 
 static int
-cp1253_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1253_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1254.h b/lib/cp1254.h
index 117b496..0d6ad72 100644
--- a/lib/cp1254.h
+++ b/lib/cp1254.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -41,7 +41,7 @@
 };
 
 static int
-cp1254_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1254_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -116,7 +116,7 @@
 };
 
 static int
-cp1254_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1254_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1255.h b/lib/cp1255.h
index e53514d..6fdfd77 100644
--- a/lib/cp1255.h
+++ b/lib/cp1255.h
@@ -168,7 +168,7 @@
    character, or 0 if none. */
 
 static int
-cp1255_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1255_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   unsigned short wc;
@@ -295,7 +295,7 @@
 };
 
 static int
-cp1255_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1255_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1256.h b/lib/cp1256.h
index ed9addb..8242f20 100644
--- a/lib/cp1256.h
+++ b/lib/cp1256.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1256_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1256_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -123,7 +123,7 @@
 };
 
 static int
-cp1256_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1256_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1257.h b/lib/cp1257.h
index 8ead70f..42d6b14 100644
--- a/lib/cp1257.h
+++ b/lib/cp1257.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp1257_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1257_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -113,7 +113,7 @@
 };
 
 static int
-cp1257_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1257_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp1258.h b/lib/cp1258.h
index c95e377..4b3513a 100644
--- a/lib/cp1258.h
+++ b/lib/cp1258.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -71,7 +71,7 @@
    character, or 0 if none. */
 
 static int
-cp1258_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp1258_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   unsigned short wc;
@@ -200,7 +200,7 @@
 };
 
 static int
-cp1258_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp1258_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp437.h b/lib/cp437.h
index ae8667a..d308a41 100644
--- a/lib/cp437.h
+++ b/lib/cp437.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp437_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp437_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -124,7 +124,7 @@
 };
 
 static int
-cp437_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp437_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp50221_0208_ext.h b/lib/cp50221_0208_ext.h
index 2fb9814..d2c7edb 100644
--- a/lib/cp50221_0208_ext.h
+++ b/lib/cp50221_0208_ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-cp50221_0208_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp50221_0208_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x60) {
@@ -122,7 +122,7 @@
 };
 
 static int
-cp50221_0208_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp50221_0208_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc >= 0x2110 && wc < 0x2170)
diff --git a/lib/cp50221_0212_ext.h b/lib/cp50221_0212_ext.h
index 3aca338..d07808d 100644
--- a/lib/cp50221_0212_ext.h
+++ b/lib/cp50221_0212_ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -46,7 +46,7 @@
 };
 
 static int
-cp50221_0212_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp50221_0212_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x70) {
@@ -111,7 +111,7 @@
 };
 
 static int
-cp50221_0212_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp50221_0212_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc >= 0x2170 && wc < 0x2180)
diff --git a/lib/cp737.h b/lib/cp737.h
index 2adeb03..28df23f 100644
--- a/lib/cp737.h
+++ b/lib/cp737.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp737_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp737_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -113,7 +113,7 @@
 };
 
 static int
-cp737_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp737_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp775.h b/lib/cp775.h
index d830ae8..b6f8dbc 100644
--- a/lib/cp775.h
+++ b/lib/cp775.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp775_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp775_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -118,7 +118,7 @@
 };
 
 static int
-cp775_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp775_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp850.h b/lib/cp850.h
index 7283793..6dd6443 100644
--- a/lib/cp850.h
+++ b/lib/cp850.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp850_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp850_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -98,7 +98,7 @@
 };
 
 static int
-cp850_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp850_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp852.h b/lib/cp852.h
index a7a2be2..5711bf0 100644
--- a/lib/cp852.h
+++ b/lib/cp852.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp852_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp852_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -121,7 +121,7 @@
 };
 
 static int
-cp852_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp852_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp853.h b/lib/cp853.h
index ee38eae..8ed2d30 100644
--- a/lib/cp853.h
+++ b/lib/cp853.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp853_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp853_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -125,7 +125,7 @@
 };
 
 static int
-cp853_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp853_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp855.h b/lib/cp855.h
index 2d6c923..f6170ce 100644
--- a/lib/cp855.h
+++ b/lib/cp855.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp855_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp855_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -104,7 +104,7 @@
 };
 
 static int
-cp855_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp855_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp856.h b/lib/cp856.h
index bd487e6..0766ebd 100644
--- a/lib/cp856.h
+++ b/lib/cp856.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp856_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp856_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -110,7 +110,7 @@
 };
 
 static int
-cp856_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp856_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp857.h b/lib/cp857.h
index 7cf87ee..980295a 100644
--- a/lib/cp857.h
+++ b/lib/cp857.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp857_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp857_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -116,7 +116,7 @@
 };
 
 static int
-cp857_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp857_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp858.h b/lib/cp858.h
index 6993df0..83702c5 100644
--- a/lib/cp858.h
+++ b/lib/cp858.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-cp858_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp858_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -35,7 +35,7 @@
 }
 
 static int
-cp858_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp858_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp860.h b/lib/cp860.h
index 5620c5a..d2f0836 100644
--- a/lib/cp860.h
+++ b/lib/cp860.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp860_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp860_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -119,7 +119,7 @@
 };
 
 static int
-cp860_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp860_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp861.h b/lib/cp861.h
index 5099a6b..5e6cebf 100644
--- a/lib/cp861.h
+++ b/lib/cp861.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp861_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp861_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -124,7 +124,7 @@
 };
 
 static int
-cp861_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp861_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp862.h b/lib/cp862.h
index 258aeb2..98ae46f 100644
--- a/lib/cp862.h
+++ b/lib/cp862.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp862_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp862_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -119,7 +119,7 @@
 };
 
 static int
-cp862_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp862_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp863.h b/lib/cp863.h
index 3362e3f..a93a915 100644
--- a/lib/cp863.h
+++ b/lib/cp863.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp863_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp863_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -124,7 +124,7 @@
 };
 
 static int
-cp863_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp863_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp864.h b/lib/cp864.h
index 2a7c9d8..d6bf86a 100644
--- a/lib/cp864.h
+++ b/lib/cp864.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -54,7 +54,7 @@
 };
 
 static int
-cp864_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp864_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x20) {
@@ -150,7 +150,7 @@
 };
 
 static int
-cp864_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp864_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0020) {
diff --git a/lib/cp865.h b/lib/cp865.h
index 3969017..4624133 100644
--- a/lib/cp865.h
+++ b/lib/cp865.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp865_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp865_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -124,7 +124,7 @@
 };
 
 static int
-cp865_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp865_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp866.h b/lib/cp866.h
index 8e20750..81cd753 100644
--- a/lib/cp866.h
+++ b/lib/cp866.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -40,7 +40,7 @@
 };
 
 static int
-cp866_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp866_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -99,7 +99,7 @@
 };
 
 static int
-cp866_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp866_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp869.h b/lib/cp869.h
index 00f71c9..97a620f 100644
--- a/lib/cp869.h
+++ b/lib/cp869.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp869_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp869_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -113,7 +113,7 @@
 };
 
 static int
-cp869_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp869_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp874.h b/lib/cp874.h
index dcd6a82..3aa861d 100644
--- a/lib/cp874.h
+++ b/lib/cp874.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-cp874_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp874_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -87,7 +87,7 @@
 };
 
 static int
-cp874_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp874_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/cp922.h b/lib/cp922.h
index 7192236..20c68b7 100644
--- a/lib/cp922.h
+++ b/lib/cp922.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -38,7 +38,7 @@
 };
 
 static int
-cp922_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp922_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -77,7 +77,7 @@
 };
 
 static int
-cp922_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp922_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a8) {
diff --git a/lib/cp932.h b/lib/cp932.h
index 5a51a7a..4115e1c 100644
--- a/lib/cp932.h
+++ b/lib/cp932.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -85,7 +85,7 @@
  */
 
 static int
-cp932_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp932_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -127,7 +127,7 @@
 }
 
 static int
-cp932_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp932_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/cp932ext.h b/lib/cp932ext.h
index 4704993..a520aa7 100644
--- a/lib/cp932ext.h
+++ b/lib/cp932ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -145,7 +145,7 @@
 };
 
 static int
-cp932ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp932ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x87) || (c1 >= 0xed && c1 <= 0xee) || (c1 >= 0xfa && c1 <= 0xfc)) {
@@ -653,7 +653,7 @@
 };
 
 static int
-cp932ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp932ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/cp936.h b/lib/cp936.h
index 8c307de..5d78442 100644
--- a/lib/cp936.h
+++ b/lib/cp936.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -47,7 +47,7 @@
  */
 
 static int
-cp936_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp936_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   /* Try GBK first. */
   {
@@ -89,7 +89,7 @@
 }
 
 static int
-cp936_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp936_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   /* Try GBK first. */
   {
diff --git a/lib/cp936ext.h b/lib/cp936ext.h
index 8fce5b3..33cde52 100644
--- a/lib/cp936ext.h
+++ b/lib/cp936ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -34,7 +34,7 @@
 };
 
 static int
-cp936ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp936ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0xa6) || (c1 == 0xa8)) {
@@ -78,7 +78,7 @@
 };
 
 static int
-cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     unsigned short c = 0;
diff --git a/lib/cp949.h b/lib/cp949.h
index 4182e9f..ffe24d5 100644
--- a/lib/cp949.h
+++ b/lib/cp949.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2007, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -37,7 +37,7 @@
 #include "uhc_2.h"
 
 static int
-cp949_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp949_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII) */
@@ -78,7 +78,7 @@
 }
 
 static int
-cp949_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp949_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/cp950.h b/lib/cp950.h
index 737f9a9..d4366de 100644
--- a/lib/cp950.h
+++ b/lib/cp950.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -129,7 +129,7 @@
 #include "cp950ext.h"
 
 static int
-cp950_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp950_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII) */
@@ -184,7 +184,7 @@
 }
 
 static int
-cp950_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp950_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/cp950ext.h b/lib/cp950ext.h
index 38efb0b..769a3ae 100644
--- a/lib/cp950ext.h
+++ b/lib/cp950ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -32,7 +32,7 @@
 };
 
 static int
-cp950ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+cp950ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0xf9)) {
@@ -117,7 +117,7 @@
 };
 
 static int
-cp950ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+cp950ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/dec_hanyu.h b/lib/dec_hanyu.h
index 31fa7e3..218ea2a 100644
--- a/lib/dec_hanyu.h
+++ b/lib/dec_hanyu.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-dec_hanyu_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+dec_hanyu_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII) */
@@ -66,7 +66,7 @@
 }
 
 static int
-dec_hanyu_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+dec_hanyu_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[3];
   int ret;
diff --git a/lib/dec_kanji.h b/lib/dec_kanji.h
index 7d117cd..66e9d62 100644
--- a/lib/dec_kanji.h
+++ b/lib/dec_kanji.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-dec_kanji_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+dec_kanji_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */
@@ -45,7 +45,7 @@
 }
 
 static int
-dec_kanji_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+dec_kanji_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/euc_cn.h b/lib/euc_cn.h
index e83bbc6..6f8702b 100644
--- a/lib/euc_cn.h
+++ b/lib/euc_cn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-euc_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+euc_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII or GB 1988-89) */
@@ -46,7 +46,7 @@
 }
 
 static int
-euc_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+euc_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/euc_jisx0213.h b/lib/euc_jisx0213.h
index b73f10e..672efa8 100644
--- a/lib/euc_jisx0213.h
+++ b/lib/euc_jisx0213.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -39,7 +39,7 @@
 #include "flushwc.h"
 
 static int
-euc_jisx0213_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+euc_jisx0213_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate;
   if (last_wc) {
@@ -143,7 +143,7 @@
 };
 
 static int
-euc_jisx0213_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+euc_jisx0213_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned short lasttwo = conv->ostate;
@@ -251,7 +251,7 @@
 }
 
 static int
-euc_jisx0213_reset (conv_t conv, unsigned char *r, int n)
+euc_jisx0213_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t lasttwo = conv->ostate;
 
diff --git a/lib/euc_jp.h b/lib/euc_jp.h
index 1c13734..fd92895 100644
--- a/lib/euc_jp.h
+++ b/lib/euc_jp.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-euc_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+euc_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */
@@ -107,7 +107,7 @@
 }
 
 static int
-euc_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+euc_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/euc_kr.h b/lib/euc_kr.h
index 66ac799..01996c0 100644
--- a/lib/euc_kr.h
+++ b/lib/euc_kr.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2007, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -24,7 +24,7 @@
 /* Specification: RFC 1557 */
 
 static int
-euc_kr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+euc_kr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII or KS C 5636-1993) */
@@ -48,7 +48,7 @@
 }
 
 static int
-euc_kr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+euc_kr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/euc_tw.h b/lib/euc_tw.h
index c2542a2..8a75064 100644
--- a/lib/euc_tw.h
+++ b/lib/euc_tw.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-euc_tw_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+euc_tw_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   /* Code set 0 (ASCII) */
@@ -78,7 +78,7 @@
 }
 
 static int
-euc_tw_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+euc_tw_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[3];
   int ret;
diff --git a/lib/gb12345.h b/lib/gb12345.h
index 90a806b..e2d99af 100644
--- a/lib/gb12345.h
+++ b/lib/gb12345.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -32,7 +32,7 @@
 #include "gb12345ext.h"
 
 static int
-gb12345_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gb12345_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   int ret;
 
@@ -47,7 +47,7 @@
 }
 
 static int
-gb12345_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gb12345_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int ret;
 
diff --git a/lib/gb12345ext.h b/lib/gb12345ext.h
index b26634e..75f1827 100644
--- a/lib/gb12345ext.h
+++ b/lib/gb12345ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1003,7 +1003,7 @@
 };
 
 static int
-gb12345ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gb12345ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x21) || (c1 == 0x26) || (c1 == 0x28) || (c1 >= 0x30 && c1 <= 0x79)) {
@@ -1758,7 +1758,7 @@
 };
 
 static int
-gb12345ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gb12345ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/gb18030.h b/lib/gb18030.h
index 1d75987..f19741a 100644
--- a/lib/gb18030.h
+++ b/lib/gb18030.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -185,7 +185,7 @@
 #include "gb18030uni.h"
 
 static int
-gb18030_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gb18030_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   int ret;
 
@@ -302,7 +302,7 @@
 };
 
 static int
-gb18030_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gb18030_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int ret;
 
diff --git a/lib/gb18030ext.h b/lib/gb18030ext.h
index 235c34a..46cd3d7 100644
--- a/lib/gb18030ext.h
+++ b/lib/gb18030ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005, 2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-gb18030ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gb18030ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0xa2) || (c1 >= 0xa4 && c1 <= 0xa9) || (c1 == 0xd7) || (c1 == 0xfe)) {
@@ -241,7 +241,7 @@
 };
 
 static int
-gb18030ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gb18030ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     unsigned short c = 0;
diff --git a/lib/gb18030uni.h b/lib/gb18030uni.h
index aa7515b..b52bda9 100644
--- a/lib/gb18030uni.h
+++ b/lib/gb18030uni.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -167,7 +167,7 @@
 };
 
 static int
-gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if (c1 >= 0x81 && c1 <= 0x84) {
@@ -220,7 +220,7 @@
 }
 
 static int
-gb18030uni_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gb18030uni_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 4) {
     unsigned int i = wc;
diff --git a/lib/gb2312.h b/lib/gb2312.h
index e13dd84..306f6f5 100644
--- a/lib/gb2312.h
+++ b/lib/gb2312.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1078,7 +1078,7 @@
 };
 
 static int
-gb2312_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gb2312_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x29) || (c1 >= 0x30 && c1 <= 0x77)) {
@@ -2531,7 +2531,7 @@
 };
 
 static int
-gb2312_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gb2312_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/gbk.h b/lib/gbk.h
index 6381c28..21b8eb9 100644
--- a/lib/gbk.h
+++ b/lib/gbk.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -60,7 +60,7 @@
 #include "cp936ext.h"
 
 static int
-gbk_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gbk_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
 
@@ -108,7 +108,7 @@
 }
 
 static int
-gbk_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gbk_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/gbkext1.h b/lib/gbkext1.h
index b440e8c..a58e24c 100644
--- a/lib/gbkext1.h
+++ b/lib/gbkext1.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -825,7 +825,7 @@
 };
 
 static int
-gbkext1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gbkext1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x81 && c1 <= 0xa0)) {
diff --git a/lib/gbkext2.h b/lib/gbkext2.h
index 1f0004c..bab083f 100644
--- a/lib/gbkext2.h
+++ b/lib/gbkext2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1146,7 +1146,7 @@
 };
 
 static int
-gbkext2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+gbkext2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0xa8 && c1 <= 0xfe)) {
diff --git a/lib/gbkext_inv.h b/lib/gbkext_inv.h
index bef9bcb..6cf775c 100644
--- a/lib/gbkext_inv.h
+++ b/lib/gbkext_inv.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -2299,7 +2299,7 @@
 };
 
 static int
-gbkext_inv_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+gbkext_inv_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/genflags.c b/lib/genflags.c
index f2d7d70..1f30129 100644
--- a/lib/genflags.c
+++ b/lib/genflags.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002, 2005-2006, 2008-2009 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002, 2005-2006, 2008-2009, 2016 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -17,6 +17,7 @@
 
 /* Creates the flags.h include file. */
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/lib/georgian_academy.h b/lib/georgian_academy.h
index 145c928..6e22caf 100644
--- a/lib/georgian_academy.h
+++ b/lib/georgian_academy.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -31,7 +31,7 @@
 };
 
 static int
-georgian_academy_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+georgian_academy_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0x80 && c < 0xa0)
@@ -76,7 +76,7 @@
 };
 
 static int
-georgian_academy_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+georgian_academy_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/georgian_ps.h b/lib/georgian_ps.h
index 4c13f62..f880888 100644
--- a/lib/georgian_ps.h
+++ b/lib/georgian_ps.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -41,7 +41,7 @@
 };
 
 static int
-georgian_ps_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+georgian_ps_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0x80 && c < 0xa0)
@@ -93,7 +93,7 @@
 };
 
 static int
-georgian_ps_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+georgian_ps_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/hkscs1999.h b/lib/hkscs1999.h
index c7605d3..b69bfe2 100644
--- a/lib/hkscs1999.h
+++ b/lib/hkscs1999.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2006, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -849,7 +849,7 @@
 };
 
 static int
-hkscs1999_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+hkscs1999_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x88 && c1 <= 0x8b) || (c1 >= 0x8d && c1 <= 0xa0) || (c1 >= 0xc6 && c1 <= 0xc8) || (c1 >= 0xf9 && c1 <= 0xfe)) {
@@ -2949,7 +2949,7 @@
 };
 
 static int
-hkscs1999_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+hkscs1999_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/hkscs2001.h b/lib/hkscs2001.h
index 06dd8af..7228f79 100644
--- a/lib/hkscs2001.h
+++ b/lib/hkscs2001.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2006, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -56,7 +56,7 @@
 };
 
 static int
-hkscs2001_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+hkscs2001_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x8c)) {
@@ -550,7 +550,7 @@
 };
 
 static int
-hkscs2001_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+hkscs2001_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/hkscs2004.h b/lib/hkscs2004.h
index f20b462..81431d2 100644
--- a/lib/hkscs2004.h
+++ b/lib/hkscs2004.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2006, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -75,7 +75,7 @@
 };
 
 static int
-hkscs2004_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+hkscs2004_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x87) || (c1 >= 0x8c && c1 <= 0x8d)) {
@@ -542,7 +542,7 @@
 };
 
 static int
-hkscs2004_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+hkscs2004_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/hkscs2008.h b/lib/hkscs2008.h
index 191184d..ab79b94 100644
--- a/lib/hkscs2008.h
+++ b/lib/hkscs2008.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2010, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2010, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -52,7 +52,7 @@
 };
 
 static int
-hkscs2008_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+hkscs2008_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x87)) {
@@ -363,7 +363,7 @@
 };
 
 static int
-hkscs2008_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+hkscs2008_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/hp_roman8.h b/lib/hp_roman8.h
index 753991b..d4ea9a5 100644
--- a/lib/hp_roman8.h
+++ b/lib/hp_roman8.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-hp_roman8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+hp_roman8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -91,7 +91,7 @@
 };
 
 static int
-hp_roman8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+hp_roman8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/hz.h b/lib/hz.h
index fac48bb..ac0e143 100644
--- a/lib/hz.h
+++ b/lib/hz.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -28,7 +28,7 @@
  */
 
 static int
-hz_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+hz_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   unsigned int count = 0;
@@ -97,7 +97,7 @@
 }
 
 static int
-hz_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+hz_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   unsigned char buf[2];
@@ -148,7 +148,7 @@
 }
 
 static int
-hz_reset (conv_t conv, unsigned char *r, int n)
+hz_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   if (state) {
diff --git a/lib/iconv.c b/lib/iconv.c
index 93dc42f..5a1a325 100644
--- a/lib/iconv.c
+++ b/lib/iconv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2008, 2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2008, 2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -19,6 +19,7 @@
 
 #include <iconv.h>
 
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 #include "config.h"
diff --git a/lib/iso2022_cn.h b/lib/iso2022_cn.h
index 9b2b3e3..0a9a3c6 100644
--- a/lib/iso2022_cn.h
+++ b/lib/iso2022_cn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -50,7 +50,7 @@
   state = (state3 << 16) | (state2 << 8) | state1
 
 static int
-iso2022_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   SPLIT_STATE;
@@ -178,7 +178,7 @@
 }
 
 static int
-iso2022_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
@@ -296,7 +296,7 @@
 }
 
 static int
-iso2022_cn_reset (conv_t conv, unsigned char *r, int n)
+iso2022_cn_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
diff --git a/lib/iso2022_cnext.h b/lib/iso2022_cnext.h
index 9d8144a..9ba1d1f 100644
--- a/lib/iso2022_cnext.h
+++ b/lib/iso2022_cnext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -60,7 +60,7 @@
   state = (state4 << 24) | (state3 << 16) | (state2 << 8) | state1
 
 static int
-iso2022_cn_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_cn_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   SPLIT_STATE;
@@ -296,7 +296,7 @@
 }
 
 static int
-iso2022_cn_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_cn_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
@@ -554,7 +554,7 @@
 }
 
 static int
-iso2022_cn_ext_reset (conv_t conv, unsigned char *r, int n)
+iso2022_cn_ext_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
diff --git a/lib/iso2022_jp.h b/lib/iso2022_jp.h
index 6e5b3f1..1bc0cd1 100644
--- a/lib/iso2022_jp.h
+++ b/lib/iso2022_jp.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -33,7 +33,7 @@
 #define STATE_JISX0208       2
 
 static int
-iso2022_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
@@ -121,7 +121,7 @@
 }
 
 static int
-iso2022_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   unsigned char buf[2];
@@ -195,7 +195,7 @@
 }
 
 static int
-iso2022_jp_reset (conv_t conv, unsigned char *r, int n)
+iso2022_jp_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   if (state != STATE_ASCII) {
diff --git a/lib/iso2022_jp1.h b/lib/iso2022_jp1.h
index 7b99ea8..527a15c 100644
--- a/lib/iso2022_jp1.h
+++ b/lib/iso2022_jp1.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -34,7 +34,7 @@
 #define STATE_JISX0212       3
 
 static int
-iso2022_jp1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_jp1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
@@ -145,7 +145,7 @@
 }
 
 static int
-iso2022_jp1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_jp1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   unsigned char buf[2];
@@ -242,7 +242,7 @@
 }
 
 static int
-iso2022_jp1_reset (conv_t conv, unsigned char *r, int n)
+iso2022_jp1_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   if (state != STATE_ASCII) {
diff --git a/lib/iso2022_jp2.h b/lib/iso2022_jp2.h
index d1e70c8..da4b21f 100644
--- a/lib/iso2022_jp2.h
+++ b/lib/iso2022_jp2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -50,7 +50,7 @@
   state = (state2 << 8) | state1
 
 static int
-iso2022_jp2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_jp2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   SPLIT_STATE;
@@ -303,7 +303,7 @@
   state = (state3 << 16) | (state2 << 8) | state1
 
 static int
-iso2022_jp2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_jp2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
@@ -652,7 +652,7 @@
 }
 
 static int
-iso2022_jp2_reset (conv_t conv, unsigned char *r, int n)
+iso2022_jp2_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
diff --git a/lib/iso2022_jp3.h b/lib/iso2022_jp3.h
index 817fe55..f9d50c2 100644
--- a/lib/iso2022_jp3.h
+++ b/lib/iso2022_jp3.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2004, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2004, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -41,7 +41,7 @@
  */
 
 static int
-iso2022_jp3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_jp3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate >> 3;
   if (last_wc) {
@@ -260,7 +260,7 @@
   /* assume lasttwo == 0, then prevstate is ignored */
 
 static int
-iso2022_jp3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_jp3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned char buf[2];
@@ -494,7 +494,7 @@
 }
 
 static int
-iso2022_jp3_reset (conv_t conv, unsigned char *r, int n)
+iso2022_jp3_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
diff --git a/lib/iso2022_jpms.h b/lib/iso2022_jpms.h
index 36046f5..64d88bd 100644
--- a/lib/iso2022_jpms.h
+++ b/lib/iso2022_jpms.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008, 2011-2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2011-2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -81,7 +81,7 @@
 #define STATE_JISX0212MS        4  /* Esc $ ( D */
 
 static int
-iso2022_jpms_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_jpms_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
@@ -278,7 +278,7 @@
 }
 
 static int
-iso2022_jpms_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_jpms_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   unsigned char buf[2];
@@ -423,7 +423,7 @@
 }
 
 static int
-iso2022_jpms_reset (conv_t conv, unsigned char *r, int n)
+iso2022_jpms_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   if (state != STATE_ASCII) {
diff --git a/lib/iso2022_kr.h b/lib/iso2022_kr.h
index df6df74..0bd3d69 100644
--- a/lib/iso2022_kr.h
+++ b/lib/iso2022_kr.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
   state = (state2 << 8) | state1
 
 static int
-iso2022_kr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso2022_kr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   SPLIT_STATE;
@@ -136,7 +136,7 @@
 }
 
 static int
-iso2022_kr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso2022_kr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
@@ -198,7 +198,7 @@
 }
 
 static int
-iso2022_kr_reset (conv_t conv, unsigned char *r, int n)
+iso2022_kr_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   SPLIT_STATE;
diff --git a/lib/iso646_cn.h b/lib/iso646_cn.h
index 4bec7bc..57e4f67 100644
--- a/lib/iso646_cn.h
+++ b/lib/iso646_cn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -23,7 +23,7 @@
  */
 
 static int
-iso646_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso646_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -39,7 +39,7 @@
 }
 
 static int
-iso646_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso646_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x0080 && !(wc == 0x0024 || wc == 0x007e)) {
     *r = wc;
diff --git a/lib/iso646_jp.h b/lib/iso646_jp.h
index 631f5fe..9adc1c6 100644
--- a/lib/iso646_jp.h
+++ b/lib/iso646_jp.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -25,7 +25,7 @@
 /* This is the lower half of JIS_X0201. */
 
 static int
-iso646_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso646_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -41,7 +41,7 @@
 }
 
 static int
-iso646_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso646_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
     *r = wc;
diff --git a/lib/iso8859_1.h b/lib/iso8859_1.h
index 05e542b..7987011 100644
--- a/lib/iso8859_1.h
+++ b/lib/iso8859_1.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-iso8859_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   *pwc = (ucs4_t) c;
@@ -30,7 +30,7 @@
 }
 
 static int
-iso8859_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x0100) {
     *r = wc;
diff --git a/lib/iso8859_10.h b/lib/iso8859_10.h
index 1a09d7b..3afb648 100644
--- a/lib/iso8859_10.h
+++ b/lib/iso8859_10.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_10_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_10_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -86,7 +86,7 @@
 };
 
 static int
-iso8859_10_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_10_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_11.h b/lib/iso8859_11.h
index c6636ab..1c76de3 100644
--- a/lib/iso8859_11.h
+++ b/lib/iso8859_11.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2004 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2004, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-iso8859_11_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_11_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa1) {
@@ -37,7 +37,7 @@
 }
 
 static int
-iso8859_11_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_11_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x00a1) {
     *r = wc;
diff --git a/lib/iso8859_13.h b/lib/iso8859_13.h
index 0b6d789..619121a 100644
--- a/lib/iso8859_13.h
+++ b/lib/iso8859_13.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_13_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_13_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -89,7 +89,7 @@
 };
 
 static int
-iso8859_13_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_13_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_14.h b/lib/iso8859_14.h
index 3a33d28..293cdc5 100644
--- a/lib/iso8859_14.h
+++ b/lib/iso8859_14.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_14_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_14_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0xa0)
@@ -101,7 +101,7 @@
 };
 
 static int
-iso8859_14_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_14_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_15.h b/lib/iso8859_15.h
index 19d7261..1ee452f 100644
--- a/lib/iso8859_15.h
+++ b/lib/iso8859_15.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -31,7 +31,7 @@
 };
 
 static int
-iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0xa0 && c < 0xc0)
@@ -57,7 +57,7 @@
 };
 
 static int
-iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_16.h b/lib/iso8859_16.h
index 1e199e1..b2c18fc 100644
--- a/lib/iso8859_16.h
+++ b/lib/iso8859_16.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -92,7 +92,7 @@
 };
 
 static int
-iso8859_16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_2.h b/lib/iso8859_2.h
index 680747c..e85e487 100644
--- a/lib/iso8859_2.h
+++ b/lib/iso8859_2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -92,7 +92,7 @@
 };
 
 static int
-iso8859_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_3.h b/lib/iso8859_3.h
index fc00539..243bd98 100644
--- a/lib/iso8859_3.h
+++ b/lib/iso8859_3.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -96,7 +96,7 @@
 };
 
 static int
-iso8859_3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_4.h b/lib/iso8859_4.h
index 0b0e104..2a8c12d 100644
--- a/lib/iso8859_4.h
+++ b/lib/iso8859_4.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -92,7 +92,7 @@
 };
 
 static int
-iso8859_4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_5.h b/lib/iso8859_5.h
index 6967e1e..11fbd26 100644
--- a/lib/iso8859_5.h
+++ b/lib/iso8859_5.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
@@ -73,7 +73,7 @@
 };
 
 static int
-iso8859_5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_6.h b/lib/iso8859_6.h
index 6a04e2e..602e031 100644
--- a/lib/iso8859_6.h
+++ b/lib/iso8859_6.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -78,7 +78,7 @@
 };
 
 static int
-iso8859_6_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_6_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_7.h b/lib/iso8859_7.h
index 6643f89..3d67815 100644
--- a/lib/iso8859_7.h
+++ b/lib/iso8859_7.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2004 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2004, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -85,7 +85,7 @@
 };
 
 static int
-iso8859_7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_8.h b/lib/iso8859_8.h
index a696cf8..98be32c 100644
--- a/lib/iso8859_8.h
+++ b/lib/iso8859_8.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-iso8859_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0xa0) {
@@ -85,7 +85,7 @@
 };
 
 static int
-iso8859_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/iso8859_9.h b/lib/iso8859_9.h
index 8fc5d10..5d60d83 100644
--- a/lib/iso8859_9.h
+++ b/lib/iso8859_9.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -34,7 +34,7 @@
 };
 
 static int
-iso8859_9_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+iso8859_9_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0xd0)
@@ -65,7 +65,7 @@
 };
 
 static int
-iso8859_9_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+iso8859_9_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00d0) {
diff --git a/lib/isoir165.h b/lib/isoir165.h
index 095ad45..ea70bdd 100644
--- a/lib/isoir165.h
+++ b/lib/isoir165.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2005, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2005, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -80,7 +80,7 @@
 #include "isoir165ext.h"
 
 static int
-isoir165_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+isoir165_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   int ret;
 
@@ -121,7 +121,7 @@
 }
 
 static int
-isoir165_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+isoir165_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/isoir165ext.h b/lib/isoir165ext.h
index 7e4188a..04865a1 100644
--- a/lib/isoir165ext.h
+++ b/lib/isoir165ext.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -157,7 +157,7 @@
 };
 
 static int
-isoir165ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+isoir165ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x2b && c1 <= 0x2f) || (c1 >= 0x7a && c1 <= 0x7e)) {
@@ -752,7 +752,7 @@
 };
 
 static int
-isoir165ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+isoir165ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/java.h b/lib/java.h
index 035b4a1..25f0871 100644
--- a/lib/java.h
+++ b/lib/java.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -25,7 +25,7 @@
  */
 
 static int
-java_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+java_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c;
   ucs4_t wc, wc2;
@@ -94,7 +94,7 @@
 }
 
 static int
-java_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+java_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x80) {
     *r = wc;
diff --git a/lib/jisx0201.h b/lib/jisx0201.h
index 12df1db..38731fe 100644
--- a/lib/jisx0201.h
+++ b/lib/jisx0201.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-jisx0201_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+jisx0201_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -43,7 +43,7 @@
 }
 
 static int
-jisx0201_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+jisx0201_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
     *r = wc;
diff --git a/lib/jisx0208.h b/lib/jisx0208.h
index adcef3b..eb09a40 100644
--- a/lib/jisx0208.h
+++ b/lib/jisx0208.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1009,7 +1009,7 @@
 };
 
 static int
-jisx0208_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+jisx0208_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x28) || (c1 >= 0x30 && c1 <= 0x74)) {
@@ -2373,7 +2373,7 @@
 };
 
 static int
-jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/jisx0212.h b/lib/jisx0212.h
index c04650e..d895805 100644
--- a/lib/jisx0212.h
+++ b/lib/jisx0212.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -910,7 +910,7 @@
 };
 
 static int
-jisx0212_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+jisx0212_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x22) || (c1 >= 0x26 && c1 <= 0x27) || (c1 >= 0x29 && c1 <= 0x2b) || (c1 >= 0x30 && c1 <= 0x6d)) {
@@ -2153,7 +2153,7 @@
 };
 
 static int
-jisx0212_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+jisx0212_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/johab.h b/lib/johab.h
index d2fcda2..12f265b 100644
--- a/lib/johab.h
+++ b/lib/johab.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2007, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -47,7 +47,7 @@
  */
 
 static int
-johab_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+johab_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -85,7 +85,7 @@
 }
 
 static int
-johab_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+johab_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/johab_hangul.h b/lib/johab_hangul.h
index 84f2697..46ed993 100644
--- a/lib/johab_hangul.h
+++ b/lib/johab_hangul.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -101,7 +101,7 @@
 };
 
 static int
-johab_hangul_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+johab_hangul_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x84 && c1 <= 0xd3)) {
@@ -194,7 +194,7 @@
 };
 
 static int
-johab_hangul_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+johab_hangul_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     if (wc >= 0x3131 && wc < 0x3164) {
diff --git a/lib/koi8_r.h b/lib/koi8_r.h
index 7c7f9f7..d89e2a4 100644
--- a/lib/koi8_r.h
+++ b/lib/koi8_r.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -51,7 +51,7 @@
 };
 
 static int
-koi8_r_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+koi8_r_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -127,7 +127,7 @@
 };
 
 static int
-koi8_r_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+koi8_r_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/koi8_ru.h b/lib/koi8_ru.h
index 71f1603..90e0aef 100644
--- a/lib/koi8_ru.h
+++ b/lib/koi8_ru.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-koi8_ru_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+koi8_ru_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -133,7 +133,7 @@
 };
 
 static int
-koi8_ru_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+koi8_ru_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/koi8_t.h b/lib/koi8_t.h
index 5c8f2be..bd56b1a 100644
--- a/lib/koi8_t.h
+++ b/lib/koi8_t.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-koi8_t_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+koi8_t_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -119,7 +119,7 @@
 };
 
 static int
-koi8_t_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+koi8_t_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/koi8_u.h b/lib/koi8_u.h
index 7553e55..c7de73e 100644
--- a/lib/koi8_u.h
+++ b/lib/koi8_u.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -51,7 +51,7 @@
 };
 
 static int
-koi8_u_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+koi8_u_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -135,7 +135,7 @@
 };
 
 static int
-koi8_u_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+koi8_u_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/ksc5601.h b/lib/ksc5601.h
index 042a85a..5be7da9 100644
--- a/lib/ksc5601.h
+++ b/lib/ksc5601.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2007, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2007, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -1185,7 +1185,7 @@
 };
 
 static int
-ksc5601_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ksc5601_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x30 && c1 <= 0x48) || (c1 >= 0x4a && c1 <= 0x7d)) {
@@ -2980,7 +2980,7 @@
 };
 
 static int
-ksc5601_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ksc5601_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
diff --git a/lib/mac_arabic.h b/lib/mac_arabic.h
index 6b54280..dac6b96 100644
--- a/lib/mac_arabic.h
+++ b/lib/mac_arabic.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_arabic_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_arabic_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -110,7 +110,7 @@
 };
 
 static int
-mac_arabic_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_arabic_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_centraleurope.h b/lib/mac_centraleurope.h
index fdc9f6e..10f5071 100644
--- a/lib/mac_centraleurope.h
+++ b/lib/mac_centraleurope.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_centraleurope_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_centraleurope_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -109,7 +109,7 @@
 };
 
 static int
-mac_centraleurope_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_centraleurope_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_croatian.h b/lib/mac_croatian.h
index b26f4bd..27e24a3 100644
--- a/lib/mac_croatian.h
+++ b/lib/mac_croatian.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_croatian_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_croatian_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -135,7 +135,7 @@
 };
 
 static int
-mac_croatian_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_croatian_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_cyrillic.h b/lib/mac_cyrillic.h
index 691d571..ea0cfbc 100644
--- a/lib/mac_cyrillic.h
+++ b/lib/mac_cyrillic.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_cyrillic_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_cyrillic_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0x80)
@@ -106,7 +106,7 @@
 };
 
 static int
-mac_cyrillic_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_cyrillic_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_greek.h b/lib/mac_greek.h
index f045869..6a81694 100644
--- a/lib/mac_greek.h
+++ b/lib/mac_greek.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_greek_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_greek_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -107,7 +107,7 @@
 };
 
 static int
-mac_greek_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_greek_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_hebrew.h b/lib/mac_hebrew.h
index 71a5813..4b8dcdc 100644
--- a/lib/mac_hebrew.h
+++ b/lib/mac_hebrew.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_hebrew_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_hebrew_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -106,7 +106,7 @@
 };
 
 static int
-mac_hebrew_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_hebrew_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_iceland.h b/lib/mac_iceland.h
index 7e284d0..56f7612 100644
--- a/lib/mac_iceland.h
+++ b/lib/mac_iceland.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_iceland_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_iceland_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -130,7 +130,7 @@
 };
 
 static int
-mac_iceland_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_iceland_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_roman.h b/lib/mac_roman.h
index f64f086..899e042 100644
--- a/lib/mac_roman.h
+++ b/lib/mac_roman.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_roman_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_roman_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -133,7 +133,7 @@
 };
 
 static int
-mac_roman_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_roman_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_romania.h b/lib/mac_romania.h
index 9d87d3d..2a2d128 100644
--- a/lib/mac_romania.h
+++ b/lib/mac_romania.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_romania_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_romania_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -135,7 +135,7 @@
 };
 
 static int
-mac_romania_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_romania_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_thai.h b/lib/mac_thai.h
index 5ba2441..ae8c848 100644
--- a/lib/mac_thai.h
+++ b/lib/mac_thai.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_thai_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_thai_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -100,7 +100,7 @@
 };
 
 static int
-mac_thai_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_thai_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_turkish.h b/lib/mac_turkish.h
index cf25896..b6c0422 100644
--- a/lib/mac_turkish.h
+++ b/lib/mac_turkish.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_turkish_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_turkish_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -131,7 +131,7 @@
 };
 
 static int
-mac_turkish_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_turkish_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mac_ukraine.h b/lib/mac_ukraine.h
index b2714cd..d02ca77 100644
--- a/lib/mac_ukraine.h
+++ b/lib/mac_ukraine.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-mac_ukraine_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mac_ukraine_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0x80)
@@ -113,7 +113,7 @@
 };
 
 static int
-mac_ukraine_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mac_ukraine_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/mulelao.h b/lib/mulelao.h
index 38ab466..bccd6cd 100644
--- a/lib/mulelao.h
+++ b/lib/mulelao.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
 };
 
 static int
-mulelao_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+mulelao_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
@@ -76,7 +76,7 @@
 };
 
 static int
-mulelao_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+mulelao_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
diff --git a/lib/nextstep.h b/lib/nextstep.h
index 5838b81..a1d8ca4 100644
--- a/lib/nextstep.h
+++ b/lib/nextstep.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-nextstep_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+nextstep_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -115,7 +115,7 @@
 };
 
 static int
-nextstep_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+nextstep_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/pt154.h b/lib/pt154.h
index ddbe381..0cb41ef 100644
--- a/lib/pt154.h
+++ b/lib/pt154.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2005 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -37,7 +37,7 @@
 };
 
 static int
-pt154_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+pt154_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80)
@@ -94,7 +94,7 @@
 };
 
 static int
-pt154_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+pt154_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/riscos1.h b/lib/riscos1.h
index 2620637..311404c 100644
--- a/lib/riscos1.h
+++ b/lib/riscos1.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -31,7 +31,7 @@
 };
 
 static int
-riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c >= 0x80 && c < 0xa0)
@@ -66,7 +66,7 @@
 };
 
 static int
-riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) {
diff --git a/lib/rk1048.h b/lib/rk1048.h
index 4b88f64..f34059e 100644
--- a/lib/rk1048.h
+++ b/lib/rk1048.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2007 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2007, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -49,7 +49,7 @@
 };
 
 static int
-rk1048_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+rk1048_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -119,7 +119,7 @@
 };
 
 static int
-rk1048_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+rk1048_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
diff --git a/lib/shift_jisx0213.h b/lib/shift_jisx0213.h
index 68805f0..e770d39 100644
--- a/lib/shift_jisx0213.h
+++ b/lib/shift_jisx0213.h
@@ -39,7 +39,7 @@
 #include "flushwc.h"
 
 static int
-shift_jisx0213_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+shift_jisx0213_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   ucs4_t last_wc = conv->istate;
   if (last_wc) {
@@ -157,7 +157,7 @@
 };
 
 static int
-shift_jisx0213_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+shift_jisx0213_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   int count = 0;
   unsigned short lasttwo = conv->ostate;
@@ -293,7 +293,7 @@
 }
 
 static int
-shift_jisx0213_reset (conv_t conv, unsigned char *r, int n)
+shift_jisx0213_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t lasttwo = conv->ostate;
 
diff --git a/lib/sjis.h b/lib/sjis.h
index c12b259..45d19e5 100644
--- a/lib/sjis.h
+++ b/lib/sjis.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -43,7 +43,7 @@
  */
 
 static int
-sjis_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+sjis_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80 || (c >= 0xa1 && c <= 0xdf))
@@ -79,7 +79,7 @@
 }
 
 static int
-sjis_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+sjis_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char buf[2];
   int ret;
diff --git a/lib/tcvn.h b/lib/tcvn.h
index 96090df..92f4ac4 100644
--- a/lib/tcvn.h
+++ b/lib/tcvn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2004, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -77,7 +77,7 @@
    character, or 0 if none. */
 
 static int
-tcvn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+tcvn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   unsigned short wc;
@@ -214,7 +214,7 @@
 };
 
 static int
-tcvn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+tcvn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080 && (wc >= 0x0020 || (0x00fe0076 & (1 << wc)) == 0)) {
diff --git a/lib/tds565.h b/lib/tds565.h
index 440e8a7..2aed4c9 100644
--- a/lib/tds565.h
+++ b/lib/tds565.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2002 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -37,7 +37,7 @@
 };
 
 static int
-tds565_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+tds565_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x40) {
@@ -83,7 +83,7 @@
 };
 
 static int
-tds565_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+tds565_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0040) {
diff --git a/lib/tis620.h b/lib/tis620.h
index 6938e4d..5350997 100644
--- a/lib/tis620.h
+++ b/lib/tis620.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-tis620_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+tis620_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
@@ -37,7 +37,7 @@
 }
 
 static int
-tis620_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+tis620_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x0080) {
     *r = wc;
diff --git a/lib/ucs2.h b/lib/ucs2.h
index 5cbe7ed..a8bf999 100644
--- a/lib/ucs2.h
+++ b/lib/ucs2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008, 2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -25,11 +25,11 @@
    in the stream, not just at the beginning. The default is big-endian. */
 /* The state is 0 if big-endian, 1 if little-endian. */
 static int
-ucs2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
-  for (; n >= 2;) {
+  for (; n >= 2 && count <= RET_COUNT_MAX && count <= INT_MAX-2;) {
     ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]);
     if (wc == 0xfeff) {
     } else if (wc == 0xfffe) {
@@ -53,7 +53,7 @@
    "ISO/IEC 10646-1:1993(E) specifies that when characters the UCS-2 form are
     serialized as octets, that the most significant octet appear first." */
 static int
-ucs2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x10000 && wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) {
     if (n >= 2) {
diff --git a/lib/ucs2be.h b/lib/ucs2be.h
index 7d7a129..cef7ec7 100644
--- a/lib/ucs2be.h
+++ b/lib/ucs2be.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs2be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs2be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 2) {
     if (s[0] >= 0xd8 && s[0] < 0xe0) {
@@ -36,7 +36,7 @@
 }
 
 static int
-ucs2be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs2be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) {
     if (n >= 2) {
diff --git a/lib/ucs2internal.h b/lib/ucs2internal.h
index 5e65a70..567df4e 100644
--- a/lib/ucs2internal.h
+++ b/lib/ucs2internal.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs2internal_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs2internal_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 2) {
     unsigned short x = *(const unsigned short *)s;
@@ -37,7 +37,7 @@
 }
 
 static int
-ucs2internal_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs2internal_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) {
     if (n >= 2) {
diff --git a/lib/ucs2le.h b/lib/ucs2le.h
index 387db7f..244a1e4 100644
--- a/lib/ucs2le.h
+++ b/lib/ucs2le.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs2le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs2le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 2) {
     if (s[1] >= 0xd8 && s[1] < 0xe0) {
@@ -36,7 +36,7 @@
 }
 
 static int
-ucs2le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs2le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) {
     if (n >= 2) {
diff --git a/lib/ucs2swapped.h b/lib/ucs2swapped.h
index c2a5cb1..6922357 100644
--- a/lib/ucs2swapped.h
+++ b/lib/ucs2swapped.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs2swapped_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs2swapped_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   /* This function assumes that 'unsigned short' has exactly 16 bits. */
   if (sizeof(unsigned short) != 2) abort();
@@ -41,7 +41,7 @@
 }
 
 static int
-ucs2swapped_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs2swapped_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   /* This function assumes that 'unsigned short' has exactly 16 bits. */
   if (sizeof(unsigned short) != 2) abort();
diff --git a/lib/ucs4.h b/lib/ucs4.h
index 6b5b6d9..02b975f 100644
--- a/lib/ucs4.h
+++ b/lib/ucs4.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008, 2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -25,11 +25,11 @@
    in the stream, not just at the beginning. The default is big-endian. */
 /* The state is 0 if big-endian, 1 if little-endian. */
 static int
-ucs4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
-  for (; n >= 4;) {
+  for (; n >= 4 && count <= RET_COUNT_MAX && count <= INT_MAX-4;) {
     ucs4_t wc = (state
                   ? s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24)
                   : (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]);
@@ -52,7 +52,7 @@
 
 /* But we output UCS-4 in big-endian order, without byte-order mark. */
 static int
-ucs4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc <= 0x7fffffff) {
     if (n >= 4) {
diff --git a/lib/ucs4be.h b/lib/ucs4be.h
index e2a0c24..0b4869b 100644
--- a/lib/ucs4be.h
+++ b/lib/ucs4be.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs4be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs4be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 4) {
     *pwc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
@@ -32,7 +32,7 @@
 }
 
 static int
-ucs4be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs4be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 4) {
     r[0] = (unsigned char) (wc >> 24);
diff --git a/lib/ucs4internal.h b/lib/ucs4internal.h
index be74b1d..e3ca4b2 100644
--- a/lib/ucs4internal.h
+++ b/lib/ucs4internal.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs4internal_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs4internal_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 4) {
     *pwc = *(const unsigned int *)s;
@@ -32,7 +32,7 @@
 }
 
 static int
-ucs4internal_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs4internal_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 4) {
     *(unsigned int *)r = wc;
diff --git a/lib/ucs4le.h b/lib/ucs4le.h
index 66e11a2..95b78fc 100644
--- a/lib/ucs4le.h
+++ b/lib/ucs4le.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs4le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs4le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 4) {
     *pwc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24);
@@ -32,7 +32,7 @@
 }
 
 static int
-ucs4le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs4le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 4) {
     r[0] = (unsigned char) wc;
diff --git a/lib/ucs4swapped.h b/lib/ucs4swapped.h
index a6aa359..de01fad 100644
--- a/lib/ucs4swapped.h
+++ b/lib/ucs4swapped.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,7 +22,7 @@
  */
 
 static int
-ucs4swapped_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+ucs4swapped_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   /* This function assumes that 'unsigned int' has exactly 32 bits. */
   if (sizeof(unsigned int) != 4) abort();
@@ -37,7 +37,7 @@
 }
 
 static int
-ucs4swapped_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+ucs4swapped_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   /* This function assumes that 'unsigned int' has exactly 32 bits. */
   if (sizeof(unsigned int) != 4) abort();
diff --git a/lib/uhc_1.h b/lib/uhc_1.h
index 5879669..b3472b4 100644
--- a/lib/uhc_1.h
+++ b/lib/uhc_1.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -803,7 +803,7 @@
 };
 
 static int
-uhc_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+uhc_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x81 && c1 <= 0xa0)) {
@@ -1696,7 +1696,7 @@
 };
 
 static int
-uhc_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+uhc_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     if (wc >= 0xac00 && wc < 0xc8b0) {
diff --git a/lib/uhc_2.h b/lib/uhc_2.h
index 1cb80a2..f493807 100644
--- a/lib/uhc_2.h
+++ b/lib/uhc_2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2012 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -485,7 +485,7 @@
 };
 
 static int
-uhc_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+uhc_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0xa1 && c1 <= 0xc6)) {
@@ -993,7 +993,7 @@
 };
 
 static int
-uhc_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+uhc_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (n >= 2) {
     if (wc >= 0xc800 && wc < 0xd7b0) {
diff --git a/lib/utf16.h b/lib/utf16.h
index 8e8957a..0b9dcb1 100644
--- a/lib/utf16.h
+++ b/lib/utf16.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -31,11 +31,11 @@
    The default is big-endian. */
 /* The state is 0 if big-endian, 1 if little-endian. */
 static int
-utf16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
-  for (; n >= 2;) {
+  for (; n >= 2 && count <= RET_COUNT_MAX && count <= INT_MAX-2;) {
     ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]);
     if (wc == 0xfeff) {
     } else if (wc == 0xfffe) {
@@ -73,7 +73,7 @@
    long as the above utf16_mbtowc function is used. */
 /* The state is 0 at the beginning, 1 after the BOM has been written. */
 static int
-utf16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+utf16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) {
     int count = 0;
diff --git a/lib/utf16be.h b/lib/utf16be.h
index 5d93ca2..ad9f4b6 100644
--- a/lib/utf16be.h
+++ b/lib/utf16be.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -24,7 +24,7 @@
 /* Specification: RFC 2781 */
 
 static int
-utf16be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf16be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   int count = 0;
   if (n >= 2) {
@@ -51,7 +51,7 @@
 }
 
 static int
-utf16be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+utf16be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (!(wc >= 0xd800 && wc < 0xe000)) {
     if (wc < 0x10000) {
diff --git a/lib/utf16le.h b/lib/utf16le.h
index b080643..2d7d3cf 100644
--- a/lib/utf16le.h
+++ b/lib/utf16le.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -24,7 +24,7 @@
 /* Specification: RFC 2781 */
 
 static int
-utf16le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf16le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   int count = 0;
   if (n >= 2) {
@@ -51,7 +51,7 @@
 }
 
 static int
-utf16le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+utf16le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (!(wc >= 0xd800 && wc < 0xe000)) {
     if (wc < 0x10000) {
diff --git a/lib/utf32.h b/lib/utf32.h
index 10beea5..3ad94c0 100644
--- a/lib/utf32.h
+++ b/lib/utf32.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008, 2011 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2011, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -31,11 +31,11 @@
    The default is big-endian. */
 /* The state is 0 if big-endian, 1 if little-endian. */
 static int
-utf32_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf32_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0;
-  for (; n >= 4;) {
+  for (; n >= 4 && count <= RET_COUNT_MAX && count <= INT_MAX-4;) {
     ucs4_t wc = (state
                   ? s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24)
                   : (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]);
@@ -61,7 +61,7 @@
 /* We output UTF-32 in big-endian order, with byte-order mark. */
 /* The state is 0 at the beginning, 1 after the BOM has been written. */
 static int
-utf32_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+utf32_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
     int count = 0;
diff --git a/lib/utf32be.h b/lib/utf32be.h
index 7c82e80..ec724f8 100644
--- a/lib/utf32be.h
+++ b/lib/utf32be.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -24,7 +24,7 @@
 /* Specification: Unicode 3.1 Standard Annex #19 */
 
 static int
-utf32be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf32be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 4) {
     ucs4_t wc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
@@ -38,7 +38,7 @@
 }
 
 static int
-utf32be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+utf32be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
     if (n >= 4) {
diff --git a/lib/utf32le.h b/lib/utf32le.h
index 926fc5a..d595b23 100644
--- a/lib/utf32le.h
+++ b/lib/utf32le.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -24,7 +24,7 @@
 /* Specification: Unicode 3.1 Standard Annex #19 */
 
 static int
-utf32le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf32le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   if (n >= 4) {
     ucs4_t wc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24);
@@ -38,7 +38,7 @@
 }
 
 static int
-utf32le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+utf32le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
     if (n >= 4) {
diff --git a/lib/utf7.h b/lib/utf7.h
index 2ff2743..4906eb0 100644
--- a/lib/utf7.h
+++ b/lib/utf7.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -65,7 +65,7 @@
  */
 
 static int
-utf7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   state_t state = conv->istate;
   int count = 0; /* number of input bytes already read */
@@ -206,7 +206,7 @@
 #define UTF7_ENCODE_OPTIONAL_CHARS 1
 
 static int
-utf7_wctomb (conv_t conv, unsigned char *r, ucs4_t iwc, int n)
+utf7_wctomb (conv_t conv, unsigned char *r, ucs4_t iwc, size_t n)
 {
   state_t state = conv->ostate;
   unsigned int wc = iwc;
@@ -321,7 +321,7 @@
 }
 
 static int
-utf7_reset (conv_t conv, unsigned char *r, int n)
+utf7_reset (conv_t conv, unsigned char *r, size_t n)
 {
   state_t state = conv->ostate;
   if (state & 3) {
diff --git a/lib/utf8.h b/lib/utf8.h
index 10ddce4..8fab264 100644
--- a/lib/utf8.h
+++ b/lib/utf8.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -24,7 +24,7 @@
 /* Specification: RFC 3629 */
 
 static int
-utf8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+utf8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = s[0];
 
@@ -96,7 +96,7 @@
 }
 
 static int
-utf8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) /* n == 0 is acceptable */
+utf8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) /* n == 0 is acceptable */
 {
   int count;
   if (wc < 0x80)
diff --git a/lib/viscii.h b/lib/viscii.h
index dd660d9..400d6f3 100644
--- a/lib/viscii.h
+++ b/lib/viscii.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2001 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -59,7 +59,7 @@
 };
 
 static int
-viscii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+viscii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {
   unsigned char c = *s;
   if (c < 0x20)
@@ -121,7 +121,7 @@
 };
 
 static int
-viscii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+viscii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {
   unsigned char c = 0;
   if (wc < 0x0080 && (wc >= 0x0020 || (0x42100064 & (1 << wc)) == 0)) {
diff --git a/tools/8bit_tab_to_h.c b/tools/8bit_tab_to_h.c
index ba5d230..dcfeca6 100644
--- a/tools/8bit_tab_to_h.c
+++ b/tools/8bit_tab_to_h.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2002, 2011-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2002, 2011-2012, 2016 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Tools.
 
    This program is free software: you can redistribute it and/or modify
@@ -234,7 +234,7 @@
         fprintf(f, "\n");
       }
       final_ret_reached = false;
-      fprintf(f, "static int\n%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", c_charsetname);
+      fprintf(f, "static int\n%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)\n", c_charsetname);
       fprintf(f, "{\n");
       fprintf(f, "  unsigned char c = *s;\n");
       if (some_invalid) {
@@ -440,7 +440,7 @@
         j1 = j2;
       }
       fix_0000 = false;
-      fprintf(f, "static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", c_charsetname);
+      fprintf(f, "static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)\n", c_charsetname);
       fprintf(f, "{\n");
       if (need_c)
         fprintf(f, "  unsigned char c = 0;\n");
diff --git a/tools/cjk_tab_to_h.c b/tools/cjk_tab_to_h.c
index d73c9a1..2baa44e 100644
--- a/tools/cjk_tab_to_h.c
+++ b/tools/cjk_tab_to_h.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2004, 2006-2007, 2010, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2004, 2006-2007, 2010, 2012, 2016 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Tools.
 
    This program is free software: you can redistribute it and/or modify
@@ -75,7 +75,7 @@
 static void output_title (const char *charsetname)
 {
   printf("/*\n");
-  printf(" * Copyright (C) 1999-2010 Free Software Foundation, Inc.\n");
+  printf(" * Copyright (C) 1999-2016 Free Software Foundation, Inc.\n");
   printf(" * This file is part of the GNU LIBICONV Library.\n");
   printf(" *\n");
   printf(" * The GNU LIBICONV Library is free software; you can redistribute it\n");
@@ -338,7 +338,7 @@
   }
 
   printf("static int\n");
-  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name);
+  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)\n", name);
   printf("{\n");
   printf("  unsigned char c1 = s[0];\n");
   printf("  if (");
@@ -449,7 +449,7 @@
   printf("\n");
 
   printf("static int\n");
-  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name);
+  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)\n", name);
   printf("{\n");
   printf("  unsigned char c1 = s[0];\n");
   printf("  if (");
@@ -614,7 +614,7 @@
     if (p >= 0)
       printf("\n");
   }
-  printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
+  printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)\n", name);
   printf("{\n");
   printf("  if (n >= 2) {\n");
   printf("    unsigned short c = 0;\n");
@@ -798,7 +798,7 @@
   printf("\n");
 
   printf("static int\n");
-  printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
+  printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)\n", name);
   printf("{\n");
   printf("  if (n >= 2) {\n");
   printf("    const Summary16 *summary = NULL;\n");
@@ -1553,7 +1553,7 @@
   printf("\n");
 
   printf("static int\n");
-  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name);
+  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)\n", name);
   printf("{\n");
   printf("  unsigned char c1 = s[0];\n");
   printf("  if (c1 >= 0x81 && c1 <= 0x84) {\n");
@@ -1607,7 +1607,7 @@
   printf("\n");
 
   printf("static int\n");
-  printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
+  printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)\n", name);
   printf("{\n");
   printf("  if (n >= 4) {\n");
   printf("    unsigned int i = wc;\n");