Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /sys_ansi.c [3af83f] .. [15dc8a] Maximize Restore

  Switch to side-by-side view

--- a/sys_ansi.c
+++ b/sys_ansi.c
@@ -41,7 +41,7 @@
 
 // Error reporting
 
-void  PrintErrorIntern( char* fmt, va_list ap)
+void  PrintErrorIntern(char* fmt, va_list ap)
 {
 	char message[512];
 	char *toPrint;
@@ -61,7 +61,7 @@
 	}else
 #endif
   {
-          printf("%s",toPrint);
+	  printf("%s", toPrint);
 
 	  // Add an end of line if none is provide
 	  if (strlen(toPrint) > 0 &&
@@ -249,8 +249,12 @@
 
 
 	if( (prfile = fopen( prefname, "rb" )) != NULL ){
-		fread( &prf, sizeof(prf), 1 , prfile);
-		fclose( prfile );
+            int i;
+            i = fread( &prf, sizeof(prf), 1 , prfile);
+            if (i != sizeof(prf)) {
+                PrintError("Unable to write to preference file [%s]\n", prefname);
+            }
+            fclose( prfile );
 	}
 
 	switch( selector){
@@ -338,7 +342,9 @@
 int 	FindFile( fullPath *fname ){
 	printf("\n");
 	printf("Load File:\n");
-	scanf("%s", fname->name); 
+	if (scanf("%s", fname->name) != 1) {
+            return -1;
+        }
 	
 	if(strlen(fname->name) > 0)
 		return 0;
@@ -349,7 +355,9 @@
 int 	SaveFileAs			( fullPath *fname, char *prompt PT_UNUSED, char *name PT_UNUSED){
 	printf("\n");
 	printf("Save File As:\n");
-	scanf("%s", fname->name); 
+	if (scanf("%s", fname->name) != 1) {
+            return -1;
+        }
 	
 	if(strlen(fname->name) > 0)
 		return 0;
@@ -411,7 +419,9 @@
 		return -1;
 	}
 	sprintf(cmd, "%s %s", application, script );
-	system( cmd );
+	if (system( cmd ) == -1) {
+            PrintError("Unable to launch script");
+        }
 	free(cmd);
 	return 0;
 }