Ticket #1735: unzip61_haiku.diff
File unzip61_haiku.diff, 7.4 KB (added by , 13 years ago) |
---|
-
beos/beocfg.h
diff -ur unzip610b/beos/beocfg.h Unzip_Haiku/beos/beocfg.h
old new 58 58 /* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */ 59 59 /* and notfirstcall are used by do_wild(). */ 60 60 61 #define USE_ICONV_MAPPING /* part of vanilla Haiku distribution */ 62 #ifdef USE_ICONV_MAPPING 63 # define MAX_CP_NAME 25 64 65 # ifdef SETLOCALE 66 # undef SETLOCALE 67 # endif 68 # define SETLOCALE(category, locale) setlocale(category, locale) 69 # include <locale.h> 70 71 # ifdef _ISO_INTERN 72 # undef _ISO_INTERN 73 # endif 74 # define _ISO_INTERN(str1) iso_intern(str1) 75 76 # ifdef _OEM_INTERN 77 # undef _OEM_INTERN 78 # endif 79 # ifndef IZ_OEM2ISO_ARRAY 80 # define IZ_OEM2ISO_ARRAY 81 # endif 82 # define _OEM_INTERN(str1) oem_intern(str1) 83 84 void iso_intern(char *); 85 void oem_intern(char *); 86 void init_conversion_charsets(void); 87 #endif /* USE_ICONV_MAPPING */ 88 61 89 #endif /* !__beocfg_h */ -
beos/beos.c
diff -ur unzip610b/beos/beos.c Unzip_Haiku/beos/beos.c
old new 34 34 #define UNZIP_INTERNAL 35 35 #include "unzip.h" 36 36 37 #ifdef USE_ICONV_MAPPING 38 #include <iconv.h> 39 #include <langinfo.h> 40 #endif /* USE_ICONV_MAPPING */ 41 37 42 #include "beos.h" 38 43 #include <errno.h> /* Just make sure we've got a few things... */ 39 44 #include <sys/types.h> … … 44 49 45 50 /* For the new post-DR8 file attributes */ 46 51 #include <kernel/fs_attr.h> 47 #include <support/ byteorder.h>52 #include <support/ByteOrder.h> 48 53 #include <storage/Mime.h> 49 54 50 55 static unsigned filtattr OF((__GPRO__ unsigned perms)); … … 1544 1549 retval = update_mime_info( fullname, FALSE, TRUE, TRUE ); 1545 1550 } 1546 1551 #endif 1552 1553 1554 #ifdef USE_ICONV_MAPPING 1555 typedef struct { 1556 char *local_charset; 1557 char *archive_charset; 1558 } CHARSET_MAP; 1559 1560 /* A mapping of local <-> archive charsets used by default to convert filenames 1561 * of DOS/Windows Zip archives. Currently very basic. */ 1562 static CHARSET_MAP dos_charset_map[] = { 1563 { "ANSI_X3.4-1968", "CP850" }, 1564 { "ISO-8859-1", "CP850" }, 1565 { "CP1252", "CP850" }, 1566 { "UTF-8", "CP866" }, 1567 { "KOI8-R", "CP866" }, 1568 { "KOI8-U", "CP866" }, 1569 { "ISO-8859-5", "CP866" } 1570 }; 1571 1572 char OEM_CP[MAX_CP_NAME] = ""; 1573 char ISO_CP[MAX_CP_NAME] = ""; 1574 1575 /* Try to guess the default value of OEM_CP based on the current locale. 1576 * ISO_CP is left alone for now. */ 1577 void init_conversion_charsets() 1578 { 1579 const char *local_charset; 1580 int i; 1581 1582 /* Make a guess only if OEM_CP not already set. */ 1583 if(*OEM_CP == '\0') { 1584 local_charset = nl_langinfo(CODESET); 1585 for(i = 0; i < sizeof(dos_charset_map)/sizeof(CHARSET_MAP); i++) 1586 if(!strcasecmp(local_charset, dos_charset_map[i].local_charset)) { 1587 strncpy(OEM_CP, dos_charset_map[i].archive_charset, 1588 sizeof(OEM_CP)); 1589 break; 1590 } 1591 } 1592 } 1593 1594 /* Convert a string from one encoding to the current locale using iconv(). 1595 * Be as non-intrusive as possible. If error is encountered during 1596 * convertion just leave the string intact. */ 1597 static void charset_to_intern(char *string, char *from_charset) 1598 { 1599 iconv_t cd; 1600 char *s,*d, *buf; 1601 size_t slen, dlen, buflen; 1602 const char *local_charset; 1603 1604 if (*from_charset == '\0') 1605 return; 1606 1607 buf = NULL; 1608 local_charset = nl_langinfo(CODESET); 1609 1610 if ((cd = iconv_open(local_charset, from_charset)) == (iconv_t)-1) 1611 return; 1612 1613 slen = strlen(string); 1614 s = string; 1615 dlen = buflen = 2 * slen; 1616 d = buf = malloc(buflen + 1); 1617 if (d) { 1618 bzero(buf, buflen); 1619 if(iconv(cd, &s, &slen, &d, &dlen) != (size_t)-1) 1620 strncpy(string, buf, buflen); 1621 free(buf); 1622 } 1623 iconv_close(cd); 1624 } 1625 1626 /* Convert a string from OEM_CP to the current locale charset. */ 1627 inline void oem_intern(char *string) 1628 { 1629 charset_to_intern(string, OEM_CP); 1630 } 1631 1632 /* Convert a string from ISO_CP to the current locale charset. */ 1633 inline void iso_intern(char *string) 1634 { 1635 charset_to_intern(string, ISO_CP); 1636 } 1637 #endif /* USE_ICONV_MAPPING */ -
beos/Makefile
diff -ur unzip610b/beos/Makefile Unzip_Haiku/beos/Makefile
old new 49 49 SHELL = /bin/sh 50 50 51 51 # Punish those of you not running on SMP hardware... 52 MAKE = make - j 4 -f beos/Makefile52 MAKE = make -f beos/Makefile 53 53 54 54 LOC=$(LOCAL_UNZIP) -DPASSWD_FROM_STDIN 55 55 AF=$(LOC) … … 82 82 LOBJS = $(OBJS) 83 83 OBJSDLL = $(OBJS) api$O 84 84 OBJX = unzipsfx$O crc32_$O crypt_$O extract_$O fileio_$O globals_$O \ 85 inflate_$O match_$O process_$O ttyio_$O ubz2err_$O $M_$O $(BEOS_MAIN)85 inflate_$O process_$O ttyio_$O ubz2err$O $M_$O match$O $(BEOS_MAIN) 86 86 LOBJX = $(OBJX) 87 87 OBJF = funzip$O crc32f$O cryptf$O globalsf$O inflatef$O ttyiof$O 88 88 UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H) … … 157 157 ifeq "$(WHAT)" "x86-gcc" 158 158 CC=gcc 159 159 LD=gcc 160 CF=-O3 -mpentiumpro \160 CF=-O3 -mpentiumpro -DUNIX \ 161 161 -Wall -Wno-multichar -Wno-trigraphs \ 162 - ansi -I. -I/boot/develop/headers/be/support \162 -I. -I/boot/develop/headers/be/support \ 163 163 -I/boot/develop/headers/be/storage $(LOC) 164 164 LF=-o unzip 165 LF2=-L/boot/develop/lib/x86 -lbe -lroot 165 LF2=-L/boot/develop/lib/x86 -lbe -lroot -liconv 166 166 BEOS_MAIN=beosmain$O 167 167 TARGET=$(UNZIPS) 168 168 endif … … 310 310 311 311 ubz2err$O: ubz2err.c $(UNZIP_H) 312 312 $(CP) ubz2err.c ubz2err_.c 313 $(CC) -c $(CF) -DSFX ubz2err_.c 313 $(CC) -c $(CF) -DSFX ubz2err_.c -o ubz2err$O 314 314 $(RM) ubz2err_.c 315 315 316 316 # funzip compilation section -
unzip.c
diff -ur unzip610b/unzip.c Unzip_Haiku/unzip.c
old new 836 836 837 837 838 838 #ifdef USE_ICONV_MAPPING 839 # ifdef UNIX 839 # ifdef UNIX 840 840 init_conversion_charsets(); 841 841 # endif 842 842 #endif /* USE_ICONV_MAPPING */ -
unzip.h
diff -ur unzip610b/unzip.h Unzip_Haiku/unzip.h
old new 500 500 * HP C V7.3-009 dislikes "defined" in macro in #if (%CC-I-EXPANDEDDEFINED). 501 501 * It seems safest to avoid any continuation lines in either. 502 502 */ 503 #if defined(__ATHEOS__) || defined(__BEOS__) || defined( MACOS)503 #if defined(__ATHEOS__) || defined(__BEOS__) || defined(__HAIKU__) || defined(MACOS) 504 504 # define J_FLAG 1 505 505 #else 506 506 # if defined( UNIX) && defined( __APPLE__) … … 547 547 int vflag; /* -v: (verbosely) list directory */ 548 548 int V_flag; /* -V: don't strip VMS version numbers */ 549 549 int W_flag; /* -W: wildcard '*' won't match '/' dir separator */ 550 #if (defined (__ATHEOS__) || defined(__BEOS__) || 550 #if (defined (__ATHEOS__) || defined(__BEOS__) ||defined(UNIX)) 551 551 int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ 552 552 #else 553 553 #if (defined(TANDEM) || defined(THEOS)) -
unzpriv.h
Binary files unzip610b/unzip.o and Unzip_Haiku/unzip.o differ Only in Unzip_Haiku/: unzipsfx Only in Unzip_Haiku/: unzipsfx.o diff -ur unzip610b/unzpriv.h Unzip_Haiku/unzpriv.h
old new 301 301 BeOS section: 302 302 ---------------------------------------------------------------------------*/ 303 303 304 #if def __BEOS__304 #if defined(__BEOS__) || defined(__HAIKU__) 305 305 # include "beos/beocfg.h" 306 306 #endif 307 307