commit: r278 - trunk/examples

[email protected]
Newsgroups gmane.network.spread.cvs
Message-ID <[email protected]>
Author: jonathan
Date: 2005-09-19 17:31:52 -0400 (Mon, 19 Sep 2005)
New Revision: 278

Modified:
   trunk/examples/fl_user.c
   trunk/examples/user.c
Log:
Apply fix (with small change) from Neil Conway for unnecessary char -> int cast. 


Modified: trunk/examples/fl_user.c
===================================================================
--- trunk/examples/fl_user.c	2005-09-19 21:26:32 UTC (rev 277)
+++ trunk/examples/fl_user.c	2005-09-19 21:31:52 UTC (rev 278)
@@ -176,8 +176,8 @@
 	  break;
 	}
       printf("enter message: ");
-      ret = (int) fgets( mess, 200, stdin );
-      if( ret==0 ) Bye();
+	  if (fgets(mess, 200, stdin) == NULL)
+		  Bye();
       mess_len = strlen( mess );
 
       printf("user.c : multicasting message of size %d:\n'%s'\n", mess_len, mess);
@@ -195,8 +195,8 @@
       ret = sscanf( &command[2], "%s", group );
       if( ret != 1 ) strcpy( group, "dummy_group_name" );
       printf("enter size of each message: ");
-      ret = (int) fgets( mess, 200, stdin );
-      if( ret==0 ) Bye();
+	  if (fgets(mess, 200, stdin) == NULL)
+		  Bye();
       ret = sscanf(mess, "%d", &mess_len );
       if( ret !=1 ) mess_len = Previous_len;
       if( mess_len < 0 ) mess_len = 0;

Modified: trunk/examples/user.c
===================================================================
--- trunk/examples/user.c	2005-09-19 21:26:32 UTC (rev 277)
+++ trunk/examples/user.c	2005-09-19 21:31:52 UTC (rev 278)
@@ -215,7 +215,8 @@
 	int	i;
 
 	for( i=0; i < sizeof(command); i++ ) command[i] = 0;
-	if( fgets( command, 130, stdin ) == 0 ) Bye();
+	if( fgets( command, 130, stdin ) == NULL ) 
+            Bye();
 
 	switch( command[0] )
 	{
@@ -253,8 +254,8 @@
 				break;
 			}
 			printf("enter message: ");
-			ret = (int) fgets( mess, 200, stdin );
-			if( ret==0 ) Bye();
+			if (fgets(mess, 200, stdin) == NULL)
+				Bye();
 			mess_len = strlen( mess );
 #ifdef _REENTRANT
 #ifdef __bsdi__		/* bsdi bug - doing a close when another thread blocks on the socket causes a seg fault */
@@ -280,8 +281,8 @@
 			ret=sscanf( &command[2], "%s", group );
 			if( ret != 1 ) strcpy( group, "dummy_group_name" );
 			printf("enter size of each message: ");
-			ret = (int) fgets( mess, 200, stdin );
-			if( ret==0 ) Bye();
+			if (fgets(mess, 200, stdin) == NULL)
+				Bye();
 			ret=sscanf(mess, "%u", &mess_len );
 			if( ret !=1 ) mess_len = Previous_len;
                         if( mess_len > MAX_MESSLEN ) mess_len = MAX_MESSLEN;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.