View | Details | Raw Unified | Return to bug 4871
Collapse All | Expand All

(-)unzip-5.50.orig/unix/unix.c (+50 lines)
Lines 29-34 Link Here
29
#define UNZIP_INTERNAL
29
#define UNZIP_INTERNAL
30
#include "unzip.h"
30
#include "unzip.h"
31
31
32
#include <iconv.h>
33
#include <langinfo.h>
34
32
#ifdef SCO_XENIX
35
#ifdef SCO_XENIX
33
#  define SYSNDIR
36
#  define SYSNDIR
34
#else  /* SCO Unix, AIX, DNIX, TI SysV, Coherent 4.x, ... */
37
#else  /* SCO Unix, AIX, DNIX, TI SysV, Coherent 4.x, ... */
Lines 1524-1526 Link Here
1524
    }
1527
    }
1525
}
1528
}
1526
#endif /* QLZIP */
1529
#endif /* QLZIP */
1530
1531
1532
char OEM_CP[MAX_CP_NAME] = "CP850";
1533
char ISO_CP[MAX_CP_NAME] = "CP1252";
1534
1535
/* Convert a string from one encoding to the current locale using iconv().
1536
 * Be as non-intrusive as possible. If error is encountered during covertion
1537
 * just leave the string intact. */
1538
static void charset_to_intern(char *string, char *from_charset)
1539
{
1540
    iconv_t cd;
1541
    char *s, *d, *buf;
1542
    size_t slen, dlen, buflen;
1543
    const char *local_charset;
1544
1545
    buf = NULL;
1546
    local_charset = nl_langinfo(CODESET);
1547
1548
    if((cd = iconv_open(local_charset, from_charset)) == (iconv_t)-1)
1549
        return;
1550
1551
    slen = dlen = buflen = strlen(string);
1552
    s = string;
1553
    d = buf = malloc(buflen + 1);
1554
    if(!d)
1555
    	goto cleanup;
1556
1557
    if(iconv(cd, &s, &slen, &d, &dlen) == (size_t)-1)
1558
    	goto cleanup;
1559
    strncpy(string, buf, buflen);
1560
    
1561
    cleanup:
1562
    free(buf);
1563
    iconv_close(cd);
1564
}
1565
1566
/* Convert a string from OEM_CP to the current locale charset. */
1567
inline void oem_intern(char *string)
1568
{
1569
    charset_to_intern(string, OEM_CP);
1570
}
1571
1572
/* Convert a string from ISO_CP to the current locale charset. */
1573
inline void iso_intern(char *string)
1574
{
1575
    charset_to_intern(string, ISO_CP);
1576
}
(-)unzip-5.50.orig/unix/unxcfg.h (+22 lines)
Lines 123-126 Link Here
123
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
123
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
124
/*    and notfirstcall are used by do_wild().                          */
124
/*    and notfirstcall are used by do_wild().                          */
125
125
126
127
#define MAX_CP_NAME 25 
128
   
129
#ifdef SETLOCALE
130
#  undef SETLOCALE
131
#endif
132
#define SETLOCALE(category, locale) setlocale(category, locale)
133
#include <locale.h>
134
   
135
#ifdef _ISO_INTERN
136
#  undef _ISO_INTERN
137
#endif
138
#define _ISO_INTERN(str1) iso_intern(str1)
139
140
#ifdef _OEM_INTERN
141
#  undef _OEM_INTERN
142
#endif
143
#ifndef IZ_OEM2ISO_ARRAY
144
#  define IZ_OEM2ISO_ARRAY
145
#endif
146
#define _OEM_INTERN(str1) oem_intern(str1)
147
126
#endif /* !__unxcfg_h */
148
#endif /* !__unxcfg_h */
(-)unzip-5.50.orig/unzip.c (+85 lines)
Lines 304-314 Link Here
304
  -2  just filenames but allow -h/-t/-z  -l  long Unix \"ls -l\" format\n\
304
  -2  just filenames but allow -h/-t/-z  -l  long Unix \"ls -l\" format\n\
305
                                         -v  verbose, multi-page format\n";
305
                                         -v  verbose, multi-page format\n";
306
306
307
#ifndef UNIX
307
static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
308
static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
308
  -h  print header line       -t  print totals for listed files or for all\n\
