macroman.patch   [plain text]


--- libiconv-1.11/lib/mac_roman.h.orig	2005-05-19 09:33:45.000000000 -0700
+++ libiconv-1.11/lib/mac_roman.h	2008-03-21 22:58:59.000000000 -0700
@@ -34,18 +34,18 @@
   0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8,
   /* 0xb0 */
   0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
-  0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x2126, 0x00e6, 0x00f8,
+  0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x00e6, 0x00f8,
   /* 0xc0 */
   0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
   0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
   /* 0xd0 */
   0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
-  0x00ff, 0x0178, 0x2044, 0x00a4, 0x2039, 0x203a, 0xfb01, 0xfb02,
+  0x00ff, 0x0178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
   /* 0xe0 */
   0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1,
   0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
   /* 0xf0 */
-  0xfffd, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
+  0xf8ff, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
   0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7,
 };
 
@@ -68,7 +68,7 @@
 }
 
 static const unsigned char mac_roman_page00[96] = {
-  0xca, 0xc1, 0xa2, 0xa3, 0xdb, 0xb4, 0x00, 0xa4, /* 0xa0-0xa7 */
+  0xca, 0xc1, 0xa2, 0xa3, 0x00, 0xb4, 0x00, 0xa4, /* 0xa0-0xa7 */
   0xac, 0xa9, 0xbb, 0xc7, 0xc2, 0x00, 0xa8, 0xf8, /* 0xa8-0xaf */
   0xa1, 0xb1, 0x00, 0x00, 0xab, 0xb5, 0xa6, 0xe1, /* 0xb0-0xb7 */
   0xfc, 0x00, 0xbc, 0xc8, 0x00, 0x00, 0x00, 0xc0, /* 0xb8-0xbf */
@@ -102,6 +102,12 @@
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
   0xf9, 0xfa, 0xfb, 0xfe, 0xf7, 0xfd, 0x00, 0x00, /* 0xd8-0xdf */
 };
+static const unsigned char mac_roman_page03[32] = {
+  0x00, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+  0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+};
 static const unsigned char mac_roman_page20[56] = {
   0x00, 0x00, 0x00, 0xd0, 0xd1, 0x00, 0x00, 0x00, /* 0x10-0x17 */
   0xd4, 0xd5, 0xe2, 0x00, 0xd2, 0xd3, 0xe3, 0x00, /* 0x18-0x1f */
@@ -111,9 +117,6 @@
   0x00, 0xdc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
   0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x40-0x47 */
 };
-static const unsigned char mac_roman_page21[8] = {
-  0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0xbd, 0x00, /* 0x20-0x27 */
-};
 static const unsigned char mac_roman_page22[104] = {
   0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0xc6, 0x00, /* 0x00-0x07 */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, /* 0x08-0x0f */
@@ -141,22 +144,33 @@
     *r = wc;
     return 1;
   }
-  else if (wc >= 0x00a0 && wc < 0x0100)
+  switch(wc) { // single-character mapping
+  case 0x20ac:
+    *r = 0xdb;
+    return 1;
+  case 0x2122:
+    *r = 0xaa;
+    return 1;
+  case 0x25ca:
+    *r = 0xd7;
+    return 1;
+  case 0xf8ff:
+    *r = 0xf0;
+    return 1;
+  }
+  // multi-character mappings
+  if (wc >= 0x00a0 && wc < 0x0100)
     c = mac_roman_page00[wc-0x00a0];
   else if (wc >= 0x0130 && wc < 0x0198)
     c = mac_roman_page01[wc-0x0130];
   else if (wc >= 0x02c0 && wc < 0x02e0)
     c = mac_roman_page02[wc-0x02c0];
-  else if (wc == 0x03c0)
-    c = 0xb9;
+  else if (wc >= 0x03a8 && wc < 0x03c8)
+    c = mac_roman_page03[wc-0x03a8];
   else if (wc >= 0x2010 && wc < 0x2048)
     c = mac_roman_page20[wc-0x2010];
-  else if (wc >= 0x2120 && wc < 0x2128)
-    c = mac_roman_page21[wc-0x2120];
   else if (wc >= 0x2200 && wc < 0x2268)
     c = mac_roman_page22[wc-0x2200];
-  else if (wc == 0x25ca)
-    c = 0xd7;
   else if (wc >= 0xfb00 && wc < 0xfb08)
     c = mac_roman_pagefb[wc-0xfb00];
   if (c != 0) {