From: arai Date: Mon, 2 Oct 2006 12:27:47 +0000 (+0000) Subject: applied the patch for the DJGPP. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7fdac2c5256bacbfc24e2e97caa47caecd03e3f1;p=lha%2Flha.git applied the patch for the DJGPP. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@846 6a8cc165-1e22-0410-a132-eb4e3f353aba --- diff --git a/ChangeLog b/ChangeLog index bb44917..85b1a51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-10-02 Koji Arai + * src/header.c, src/lha.h, src/lha_macro.h, src/lhadd.c, src/lharc.c, src/lhext.c, src/lhlist.c, src/vsnprintf.c, tests/lha-test.in, tests/lha-test11, tests/lha-test12: + applied the patch for the DJGPP. Thanks to Doug Kaufman. + * 00readme.autoconf, configure.ac: changed mail address. 2006-09-11 Koji Arai diff --git a/configure.ac b/configure.ac index 987070a..bcd887b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([LHa for UNIX], 1.14i-ac20060911, arai@users.sourceforge.jp, lha) +AC_INIT([LHa for UNIX], 1.14i-ac20061002, arai@users.sourceforge.jp, lha) AC_CANONICAL_HOST AC_CANONICAL_TARGET AM_INIT_AUTOMAKE diff --git a/src/header.c b/src/header.c index cf98fde..e919a35 100644 --- a/src/header.c +++ b/src/header.c @@ -719,7 +719,7 @@ get_header_level0(fp, hdr, data) hdr->name[i] = '\0'; /* defaults for other type */ - hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW; hdr->unix_gid = 0; hdr->unix_uid = 0; @@ -732,7 +732,7 @@ get_header_level0(fp, hdr, data) hdr->has_crc = FALSE; return TRUE; - } + } error("Unkonwn header (lha file?)"); exit(1); @@ -836,7 +836,7 @@ get_header_level1(fp, hdr, data) hdr->name[i] = '\0'; /* defaults for other type */ - hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW; hdr->unix_gid = 0; hdr->unix_uid = 0; @@ -919,7 +919,7 @@ get_header_level2(fp, hdr, data) hdr->header_level = get_byte(); /* defaults for other type */ - hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW; hdr->unix_gid = 0; hdr->unix_uid = 0; @@ -999,7 +999,7 @@ get_header_level3(fp, hdr, data) hdr->header_level = get_byte(); /* defaults for other type */ - hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW; hdr->unix_gid = 0; hdr->unix_uid = 0; @@ -1119,7 +1119,7 @@ get_header(fp, hdr) system_kanji_code, archive_delim, system_delim, filename_case); - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + if (S_ISLNK(hdr->unix_mode)) { char *p; /* split symbolic link */ p = strchr(hdr->name, '|'); @@ -1285,7 +1285,7 @@ init_header(name, v_stat, hdr) } } -#ifdef S_IFLNK +#if defined(S_IFLNK) && !defined(__DJGPP__) if (is_symlink(v_stat)) { memcpy(hdr->method, LZHDIRS_METHOD, METHOD_TYPE_STORAGE); hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; @@ -1600,7 +1600,7 @@ write_header(fp, hdr) archive_delim = "\\"; } - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + if (S_ISLNK(hdr->unix_mode)) { char *p; p = strchr(hdr->name, '|'); if (p) { diff --git a/src/lha.h b/src/lha.h index d8bc778..00b3a9c 100644 --- a/src/lha.h +++ b/src/lha.h @@ -154,6 +154,10 @@ int fnmatch(const char *pattern, const char *string, int flags); #include #endif +#ifdef __DJGPP__ +#include +#endif /* __DJGPP__ */ + #ifndef SEEK_SET #define SEEK_SET 0 #define SEEK_CUR 1 diff --git a/src/lha_macro.h b/src/lha_macro.h index abad3c0..a1a1611 100644 --- a/src/lha_macro.h +++ b/src/lha_macro.h @@ -171,6 +171,34 @@ #define LZHEADER_STORAGE 4096 +#ifndef S_IFREG +#define S_IFREG UNIX_FILE_REGULAR +#endif + +#ifndef S_IFDIR +#define S_IFDIR UNIX_FILE_DIRECTORY +#endif + +#ifndef S_IFLNK +#define S_IFLNK UNIX_FILE_SYMLINK +#endif + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & UNIX_FILE_TYPEMASK) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & UNIX_FILE_TYPEMASK) == S_IFDIR) +#endif + +#ifndef S_ISLNK +#ifdef __DJGPP__ +#define S_ISLNK(m) 0 +#else +#define S_ISLNK(m) (((m) & UNIX_FILE_TYPEMASK) == S_IFLNK) +#endif +#endif + /* ------------------------------------------------------------------------ */ /* FILE Attribute */ /* ------------------------------------------------------------------------ */ diff --git a/src/lhadd.c b/src/lhadd.c index 4eb3a21..6a8bd62 100644 --- a/src/lhadd.c +++ b/src/lhadd.c @@ -30,7 +30,7 @@ add_one(fp, nafp, hdr) header_pos = ftello(nafp); write_header(nafp, hdr);/* DUMMY */ - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + if (S_ISLNK(hdr->unix_mode)) { if (!quiet) printf("%s -> %s\t- Symbolic Link\n", hdr->name, hdr->realname); } @@ -192,11 +192,11 @@ find_update_files(oafp) init_sp(&sp); while (get_header(oafp, &hdr)) { - if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR) { + if (S_ISREG(hdr.unix_mode)) { if (stat(hdr.name, &stbuf) >= 0) /* exist ? */ add_sp(&sp, hdr.name, strlen(hdr.name) + 1); } - else if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY) { + else if (S_ISDIR(hdr.unix_mode)) { strcpy(name, hdr.name); /* ok */ len = strlen(name); if (len > 0 && name[len - 1] == '/') @@ -225,7 +225,7 @@ delete(oafp, nafp) if (need_file(ahdr.name)) { /* skip */ fseeko(oafp, ahdr.packed_size, SEEK_CUR); if (noexec || !quiet) { - if ((ahdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) + if (S_ISLNK(ahdr.unix_mode)) message("delete %s -> %s", ahdr.name, ahdr.realname); else message("delete %s", ahdr.name); @@ -317,8 +317,8 @@ temporary_to_new_archive_file(new_archive_size) if (!strcmp(new_archive_name, "-")) { nafp = stdout; - writing_filename = "starndard output"; -#if __MINGW32__ + writing_filename = "standard output"; +#if defined(__MINGW32__) || defined(__DJGPP__) setmode(fileno(stdout), O_BINARY); #endif } diff --git a/src/lharc.c b/src/lharc.c index 26dd504..4683a4e 100644 --- a/src/lharc.c +++ b/src/lharc.c @@ -120,7 +120,7 @@ static void print_tiny_usage() { #if HAVE_LIBAPPLEFILE - fprintf(stderr, "\ + fprintf(stdout, "\ usage: lha [-][] [- ...] archive_file [file...]\n\ commands: [axelvudmcpt]\n\ options: [q[012]vnfto[567]dizg012eb[w=|x=]]\n\ @@ -130,7 +130,7 @@ usage: lha [-][] [- ...] archive_file [file...]\n\ --help\n\ --version\n"); #else - fprintf(stderr, "\ + fprintf(stdout, "\ usage: lha [-][] [- ...] archive_file [file...]\n\ commands: [axelvudmcpt]\n\ options: [q[012]vnfto[567]dizg012e[w=|x=]]\n\ @@ -145,7 +145,7 @@ usage: lha [-][] [- ...] archive_file [file...]\n\ static void print_usage() { - fprintf(stderr, "\ + fprintf(stdout, "\ LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa\n\ LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki\n\ LHx(arc) for OSK V 2.01 Modified 1990 Momozou\n\ @@ -157,7 +157,7 @@ LHa for UNIX V 1.14i Modified 2000 Tsugio Okamoto\n\ print_tiny_usage(); - fprintf(stderr, "\ + fprintf(stdout, "\ commands: options:\n\ a Add(or replace) to archive q{num} quiet (num:quiet mode)\n\ x,e EXtract from archive v verbose\n\ @@ -165,16 +165,16 @@ commands: options:\n\ u Update newer files to archive f force (over write at extract)\n\ d Delete from archive t FILES are TEXT file\n"); #ifdef SUPPORT_LH7 - fprintf(stderr, "\ + fprintf(stdout, "\ m Move to archive (means 'ad') o[567] compression method (a/u/c)\n\ "); #endif #ifndef SUPPORT_LH7 - fprintf(stderr, "\ + fprintf(stdout, "\ m Move to archive (means 'ad') o use LHarc compatible method (a/u/c)\n\ "); #endif - fprintf(stderr, "\ + fprintf(stdout, "\ c re-Construct new archive d delete FILES after (a/u/c)\n\ p Print to STDOUT from archive i ignore directory path (x/e)\n\ t Test file CRC in archive z files not compress (a/u/c)\n\ @@ -183,21 +183,21 @@ commands: options:\n\ 0/1/2 header level (a/u/c)\n\ "); #ifdef EUC - fprintf(stderr, "\ + fprintf(stdout, "\ e TEXT code convert from/to EUC\n\ "); #endif #if HAVE_LIBAPPLEFILE - fprintf(stderr, "\ + fprintf(stdout, "\ b decode MacBinary (x/e)\n\ "); #endif - fprintf(stderr, "\ + fprintf(stdout, "\ w= specify extract directory (x/e)\n\ x= eXclude files (a/u/c)\n\ "); #if IGNORE_DOT_FILES /* experimental feature */ - fprintf(stderr, "\ + fprintf(stdout, "\ X ignore dot files (a/u/c)\n\ "); #endif @@ -1321,7 +1321,7 @@ open_old_archive() if (!strcmp(archive_name, "-")) { if (cmd == CMD_EXTRACT || cmd == CMD_LIST) { -#if __MINGW32__ +#if defined(__MINGW32__) || defined(__DJGPP__) setmode(fileno(stdin), O_BINARY); #endif return stdin; diff --git a/src/lhext.c b/src/lhext.c index 0b7743a..8100ffd 100644 --- a/src/lhext.c +++ b/src/lhext.c @@ -164,7 +164,7 @@ adjust_info(name, hdr) /* adjust file stamp */ utimebuf.actime = utimebuf.modtime = hdr->unix_last_modified_stamp; - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) + if (!(S_ISLNK(hdr->unix_mode))) utime(name, &utimebuf); if (hdr->extend_type == EXTEND_UNIX @@ -173,7 +173,7 @@ adjust_info(name, hdr) #ifdef NOT_COMPATIBLE_MODE Please need your modification in this space. #else - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) + if (!(S_ISLNK(hdr->unix_mode))) chmod(name, hdr->unix_mode); #endif if (!getuid()){ @@ -271,7 +271,7 @@ extract_one(afp, hdr) break; } - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR + if (S_ISREG(hdr->unix_mode) && method != LZHDIRS_METHOD_NUM) { extract_regular: #if 0 @@ -314,7 +314,7 @@ extract_one(afp, hdr) verbose = TRUE; } -#if __MINGW32__ +#if defined(__MINGW32__) || defined(__DJGPP__) { int old_mode; fflush(stdout); @@ -344,7 +344,7 @@ extract_one(afp, hdr) hdr->original_size, hdr->packed_size, name, method, &read_size); #endif /* HAVE_LIBAPPLEFILE */ -#if __MINGW32__ +#if defined(__MINGW32__) || defined(__DJGPP__) fflush(stdout); setmode(fileno(stdout), old_mode); } @@ -435,8 +435,8 @@ extract_one(afp, hdr) if (hdr->has_crc && crc != hdr->crc) error("CRC error: \"%s\"", name); } - else if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY - || (hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK + else if (S_ISDIR(hdr->unix_mode) + || S_ISLNK(hdr->unix_mode) || method == LZHDIRS_METHOD_NUM) { /* ¢¬¤³¤ì¤Ç¡¢Symbolic Link ¤Ï¡¢Âç¾æÉפ«¡© */ if (!ignore_directory && !verify_mode) { @@ -446,7 +446,7 @@ extract_one(afp, hdr) return read_size; } /* NAME has trailing SLASH '/', (^_^) */ - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) { + if (S_ISLNK(hdr->unix_mode)) { int l_code; #ifdef S_IFLNK @@ -482,7 +482,8 @@ extract_one(afp, hdr) name, hdr->realname); return read_size; #endif - } else { /* make directory */ + } + else { /* make directory */ if (!output_to_stdout && !make_parent_path(name)) return read_size; /* save directory information */ diff --git a/src/lhlist.c b/src/lhlist.c index e9b403b..a35b93c 100644 --- a/src/lhlist.c +++ b/src/lhlist.c @@ -125,7 +125,7 @@ list_one(hdr) char modebits[11]; if (verbose) { - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK) + if (S_ISLNK(hdr->unix_mode)) printf("%s\n", hdr->name); else printf("%s -> %s\n", hdr->name, hdr->realname); @@ -138,9 +138,9 @@ list_one(hdr) case EXTEND_UNIX: mode = hdr->unix_mode; - if (mode & UNIX_FILE_DIRECTORY) + if (S_ISDIR(mode)) modebits[0] = 'd'; - else if ((mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) + else if (S_ISLNK(mode)) modebits[0] = 'l'; else modebits[0] = '-'; @@ -259,7 +259,7 @@ list_one(hdr) print_stamp(hdr->unix_last_modified_stamp); if (!verbose) { - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK) + if (!(S_ISLNK(hdr->unix_mode))) printf(" %s", hdr->name); else { printf(" %s -> %s", hdr->name, hdr->realname); diff --git a/src/vsnprintf.c b/src/vsnprintf.c index b21261d..1530b28 100644 --- a/src/vsnprintf.c +++ b/src/vsnprintf.c @@ -198,7 +198,7 @@ typedef struct __sFILE { #endif -#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC) +#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC) || defined(__DJGPP__) #include #endif diff --git a/tests/lha-test.in b/tests/lha-test.in index 37b7376..1d67090 100644 --- a/tests/lha-test.in +++ b/tests/lha-test.in @@ -106,7 +106,8 @@ testsuite lha-test11 testsuite lha-test12 testsuite lha-test13 case `$lha --version 2>&1` in -*-pc-mingw*) +*djgpp* | *-pc-mingw*) + # No symlink support on DJGPP and MinGW message testing to handle symbolic links ... skip ;; *) diff --git a/tests/lha-test11 b/tests/lha-test11 index 9084af3..93c4ae0 100644 --- a/tests/lha-test11 +++ b/tests/lha-test11 @@ -10,7 +10,7 @@ message testing the long filename support # mkdir test-tmp1 case $(uname) in -CYGWIN*) +MS-DOS* | CYGWIN*) # 190 bytes file=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 ;; *) @@ -24,7 +24,7 @@ $lha cg test-tmp1-hg.lzh test-tmp1 2> test-stderr # on Cygwin/MinGW, skip this test. # the length of pathname does not amount to the limit of level 0 header. case $(uname) in -CYGWIN*) true ;; +MS-DOS* | CYGWIN*) true ;; *) test -s test-stderr ;; esac check $? $LINENO @@ -33,7 +33,7 @@ $lha c0 test-tmp1-h0.lzh test-tmp1 2> test-stderr # on Cygwin/MinGW, skip this test. # the length of pathname does not amount to the limit of level 0 header. case $(uname) in -CYGWIN*) true ;; +MS-DOS* | CYGWIN*) true ;; *) test -s test-stderr ;; esac check $? $LINENO diff --git a/tests/lha-test12 b/tests/lha-test12 index 75a7184..09dd2ee 100644 --- a/tests/lha-test12 +++ b/tests/lha-test12 @@ -1,33 +1,34 @@ # -*- shell-script -*- message testing the end of line conversion. -# NL to CR NL in archive -$lha ct test-tmp-crnl.lzh test-a test-b test-c +# LF to CR LF in archive +$lha ct test-tmp-crlf.lzh test-a test-b test-c check $? $LINENO # no convert -$lha xw=test-tmp-crnl test-tmp-crnl.lzh +$lha xw=test-tmp-crlf test-tmp-crlf.lzh check $? $LINENO -diff -r test-1 test-tmp-crnl +# use GNU diff option --binary for DJGPP. +diff -r --binary test-1 test-tmp-crlf test $? -ne 0 check $? $LINENO sed -e 's/$/ -/' < test-a | diff test-tmp-crnl/test-a - +/' < test-a | diff test-tmp-crlf/test-a - check $? $LINENO sed -e 's/$/ -/' < test-b | diff test-tmp-crnl/test-b - +/' < test-b | diff test-tmp-crlf/test-b - check $? $LINENO sed -e 's/$/ -/' < test-c | diff test-tmp-crnl/test-c - +/' < test-c | diff test-tmp-crlf/test-c - check $? $LINENO -# CR NL to NL -$lha xtw=test-tmp-nl test-tmp-crnl.lzh +# CR LF to LF +$lha xtw=test-tmp-nl test-tmp-crlf.lzh check $? $LINENO diff -r test-1 test-tmp-nl check $? $LINENO # no convert $lha c test-tmp-nl.lzh test-a test-b test-c check $? $LINENO -# CR NL to NL (cannot convert) +# CR LF to LF (cannot convert) $lha xtw=test-tmp-nl2 test-tmp-nl.lzh check $? $LINENO diff -r test-1 test-tmp-nl2