[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: f_print.c



  User: cnieves 
  Date: 07/02/10 16:08:18

  Modified:    .        f_print.c
  Log:
  * src/f_print.c: Make f_print_header return an error return value
  
    if something goes wrong, and propagate it to the caller functions.
  
    Unlink the file created by f_print_file if there is an error in
  
    f_print_header.	
  
  
  
  
  Revision  Changes    Path
  1.27      +17 -8     eda/geda/gaf/libgeda/src/f_print.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: f_print.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/f_print.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- f_print.c	10 Feb 2007 17:41:44 -0000	1.26
  +++ f_print.c	10 Feb 2007 21:08:18 -0000	1.27
  @@ -91,7 +91,7 @@
    *  \param [in] fp            The postscript document to write to.
    *  \param [in] paper_size_x  The width of the document on paper in inches.
    *  \param [in] paper_size_y  The height of the document on paper in inches.
  - *  \return 1 on success, 0 on failure.
  + *  \return 0 on success, -1 on failure.
    */
   int f_print_header(TOPLEVEL *w_current, FILE *fp, 
   		   int paper_size_x, int paper_size_y) 
  @@ -140,7 +140,7 @@
     if(buf == NULL) {
       s_log_message("Unable to allocate %d bytes in f_print_header()\n"
   		  "Giving up on printing.\n",PROLOG_BUFFER_SIZE);
  -    return 0;
  +    return -1;
     }
     /* Open the prolog file */
     prolog = fopen(w_current->postscript_prolog,"r");
  @@ -149,7 +149,7 @@
   		  "in f_print_header()\n"
   		  "Giving up on printing\n", w_current->postscript_prolog);
       g_free(buf);  /* If we got to here, the buffer was allocated. */
  -    return 0;
  +    return -1;
     }
     /* Loop while reading file into buffer and dump it
      * back out to the supplied file handle
  @@ -165,7 +165,7 @@
   		  "in f_print_header()\n"
   		  "Giving up on printing\n", w_current->postscript_prolog);
       g_free(buf);  /* If we got to here, the buffer was allocated. */
  -    return 0;
  +    return -1;
     }
   
     if(ferror(fp)) {
  @@ -173,7 +173,7 @@
   		  "in f_print_header()\n"
   		  "Giving up on printing\n");
       g_free(buf);  /* If we got to here, the buffer was allocated. */
  -    return 0;
  +    return -1;
     }
     g_free(buf);  /* If we got to here, the buffer was allocated. */
   
  @@ -376,6 +376,11 @@
     }
   
     result = f_print_stream(w_current, fp);
  +  
  +  if (result != 0) {
  +    /* If there was an error in f_print_stream, then unlink the output file. */
  +    unlink(filename);
  +  }
     fclose (fp);
     return result;
   }
  @@ -502,9 +507,13 @@
   #endif  
   
     /* Output the header */
  -  f_print_header(w_current, fp, 
  +  if (f_print_header(w_current, fp, 
   		 w_current->paper_width, 
  -		 w_current->paper_height);
  +		     w_current->paper_height) != 0) {
  +
  +    /* There was an error in f_print_header */
  +    return -1;
  +  }
   
     /* Output font re-encoding */
     if (unicode_count) {
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs