Subject: Re: format bug in 1.57

From: Zheng Gengbing <[email-masked]>
Date: Thu, 13 Jun 1996 08:28:25 +0800 (EAT)

On Wed, 12 Jun 1996, Guansong Zhang wrote:

> Yes, I noticed that PKU's modification bring this bug back. But the last time I
> ask Zheng Gengbin about this, this was omitted.
> 
> Now Zheng Gengbin please see this change whether affects the work of hpfsc.
> 
> 
> On Jun 12,  7:10pm, Zheng Qiang wrote:
> > Subject: Re: format bug in 1.57
> > On Sun, 9 Jun 1996, Guansong Zhang wrote:
> >
> > > You can see this bug in a lots files in testsuite/example:
> > >
> > > in atmosphere.dep.src:
> > >
> > > 100         format (,' miles.')
> > > --------------------^
> > >
> > > The above are error messages given out when I try to compile the unparse
> result
> > > on DEC. Compare with their coresponding .f file, you will find out this
> bug. In
> > > fact, this bug maybe the only one prevent us from re-run the test set on
> F90
> > > features (now they are in testsuite/example). So please pay attention to
> them.
> > >
> >   This one was removed now, but I think you still need Zheng Gengbing's
> > admission because like what I've reported, this bug was really removed
> > before, but for some reason, Zheng Gengbing did some modification, I
> > think, Maybe the modification made by me this time will cause some other
> > problem which was solved by him.
> >
> >   Now the new f90.y is in the directory tozgs. Since the
> > hpfFrontEnd-1.57.tar.gz is not a proper one. The following is what I did
> > in case you want to test it on 1.57:
> >
> > the things before I modified:
> > -----------------------------------------
> > format_item_list
> >     :  format_item {
> >           char sp1[STR_LENGTH];
> >
> >           sp1[0]='\0';
> >           strcpy(sp1,$1);
> >           $$ = copys(sp1);               /* zheng.gb 1996.5.29 */
> >           }
> >     |  format_item_list COMMA format_item {
> >           char  sp1[STR_LENGTH];
> >
> >           if(debugFlag_g==1) printf("format_item :%s\n",$3);
> >           sp1[0]='\0';
> >           strcat(sp1,(char *)",");
> >           strcat(sp1,$3);
> >           $$=copys(sp1);
> > /*                                         zheng.gb   1996.5.4
> >           strcat($1,(char *)",");
> >           strcat($1,$3);
> >           strcpy($$,$1);
> > */
> >           }
> >     ;
> >
> > After I modified , it turn out to be:
> > --------------------------------
> > format_item_list
> >     :  format_item {
> >           char sp1[STR_LENGTH];
> >
> >           sp1[0]='\0';
> >           strcpy(sp1,$1);
> >           $$ = copys(sp1);               /* zheng.gb 1996.5.29 */
> >           }
> >     |  format_item_list COMMA format_item {
> > /*          char  sp1[STR_LENGTH];
> >
> >           if(debugFlag_g==1) printf("format_item :%s\n",$3);
> >           sp1[0]='\0';
> >           strcat(sp1,(char *)",");
> >           strcat(sp1,$3);
> >           $$=copys(sp1);
> > /*                                         zheng.gb   1996.5.4 */
> >           strcat($1,(char *)","); /* Zheng Qiang 96/06/11 */
> >           strcat($1,$3);
> >           strcpy($$,$1);
> >
> >           }
> >     ;
> >
> >-- End of excerpt from Zheng Qiang
> 

	No , your change is dangerous . Please notice that format_item_list
is type of pointer of character , strcpy to a pointer which maybe occupied
no space is very dangerous . In fact , this is why I do the 2 changes.
(2 copys() above ) This removed the bug of core dump in our machine . 

	But it is still my fault to forget the strcat the $1 which cause the
problem . I have changed that .
	
	This time , it looks like:

format_item_list
    :  format_item {
          char sp1[STR_LENGTH];

          sp1[0]='\0';
          strcpy(sp1,$1);
          $$ = copys(sp1);               /* zheng.gb 1996.5.29 */
          }
    |  format_item_list COMMA format_item {
          char  sp1[STR_LENGTH];

          if(debugFlag_g==1) printf("format_item :%s\n",$3);
          sp1[0]='\0';
>>>>>     strcat(sp1,$1); <<<<<<
          strcat(sp1,(char *)",");
          strcat(sp1,$3);
          $$=copys(sp1);
/*                                         zheng.gb   1996.5.4
          strcat($1,(char *)",");
          strcat($1,$3);
          strcpy($$,$1);
*/
          }

the statement in >>>> <<<<< is new to version of 1.57 .(before Zheng Qiang's
change)