-/* $Header: consarg.c,v 3.0.1.1 89/11/11 04:14:30 lwall Locked $
+/* $Header: consarg.c,v 3.0.1.4 90/03/12 16:24:40 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: consarg.c,v $
+ * Revision 3.0.1.4 90/03/12 16:24:40 lwall
+ * patch13: return (@array) did counter-intuitive things
+ *
+ * Revision 3.0.1.3 90/02/28 16:47:54 lwall
+ * patch9: the x operator is now up to 10 times faster
+ * patch9: @_ clobbered by ($foo,$bar) = split
+ *
+ * Revision 3.0.1.2 89/11/17 15:11:34 lwall
+ * patch5: defined $foo{'bar'} should not create element
+ *
* Revision 3.0.1.1 89/11/11 04:14:30 lwall
* patch2: '-' x 26 made warnings about undefined value
* patch2: eval with no args caused strangeness
break;
case O_REPEAT:
i = (int)str_gnum(s2);
+ tmps = str_get(s1);
str_nset(str,"",0);
- while (i-- > 0)
- str_scat(str,s1);
+ STR_GROW(str, i * s1->str_cur + 1);
+ repeatcpy(str->str_ptr, tmps, s1->str_cur, i);
+ str->str_cur = i * s1->str_cur;
+ str->str_ptr[str->str_cur] = '\0';
break;
case O_MULTIPLY:
value = str_gnum(s1);
}
}
else if (arg1->arg_type == O_AELEM || arg1->arg_type == O_LAELEM)
- arg1->arg_type = O_LAELEM;
+ if (arg->arg_type == O_DEFINED)
+ arg1->arg_type = O_AELEM;
+ else
+ arg1->arg_type = O_LAELEM;
else if (arg1->arg_type == O_ARRAY || arg1->arg_type == O_LARRAY) {
arg1->arg_type = O_LARRAY;
if (arg->arg_len > 1) {
arg2 = arg[2].arg_ptr.arg_arg;
if (arg2->arg_type == O_SPLIT) { /* use split's builtin =?*/
spat = arg2[2].arg_ptr.arg_spat;
- if (spat->spat_repl[1].arg_ptr.arg_stab == defstab &&
+ if (!(spat->spat_flags & SPAT_ONCE) &&
nothing_in_common(arg1,spat->spat_repl)) {
spat->spat_repl[1].arg_ptr.arg_stab =
arg1[1].arg_ptr.arg_stab;
+ spat->spat_flags |= SPAT_ONCE;
arg_free(arg1); /* recursive */
free_arg(arg); /* non-recursive */
return arg2; /* split has builtin assign */
arg[1].arg_flags |= AF_ARYOK;
}
else if (arg1->arg_type == O_HELEM || arg1->arg_type == O_LHELEM)
- arg1->arg_type = O_LHELEM;
+ if (arg->arg_type == O_DEFINED)
+ arg1->arg_type = O_HELEM; /* avoid creating one */
+ else
+ arg1->arg_type = O_LHELEM;
else if (arg1->arg_type == O_HASH || arg1->arg_type == O_LHASH) {
arg1->arg_type = O_LHASH;
if (arg->arg_len > 1) {
int optype;
ARG *arg;
{
- if (optype == O_PRTF ||
+ ARG *tmparg = arg;
+
+ if (optype == O_RETURN && arg->arg_type == O_ITEM &&
+ arg[1].arg_type == A_EXPR && (tmparg = arg[1].arg_ptr.arg_arg) &&
+ ((tmparg->arg_flags & AF_LISTISH) || (tmparg->arg_type == O_ARRAY) )) {
+ tmparg = listish(tmparg);
+ free_arg(arg);
+ arg = tmparg;
+ }
+ else if (optype == O_PRTF ||
(arg->arg_type == O_ASLICE || arg->arg_type == O_HSLICE ||
arg->arg_type == O_F_OR_R) )
arg = listish(arg);