1 diff -urN --exclude-from=- cdrtools-2.01/include/unls.h cdrtools-2.01-jh/include/unls.h
2 --- cdrtools-2.01/include/unls.h 2003-06-16 00:41:23.000000000 +0300
3 +++ cdrtools-2.01-jh/include/unls.h 2004-02-02 18:31:22.000000000 +0200
17 unsigned char **page_uni2charset;
18 struct nls_unicode *charset2uni;
23 void (*inc_use_count) __PR((void));
24 void (*dec_use_count) __PR((void));
26 extern void unload_nls __PR((struct nls_table *));
27 extern struct nls_table *load_nls_default __PR((void));
28 extern int init_nls_file __PR((char * name));
30 +extern int init_nls_iconv __PR((char * name));
35 diff -urN --exclude-from=- cdrtools-2.01/libunls/libunls.mk cdrtools-2.01-jh/libunls/libunls.mk
36 --- cdrtools-2.01/libunls/libunls.mk 2000-03-25 14:51:56.000000000 +0200
37 +++ cdrtools-2.01-jh/libunls/libunls.mk 2004-02-02 18:31:22.000000000 +0200
42 +CPPOPTS += -DUSE_ICONV
46 diff -urN --exclude-from=- cdrtools-2.01/libunls/nls.h cdrtools-2.01-jh/libunls/nls.h
47 --- cdrtools-2.01/libunls/nls.h 2002-12-03 02:34:27.000000000 +0200
48 +++ cdrtools-2.01-jh/libunls/nls.h 2004-02-02 18:31:22.000000000 +0200
50 extern int init_nls_cp10079 __PR((void));
51 extern int init_nls_cp10081 __PR((void));
52 extern int init_nls_file __PR((char * name));
54 +extern int init_nls_iconv __PR((char * name));
58 diff -urN --exclude-from=- cdrtools-2.01/libunls/nls_iconv.c cdrtools-2.01-jh/libunls/nls_iconv.c
59 --- cdrtools-2.01/libunls/nls_iconv.c 1970-01-01 02:00:00.000000000 +0200
60 +++ cdrtools-2.01-jh/libunls/nls_iconv.c 2004-02-02 18:31:22.000000000 +0200
62 +/* @(#)nls_iconv.c 1.0 02/04/20 2002 J. Schilling */
64 +static char sccsid[] =
65 + "@(#)nls_iconv.c 1.0 02/01/20 2002 J. Schilling";
68 + * This program is free software; you can redistribute it and/or modify
69 + * it under the terms of the GNU General Public License as published by
70 + * the Free Software Foundation; either version 2, or (at your option)
71 + * any later version.
73 + * This program is distributed in the hope that it will be useful,
74 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
75 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 + * GNU General Public License for more details.
78 + * You should have received a copy of the GNU General Public License
79 + * along with this program; see the file COPYING. If not, write to
80 + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
83 + * Modifications to make the code portable Copyright (c) 2000 J. Schilling
85 + * nls_iconv: create a pseudo-charset table to use iconv() provided by C
86 + * library or libiconv by Bruno Haible
87 + * The Unicode to charset table has only exact mappings.
90 + * Jungshik Shin (jshin@mailaps.org) 04-Feb-2002
101 +static void inc_use_count __PR((void));
102 +static void dec_use_count __PR((void));
118 +init_nls_iconv(charset)
121 + iconv_t iconv_d; /* iconv conversion descriptor */
122 + struct nls_table *table;
124 + /* give up if no charset is given */
125 + if (charset == NULL)
128 + /* see if we already have a table with this name - built in tables
129 + have precedence over iconv() - i.e. can't have the name of an
130 + existing table. Also, we may have already registered this file
132 + if (find_nls(charset) != NULL)
135 + if ((iconv_d = iconv_open("UCS-2BE", charset)) == (iconv_t) -1)
139 + /* set up the table */
140 + if ((table = (struct nls_table *)malloc(sizeof (struct nls_table)))
145 + /* give the table the file name, so we can find it again if needed */
146 + table->charset = strdup(charset);
147 + table->iconv_d = iconv_d;
148 + table->page_uni2charset = NULL;
149 + table->charset2uni = NULL;
150 + table->inc_use_count = inc_use_count;
151 + table->dec_use_count = dec_use_count;
152 + table->next = NULL;
154 + /* register the table */
155 + return register_nls(table);
158 diff -urN --exclude-from=- cdrtools-2.01/libunls/Targets cdrtools-2.01-jh/libunls/Targets
159 --- cdrtools-2.01/libunls/Targets 2002-12-03 02:34:27.000000000 +0200
160 +++ cdrtools-2.01-jh/libunls/Targets 2004-02-02 18:31:22.000000000 +0200
168 diff -urN --exclude-from=- cdrtools-2.01/mkisofs/joliet.c cdrtools-2.01-jh/mkisofs/joliet.c
169 --- cdrtools-2.01/mkisofs/joliet.c 2003-04-28 01:36:08.000000000 +0300
170 +++ cdrtools-2.01-jh/mkisofs/joliet.c 2004-02-03 14:15:17.000000000 +0200
172 #include <unls.h> /* For UNICODE translation */
180 static Uint jpath_table_index;
181 static struct directory **jpathlist;
182 static int next_jpath_index = 1;
183 @@ -103,13 +108,23 @@
187 - void convert_to_unicode __PR((unsigned char *buffer,
193 + convert_to_unicode __PR((unsigned char *buffer,
194 int size, char *source, struct nls_table *inls));
195 - int joliet_strlen __PR((const char *string));
196 + int joliet_strlen __PR((const char *string, struct nls_table *inls));
198 -static void convert_to_unicode __PR((unsigned char *buffer,
204 + convert_to_unicode __PR((unsigned char *buffer,
205 int size, char *source, struct nls_table *inls));
206 -static int joliet_strlen __PR((const char *string));
207 +static int joliet_strlen __PR((const char *string, struct nls_table *inls));
209 static void get_joliet_vol_desc __PR((struct iso_primary_descriptor *jvol_desc));
210 static void assign_joliet_directory_addresses __PR((struct directory *node));
216 + if(inls->charset2uni == NULL || onls->page_uni2charset == NULL) {
218 + * This shouldn't be reached
220 + static BOOL iconv_warned = FALSE;
221 + if(!iconv_warned) {
222 + error("Warning: Iconv conversion not supported in conv_charset.\n");
223 + iconv_warned = TRUE;
229 /* get high and low UNICODE bytes */
230 uh = inls->charset2uni[c].uni2;
231 ul = inls->charset2uni[c].uni1;
232 @@ -186,10 +215,18 @@
251 convert_to_unicode(buffer, size, source, inls)
252 unsigned char *buffer;
254 tmpbuf = (Uchar *) source;
258 + if (inls->iconv_d && inls->charset2uni==NULL &&
259 + inls->page_uni2charset==NULL) {
260 + char *inptr = tmpbuf;
261 + char *outptr = buffer;
262 + size_t inleft = strlen(tmpbuf);
263 + size_t inlen = inleft;
264 + size_t outleft = size;
266 + iconv(inls->iconv_d, NULL, NULL, NULL, NULL);
267 + if(iconv(inls->iconv_d, &inptr, &inleft, &outptr, &outleft) ==
268 + (size_t)-1 && errno == EILSEQ) {
269 + fprintf(stderr, "Incorrectly encoded string (%s) "
270 + "encountered.\nPossibly creating an invalid "
271 + "Joliet extension. Aborting.\n", source);
275 + for (i = 0; (i + 1) < size - outleft; i += 2) { /* Size may be odd!!!*/
276 + if (buffer[i]=='\0') {
277 + switch (buffer[i+1]) { /* Invalid characters for Joliet */
286 + if (buffer[i+1] == 0x7f ||
287 + buffer[i+1] < 0x20)
292 + if (size & 1) { /* beautification */
293 + buffer[size - 1] = 0;
295 + if (source == NULL) {
298 + return (inlen - inleft);
303 * Now start copying characters. If the size was specified to be 0,
304 * then assume the input was 0 terminated.
306 if (source == NULL) {
315 @@ -287,12 +372,50 @@
319 -joliet_strlen(string)
320 +joliet_strlen(string, inls)
322 + struct nls_table *inls;
327 + if (inls->iconv_d && inls->charset2uni==NULL &&
328 + inls->page_uni2charset==NULL) {
330 + * we const-cast since we're sure iconv won't change
331 + * the string itself
333 + char *string_ptr = (char *)string;
334 + size_t string_len = strlen(string);
337 + * iconv has no way of finding out the required size
341 + char *tmp, *tmp_ptr;
342 + /* we assume that the maximum length is 2 * jlen */
343 + size_t tmp_len = (size_t)jlen * 2 + 1;
344 + tmp = e_malloc(tmp_len);
347 + iconv(inls->iconv_d, NULL, NULL, NULL, NULL);
348 + iconv(inls->iconv_d, &string_ptr, &string_len, &tmp_ptr,
352 + * iconv advanced the tmp pointer with as many chars
353 + * as it has written to it, so we add up the delta
355 + rtn = (tmp_ptr - tmp);
359 + rtn = strlen(string) << 1;
362 rtn = strlen(string) << 1;
366 * We do clamp the maximum length of a Joliet string to be the
367 @@ -480,16 +603,33 @@
368 /* compare the Unicode names */
370 while (*rpnt && *lpnt) {
374 + ri = convert_to_unicode(rtmp, 2, rpnt, rinls);
375 + li = convert_to_unicode(ltmp, 2, lpnt, linls);
385 convert_to_unicode(rtmp, 2, rpnt, rinls);
386 convert_to_unicode(ltmp, 2, lpnt, linls);
389 if (a_to_u_2_byte(rtmp) < a_to_u_2_byte(ltmp))
391 if (a_to_u_2_byte(rtmp) > a_to_u_2_byte(ltmp))
401 @@ -574,10 +714,10 @@
404 if (USE_MAC_NAME(de))
405 - namelen = joliet_strlen(de->hfs_ent->name);
406 + namelen = joliet_strlen(de->hfs_ent->name, hfs_inls);
408 #endif /* APPLE_HYB */
409 - namelen = joliet_strlen(de->name);
410 + namelen = joliet_strlen(de->name, in_nls);
413 jpath_table_l[jpath_table_index] = 1;
414 @@ -742,10 +882,10 @@
416 /* Use the HFS name if it exists */
417 if (USE_MAC_NAME(s_entry1))
418 - cvt_len = joliet_strlen(s_entry1->hfs_ent->name);
419 + cvt_len = joliet_strlen(s_entry1->hfs_ent->name, hfs_inls);
421 #endif /* APPLE_HYB */
422 - cvt_len = joliet_strlen(s_entry1->name);
423 + cvt_len = joliet_strlen(s_entry1->name, in_nls);
426 * Fix the record length
427 @@ -891,12 +1031,12 @@
428 if (USE_MAC_NAME(s_entry))
429 /* Use the HFS name if it exists */
431 - joliet_strlen(s_entry->hfs_ent->name) +
432 + joliet_strlen(s_entry->hfs_ent->name, hfs_inls) +
433 offsetof(struct iso_path_table, name[0]);
435 #endif /* APPLE_HYB */
437 - joliet_strlen(s_entry->name) +
438 + joliet_strlen(s_entry->name, in_nls) +
439 offsetof(struct iso_path_table, name[0]);
440 if (jpath_table_size & 1) {
442 @@ -918,13 +1058,13 @@
443 /* Use the HFS name if it exists */
445 offsetof(struct iso_directory_record, name[0])
446 - + joliet_strlen(s_entry->hfs_ent->name)
447 + + joliet_strlen(s_entry->hfs_ent->name, hfs_inls)
450 #endif /* APPLE_HYB */
452 offsetof(struct iso_directory_record, name[0])
453 - + joliet_strlen(s_entry->name)
454 + + joliet_strlen(s_entry->name, in_nls)
458 @@ -1072,6 +1212,9 @@
461 while (*rpnt && *lpnt) {
465 if (*rpnt == ';' && *lpnt != ';')
467 if (*rpnt != ';' && *lpnt == ';')
468 @@ -1092,16 +1235,32 @@
474 + ri = convert_to_unicode(rtmp, 2, rpnt, rinls);
475 + li = convert_to_unicode(ltmp, 2, lpnt, linls);
485 convert_to_unicode(rtmp, 2, rpnt, rinls);
486 convert_to_unicode(ltmp, 2, lpnt, linls);
489 if (a_to_u_2_byte(rtmp) < a_to_u_2_byte(ltmp))
491 if (a_to_u_2_byte(rtmp) > a_to_u_2_byte(ltmp))
501 diff -urN --exclude-from=- cdrtools-2.01/mkisofs/Makefile cdrtools-2.01-jh/mkisofs/Makefile
502 --- cdrtools-2.01/mkisofs/Makefile 2004-01-02 17:23:32.000000000 +0200
503 +++ cdrtools-2.01-jh/mkisofs/Makefile 2004-02-02 18:31:22.000000000 +0200
506 CPPOPTS += -DDVD_VIDEO
508 +CPPOPTS += -DUSE_ICONV
509 CPPOPTS += -I../libhfs_iso/
510 CPPOPTS += -DHAVE_CONFIG_H -DUSE_LIBSCHILY -DUSE_SCG \
511 '-DAPPID_DEFAULT="MKISOFS ISO 9660/HFS FILESYSTEM BUILDER & CDRECORD CD-R/DVD CREATOR (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING"' \
512 diff -urN --exclude-from=- cdrtools-2.01/mkisofs/mkisofs.c cdrtools-2.01-jh/mkisofs/mkisofs.c
513 --- cdrtools-2.01/mkisofs/mkisofs.c 2004-01-07 01:23:46.000000000 +0200
514 +++ cdrtools-2.01-jh/mkisofs/mkisofs.c 2004-02-02 18:31:22.000000000 +0200
517 #endif /* no_more_needed */
521 +#include <langinfo.h>
524 struct directory *root = NULL;
528 int do_sort = 0; /* sort file data */
535 struct nls_table *in_nls = NULL; /* input UNICODE conversion table */
536 struct nls_table *out_nls = NULL; /* output UNICODE conversion table */
538 @@ -2235,6 +2244,37 @@
539 init_nls_file(hfs_ocharset);
540 #endif /* APPLE_HYB */
543 + iconv_possible = !(iso9660_level >= 4 || ((ocharset &&
544 + strcmp(ocharset, icharset ? icharset : "")) &&
545 + use_RockRidge) || apple_ext || apple_hyb);
547 + setlocale(LC_CTYPE, "");
549 + if (icharset == NULL && iconv_possible) {
550 + char *charset = nl_langinfo(CODESET);
551 + /* set to detected value but only if it is not pure US-ASCII */
552 + if(strcmp(charset, "ANSI_X3.4-1968") != 0)
553 + icharset = charset;
555 + if(icharset && verbose > 0)
556 + fprintf(stderr, "INFO:\t"
557 + "%s character encoding detected by locale settings."
558 + "\n\tAssuming %s encoded filenames on source "
560 + "\tuse -input-charset to override.\n",
561 + icharset, icharset);
564 + if(iconv_possible) {
566 + * don't care if initialization fails
568 + init_nls_iconv(icharset);
569 + init_nls_iconv(ocharset);
573 if (icharset == NULL) {
574 #if (defined(__CYGWIN32__) || defined(__CYGWIN__)) && !defined(IS_CYGWIN_1)
575 in_nls = load_nls("cp437");
576 @@ -2262,6 +2302,12 @@
577 if (in_nls == NULL || out_nls == NULL) { /* Unknown charset specified */
578 fprintf(stderr, "Unknown charset\nKnown charsets are:\n");
579 list_nls(); /* List all known charset names */
581 + if(!iconv_possible)
582 + fprintf(stderr, "Iconv charsets cannot be used with "
583 + "Apple extension, HFS, ISO9660 version 2 or\n"
589 diff -urN --exclude-from=- cdrtools-2.01/mkisofs/mkisofs.h cdrtools-2.01-jh/mkisofs/mkisofs.h
590 --- cdrtools-2.01/mkisofs/mkisofs.h 2003-12-28 15:38:51.000000000 +0200
591 +++ cdrtools-2.01-jh/mkisofs/mkisofs.h 2004-02-02 18:31:22.000000000 +0200
597 +extern size_t convert_to_unicode __PR((unsigned char *buffer,
598 + int size, char *source, struct nls_table *inls));
600 extern void convert_to_unicode __PR((unsigned char *buffer,
601 int size, char *source, struct nls_table *inls));
602 -extern int joliet_strlen __PR((const char *string));
604 +extern int joliet_strlen __PR((const char *string, struct nls_table *inls));
606 extern unsigned char conv_charset __PR((unsigned char, struct nls_table *,
607 struct nls_table *));
608 diff -urN --exclude-from=- cdrtools-2.01/mkisofs/udf.c cdrtools-2.01-jh/mkisofs/udf.c
609 --- cdrtools-2.01/mkisofs/udf.c 2003-04-28 01:34:52.000000000 +0300
610 +++ cdrtools-2.01-jh/mkisofs/udf.c 2004-02-02 18:31:22.000000000 +0200
615 - expanded_length = joliet_strlen(src);
616 + expanded_length = joliet_strlen(src, in_nls);
617 if (expanded_length > 1024)
618 expanded_length = 1024;
619 if (expanded_length > (dst_size-1)*2)