Phil Dibowitz wrote:
Stephen Warren wrote:
There is one cosmetic bug, in that print CTRL-H doesn't do a backspace on Windows, so the percentage progress messages looks like turd. I'll see if that's easy to fix...

Eh, what? That should never happen on windows:

#ifdef WIN32
        GetConsoleScreenBufferInfo(con, &sbi);
        SetConsoleCursorPosition(con, sbi.dwCursorPosition);
#else
        if (count != 0) {
                printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
        }
#endif

That code never gets executed if WIN32 is defined... something's very odd...

Yeah, I hadn't looked at the code, and was assuming that ^H wasn't working. In fact, it the issue was that the WIN32 code branch is a no-op.

Attached is a patch that:

concordance.c:
        Fix progress message formatting on WIN32 by actually adjusting
        the cursor position.

        Fix some trailing white-space.

        Localize a variable declaration to where it's used.

Note: This is another Windows/Cygwin-based patch, so if it fails to apply, maybe utod is required.
? concordance/win/Debug
? concordance/win/Release
? concordance/win/concordance.vcproj.ESK.Stephen Warren.user
? consnoop/win/consnoop.vcproj.ESK.Stephen Warren.user
? libconcord/win/Debug
? libconcord/win/Release
? libconcord/win/libconcord_libusb.vcproj.ESK.Stephen Warren.user
? libconcord/win/libconcord_winhid.vcproj.ESK.Stephen Warren.user
? win/concordance.ncb
? win/concordance.suo
Index: concordance/concordance.c
===================================================================
RCS file: /cvsroot/concordance/concordance/concordance/concordance.c,v
retrieving revision 1.24
diff -u -p -r1.24 concordance.c
--- concordance/concordance.c   11 Apr 2008 05:05:26 -0000      1.24
+++ concordance/concordance.c   11 Apr 2008 05:50:18 -0000
@@ -50,7 +50,6 @@ char* basename(char* file_name)
 }
 
 HANDLE con;
-CONSOLE_SCREEN_BUFFER_INFO sbi;
 
 #else
 /* NON-Windows */
@@ -106,13 +105,22 @@ void cb_print_percent_status(uint32_t co
 {
        int is_bytes;
 #ifdef WIN32
-       GetConsoleScreenBufferInfo(con, &sbi);
-       SetConsoleCursorPosition(con, sbi.dwCursorPosition);
-#else                   
+       CONSOLE_SCREEN_BUFFER_INFO sbi;
+#endif
+
        if (count != 0) {
+#ifdef WIN32
+               GetConsoleScreenBufferInfo(con, &sbi);
+               sbi.dwCursorPosition.X -= 14;
+               if (sbi.dwCursorPosition.X < 0) {
+                       sbi.dwCursorPosition.X = 0;
+               }
+               SetConsoleCursorPosition(con, sbi.dwCursorPosition);
+#else
                printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
+#endif
        }
-#endif          
+
        is_bytes = 0;
        if (arg) {
                is_bytes = (int)(arg);
@@ -123,7 +131,7 @@ void cb_print_percent_status(uint32_t co
        } else {
                printf("%3i%%          ", curr*100/total);
        }
-               fflush(stdout);
+       fflush(stdout);
 }
 
 /*
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to