2013-12-20  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* watt/bin/djgpp.mak: -march=i386 -mtune=i586 added to CFLAGS to generate
	i386 compatible code.

	* watt/src/makefile.all: -march=i386 -mtune=i586 added to CFLAGS to generate
	i386 compatible code.
	-gcoff flag removed when building DXE module. 

	* watt/src/zlib/makefile.all: -march=i386 -mtune=i586 added to CFLAGS
	to generate i386 compatible code.


2013-12-13  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* watt/src/getnet.c (getnetent): Abort function returning a NULL pointer
	if networkFile is a NULL pointer.


2013-12-10  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* watt/src/cpumodel.s: Code removed according a suggestion of Mikulas Patocka.
	See: http://www.bttr-software.de/forum/board_entry.php?id=12993#p12993.

	* watt/src/get_ai.c: Code moved to the beginning of the function according
	a suggestion of Mikulas Patocka.
	See: http://www.bttr-software.de/forum/board_entry.php?id=12993#p12993





diff -aprNU5 watt.r1/src/cpumodel.s watt/src/cpumodel.s
--- watt.r1/src/cpumodel.s	2005-12-29 16:10:34 +0100
+++ watt/src/cpumodel.s	2013-12-10 20:29:24 +0100
@@ -200,14 +200,22 @@ is486x:
 n6x86:
     setCx86 ($0xC3, %cx)    /* Restore old CCR3 */
     sti
 
 ncyrix:
+#if 0
+    /*
+     *  Juan M. Guerrero: 2013-12-10
+     *  Code removed according to a suggestion of Mikulas Patocka
+     *  while porting Links to DOS using DJGPP.
+     *  See: http://www.bttr-software.de/forum/board_entry.php?id=12993#p12993
+     */
     popfl                   /* restore original EFLAGS */
     call check_x87
     popl %ebx
     jmp  end_CheckCpuType
+#endif
 
 is386:
     popfl                   /* restore original EFLAGS */
     call check_x87
 
