Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 605)
+++ /trunk/Config.kmk	(revision 606)
@@ -98,6 +98,7 @@
 TEMPLATE_BIN_LDFLAGS            = /SUBSYSTEM:console /INCREMENTAL:no /NOD /DEBUG
 TEMPLATE_BIN_LIBS               = \
+	$(PATH_TOOL_VCC70_LIB)/oldnames.lib \
 	$(PATH_TOOL_VCC70_LIB)/libcmt.lib \
-	$(PATH_TOOL_VCC70_LIB)/oldnames.lib
+	$(PATH_TOOL_VCC70_LIB)/libcpmt.lib
 TEMPLATE_BIN_LIBS.profile       = g:/coding/vbox/trunk/out/win32/debug/lib/kPrf2.lib
  ifdef NIX_INSTALL_DIR
Index: /trunk/src/sed/Makefile.kmk
===================================================================
--- /trunk/src/sed/Makefile.kmk	(revision 605)
+++ /trunk/src/sed/Makefile.kmk	(revision 606)
@@ -33,5 +33,9 @@
 	lib/regex.c
 ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
-kmk_SOURCES += 
+kmk_sed_SOURCES += \
+	lib/strverscmp.c \
+	lib/obstack.c \
+	lib/mkstemp.c \
+	lib/getline.c
 endif
 
Index: /trunk/src/sed/basicdefs.h
===================================================================
--- /trunk/src/sed/basicdefs.h	(revision 605)
+++ /trunk/src/sed/basicdefs.h	(revision 606)
@@ -60,5 +60,7 @@
 # define __bool_true_false_are_defined 1
 #else
-# include <stdbool.h>
+# if HAVE_STDBOOL_H
+#  include <stdbool.h>
+# endif
 #endif
 