309
  -h  print header line       -t  print totals for listed files or for all\n\
309
  -z  print zipfile comment  %c-T%c print file times in sortable decimal format\
310
  -z  print zipfile comment  %c-T%c print file times in sortable decimal format\
310
\n %c-C%c be case-insensitive   %s\
311
\n %c-C%c be case-insensitive   %s\
311
  -x  exclude filenames that follow from listing\n";
312
  -x  exclude filenames that follow from listing\n";
313
#else /* UNIX */
314
static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
315
  -h  print header line       -t  print totals for listed files or for all\n\
316
  -z  print zipfile comment  %c-T%c print file times in sortable decimal format\
317
\n %c-C%c be case-insensitive   %s\
318
  -x  exclude filenames that follow from listing\n\
319
  -O CHARSET  specify a character encoding for DOS, Windows and OS/2 archives\n\
320
  -I CHARSET  specify a character encoding for UNIX and other archives\n";
321
#endif /* !UNIX */
312
#ifdef MORE
322
#ifdef MORE
313
#ifdef VMS
323
#ifdef VMS
314
   static ZCONST char Far ZipInfoUsageLine4[] =
324
   static ZCONST char Far ZipInfoUsageLine4[] =
Lines 589-594 Link Here
589
#endif /* ?VM_CMS */
599
#endif /* ?VM_CMS */
590
#endif /* ?MACOS */
600
#endif /* ?MACOS */
591
601
602
#ifndef UNIX
592
static ZCONST char Far UnzipUsageLine4[] = "\
603
static ZCONST char Far UnzipUsageLine4[] = "\
593
modifiers:                                   -q  quiet mode (-qq => quieter)\n\
604
modifiers:                                   -q  quiet mode (-qq => quieter)\n\
594
  -n  never overwrite existing files         -a  auto-convert any text files\n\
605
  -n  never overwrite existing files         -a  auto-convert any text files\n\
Lines 596-601 Link Here
596
 -j  junk paths (do not make directories)   -v  be verbose/print version info\n\
607
 -j  junk paths (do not make directories)   -v  be verbose/print version info\n\
597
 %c-C%c match filenames case-insensitively    %c-L%c make (some) names \
608
 %c-C%c match filenames case-insensitively    %c-L%c make (some) names \
598
lowercase\n %-42s %c-V%c retain VMS version numbers\n%s";
609
lowercase\n %-42s %c-V%c retain VMS version numbers\n%s";
610
#else /* UNIX */
611
static ZCONST char Far UnzipUsageLine4[] = "\
612
modifiers:                                   -q  quiet mode (-qq => quieter)\n\
613
  -n  never overwrite existing files         -a  auto-convert any text files\n\
614
  -o  overwrite files WITHOUT prompting      -aa treat ALL files as text\n \
615
 -j  junk paths (do not make directories)   -v  be verbose/print version info\n\
616
 %c-C%c match filenames case-insensitively    %c-L%c make (some) names \
617
lowercase\n %-42s %c-V%c retain VMS version numbers\n%s\n\
618
  -O CHARSET  specify a character encoding for DOS, Windows and OS/2 archives\n\
619
  -I CHARSET  specify a character encoding for UNIX and other archives\n\n";
620
#endif /* !UNIX */
599
621
600
static ZCONST char Far UnzipUsageLine5[] = "\
622
static ZCONST char Far UnzipUsageLine5[] = "\
601
Examples (see unzip.txt for more info):\n\
623
Examples (see unzip.txt for more info):\n\
Lines 1070-1075 Link Here
1070
    argc = *pargc;
1092
    argc = *pargc;
1071
    argv = *pargv;
1093
    argv = *pargv;
1072
1094
1095
#ifdef UNIX
1096
    extern char OEM_CP[MAX_CP_NAME];
1097
    extern char ISO_CP[MAX_CP_NAME];
1098
#endif
1099
    
1073
    while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
1100
    while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
1074
        s = *argv + 1;
1101
        s = *argv + 1;
1075
        while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
1102
        while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
Lines 1233-1238 Link Here
1233
                    }
1260
                    }
1234
                    break;
1261
                    break;
1235
#endif  /* MACOS */
1262
#endif  /* MACOS */
1263
#ifdef UNIX
1264
    			case ('I'):