diff -aprNU5 watt.r1/src/get_ai.c watt/src/get_ai.c
--- watt.r1/src/get_ai.c	2006-01-06 17:42:12 +0100
+++ watt/src/get_ai.c	2013-12-10 20:29:24 +0100
@@ -525,10 +525,23 @@ static int explore_fqdn (const struct ad
   struct hostent   *hp;
   struct addrinfo sentinel, *cur;
   int    error, af, i;
   char  *ap;
 
+#if 1
+  /*
+   *  Juan M. Guerrero: 2013-12-10
+   *  Code moved to the beginning of the function according
+   *  to a suggestion of Mikulas Patocka while porting Links
+   *  to DOS using DJGPP.
+   *  See: http://www.bttr-software.de/forum/board_entry.php?id=12993#p12993
+   */
+  struct hostent copy;
+  struct in6_addr addr [MAX_ADDRESSES+1];
+  char           *list [MAX_ADDRESSES+1];
+#endif
+
 #ifdef TEST_PROG
   SOCK_DEBUGF (("\nexplore_fqdn"));
 #endif
 
   error = 0;
@@ -587,13 +600,22 @@ static int explore_fqdn (const struct ad
   /* Perform a shallow copy of 'hp'. Since 'hp' is returned from
    * fill_hostent(), the contents will be destroyed in below
    * get_name() otherwise.
    */
   {
+#if 0
+    /*
+     *  Juan M. Guerrero: 2013-12-10
+     *  Code removed according to a suggestion of Mikulas Patocka
+     *  while porting Links to DOS using DJGPP.
+     *  Code moved to the beginning of the function.
+     *  See: http://www.bttr-software.de/forum/board_entry.php?id=12993#p12993
+     */
     struct hostent copy;
     struct in6_addr addr [MAX_ADDRESSES+1];
     char           *list [MAX_ADDRESSES+1];
+#endif
 
     copy = *hp;
     memset (&addr, 0, sizeof(addr));
     memset (&list, 0, sizeof(list));
     for (i = 0; hp->h_addr_list[i]; i++)
diff -aprNU5 watt.r1/src/getnet.c watt/src/getnet.c
--- watt.r1/src/getnet.c	2005-10-11 17:17:18 +0200
+++ watt/src/getnet.c	2013-12-12 14:18:56 +0100
@@ -177,11 +177,11 @@ struct netent * W32_CALL getnetent (void
   struct _netent n;
   char  *name, *net, *alias;
   char   buf [2*MAX_NAMELEN], *tok;
   int    i;
 
-  if (!netdb_init())
+  if (!netdb_init() || !networkFile)
      return (NULL);
 
   while (1)
   {
     if (!fgets(buf,sizeof(buf),networkFile))
diff -aprNU5 watt.r2/bin/djgpp.mak watt/bin/djgpp.mak
--- watt.r2/bin/djgpp.mak	2013-01-12 16:44:32 +0100
+++ watt/bin/djgpp.mak	2013-12-20 10:22:58 +0100
@@ -48,11 +48,11 @@ else
   WATTLIB = ../lib/libwatt.a
   EXTRAS  = tiny.c
 endif
 
 CC      = gcc
-CFLAGS += -Wall -W -g -O2 -I$(INC_DIR) #-s # strip symbols from .exe
+CFLAGS += -Wall -W -g -O2 -I$(INC_DIR) -march=i386 -mtune=i586 #-s # strip symbols from .exe
 
 ifeq ($(USE_EXCEPT),1)
   CFLAGS += -DUSE_EXCEPT
   EXTRAS += d:/prog/mw/except/lib/libexc.a
 endif
diff -aprNU5 watt.r2/src/makefile.all watt/src/makefile.all
--- watt.r2/src/makefile.all	2013-01-12 16:44:32 +0100
+++ watt/src/makefile.all	2013-12-20 10:55:10 +0100
@@ -149,11 +149,11 @@ PKT_STUB = pkt_stub.h
 
 @ifdef DJGPP
 
 CC     = gcc
 CFLAGS = -O2 -g -I. -I../inc -W -Wall -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-         -ffast-math #-ffunction-sections -fomit-frame-pointer
+         -ffast-math -march=i386 -mtune=i586 #-ffunction-sections -fomit-frame-pointer
 
 AS     = as --gdwarf2
 TARGET = ../lib/libwatt.a
 OBJDIR = djgpp
 
@@ -196,12 +196,12 @@ clean:
 @elifdef DJGPP_DXE
 #
 # Not working yet.
 #
 CC     = gcc
-CFLAGS = -O2 -g -gcoff -I. -I../inc -Id:/prog/mw/except \
-         -DWATT32_DOS_DLL -W -Wall -fno-strength-reduce -ffast-math
+CFLAGS = -O2 -g -I. -I../inc -Id:/prog/mw/except \
+         -DWATT32_DOS_DLL -W -Wall -fno-strength-reduce -ffast-math -march=i386 -mtune=i586
 
 WARNING = -Wbad-function-cast -Wcast-qual -Wmissing-declarations \
           -Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes \
           -Wwrite-strings -Wundef -Wcast-align -Wsign-compare
 
diff -aprNU5 watt.r2/src/zlib/makefile.all watt/src/zlib/makefile.all
--- watt.r2/src/zlib/makefile.all	2013-01-12 16:44:32 +0100
+++ watt/src/zlib/makefile.all	2013-12-20 10:55:16 +0100
@@ -41,11 +41,11 @@ OBJS = $(OBJDIR)\adler32.obj  $(OBJDIR)\
 ########################################################################
 
 @ifdef DJGPP
 
 CC     = gcc
-CFLAGS = -O2 -g -W -Wall -I../../inc
+CFLAGS = -O2 -g -W -Wall -I../../inc -march=i386 -mtune=i586
 OBJDIR = ../djgpp
 
 OBJS := $(subst \,/,$(OBJS))
 OBJS := $(OBJS:.obj=.o)
 
@@ -62,11 +62,11 @@ clean:
 ########################################################################
 
 @elifdef DJGPP_DXE
 
 CC     = gcc
-CFLAGS = -O2 -g -gcoff -I../../inc -D_DLL -W -Wall
+CFLAGS = -O2 -g -gcoff -I../../inc -D_DLL -W -Wall -march=i386 -mtune=i586
 OBJDIR = ../djgpp/dxe
 
 OBJS := $(subst \,/,$(OBJS))
 OBJS := $(OBJS:.obj=.o)
 
