2015-01-08 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* doc/unrtf.1: Adjust documentation to DJGPP.

	* src/my_iconv.c: Include config.h to define EILSEQ.

	* src/output.c [__DJGPP__]: Include inttypes.h and stdint.h
	but do not include arpa/inet.h.

	* src/path.c: [__DJGPP__]: New function unixify_path.
	(search_in_path): Use IS_SLASH instead of checking for hardcoded slash.
	(check_dirs), [__DJGPP__]: Use function unixify_path to convert DOS
	style path into DJGPP specific style path.






diff -aprNU5 unrtf-0.21.9.orig/src/my_iconv.c unrtf-0.21.9/src/my_iconv.c
--- unrtf-0.21.9.orig/src/my_iconv.c	2014-12-20 08:41:34 +0100
+++ unrtf-0.21.9/src/my_iconv.c	2015-01-08 20:02:32 +0100
@@ -8,10 +8,12 @@
  * 04 Jan 10, daved@physiol.usyd.edu.au: use path specfied with -P to
  *	load charmap file(s)
  * 07 Oct 11, jf@dockes.org, major changes to unicode translations
  *--------------------------------------------------------------------*/
 
+#include <config.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
diff -aprNU5 unrtf-0.21.9.orig/src/output.c unrtf-0.21.9/src/output.c
--- unrtf-0.21.9.orig/src/output.c	2014-12-20 08:41:34 +0100
+++ unrtf-0.21.9/src/output.c	2015-01-08 20:02:32 +0100
@@ -56,11 +56,18 @@
 
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 
-#include <arpa/inet.h>
+#ifdef __DJGPP__
+#if  __DJGPP__ == 2 && __DJGPP_MINOR__ > 3
+#include <inttypes.h>
+#endif
+#include <stdint.h>     /* inttypes.h does not include this.  */
+#else
+#include <arpa/inet.h>  /* DJGPP does not provide this.  */
+#endif
 
 #include "malloc.h"
 #include "defs.h"
 #include "error.h"
 #include "output.h"
diff -aprNU5 unrtf-0.21.9.orig/src/path.c unrtf-0.21.9/src/path.c
--- unrtf-0.21.9.orig/src/path.c	2014-12-23 00:20:14 +0100
+++ unrtf-0.21.9/src/path.c	2015-01-08 19:46:04 +0100
@@ -10,10 +10,70 @@ char *search_path;
 int   path_checked;
 
 static int n_path_dirs;
 static struct path_dir topdir;
 
+#ifdef __DJGPP__
+/*
+ *  Changes the DOS syntax of paths to DJGPP syntax.
+ *  E.g.:  c:\foo/bar;z:/bar\foo  -->  /dev/c/foo/bar:dev/z/bar/foo
+ *  This works with DJGPP only.
+ */
+# define IS_SLASH(c)        ((c) == '/' || (c) == '\\')
+# define IS_ABSOLUTE(path)  ((path)[0] >= 'A' && (path)[0] <= 'z' && (path)[1] == ':' && IS_SLASH((path)[2]))
+
+char *orig_search_path;
+
+static void unixify_path(void)
+{
+  orig_search_path = search_path;;
+
+  if (search_path)
+  {
+    char *unixified_path = my_malloc(2 * FILENAME_MAX);
+
+    if (unixified_path)
+    {
+      char *path;
+      int i;
+
+      for (i = 0, path = search_path; *path; path++, i++)
+      {
+        if (*path == ';' || *path == ':')
+        {
+          unixified_path[i] = ':';
+          if (IS_ABSOLUTE(path + 1))
+          {
+            unixified_path[++i] = '/';
+            unixified_path[++i] = 'd';
+            unixified_path[++i] = 'e';
+            unixified_path[++i] = 'v';
+            unixified_path[++i] = '/';
+            unixified_path[++i] = *++path;  /* drive letter */
+            path++;  /* discard colon following drive letter */
+          }
+        }
+        else if (IS_SLASH(*path))
+          unixified_path[i] = '/';
+        else
+          unixified_path[i] = *path;
+      }
+      unixified_path[i] = '\0';
+
+      search_path = unixified_path;
+    }
+    else
+    {
+      fprintf(stderr, "Out of memory\n");
+      exit(1);
+    }
+  }
+}
+#else
+# define IS_SLASH(c)  ((c) == '/')
+#endif
+
 char *search_in_path(const char *name, char *suffix)
 {
     int maxplen = 0;
     int l;
     char *fullname = 0;
@@ -51,11 +111,11 @@ char *search_in_path(const char *name, c
     for (path_dir_p = &topdir; path_dir_p->dir_name; 
 	 path_dir_p = path_dir_p->next) {
 
 	strcpy(path, path_dir_p->dir_name);
 
-	if(path[strlen(path)-1] != '/')
+	if(!IS_SLASH(path[strlen(path)-1]))
 	    strcat(path, "/");
 	strcat(path, fullname);
 	/* fprintf(stderr, "Testing for [%s]\n", path); */
 	if(access(path, F_OK|R_OK))
 	    continue;
@@ -74,10 +134,13 @@ int check_dirs()
     char *dir_name;
     struct path_dir *path_dir_p = &topdir;
 
     /*fprintf(stderr, "check_dirs: search_path: [%s]\n", search_path);*/
 
+#ifdef __DJGPP__
+    unixify_path();
+#endif
     for (p = search_path; *p != '\0';) {
 	dir_name = p;
 	if((colon = strchr(p, ':')) != NULL) {
 	    p = colon;
 	    *p++ = '\0';
@@ -94,10 +157,13 @@ int check_dirs()
 	    }
 	path_dir_p = path_dir_p->next;
 	path_dir_p->dir_name = 0;
 	n_path_dirs++;
     }
+#ifdef __DJGPP__
+    search_path = orig_search_path;
+#endif
     path_checked = 1;
     return(n_path_dirs);
 }
 
 void show_dirs()
