Re: More problems with ncgen/ncdump

Hi,

It turns out that there is a bug in the new ncgen, that appears when trying
to generate the C code to define an attribute containing a printf-type
format string.  For example, a segmentation violation will likely occur when
invoking "ncgen -c" on the following simple CDL file:

    netcdf bug {
    dimensions:
            len = 80;
    variables:
            char x(len);
                    x:format="%s";
    }

This will be fixed in the next minor release, but if you encounter the bug
before then, you can apply the appended patch to ncgen/generate.c and
rebuild ncgen.

Thanks to Dr. Ata Etemadi, Imperial College, for finding the bug.
________________________________________________________________________
Russ Rew                                        Unidata Program Center
russ@xxxxxxxxxxxxxxxx                           UCAR, PO Box 3000
                                                Boulder, CO 80307-3000


==================================================================
diff -c1 -r1.28 generate.c
*** /tmp/RCSAa05027     Tue Jun 15 11:13:44 1993
--- generate.c  Tue Jun 15 11:12:09 1993
***************
*** 3,5 ****
   *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
!  *   $Header: /home/russ/src/netcdf/ncgen/RCS/generate.c,v 1.28 1993/06/10 
20:00:23 russ Exp $
   *********************************************************************/
--- 3,5 ----
   *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
!  *   $Header: /home/russ/src/netcdf/ncgen/RCS/generate.c,v 1.29 1993/06/15 
17:11:46 russ Exp $
   *********************************************************************/
***************
*** 79,81 ****
  
- #define fpr    (void) fprintf
  
--- 79,80 ----
***************
*** 90,93 ****
      
!     fpr(cout, stmnt);
!     fpr(cout, "\n");
  }
--- 89,92 ----
      
!     fputs(stmnt, cout);
!     fputs("\n", cout);
  }
***************
*** 366,369 ****
      if(stmnt[0] == '*') {
!       fpr(fout, stmnt);
!       fpr(fout,"\n");
        return;
--- 365,368 ----
      if(stmnt[0] == '*') {
!       fputs(stmnt, fout);
!       fputs("\n", fout);
        return;
***************
*** 374,377 ****
          derror("FORTRAN statement too long: %s",stmnt);
!       fpr(fout, "     %c", cont[line++]);
!       fpr(fout, "%.66s\n", stmnt);
        len -= 66;
--- 373,376 ----
          derror("FORTRAN statement too long: %s",stmnt);
!       (void) fprintf(fout, "     %c", cont[line++]);
!       (void) fprintf(fout, "%.66s\n", stmnt);
        len -= 66;