Enlightenment CVS committal

Author  : titan
Project : e17
Module  : apps/ephoto

Dir     : e17/apps/ephoto/src/bin


Modified Files:
        ephoto.c 


Log Message:
Patch from Marcus Huwe to fix ephoto warnings with scanf.

===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ephoto.c    19 Apr 2007 03:17:11 -0000      1.5
+++ ephoto.c    20 May 2007 03:44:11 -0000      1.6
@@ -71,7 +71,12 @@
                        printf("Are you sure you want to create an album with "
                               "the name %s and the description %s? ", 
                               name, description);
-                       scanf("%c", &input);
+                       int ret = scanf("%c", &input);
+                       if(!ret || ret == EOF)
+                       {
+                               printf("read error\n");
+                               return 1;
+                       }
                        if(input == 'y' || input == 'Y')
                        {
                                db = ephoto_db_init();
@@ -112,7 +117,12 @@
                        printf("Are you sure you want to add an image "
                               "to album %s with a name %s and path %s? ", 
                               album, name, path);
-                       scanf("%c", &input);
+                       int ret = scanf("%c", &input);
+                       if(!ret || ret == EOF)
+                       {
+                               printf("read error\n");
+                               return 1;
+                       }
                        if(input == 'y' || input == 'Y')
                        {
                                db = ephoto_db_init();
@@ -145,7 +155,12 @@
                         printf("Are you sure you want to add images "
                                "from the directory %s to the album %s? ",
                                path, album);
-                        scanf("%c", &input);
+                        int ret = scanf("%c", &input);
+                                                               if(!ret || ret 
== EOF)
+                                                               {
+                                                                               
printf("read error\n");
+                                                                               
return 1;
+                                                               }
                         if(input == 'y' || input == 'Y')
                         {
                                db = ephoto_db_init();
@@ -211,7 +226,12 @@
 
                        printf("Are you sure you want to remove the album %s? 
", 
                               name);
-                       scanf("%c", &input);
+                       int ret = scanf("%c", &input);
+                       if(!ret || ret == EOF)
+                       {
+                               printf("read error\n");
+                               return 1;
+                       }
                        if(input == 'y' || input == 'Y')
                        {
                                db = ephoto_db_init();
@@ -245,7 +265,12 @@
                        printf("Are you sure you want to remove the image %s "
                               "from the album %s? ", 
                               path, album);
-                       scanf("%c", &input);
+                       int ret = scanf("%c", &input);
+                       if(!ret || ret == EOF)
+                       {
+                               printf("read error\n");
+                               return 1;
+                       }
                        if(input == 'y' || input == 'Y')
                        {
                                db = ephoto_db_init();



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to