[comp.sources.bugs] Perl 3.0 dumps core on write

win@wrkof.UUCP (Winfried Koenig) (09/13/89)

--------------
On my Interactive UNIX Rel. 2.0.2  Perl 3.0 dumps core
on the command:

write();	# no filehandle, write to stdout

With my patch for eval.c it seems to work.

The same code is also used for close(), but this
command	may be not valide without filehandle.

--------------
With Perl 2.0 the illegal command

write;		# illegal

had the same effect as

write();

but with Perl 3.0 the illegal version is no-op 
and no syntax error. Any help?

--------------
*** eval.c.dist	Wed Sep  6 02:36:05 1989
--- eval.c	Tue Sep 12 19:07:00 1989
***************
*** 409,415 ****
  	STABSET(str);
  	break;
      case O_WRITE:
! 	if (maxarg == 0)
  	    stab = defoutstab;
  	else if ((arg[1].arg_type & A_MASK) == A_WORD)
  	    stab = arg[1].arg_ptr.arg_stab;
--- 409,415 ----
  	STABSET(str);
  	break;
      case O_WRITE:
! 	if (maxarg == 1)
  	    stab = defoutstab;
  	else if ((arg[1].arg_type & A_MASK) == A_WORD)

--
Winfried Koenig			Phone:	+49 69 868707
Arendsstrasse 12		Smart:	win@incom.de
D-6050 Offenbach		Bang:	{unido,watzman}!wrkof!win
West-Germany

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (09/15/89)

In article <399@wrkof.UUCP> win@incom.de (Winfried Koenig) writes:
: --------------
: On my Interactive UNIX Rel. 2.0.2  Perl 3.0 dumps core
: on the command:
: 
: write();	# no filehandle, write to stdout
: 
: With my patch for eval.c it seems to work.
: ... 
: --------------
: *** eval.c.dist	Wed Sep  6 02:36:05 1989
: --- eval.c	Tue Sep 12 19:07:00 1989
: ***************
: *** 409,415 ****
:   	STABSET(str);
:   	break;
:       case O_WRITE:
: ! 	if (maxarg == 0)
:   	    stab = defoutstab;
:   	else if ((arg[1].arg_type & A_MASK) == A_WORD)
:   	    stab = arg[1].arg_ptr.arg_stab;
: --- 409,415 ----
:   	STABSET(str);
:   	break;
:       case O_WRITE:
: ! 	if (maxarg == 1)
:   	    stab = defoutstab;
:   	else if ((arg[1].arg_type & A_MASK) == A_WORD)
: 

A more correct patch would be:

*** eval.c.old	Wed Sep 13 13:20:22 1989
--- eval.c	Wed Sep 13 13:24:10 1989
***************
*** 415,422 ****
      case O_WRITE:
  	if (maxarg == 0)
  	    stab = defoutstab;
! 	else if ((arg[1].arg_type & A_MASK) == A_WORD)
! 	    stab = arg[1].arg_ptr.arg_stab;
  	else
  	    stab = stabent(str_get(st[1]),TRUE);
  	if (!stab_io(stab)) {
--- 415,424 ----
      case O_WRITE:
  	if (maxarg == 0)
  	    stab = defoutstab;
! 	else if ((arg[1].arg_type & A_MASK) == A_WORD) {
! 	    if (!(stab = arg[1].arg_ptr.arg_stab))
! 		stab = defoutstab;
! 	}
  	else
  	    stab = stabent(str_get(st[1]),TRUE);
  	if (!stab_io(stab)) {