1265
                    if (negative) {
1266
                        Info(slide, 0x401, ((char *)slide,
1267
                          "error:  encodings can't be negated"));
1268
                        return(PK_PARAM);
1269
    				} else {
1270
    					if(*s) { /* Handle the -Icharset case */
1271
    						/* Assume that charsets can't start with a dash to spot arguments misuse */
1272
    						if(*s == '-') { 
1273
    	                        Info(slide, 0x401, ((char *)slide,
1274
        		                  "error:  a valid character encoding should follow the -I argument"));
1275
    	                        return(PK_PARAM); 
1276
    						}
1277
    						strncpy(ISO_CP, s, sizeof(ISO_CP));
1278
    					} else { /* -I charset */
1279
    						++argv;
1280
    						if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
1281
    	                        Info(slide, 0x401, ((char *)slide,
1282
        		                  "error:  a valid character encoding should follow the -I argument"));
1283
    	                        return(PK_PARAM); 
1284
    						}
1285
    						s = *argv;
1286
    						strncpy(ISO_CP, s, sizeof(ISO_CP));
1287
    					}
1288
    					while(*(++s)); /* No params straight after charset name */
1289
    				}
1290
    				break;
1291
#endif /* ?UNIX */
1236
                case ('j'):    /* junk pathnames/directory structure */
1292
                case ('j'):    /* junk pathnames/directory structure */
1237
                    if (negative)
1293
                    if (negative)
1238
                        uO.jflag = FALSE, negative = 0;
1294
                        uO.jflag = FALSE, negative = 0;
Lines 1299-1304 Link Here
1299
                    } else
1355
                    } else
1300
                        ++uO.overwrite_all;
1356
                        ++uO.overwrite_all;
1301
                    break;
1357
                    break;
1358
#ifdef UNIX
1359
    			case ('O'):
1360
                    if (negative) {
1361
                        Info(slide, 0x401, ((char *)slide,
1362
                          "error:  encodings can't be negated"));
1363
                        return(PK_PARAM);
1364
    				} else {
1365
    					if(*s) { /* Handle the -Ocharset case */
1366
    						/* Assume that charsets can't start with a dash to spot arguments misuse */
1367
    						if(*s == '-') { 
1368
    	                        Info(slide, 0x401, ((char *)slide,
1369
        		                  "error:  a valid character encoding should follow the -I argument"));
1370
    	                        return(PK_PARAM); 
1371
    						}
1372
    						strncpy(OEM_CP, s, sizeof(OEM_CP));
1373
    					} else { /* -O charset */
1374
    						++argv;
1375
    						if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
1376
    	                        Info(slide, 0x401, ((char *)slide,
1377
        		                  "error:  a valid character encoding should follow the -O argument"));
1378
    	                        return(PK_PARAM); 
1379
    						}
1380
    						s = *argv;
1381
    						strncpy(OEM_CP, s, sizeof(OEM_CP));
1382
    					}
1383
    					while(*(++s)); /* No params straight after charset name */
1384
    				}
1385
    				break;
1386
#endif /* ?UNIX */
1302
                case ('p'):    /* pipes:  extract to stdout, no messages */
1387
                case ('p'):    /* pipes:  extract to stdout, no messages */
1303
                    if (negative) {
1388
                    if (negative) {
1304
                        uO.cflag = FALSE;
1389
                        uO.cflag = FALSE;
(-)unzip-5.50.orig/unzpriv.h (-1 / +3 lines)
Lines 1103-1109 Link Here
1103
#  define lastchar(ptr, len) (ptr[(len)-1])
1103
#  define lastchar(ptr, len) (ptr[(len)-1])
1104
#  define MBSCHR(str, c) strchr(str, c)
1104
#  define MBSCHR(str, c) strchr(str, c)
1105
#  define MBSRCHR(str, c) strrchr(str, c)
1105
#  define MBSRCHR(str, c) strrchr(str, c)
1106
#  define SETLOCALE(category, locale)
1106
#  ifndef SETLOCALE
1107
#    define SETLOCALE(category, locale)
1108
#  endif
1107
#endif /* ?_MBCS */
1109
#endif /* ?_MBCS */
1108
#define INCSTR(ptr) PREINCSTR(ptr)
1110
#define INCSTR(ptr) PREINCSTR(ptr)
1109
1111
(-)unzip-5.50.orig/zipinfo.c (+62 lines)
Lines 440-445 Link Here
440
    int    tflag_slm=TRUE, tflag_2v=FALSE;
440
    int    tflag_slm=TRUE, tflag_2v=FALSE;
441
    int    explicit_h=FALSE, explicit_t=FALSE;
441
    int    explicit_h=FALSE, explicit_t=FALSE;
442
442
443
#ifdef UNIX
444
    extern char OEM_CP[MAX_CP_NAME];
445
    extern char ISO_CP[MAX_CP_NAME];
446
#endif
443
447
444
#ifdef MACOS
448
#ifdef MACOS
445
    uO.lflag = LFLAG;         /* reset default on each call */
449
    uO.lflag = LFLAG;         /* reset default on each call */
Lines 484-489 Link Here
484
                            uO.lflag = 0;
488
                            uO.lflag = 0;
485
                    }
489
                    }
