aboutsummaryrefslogtreecommitdiff
path: root/converters/chmview/files
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2007-03-05 12:15:12 +0000
committerRong-En Fan <rafan@FreeBSD.org>2007-03-05 12:15:12 +0000
commit2ab017c14b165861ff2af15e04c5062072959617 (patch)
tree57b6c677a404588865c4ee0a7237f2bf1263b33a /converters/chmview/files
parentb73b1c0f6480c0f0e789d656506380b49177394f (diff)
downloadports-2ab017c14b165861ff2af15e04c5062072959617.tar.gz
ports-2ab017c14b165861ff2af15e04c5062072959617.zip
- Update to 2.0 beta 3
- Use USE_DOS2UNIX instead our own wheel PR: ports/109393 Submitted by: Ivan Petrov <petrovdear at gmail.com>
Notes
Notes: svn path=/head/; revision=186575
Diffstat (limited to 'converters/chmview/files')
-rw-r--r--converters/chmview/files/Makefile15
-rw-r--r--converters/chmview/files/convert.sh20
-rw-r--r--converters/chmview/files/patch-aa185
-rw-r--r--converters/chmview/files/patch-ab95
4 files changed, 186 insertions, 129 deletions
diff --git a/converters/chmview/files/Makefile b/converters/chmview/files/Makefile
index 2512ed0131ed..7384cdcdef2e 100644
--- a/converters/chmview/files/Makefile
+++ b/converters/chmview/files/Makefile
@@ -5,18 +5,19 @@ OBJDIR = .
EXEDIR = .
EXENAME = $(EXEDIR)/chmview
-CFLAGS += -g
-LFLAGS += -g
+CFLAGS += -DUNIX
all: $(EXENAME)
OBJS = $(OBJDIR)/chmview.o \
- $(OBJDIR)/chmlib.o \
- $(OBJDIR)/lzx.o
+ $(OBJDIR)/chm_lib.o \
+ $(OBJDIR)/lzx.o \
+ $(OBJDIR)/utf8.o
-$(OBJDIR)/chmview.o: chmview.c chmlib.h
-$(OBJDIR)/chmlib.o: chmlib.c chmlib.h fixendian.h lzx.h
-$(OBJDIR)/lzx.o: lzx.c lzx.h lzx_int.h
+$(OBJDIR)/chmview.o: chmview.c chm_lib.h
+$(OBJDIR)/chm_lib.o: chm_lib.c chm_lib.h lzx.h
+$(OBJDIR)/utf8.o: utf8.c utf8.h
+$(OBJDIR)/lzx.o: lzx.c lzx.h
.c.o:
$(CC) $(CFLAGS) -c ${.IMPSRC}
diff --git a/converters/chmview/files/convert.sh b/converters/chmview/files/convert.sh
deleted file mode 100644
index d2a0192f09a2..000000000000
--- a/converters/chmview/files/convert.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-if [ X$1 = X ]
-then
- exit 0
-fi
-
-if ! cd $1
-then
- exit 1
-fi
-
-rm makefile
-
-for FILE in *
-do
- tr -d '\r' <${FILE} >${FILE}.NEW
- mv ${FILE}.NEW ${FILE}
-done
-
diff --git a/converters/chmview/files/patch-aa b/converters/chmview/files/patch-aa
index 2420b1ae8087..1992580c9b9d 100644
--- a/converters/chmview/files/patch-aa
+++ b/converters/chmview/files/patch-aa
@@ -1,9 +1,180 @@
-diff -r -u ../src/chmlib.h ./chmlib.h
---- ../src/chmlib.h Sun Dec 1 01:26:02 2002
-+++ ./chmlib.h Fri Mar 28 17:40:39 2003
-@@ -129,3 +129,5 @@
- chmfile *chm_openfile(char *fname);
+--- ../src/chmview.c
++++ chmview.c.new
+@@ -17,16 +17,30 @@
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
- void chm_close(chmfile *l);
++#ifndef UNIX
+ #include <windows.h>
++#endif
+
-+#define MODE 0755
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <limits.h>
++
++#ifdef UNIX
++#include <errno.h>
++#include <locale.h>
++#else
+ #include <dir.h>
++#endif
+
+ #include "chm_lib.h"
+ #include "utf8.h"
+
++#ifdef UNIX
++#define _strnicmp strncasecmp
++#define MODE 755
++#endif
++
+ struct cb_data
+ {
+ int extractwithoutpath;
+@@ -44,6 +58,7 @@
+ return p;
+ }
+
++#ifndef UNIX
+ int makedir(char *path)
+ {
+ char *end;
+@@ -75,6 +90,39 @@
+ }
+ return 1;
+ }
++#else
++static int makedir(char *path)
++{
++ char *slash;
++ int was_error, done, err;
++
++ slash = path;
++ done = 0;
++ was_error = 0;
++
++ do {
++ slash = index(slash + 1, '/');
++ if (slash)
++ {
++ *slash = 0;
++ if (mkdir(path, MODE) == -1 && EEXIST != errno)
++ was_error = 1;
++ *slash = '/';
++ }
++ else
++ done = 1;
++ } while (! done && ! was_error);
++
++ if (was_error)
++ {
++ perror("mkdir");
++ exit(1);
++ /* return 0; */
++ }
++
++ return 1;
++}
++#endif
+
+ const char ILLEGAL_SYMB[] = "<>:|?*\"";
+ const char ILLEGAL_REPL[] = "()_!__'";
+@@ -103,6 +151,9 @@
+ char fullpath[CHM_MAX_PATHLEN*2+1];
+ char target[CHM_MAX_PATHLEN*2+1];
+ wchar_t temp[CHM_MAX_PATHLEN+1];
++#ifdef UNIX
++ size_t pathlen;
++#endif
+
+ if (ui->length)
+ {
+@@ -116,13 +167,32 @@
+ return -1;
+ }
+ }
++#ifndef UNIX
+ GetCurrentDirectory(sizeof(fullpath)-1,fullpath);
+ while ((p = strstr(fullpath,"\\")) != NULL)
+ *p = '/';
+ if (fullpath[strlen(fullpath)-1] != '/')
+ strcat(fullpath,"/");
++#else
++ getcwd(fullpath, sizeof(fullpath)-1);
++ pathlen = strlen(fullpath);
++ if (pathlen == 0)
++ return -1; /* impossible but... defensive programming */
++ if (fullpath[pathlen - 1] != '/')
++ {
++ if (pathlen == PATH_MAX)
++ return -1;
++ else
++ fullpath[pathlen] = '/';
++ fullpath[pathlen+1] = 0;
++ }
++#endif
+ decode_UTF8(temp,ui->path);
++#ifndef UNIX
+ WideCharToMultiByte(CP_ACP,0,temp,-1,target,sizeof(target),NULL,NULL);
++#else
++ wcstombs(target, temp, sizeof(target));
++#endif
+ ReplaceIllegalChars(target);
+ strcat(fullpath,extractwithoutpath?pointtoname(target):(target[0]=='/'?target+1:target));
+ if (!extractwithoutpath)
+@@ -153,15 +223,19 @@
+ wchar_t temp[CHM_MAX_PATHLEN+1];
+
+ decode_UTF8(temp,ui->path);
++#ifndef UNIX
+ WideCharToMultiByte(CP_OEMCP,0,temp,-1,target,sizeof(target),NULL,NULL);
++#else
++ wcstombs(target, temp, sizeof(target));
++#endif
+ printf("Extracting %s ",target);
+ if (savetofile(c, ui, extractwithoutpath))
+ {
+ printf("Error\n");
+ error=1;
+ //return CHM_ENUMERATOR_FAILURE;
+- }
+- printf("OK\n");
++ } else
++ printf("OK\n");
+ }
+
+ int _extract_callback_all(struct chmFile *c, struct chmUnitInfo *ui, void *context)
+@@ -193,7 +267,11 @@
+ wchar_t temp[CHM_MAX_PATHLEN+1];
+
+ decode_UTF8(temp,ui->path);
++#ifndef UNIX
+ WideCharToMultiByte(CP_OEMCP,0,temp,-1,target,sizeof(target),NULL,NULL);
++#else
++ wcstombs(target, temp, sizeof(target));
++#endif
+
+ if ((target)[0] == '/')
+ {
+@@ -243,6 +321,9 @@
+
+ infname = argv[2];
+
++#ifdef UNIX
++ setlocale(LC_ALL,"");
++#endif
+ c = chm_open(infname);
+ if (!c)
+ exit(-1);
+@@ -305,7 +386,11 @@
+ strcat(target,name+1);
+ else
+ strcat(target,name);
++#ifndef UNIX
+ MultiByteToWideChar(CP_ACP,0,target,-1,temp,sizeof(temp));
++#else
++ mbstowcs(temp, target, sizeof(target));
++#endif
+ encode_UTF8(target,temp);
+ status = chm_resolve_object(c,target,&ui);
+ if (status==CHM_RESOLVE_SUCCESS && ui.path[strlen(ui.path)-1]!='/')
diff --git a/converters/chmview/files/patch-ab b/converters/chmview/files/patch-ab
deleted file mode 100644
index 8ea84981592b..000000000000
--- a/converters/chmview/files/patch-ab
+++ /dev/null
@@ -1,95 +0,0 @@
-diff -r -u ../src/chmview.c ./chmview.c
---- ../src/chmview.c Fri Mar 28 20:59:31 2003
-+++ ./chmview.c Fri Mar 28 19:01:39 2003
-@@ -3,9 +3,7 @@
- #include <limits.h>
- #include <errno.h>
- #include <string.h>
--#include <dir.h>
- #include "chmlib.h"
--#define PATH_MAX 512
-
- static char *pointtoname(char *path)
- {
-@@ -15,6 +13,7 @@
- return p;
- }
-
-+#if 0
- static int makedir(char *path)
- {
- char *end;
-@@ -47,6 +46,38 @@
- }
- return 1;
- }
-+#else
-+static int makedir(char *path)
-+{
-+ char *slash;
-+ int was_error, done, err;
-+
-+ slash = path;
-+ done = 0;
-+ was_error = 0;
-+
-+ do {
-+ slash = index(slash + 1, '/');
-+ if (slash)
-+ {
-+ *slash = 0;
-+ if (mkdir(path, MODE) == -1 && EEXIST != errno)
-+ was_error = 1;
-+ *slash = '/';
-+ }
-+ else
-+ done = 1;
-+ } while (! done && ! was_error);
-+
-+ if (was_error)
-+ {
-+ perror("mkdir");
-+ return 0;
-+ }
-+
-+ return 1;
-+}
-+#endif
-
- static int savetofile(chmfile *c, char *target, int extractwithoutpath)
- {
-@@ -55,18 +86,25 @@
- char *rtarget;
- char *p;
- FILE *f;
-- char path[PATH_MAX];
-- char fullpath[PATH_MAX];
-+ char fullpath[PATH_MAX + 1];
-+ size_t pathlen;
-
- if (chm_getfile(c, target, &length, &outbuf) != 0)
- return 1;
-- getcurdir(0,path);
-- fullpath[0]=getdisk()+'A'; fullpath[1]=':'; fullpath[2]='/'; fullpath[3]='\0';
-- strcat(fullpath,path);
-- while ((p = strstr(fullpath,"\\")) != NULL)
-- *p = '/';
-- if (fullpath[strlen(fullpath)-1] != '/')
-- strcat(fullpath,"/");
-+
-+ getcwd(fullpath,PATH_MAX-1);
-+ pathlen = strlen(fullpath);
-+ if (pathlen == 0)
-+ return -1; /* impossible but... defensive programming */
-+ if (fullpath[pathlen - 1] != '/')
-+ {
-+ if (pathlen == PATH_MAX)
-+ return -1;
-+ else
-+ fullpath[pathlen] = '/';
-+ fullpath[pathlen+1] = 0;
-+ }
-+
- strcat(fullpath,extractwithoutpath?pointtoname(target):target+1);
- if (!extractwithoutpath)
- if (!makedir(fullpath))