From b1dcae0da4f5e9713fd54678ec42709a1744474b Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@pobox.com>
Date: Sun, 17 Feb 2019 16:08:01 +0000
Subject: win32: fix POSIX build

There were a few places where changes intended for the WIN32 build
also affected the POSIX build.  Fix these so the result of 'make
defconfig; make' for busybox-w32 is identical to upstream BusyBox.
---
 coreutils/sum.c             |  2 +-
 debianutils/pipe_progress.c |  9 +++++----
 libbb/appletlib.c           |  8 ++++++++
 shell/ash.c                 | 14 ++++++++++++++
 4 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/coreutils/sum.c b/coreutils/sum.c
index dba8e8e76..a15d1932d 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -84,7 +84,7 @@ static unsigned sum_file(const char *file, unsigned type)
 		s = (r & 0xffff) + (r >> 16);
 		printf("%u %"LL_FMT"u %s\n", s, (total_bytes + 511) / 512, file);
 	} else
-		printf("%05u %5"OFF_FMT"u %s\n", s, (total_bytes + 1023) / 1024, file);
+		printf("%05u %5"LL_FMT"u %s\n", s, (total_bytes + 1023) / 1024, file);
 	return 1;
 #undef buf
 }
diff --git a/debianutils/pipe_progress.c b/debianutils/pipe_progress.c
index fd08a145e..28c4fd70e 100644
--- a/debianutils/pipe_progress.c
+++ b/debianutils/pipe_progress.c
@@ -16,10 +16,11 @@
 
 //kbuild:lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o
 
-//usage:#define pipe_progress_trivial_usage
-//usage:     ""
-//usage:#define pipe_progress_full_usage "\n\n"
-//usage:     "Display a dot to indicate pipe activity"
+//usage:#define pipe_progress_trivial_usage IF_PLATFORM_POSIX(NOUSAGE_STR)
+//usage:	IF_PLATFORM_MINGW32("")
+//usage:#define pipe_progress_full_usage IF_PLATFORM_POSIX("")
+//usage:	IF_PLATFORM_MINGW32("\n\n")
+//usage:	IF_PLATFORM_MINGW32("Display a dot to indicate pipe activity")
 
 #include "libbb.h"
 
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index be243de79..b7e5e3f1f 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -160,7 +160,11 @@ void FAST_FUNC bb_show_usage(void)
 			ap--;
 		}
 		full_write2_str(bb_banner);
+#if ENABLE_PLATFORM_MINGW32
 		full_write2_str(" multi-call binary\n");
+#else
+		full_write2_str(" multi-call binary.\n"); /* common string */
+#endif
 		if (*p == '\b')
 			full_write2_str("\nNo help available\n");
 		else {
@@ -869,7 +873,11 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
 
 		dup2(1, 2);
 		full_write2_str(bb_banner); /* reuse const string */
+#if ENABLE_PLATFORM_MINGW32
 		full_write2_str(" multi-call binary\n"); /* reuse */
+#else
+		full_write2_str(" multi-call binary.\n"); /* reuse */
+#endif
 #if defined(MINGW_VER)
 		if (sizeof(MINGW_VER) > 5) {
 			full_write2_str(MINGW_VER "\n\n");
diff --git a/shell/ash.c b/shell/ash.c
index 89bd886d3..d63304bdb 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -462,7 +462,9 @@ struct globals_misc {
 	int rootpid;            /* pid of main shell */
 	/* shell level: 0 for the main shell, 1 for its children, and so on */
 	int shlvl;
+#if ENABLE_PLATFORM_MINGW32
 	int loopnest;           /* current loop nesting level */
+#endif
 #define rootshell (!shlvl)
 	int errlinno;
 
@@ -472,7 +474,9 @@ struct globals_misc {
 	char *physdir; // = nullstr;    /* physical working directory */
 
 	char *arg0; /* value of $0 */
+#if ENABLE_PLATFORM_MINGW32
 	char *commandname;
+#endif
 
 	struct jmploc *exception_handler;
 
@@ -551,12 +555,16 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
 #define rootpid     (G_misc.rootpid    )
 #define shlvl       (G_misc.shlvl      )
 #define errlinno    (G_misc.errlinno   )
+#if ENABLE_PLATFORM_MINGW32
 #define loopnest    (G_misc.loopnest   )
+#endif
 #define minusc      (G_misc.minusc     )
 #define curdir      (G_misc.curdir     )
 #define physdir     (G_misc.physdir    )
 #define arg0        (G_misc.arg0       )
+#if ENABLE_PLATFORM_MINGW32
 #define commandname (G_misc.commandname)
+#endif
 #define exception_handler (G_misc.exception_handler)
 #define exception_type    (G_misc.exception_type   )
 #define suppress_int      (G_misc.suppress_int     )
@@ -1429,6 +1437,9 @@ struct parsefile {
 
 static struct parsefile basepf;        /* top level input file */
 static struct parsefile *g_parsefile = &basepf;  /* current input file */
+#if ENABLE_PLATFORM_POSIX
+static char *commandname;              /* currently executing command */
+#endif
 
 
 /* ============ Message printing */
@@ -9486,6 +9497,9 @@ defun(union node *func)
 #define SKIPFUNC       (1 << 2)
 static smallint evalskip;       /* set to SKIPxxx if we are skipping commands */
 static int skipcount;           /* number of levels to skip */
+#if ENABLE_PLATFORM_POSIX
+static int loopnest;            /* current loop nesting level */
+#endif
 static int funcline;            /* starting line number of current function, or 0 if not in a function */
 
 /* Forward decl way out to parsing code - dotrap needs it */
-- 
cgit v1.2.3-55-g6feb