486
                    break;
490
                    break;
491
#ifdef UNIX
492
    			case ('I'):
493
                    if (negative) {
494
                        Info(slide, 0x401, ((char *)slide,
495
                          "error:  encodings can't be negated"));
496
                        return(PK_PARAM);
497
    				} else {
498
    					if(*s) { /* Handle the -Icharset case */
499
    						/* Assume that charsets can't start with a dash to spot arguments misuse */
500
    						if(*s == '-') { 
501
    	                        Info(slide, 0x401, ((char *)slide,
502
        		                  "error:  a valid character encoding should follow the -I argument"));
503
    	                        return(PK_PARAM); 
504
    						}
505
    						strncpy(ISO_CP, s, sizeof(ISO_CP));
506
    					} else { /* -I charset */
507
    						++argv;
508
    						if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
509
    	                        Info(slide, 0x401, ((char *)slide,
510
        		                  "error:  a valid character encoding should follow the -I argument"));
511
    	                        return(PK_PARAM); 
512
    						}
513
    						s = *argv;
514
    						strncpy(ISO_CP, s, sizeof(ISO_CP));
515
    					}
516
    					while(*(++s)); /* No params straight after charset name */
517
    				}
518
    				break;
519
#endif /* ?UNIX */
487
                case 'l':      /* longer form of "ls -l" type listing */
520
                case 'l':      /* longer form of "ls -l" type listing */
488
                    if (negative)
521
                    if (negative)
489
                        uO.lflag = -2, negative = 0;
522
                        uO.lflag = -2, negative = 0;
Lines 504-509 Link Here
504
                        G.M_flag = TRUE;
537
                        G.M_flag = TRUE;
505
                    break;
538
                    break;
506
#endif
539
#endif
540
#ifdef UNIX
541
    			case ('O'):
542
                    if (negative) {
543
                        Info(slide, 0x401, ((char *)slide,
544
                          "error:  encodings can't be negated"));
545
                        return(PK_PARAM);
546
    				} else {
547
    					if(*s) { /* Handle the -Ocharset case */
548
    						/* Assume that charsets can't start with a dash to spot arguments misuse */
549
    						if(*s == '-') { 
550
    	                        Info(slide, 0x401, ((char *)slide,
551
        		                  "error:  a valid character encoding should follow the -I argument"));
552
    	                        return(PK_PARAM); 
553
    						}
554
    						strncpy(OEM_CP, s, sizeof(OEM_CP));
555
    					} else { /* -O charset */
556
    						++argv;
557
    						if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
558
    	                        Info(slide, 0x401, ((char *)slide,
559
        		                  "error:  a valid character encoding should follow the -O argument"));
560
    	                        return(PK_PARAM); 
561
    						}
562
    						s = *argv;
563
    						strncpy(OEM_CP, s, sizeof(OEM_CP));
564
    					}
565
    					while(*(++s)); /* No params straight after charset name */
566
    				}
567
    				break;
568
#endif /* ?UNIX */
507
                case 's':      /* default:  shorter "ls -l" type listing */
569
                case 's':      /* default:  shorter "ls -l" type listing */
508
                    if (negative)
570
                    if (negative)
509
                        uO.lflag = -2, negative = 0;
571
                        uO.lflag = -2, negative = 0;

Return to bug 4871