freebsd-ports/archivers/unrar-iconv/files/patch-iconv
Sunpoet Po-Chuan Hsieh 37694a56b1 - Update to unrar 5.01 (5.0.14)
- Use = instead of +=
- Use CONFLICTS_INSTALL instead off CONFLICTS

Submitted by:	sunpoet (myself)
Approved by:	maintainer (no object, 3 weeks)
2014-02-28 15:15:19 +00:00

171 lines
6.1 KiB
Text

--- cmddata.cpp.orig 2013-12-01 16:10:14.000000000 +0800
+++ cmddata.cpp 2014-02-04 09:29:52.919682515 +0800
@@ -179,6 +179,34 @@
// Suppress the copyright message and final end of line for 'lb' and 'vb'.
if ((CmdChar=='L' || CmdChar=='V') && Command[1]=='B')
BareOutput=true;
+#ifdef WITH_ICONV
+ if ( (encInt[0] != '\0') || (encExt[0] != '\0') ) {
+ char fullEncInt[ENC_MAXLEN + OPT_MAXLEN + 1];
+ char fullEncExt[ENC_MAXLEN + OPT_MAXLEN + 1];
+
+ strcpy(fullEncInt, encInt);
+ strcpy(fullEncExt, encExt);
+
+ if (encOpt[0] == '\0') strcpy(encOpt, OPT_DEFAULT);
+
+ if (encOpt[0] != '\0') {
+ strcat(fullEncInt, "//"); strcat(fullEncInt, encOpt);
+ strcat(fullEncExt, "//"); strcat(fullEncExt, encOpt);
+ }
+
+ h_E2I = iconv_open(fullEncInt, encExt);
+ h_I2E = iconv_open(fullEncExt, encInt);
+
+ if ( (h_E2I == (iconv_t)(-1)) || (h_I2E == (iconv_t)(-1)) ) {
+ if (h_E2I != (iconv_t)(-1)) iconv_close(h_E2I);
+ if (h_I2E != (iconv_t)(-1)) iconv_close(h_I2E);
+ mprintf(St(MIconvCannotOpen), encInt, encExt, encOpt);
+ }
+ } else {
+ h_E2I = (iconv_t)(-1);
+ h_I2E = (iconv_t)(-1);
+ }
+#endif
}
@@ -872,6 +900,22 @@
else
wcsncpyz(CommentFile,Switch+1,ASIZE(CommentFile));
break;
+#ifdef WITH_ICONV
+ case 'L':
+ switch(toupperw(Switch[1]))
+ {
+ case 'L':
+ strncpyz(encExt, (const char *)Switch+2, ASIZE(encExt));
+ break;
+ case 'A':
+ strncpyz(encInt, (const char *)Switch+2, ASIZE(encInt));
+ break;
+ case 'O':
+ strncpyz(encOpt, (const char *)Switch+2, ASIZE(encOpt));
+ break;
+ }
+ break;
+#endif
#ifndef GUI
case '?' :
OutHelp(RARX_SUCCESS);
@@ -950,7 +994,11 @@
MCHelpSwAT,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,MCHelpSwAI,MCHelpSwAP,
MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,
MCHelpSwDH,MCHelpSwEP,MCHelpSwEP3,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
- MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwN,MCHelpSwNa,MCHelpSwNal,
+ MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,
+#ifdef WITH_ICONV
+ MCHelpSwLA,MCHelpSwLL,MCHelpSwLO,
+#endif
+ MCHelpSwN,MCHelpSwNa,MCHelpSwNal,
MCHelpSwO,MCHelpSwOC,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,
MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,
--- global.hpp.orig 2013-12-01 16:10:14.000000000 +0800
+++ global.hpp 2014-02-04 15:14:20.104268441 +0800
@@ -9,6 +9,19 @@
EXTVAR ErrorHandler ErrHandler;
+#ifdef WITH_ICONV
+#define OPT_DEFAULT "IGNORE" /* ignore unrepresentable chars */
+
+#define ENC_MAXLEN 32 /* encoding name maximum length */
+#define OPT_MAXLEN 9 /* strlen("TRANSLIT") */
+
+EXTVAR iconv_t h_E2I; /* ExtToInt handler */
+EXTVAR iconv_t h_I2E; /* IntToExt handler */
+EXTVAR char encInt[ENC_MAXLEN]; /* internal (archive) encoding */
+EXTVAR char encExt[ENC_MAXLEN]; /* external (filesystem) encoding */
+EXTVAR char encOpt[OPT_MAXLEN]; /* encoding option (ignore/translit) */
+
+#endif
#endif
--- loclang.hpp.orig 2013-12-01 16:10:14.000000000 +0800
+++ loclang.hpp 2014-02-04 15:14:20.105262904 +0800
@@ -7,7 +7,7 @@
#define MCopyright "\nRAR %s Copyright (c) 1993-%d Alexander Roshal %d %s %d"
#define MRegTo "\nRegistered to %s\n"
#define MShare "\nTrial version Type RAR -? for help\n"
-#define MUCopyright "\nUNRAR %s freeware Copyright (c) 1993-%d Alexander Roshal\n"
+#define MUCopyright "\nUNRAR %s (iconv) freeware Copyright (c) 1993-%d Alexander Roshal\n"
#define MBeta "beta"
#define MMonthJan "Jan"
#define MMonthFeb "Feb"
@@ -332,7 +332,7 @@
#define MSyncScanError "\nFile search errors, cannot synchronize archive"
#define MCorrectingName "\nWARNING: Attempting to correct the invalid file name"
#define MUnpCannotMerge "\nWARNING: You need to start extraction from a previous volume to unpack %s"
-#define MUnknownOption "\nERROR: Unknown option: %s"
+#define MUnknownOption "\nERROR: Unknown option: %s\n"
#define MSubHeadCorrupt "\nERROR: Corrupt data header found, ignored"
#define MSubHeadUnknown "\nWARNING: Unknown data header format, ignored"
#define MSubHeadDataCRC "\nERROR: Corrupt %s data block"
@@ -360,6 +360,12 @@
#define MMaxPathLimit "\nTotal path and file name length must not exceed %d characters"
#define MRecVolLimit "\nTotal number of usual and recovery volumes must not exceed %d"
#define MVolumeNumber "volume %d"
+#ifdef WITH_ICONV
+#define MCHelpSwLA "\n la<encoding> Archive internal filenames encoding"
+#define MCHelpSwLL "\n ll<encoding> Your locale encoding"
+#define MCHelpSwLO "\n lo<option> Encoding option {ignore,translit,<empty>}"
+#define MIconvCannotOpen "\nCannot open iconv to convert between '%s' and '%s' with option '%s'"
+#endif
#define MCannotDelete "\nCannot delete %s"
#define MCalcCRC "\nCalculating the checksum"
#define MTooLargeSFXArc "\nWARNING: Too large SFX archive. Windows cannot run the executable file exceeding 4 GB."
--- os.hpp.orig 2013-12-01 16:10:14.000000000 +0800
+++ os.hpp 2014-02-04 15:16:02.730256100 +0800
@@ -151,6 +151,10 @@
#include <utime.h>
#include <locale.h>
+#ifdef WITH_ICONV
+#include <iconv.h>
+#endif
+
#ifdef S_IFLNK
#define SAVE_LINKS
#endif
--- strfn.cpp.orig 2013-12-01 16:10:14.000000000 +0800
+++ strfn.cpp 2014-02-04 09:35:08.461664945 +0800
@@ -14,6 +14,19 @@
void IntToExt(const char *Src,char *Dest,size_t DestSize)
{
+#ifdef WITH_ICONV
+ static size_t ret;
+ ret = (size_t)(-1);
+ if (h_I2E != (iconv_t)(-1)) {
+ static size_t inbytesleft, outbytesleft;
+ inbytesleft = strlen(Src)+1;
+ outbytesleft = NM;
+ ret = iconv(h_I2E, &Src, &inbytesleft, &Dest, &outbytesleft);
+ Dest[outbytesleft-inbytesleft]=NULL;
+ }
+ if (ret == (size_t)(-1))
+ strncpyz(Dest,Src,DestSize);
+#else /* !WITH_ICONV */
#ifdef _WIN_ALL
OemToCharBuffA(Src,Dest,(DWORD)DestSize);
Dest[DestSize-1]=0;
@@ -21,6 +34,7 @@
if (Dest!=Src)
strncpyz(Dest,Src,DestSize);
#endif
+#endif /* !WITH_ICONV */
}