--- less-418/defines.wn	2007-11-06 11:45:58.000000000 +1000
+++ less418j/defines.h	2008-08-18 23:42:28.000000000 +1000
@@ -272,7 +272,7 @@
 #define HAVE_SYSTEM	1
 
 /* Define if you have the snprintf function.  */
-#define HAVE_SNPRINTF	0
+#define HAVE_SNPRINTF	1
 
 /* Define if you have the <ctype.h> header file.  */
 #define HAVE_CTYPE_H 1
@@ -287,7 +287,7 @@
 #define HAVE_FCNTL_H 1
 
 /* Define if you have the <limits.h> header file.  */
-#define HAVE_LIMITS_H 0
+#define HAVE_LIMITS_H 1
 
 /* Define if you have the <stdio.h> header file.  */
 #define HAVE_STDIO_H 1
@@ -329,5 +329,6 @@
 #define HAVE_VALUES_H 1
 #endif
 
-#define	popen	_popen
-#define	pclose	_pclose
+#define	popen		_popen
+#define	pclose		_pclose
+#define	snprintf	_snprintf
diff -up less-418/less.man less418j/less.man
--- less-418/less.man	2008-01-03 11:56:36.000000000 +1000
+++ less418j/less.man	2008-08-18 23:17:48.000000000 +1000
@@ -480,8 +480,8 @@ LESS(1)
               being set: n=normal, s=standout, d=bold, u=underlined,  k=blink.
               [4mcolor[24m  is  a  pair  of numbers separated by a period.  The first
               number selects the foreground color and the second  selects  the
-              background  color of the text.  A single number [4mN[24m is the same as
-              [4mN.0[24m.
+              background color of the text.  A single number [4mN[24m will select the
+              foreground color and use the normal background color.
 
        -e or --quit-at-eof
               Causes [4mless[24m to automatically exit the  second  time  it  reaches
diff -up less-418/less.nro less418j/less.nro
--- less-418/less.nro	2008-01-03 11:56:34.000000000 +1000
+++ less418j/less.nro	2008-08-16 20:52:32.000000000 +1000
@@ -498,7 +498,8 @@ being set: n=normal, s=standout, d=bold,
 \fIcolor\fP is a pair of numbers separated by a period.  
 The first number selects the foreground color and the second selects 
 the background color of the text.
-A single number \fIN\fP is the same as \fIN.0\fP.
+A single number \fIN\fP will select the foreground color and use the normal
+background color.
 .IP "\-e or \-\-quit-at-eof"
 Causes 
 .I less 
diff -up less-418/lsystem.c less418j/lsystem.c
--- less-418/lsystem.c	2007-12-11 02:35:54.000000000 +1000
+++ less418j/lsystem.c	2008-08-16 00:12:46.000000000 +1000
@@ -49,7 +49,7 @@ lsystem(cmd, donemsg)
 	register char *p;
 #endif
 	IFILE save_ifile;
-#if MSDOS_COMPILER
+#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
 	char cwd[FILENAME_MAX+1];
 #endif
 
@@ -68,6 +68,10 @@ lsystem(cmd, donemsg)
 	}
 
 #if MSDOS_COMPILER
+#if MSDOS_COMPILER==WIN32C
+	if (*cmd == '\0')
+		cmd = getenv("COMSPEC");
+#else
 	/*
 	 * Working directory is global on MSDOS.
 	 * The child might change the working directory, so we
@@ -77,6 +81,7 @@ lsystem(cmd, donemsg)
 	 */
 	getcwd(cwd, FILENAME_MAX);
 #endif
+#endif
 
 	/*
 	 * Close the current input file.
@@ -192,7 +197,7 @@ lsystem(cmd, donemsg)
 	init();
 	screen_trashed = 1;
 
-#if MSDOS_COMPILER
+#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
 	/*
 	 * Restore the previous directory (possibly
 	 * changed by the child program we just ran).
diff -up less-418/optfunc.c less418j/optfunc.c
--- less-418/optfunc.c	2007-12-11 02:35:54.000000000 +1000
+++ less418j/optfunc.c	2008-08-15 22:38:56.000000000 +1000
@@ -472,14 +472,14 @@ colordesc(s, fg_color, bg_color)
 		return;
 	}
 	if (*s != '.')
-		bg = 0;
+		bg = nm_bg_color;
 	else
 	{
 		s++;
 		bg = getnum(&s, "D", &err);
 		if (err)
 		{
-			error("Missing fg color in -D", NULL_PARG);
+			error("Missing bg color in -D", NULL_PARG);
 			return;
 		}
 	}
diff -up less-418/os.c less418j/os.c
--- less-418/os.c	2007-12-11 02:35:54.000000000 +1000
+++ less418j/os.c	2008-08-16 17:35:30.000000000 +1000
@@ -275,20 +275,40 @@ percent_pos(pos, percent, fraction)
 	int percent;
 	long fraction;
 {
-	/* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
-	long perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
-	POSITION temp;
-
-	if (perden == 0)
-		return (0);
-	temp = pos * perden;  /* This might overflow. */
-	if (temp / perden == pos)
-		/* No overflow */
-		return (temp / NUM_FRAC_DENOM);
-	else
-		/* Above calculation overflows; 
-		 * use a method that is less precise but won't overflow. */
-		return (perden * (pos / NUM_FRAC_DENOM));
+	long denom;
+	long f, g, h;
+	POSITION temp = 0;
+	POSITION ftemp = 0;
+
+	if (percent != 0)
+	{
+		/* Find the greatest common divisor and reduce the fraction. */
+		for (f = 100, g = percent; (h = f % g) != 0; f = g, g = h) ;
+		denom = 100 / g;
+		percent /= g;
+
+		temp = pos * percent; /* This might overflow. */
+		if (temp / percent == pos)
+			/* No overflow */
+			temp /= denom;
+		else
+			/* Above calculation overflows;
+			 * use a method that is less precise but won't overflow. */
+			temp = percent * (pos / denom);
+	}
+	if (fraction != 0)
+	{
+		for (f = NUM_FRAC_DENOM, g = fraction; (h = f % g) != 0; f = g, g = h) ;
+		denom = NUM_FRAC_DENOM / g;
+		fraction /= g;
+
+		ftemp = pos * fraction;
+		if (ftemp / fraction == pos)
+			ftemp /= denom;
+		else
+			ftemp = fraction * (pos / denom);
+	}
+	return (temp + ftemp / 100);
 }
 
 #if !HAVE_STRCHR
diff -up less-418/output.c less418j/output.c
--- less-418/output.c	2008-01-03 11:54:46.000000000 +1000
+++ less418j/output.c	2008-08-16 20:50:20.000000000 +1000
@@ -128,6 +128,7 @@ flush()
 			 */
 			char *anchor, *p, *p_next;
 			unsigned char fg, bg;
+			static unsigned char at;
 #if MSDOS_COMPILER==WIN32C
 			/* Screen colors used by 3x and 4x SGR commands. */
 			static unsigned char screen_color[] = {
@@ -216,35 +217,38 @@ flush()
 						switch (code)
 						{
 						default:
-						/* case 0:  all attrs off */
-						/* case 22: bold off */
-						/* case 23: italic off */
-						/* case 24: underline off */
-						/* case 27: inverse off */
+						/* case 0: all attrs off */
 							fg = nm_fg_color;
 							bg = nm_bg_color;
+							at = 0;
 							break;
 						case 1:	/* bold on */
-							fg = bo_fg_color;
-							bg = bo_bg_color;
+							at |= 1;
 							break;
 						case 3:	/* italic on */
 						case 7: /* inverse on */
-							fg = so_fg_color;
-							bg = so_bg_color;
+							at |= 2;
 							break;
 						case 4:	/* underline on */
-							fg = ul_fg_color;
-							bg = ul_bg_color;
+							at |= 4;
 							break;
 						case 5: /* slow blink on */
 						case 6: /* fast blink on */
-							fg = bl_fg_color;
-							bg = bl_bg_color;
+							at |= 8;
 							break;
 						case 8:	/* concealed on */
 							fg = (bg & 7) | 8;
 							break;
+						case 22: /* bold off */
+							at &= ~1;
+							break;
+						case 23: /* italic off */
+						case 27: /* inverse off */
+							at &= ~2;
+							break;
+						case 24: /* underline off */
+							at &= ~4;
+							break;
 						case 30: case 31: case 32:
 						case 33: case 34: case 35:
 						case 36: case 37:
@@ -266,6 +270,23 @@ flush()
 					}
 					if (!is_ansi_end(*p) || p == p_next)
 						break;
+					if (at & 1)
+					{
+							fg = bo_fg_color;
+							bg = bo_bg_color;
+					} else if (at & 2)
+					{
+							fg = so_fg_color;
+							bg = so_bg_color;
+					} else if (at & 4)
+					{
+							fg = ul_fg_color;
+							bg = ul_bg_color;
+					} else if (at & 8)
+					{
+							fg = bl_fg_color;
+							bg = bl_bg_color;
+					}
 					fg &= 0xf;
 					bg &= 0xf;
 					WIN32setcolors(fg, bg);
diff -up less-418/screen.c less418j/screen.c
--- less-418/screen.c	2008-01-01 10:50:44.000000000 +1000
+++ less418j/screen.c	2008-08-16 21:09:28.000000000 +1000
@@ -1787,7 +1787,7 @@ win32_scroll_up(n)
 
 	/* Move the source text to the top of the screen. */
 	new_org.X = rcSrc.Left;
-	new_org.Y = 0;
+	new_org.Y = rcClip.Top;
 
 	/* Fill the right character and attributes. */
 	fillchar.Char.AsciiChar = ' ';
@@ -2489,7 +2489,8 @@ WIN32textout(text, len)
 	int len;
 {
 #if MSDOS_COMPILER==WIN32C
-	WriteConsole(con_out, text, len, NULL, NULL);
+	DWORD out;
+	WriteConsole(con_out, text, len, &out, NULL);
 #else
 	char c = text[len];
 	text[len] = '\0';
