Fix typo in license headers
[oweals/cde.git] / cde / programs / dtcreate / fileio.c
index 9ba48bea61b2af767dadf8ed41a85d82a10c0db0..ccb637511193696d2520a3271087dd5d6c2009b5 100644 (file)
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  * Floor, Boston, MA 02110-1301 USA
  */
@@ -412,6 +412,9 @@ ushort WriteDefinitionFile(char *pszFile, ActionData *pAD)
   char            *ptr;
   char            *msgPtr, *fmtPtr, *errPtr;
 
+  if (!pszFile)
+      return 1;
+
   /***************************************************************************/
   /* Open action and filetypes definition file for writing.                  */
   /***************************************************************************/
@@ -613,8 +616,11 @@ ushort WriteDefinitionFile(char *pszFile, ActionData *pAD)
     }
   }
   SetCookie(fp);
-  if (fp) fclose(fp);
+  if (fp)
+      fclose(fp);
+
   chmod(pszFile, 0644);
+
   return(0);
 }
 
@@ -655,7 +661,7 @@ ushort WriteActionFile(ActionData *pAD)
   /***************************************************************************/
   /* Open action file for writing.                                           */
   /***************************************************************************/
-  if (pszFile && (fp = fopen(pszFile, "w")) == NULL) {
+  if (pszFile == NULL || (fp = fopen(pszFile, "w")) == NULL) {
 #ifdef DEBUG
     printf("Can not open file.\n"); /* debug */
 #endif
@@ -694,7 +700,7 @@ ushort WriteActionFile(ActionData *pAD)
   fprintf(fp, "echo \"Common Desktop Environment Dt action\"\n");
   fprintf(fp, "\n");
 
-  if (fp) fclose(fp);
+  fclose(fp);
   chmod(pszFile, 0755);
   return(0);
 }
@@ -746,7 +752,7 @@ int OpenDefinitionFile(char *pszFile, ActionData *pAD)
 
 {
   FILE       *fp = (FILE *)NULL;
-  int        rc;
+  int        rc = 1;
   char       *msgPtr, *fmtPtr, *errPtr;
 
   /***************************************************************************/
@@ -789,10 +795,11 @@ int OpenDefinitionFile(char *pszFile, ActionData *pAD)
        sprintf(errPtr, fmtPtr, msgPtr, pszFile);
         display_error_message(CreateActionAppShell, errPtr);
        XtFree(errPtr);
+       fclose(fp);
         return(1);
      }
   }
-  if (fp) fclose(fp);
+  fclose(fp);
   return(rc);
 }