Index: /trunk/src/sed/config.h.win
===================================================================
--- /trunk/src/sed/config.h.win	(revision 606)
+++ /trunk/src/sed/config.h.win	(revision 606)
@@ -0,0 +1,405 @@
+/* config.h.win  Maintaind by hand.  */
+/* config_h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define to 1 if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define to 1 if translation of program messages to the user's native
+   language is requested. */
+/* #undef ENABLE_NLS */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+/*#define HAVE_ALLOCA_H 1*/
+
+/* Define to 1 if you have the <argz.h> header file. */
+/*#define HAVE_ARGZ_H 1*/
+
+/* Define to 1 if you have the `bcopy' function. */
+/*#define HAVE_BCOPY 1*/
+
+/* Define to 1 if you have the `btowc' function. */
+#define HAVE_BTOWC 1
+
+/* Define to 1 if you have the `bzero' function. */
+/*#define HAVE_BZERO 1*/
+
+/* Define if the GNU dcgettext() function is already present or preinstalled.
+   */
+/* #undef HAVE_DCGETTEXT */
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+   */
+#define HAVE_DIRENT_H 1 /* unused */
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the `fchmod' function. */
+/*#define HAVE_FCHMOD 1*/
+
+/* Define to 1 if you have the `fchown' function. */
+/*#define HAVE_FCHOWN 1*/
+
+/* Define to 1 if you have the `feof_unlocked' function. */
+/*#define HAVE_FEOF_UNLOCKED 1*/
+
+/* Define to 1 if you have the `fgets_unlocked' function. */
+/*#define HAVE_FGETS_UNLOCKED 1*/
+
+/* Define to 1 if you have the `getcwd' function. */
+#define HAVE_GETCWD 1
+
+/* Define to 1 if you have the `getc_unlocked' function. */
+/*#define HAVE_GETC_UNLOCKED 1*/
+
+/* Define to 1 if you have the `getegid' function. */
+/*#define HAVE_GETEGID 1*/
+
+/* Define to 1 if you have the `geteuid' function. */
+/*#define HAVE_GETEUID 1*/
+
+/* Define to 1 if you have the `getgid' function. */
+/*#define HAVE_GETGID 1*/
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1 /* unused */
+
+/* Define if the GNU gettext() function is already present or preinstalled. */
+/* #undef HAVE_GETTEXT */
+
+/* Define to 1 if you have the `getuid' function. */
+#define HAVE_GETUID 1 /* unused (intl) */
+
+/* Define if you have the iconv() function. */
+#define HAVE_ICONV 1 /* unused (intl?) */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+/*#define HAVE_INTTYPES_H 1*/
+
+/* Define to 1 if you have the <io.h> header file. */
+/* #undef HAVE_IO_H */
+
+/* Define to 1 if you have the `isascii' function. */
+/*#define HAVE_ISASCII 1*/ /* don't think we've got this... */
+
+/* Define to 1 if you have the `isatty' function. */
+#define HAVE_ISATTY 1
+
+/* Define to 1 if you have the `isblank' function. */
+/*#define HAVE_ISBLANK 1*/ /* don't think we've got this... */
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+/*#define HAVE_LANGINFO_CODESET 1*/
+
+/* Define if your <locale.h> file defines LC_MESSAGES. */
+#define HAVE_LC_MESSAGES 1 /* ??? */
+
+/* Define to 1 if you have the `regex' library (-lregex). */
+/* #undef HAVE_LIBREGEX */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if you support file names longer than 14 characters. */
+#define HAVE_LONG_FILE_NAMES 1
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <mcheck.h> header file. */
+/*#define HAVE_MCHECK_H 1*/
+
+/* Define to 1 if you have the `memchr' function. */
+#define HAVE_MEMCHR 1
+
+/* Define to 1 if you have the `memcmp' function. */
+#define HAVE_MEMCMP 1
+
+/* Define to 1 if you have the `memcpy' function. */
+#define HAVE_MEMCPY 1
+
+/* Define to 1 if you have the `memmove' function. */
+#define HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mempcpy' function. */
+/*#define HAVE_MEMPCPY 1*/
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkstemp' function. */
+/*#define HAVE_MKSTEMP 1*/
+
+/* Define to 1 if you have a working `mmap' system call. */
+/*#define HAVE_MMAP 1*/
+
+/* Define to 1 if you have the `munmap' function. */
+/*#define HAVE_MUNMAP 1*/
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+/* #undef HAVE_NDIR_H */
+
+/* Define to 1 if you have the <nl_types.h> header file. */
+/*#define HAVE_NL_TYPES_H 1*/
+
+/* Define to 1 if libc includes obstacks. */
+/*#define HAVE_OBSTACK 1*/
+
+/* Define to 1 if you have the `pathconf' function. */
+#define HAVE_PATHCONF 1 /* ?? */
+
+/* Define to 1 if you have the `popen' function. */
+/*#define HAVE_POPEN 1*/  /** @todo popen */
+
+/* Define to 1 if you have the `putenv' function. */
+#define HAVE_PUTENV 1
+
+/* Define to 1 if you have the <regex.h> header file. */
+/* #undef HAVE_REGEX_H */
+
+/* Define to 1 if you have the `setenv' function. */
+/*#define HAVE_SETENV 1*/
+
+/* Define to 1 if you have the `setlocale' function. */
+#define HAVE_SETLOCALE 1
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define to 1 if stdbool.h conforms to C99. */
+/*#define HAVE_STDBOOL_H 1*/
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `stpcpy' function. */
+/*#define HAVE_STPCPY 1*/
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#define HAVE_STRCASECMP 1
+#define strcasecmp(__a,__b) stricmp((__a),(__b))
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+/*#define HAVE_STRINGS_H 1*/
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if you have the `strverscmp' function. */
+/*#define HAVE_STRVERSCMP 1*/
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+   */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+/*#define HAVE_SYS_FILE_H 1*/
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+   */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+/*#define HAVE_SYS_PARAM_H 1*/
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `tsearch' function. */
+#define HAVE_TSEARCH 1 /* ??? */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+/*#define HAVE_UNISTD_H 1*/
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the `wcrtomb' function. */
+#define HAVE_WCRTOMB 1
+
+/* Define to 1 if you have the `wcscoll' function. */
+#define HAVE_WCSCOLL 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if the system has the type `_Bool'. */
+/*#define HAVE__BOOL 1*/
+
+/* Define to 1 if you have the `__argz_count' function. */
+/*#define HAVE___ARGZ_COUNT 1*/
+
+/* Define to 1 if you have the `__argz_next' function. */
+/*#define HAVE___ARGZ_NEXT 1*/
+
+/* Define to 1 if you have the `__argz_stringify' function. */
+/*#define HAVE___ARGZ_STRINGIFY 1*/
+
+/* Define as const if the declaration of iconv() needs const. */
+/*#define ICONV_CONST */
+
+/* Name of package */
+#define PACKAGE "sed"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "bonzini@gnu.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "sed"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "sed 4.1.5"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "sed"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "4.1.5"
+
+/* Define to the version of GNU sed whose features are supported by this sed.
+   */
+#define SED_FEATURE_VERSION "4.1"
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "4.1.5"
+
+/* Define to 1 if on AIX 3.
+   System headers sometimes define this.
+   We just want to avoid a redefinition error message.  */
+#ifndef _ALL_SOURCE
+/* # undef _ALL_SOURCE */
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#define _FILE_OFFSET_BITS 64
+
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Include BSD functions in regex, used by the testsuite */
+#define _REGEX_RE_COMP 1
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to `int' if <sys/types.h> does not define. */
+#define ssize_t int /* does 14.0 have this? */
+
+/* Additional defines and includes to make it work with the microsoft compiler */
+#ifndef __config_h_included_already
+#define __config_h_included_already
+
+#define HAVE_FCNTL_H 1 /* no idea why this isn't in config.h.in... */
+
+#define VOID void
+#define inline _inline
+#include <io.h> /* isatty ++ */
+#include <sys/stat.h>
+#define S_ISDIR(m)  (((m) & _S_IFMT) == _S_IFDIR)
+#define S_ISREG(m)  (((m) & _S_IFMT) == _S_IFREG)
+#define S_ISLNK(m)  0
+#include <string.h> /* memory.h != string.h it seem even if the code assumes so. */
+
+/* stdbool.h replacement */
+  typedef char bool;
+#define false 0
+#define true 1
+
+/* mbsinit isn't defined?!? */
+#include <wchar.h> 
+int _inline mbsinit(const mbstate_t *_p)
+{
+    return (_p) == (const mbstate_t *)0 || *(_p) == 0;
+}
+
+/* mkstemp, getline */
+#endif
Index: /trunk/src/sed/lib/regcomp.c
===================================================================
--- /trunk/src/sed/lib/regcomp.c	(revision 605)
+++ /trunk/src/sed/lib/regcomp.c	(revision 606)
@@ -561,6 +561,10 @@
 static const bitset_t utf8_sb_map =
 {
-  /* Set the first 128 bits.  */
+    /* Set the first 128 bits.  */
+#ifdef _MSC_VER
+  BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, 0, 0, 0, 0
+#else
   [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
+#endif
 };
 #endif
Index: /trunk/src/sed/lib/regex_internal.h
===================================================================
--- /trunk/src/sed/lib/regex_internal.h	(revision 605)
+++ /trunk/src/sed/lib/regex_internal.h	(revision 606)
@@ -92,5 +92,7 @@
 #else
 # define BE(expr, val) (expr)
-# define inline
+# ifndef inline /* bird: silly since the rest of sed depends on this working.. */
+#  define inline
+# endif 
 #endif
 
@@ -413,5 +415,9 @@
 #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
 
-#include <alloca.h>
+#if HAVE_ALLOCA_H
+# include <alloca.h>
+#elif HAVE_MALLOC_H
+# include <malloc.h>
+#endif
 
 #ifndef _LIBC
Index: /trunk/src/sed/lib/regexec.c
===================================================================
--- /trunk/src/sed/lib/regexec.c	(revision 605)
+++ /trunk/src/sed/lib/regexec.c	(revision 606)
@@ -2899,5 +2899,9 @@
     }
 
+#ifdef __GNUC__ /* silly buggers. */
   str_idx = path->next_idx ?: top_str;
+#else
+  str_idx = path->next_idx ? path->next_idx : top_str;
+#endif 
 
   /* Temporary modify MCTX.  */
