Borut Razem : ping: Sleep 1 second less.

Alexandre Julliard julliard at winehq.org
Wed Nov 24 11:28:41 CST 2010


Module: wine
Branch: master
Commit: 814bbc465bf54d7214f0c29261eb96e6f712ac3c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=814bbc465bf54d7214f0c29261eb96e6f712ac3c

Author: Borut Razem <borut.razem at siol.net>
Date:   Tue Nov 23 22:14:17 2010 +0100

ping: Sleep 1 second less.

---

 programs/ping/ping_main.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/programs/ping/ping_main.c b/programs/ping/ping_main.c
index 70db17f..037fa4d 100644
--- a/programs/ping/ping_main.c
+++ b/programs/ping/ping_main.c
@@ -18,6 +18,7 @@
  */
 
 #include <unistd.h>
+#include <stdio.h>
 #include <windows.h>
 
 #include "wine/debug.h"
@@ -26,15 +27,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(ping);
 
 static void usage(void)
 {
-    WINE_MESSAGE( "Usage: ping [-n count] [-w timeout] target_name\n\n" );
-    WINE_MESSAGE( "Options:\n" );
-    WINE_MESSAGE( "    -n  Number of echo requests to send.\n" );
-    WINE_MESSAGE( "    -w  Timeout in milliseconds to wait for each reply.\n" );
+    printf("Usage: ping [-n count] [-w timeout] target_name\n\n"
+           "Options:\n"
+           "    -n  Number of echo requests to send.\n"
+           "    -w  Timeout in milliseconds to wait for each reply.\n");
 }
 
 int main(int argc, char** argv)
 {
-    int n = 0;
+    unsigned int n = 0;
     int optc;
 
     WINE_FIXME( "this command currently just sleeps based on -n parameter\n" );
@@ -44,7 +45,12 @@ int main(int argc, char** argv)
         switch(optc)
         {
             case 'n':
-                n = atoi( optarg );
+                n = atoi(optarg);
+                if (n == 0)
+                {
+                  printf("Bad value for option -n, valid range is from 1 to 4294967295.\n");
+                  exit(1);
+                }
                 break;
             case '?':
                 usage();
@@ -56,6 +62,8 @@ int main(int argc, char** argv)
         }
     }
 
-    Sleep(n * 1000);
+    if (n != 0)
+      Sleep((n - 1) * 1000);
+
     return 0;
 }




More information about the wine-cvs mailing list