~vcs-imports/gawk/master

« back to all changes in this revision

Viewing changes to interpret.h

Update README.solaris.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * interpret.h ---  run a list of instructions.
3
3
 */
4
4
 
5
 
/*
6
 
 * Copyright (C) 1986, 1988, 1989, 1991-2023,
7
 
 * the Free Software Foundation, Inc.
8
 
 *
 
5
/* 
 
6
 * Copyright (C) 1986, 1988, 1989, 1991-2013 the Free Software Foundation, Inc.
 
7
 * 
9
8
 * This file is part of GAWK, the GNU implementation of the
10
9
 * AWK Programming Language.
11
 
 *
 
10
 * 
12
11
 * GAWK is free software; you can redistribute it and/or modify
13
12
 * it under the terms of the GNU General Public License as published by
14
13
 * the Free Software Foundation; either version 3 of the License, or
15
14
 * (at your option) any later version.
16
 
 *
 
15
 * 
17
16
 * GAWK is distributed in the hope that it will be useful,
18
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
19
 * GNU General Public License for more details.
21
 
 *
 
20
 * 
22
21
 * You should have received a copy of the GNU General Public License
23
22
 * along with this program; if not, write to the Free Software
24
23
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
25
24
 */
26
25
 
27
 
/*
28
 
 * If "r" is a field, valref should normally be > 1, because the field is
29
 
 * created initially with valref 1, and valref should be bumped when it is
30
 
 * pushed onto the stack by Op_field_spec. On the other hand, if we are
31
 
 * assigning to $n, then Op_store_field calls unref(*lhs) before assigning
32
 
 * the new value, so that decrements valref. So if the RHS is a field with
33
 
 * valref 1, that effectively means that this is an assignment like "$n = $n",
34
 
 * so a no-op, other than triggering $0 reconstitution.
35
 
 */
36
 
 
37
 
// not a macro so we can step into it with a debugger
38
 
#ifndef UNFIELD_DEFINED
39
 
#define UNFIELD_DEFINED 1
40
 
static inline void
41
 
unfield(NODE **l, NODE **r)
42
 
{
43
 
        /* if was a field, turn it into a var */
44
 
        if (((*r)->flags & MALLOC) != 0 || (*r)->valref == 1) {
45
 
                (*l) = (*r);
46
 
        } else {
47
 
                (*l) = dupnode(*r);
48
 
                DEREF(*r);
49
 
        }
50
 
}
51
 
 
52
 
#define UNFIELD(l, r)   unfield(& (l), & (r))
53
 
#endif
54
26
 
55
27
int
56
28
r_interpret(INSTRUCTION *code)
67
39
        Regexp *rp;
68
40
        NODE *set_array = NULL; /* array with a post-assignment routine */
69
41
        NODE *set_idx = NULL;   /* the index of the array element */
70
 
        bool in_indirect_call = false;
71
42
 
72
43
 
73
44
/* array subscript */
101
72
                }
102
73
#endif
103
74
 
104
 
                op = pc->opcode;
105
 
                if (do_itrace) {
106
 
                        fprintf(stderr, "+ %s\n", opcode2str(op));
107
 
                        fflush(stderr);
108
 
                }
109
 
 
110
 
                switch (op) {
 
75
                switch ((op = pc->opcode)) {
111
76
                case Op_rule:
112
 
                        currule = pc->in_rule;   /* for use in Op_K_next, Op_K_nextfile, Op_K_getline */
113
 
                        // 8/2020: See node BEGINFILE/ENDFILE in the manual.  We clear the record
114
 
                        // since conceptually we are before reading a new record from the
115
 
                        // upcoming file but haven't read it yet.
116
 
                        if (currule == BEGINFILE)
117
 
                                set_record("", 0, NULL);
118
 
 
 
77
                        currule = pc->in_rule;   /* for sole use in Op_K_next, Op_K_nextfile, Op_K_getline */
119
78
                        /* fall through */
120
79
                case Op_func:
121
80
                        source = pc->source_file;
124
83
                case Op_atexit:
125
84
                {
126
85
                        bool stdio_problem = false;
127
 
                        bool got_EPIPE = false;
128
86
 
129
87
                        /* avoid false source indications */
130
88
                        source = NULL;
131
89
                        sourceline = 0;
132
 
                        (void) nextfile(& curfile, true);       /* close input data file */
 
90
                        (void) nextfile(& curfile, true);       /* close input data file */ 
133
91
                        /*
134
92
                         * This used to be:
135
93
                         *
140
98
                         * and pipes, in that it doesn't affect their exit status.
141
99
                         * So we no longer do either.
142
100
                         */
143
 
                        (void) close_io(& stdio_problem, & got_EPIPE);
 
101
                        (void) close_io(& stdio_problem);
144
102
                        /*
145
103
                         * However, we do want to exit non-zero if there was a problem
146
104
                         * with stdout/stderr, so we reinstate a slightly different
150
108
                                exit_val = 1;
151
109
 
152
110
                        close_extensions();
153
 
 
154
 
                        if (got_EPIPE)
155
 
                                die_via_sigpipe();
156
111
                }
157
112
                        break;
158
113
 
169
124
                                orig = m->stptr;
170
125
                                trans = dgettext(TEXTDOMAIN, orig);
171
126
                                m->stptr[m->stlen] = save;
172
 
                                if (trans != orig)      // got a translation
173
 
                                        m = make_string(trans, strlen(trans));
174
 
                                else
175
 
                                        UPREF(m);
 
127
                                m = make_string(trans, strlen(trans));
176
128
                        } else
177
129
                                UPREF(m);
178
130
                        PUSH(m);
180
132
 
181
133
                case Op_push:
182
134
                case Op_push_arg:
183
 
                case Op_push_arg_untyped:
184
135
                {
185
136
                        NODE *save_symbol;
186
137
                        bool isparam = false;
197
148
                                        m = m->orig_array;
198
149
                                }
199
150
                        }
200
 
 
 
151
                                
201
152
                        switch (m->type) {
202
153
                        case Node_var:
203
154
                                if (do_lint && var_uninitialized(m))
212
163
 
213
164
                        case Node_var_new:
214
165
uninitialized_scalar:
215
 
                                if (do_lint)
216
 
                                        lintwarn(isparam ?
217
 
                                                _("reference to uninitialized argument `%s'") :
218
 
                                                _("reference to uninitialized variable `%s'"),
219
 
                                                                save_symbol->vname);
220
 
 
221
 
                                if (op != Op_push_arg_untyped) {
222
 
                                        // convert very original untyped to scalar
223
 
                                        m->type = Node_var;
224
 
                                        m->var_value = dupnode(Nnull_string);
225
 
                                        m->flags &= ~(MPFN | MPZN);
226
 
 
227
 
                                        // set up local param by value
228
 
                                        m = dupnode(Nnull_string);
229
 
                                }
230
 
 
231
 
                                UPREF(m);
232
 
                                PUSH(m);
233
 
                                break;
234
 
 
235
 
                        case Node_elem_new:
236
 
                                if (do_lint)
237
 
                                        lintwarn(isparam ?
238
 
                                                _("reference to uninitialized argument `%s'") :
239
 
                                                _("reference to uninitialized variable `%s'"),
240
 
                                                                save_symbol->vname);
241
 
 
242
 
                                if (op != Op_push_arg_untyped) {
243
 
                                        // convert very original untyped to scalar
244
 
                                        m->type = Node_var;
245
 
                                        m->var_value = dupnode(Nnull_string);
246
 
                                        m->flags &= ~(MPFN | MPZN);
247
 
 
248
 
                                        // set up local param by value
249
 
                                        DEREF(m);
250
 
                                        m = dupnode(Nnull_string);
251
 
                                }
252
 
 
 
166
                                m->type = Node_var;
 
167
                                m->var_value = dupnode(Nnull_string);
 
168
                                if (do_lint)
 
169
                                        lintwarn(isparam ?
 
170
                                                _("reference to uninitialized argument `%s'") :
 
171
                                                _("reference to uninitialized variable `%s'"),
 
172
                                                                save_symbol->vname);
 
173
                                m = dupnode(Nnull_string);
253
174
                                PUSH(m);
254
175
                                break;
255
176
 
256
177
                        case Node_var_array:
257
 
                                if (op == Op_push_arg || op == Op_push_arg_untyped)
 
178
                                if (op == Op_push_arg)
258
179
                                        PUSH(m);
259
180
                                else
260
181
                                        fatal(_("attempt to use array `%s' in a scalar context"),
262
183
                                break;
263
184
 
264
185
                        default:
265
 
                                cant_happen("unexpected parameter type %s", nodetype2str(m->type));
 
186
                                cant_happen();
266
187
                        }
267
188
                }
268
 
                        break;
 
189
                        break;  
269
190
 
270
191
                case Op_push_param:             /* function argument */
271
192
                        m = pc->memory;
277
198
                                PUSH(m);
278
199
                                break;
279
200
                        }
280
 
                        /* fall through */
 
201
                        /* else
 
202
                                fall through */
281
203
                case Op_push_array:
282
204
                        PUSH(pc->memory);
283
205
                        break;
289
211
 
290
212
                case Op_subscript:
291
213
                        t2 = mk_sub(pc->sub_count);
292
 
                        t1 = POP_ARRAY(false);
 
214
                        t1 = POP_ARRAY();
293
215
 
294
 
                        if (in_array(t1, t2) == NULL) {
 
216
                        if (do_lint && in_array(t1, t2) == NULL) {
295
217
                                t2 = force_string(t2);
296
 
 
297
 
                                if (t1 == func_table) {
298
 
                                        fatal(_("reference to uninitialized element `%s[\"%.*s\"] is not allowed'"),
299
 
                                                "FUNCTAB", (int) t2->stlen, t2->stptr);
300
 
                                } else if (t1 == symbol_table) {
301
 
                                        fatal(_("reference to uninitialized element `%s[\"%.*s\"] is not allowed'"),
302
 
                                                "SYMTAB", (int) t2->stlen, t2->stptr);
303
 
                                } else if (do_lint) {
304
 
                                        lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"),
305
 
                                                array_vname(t1), (int) t2->stlen, t2->stptr);
306
 
                                        if (t2->stlen == 0)
307
 
                                                lintwarn(_("subscript of array `%s' is null string"), array_vname(t1));
308
 
                                }
 
218
                                lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"),
 
219
                                        array_vname(t1), (int) t2->stlen, t2->stptr);
 
220
                                if (t2->stlen == 0)
 
221
                                        lintwarn(_("subscript of array `%s' is null string"), array_vname(t1));
309
222
                        }
310
223
 
311
 
                        // continue the regular processing
312
 
 
313
224
                        /* for FUNCTAB, get the name as the element value */
314
225
                        if (t1 == func_table) {
315
226
                                static bool warned = false;
316
 
 
317
 
                                if (do_lint_extensions && ! warned) {
 
227
                                
 
228
                                if (do_lint && ! warned) {
318
229
                                        warned = true;
319
230
                                        lintwarn(_("FUNCTAB is a gawk extension"));
320
231
                                }
331
242
                        /* for SYMTAB, step through to the actual variable */
332
243
                        if (t1 == symbol_table) {
333
244
                                static bool warned = false;
334
 
 
335
 
                                if (do_lint_extensions && ! warned) {
 
245
                                
 
246
                                if (do_lint && ! warned) {
336
247
                                        warned = true;
337
248
                                        lintwarn(_("SYMTAB is a gawk extension"));
338
249
                                }
339
250
                                if (r->type == Node_var)
340
251
                                        r = r->var_value;
341
 
                                else if (r->type == Node_var_new) {
342
 
                                        // variable may exist but have never been set.
343
 
                                        r->var_value = dupnode(Nnull_string);
344
 
                                        r = r->var_value;
345
 
                                }
346
252
                        }
347
253
 
348
 
                        if (r->type == Node_val
349
 
                            || r->type == Node_var
350
 
                            || r->type == Node_elem_new)
 
254
                        if (r->type == Node_val)
351
255
                                UPREF(r);
352
256
                        PUSH(r);
353
257
                        break;
354
258
 
355
259
                case Op_sub_array:
356
260
                        t2 = mk_sub(pc->sub_count);
357
 
                        t1 = POP_ARRAY(false);
 
261
                        t1 = POP_ARRAY();
358
262
                        r = in_array(t1, t2);
359
 
 
360
 
                        if (r == NULL) {
361
 
                                t2 = force_string(t2);
362
 
 
363
 
                                if (t1 == func_table) {
364
 
                                        fatal(_("reference to uninitialized element `%s[\"%.*s\"] is not allowed'"),
365
 
                                                "FUNCTAB", (int) t2->stlen, t2->stptr);
366
 
                                } else if (t1 == symbol_table) {
367
 
                                        fatal(_("reference to uninitialized element `%s[\"%.*s\"] is not allowed'"),
368
 
                                                "SYMTAB", (int) t2->stlen, t2->stptr);
369
 
                                } else if (do_lint) {
370
 
                                        lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"),
371
 
                                                array_vname(t1), (int) t2->stlen, t2->stptr);
372
 
                                        if (t2->stlen == 0)
373
 
                                                lintwarn(_("subscript of array `%s' is null string"), array_vname(t1));
374
 
                                }
375
 
                        }
376
 
 
377
263
                        if (r == NULL) {
378
264
                                r = make_array();
379
265
                                r->parent_array = t1;
380
 
                                t2 = force_string(t2);
381
 
                                r->vname = estrdup(t2->stptr, t2->stlen);       /* the subscript in parent array */
382
 
                                assoc_set(t1, t2, r);
383
 
                        } else if (r->type == Node_elem_new) {
384
 
                                r = force_array(r, false);
385
 
                                r->parent_array = t1;
386
 
                                t2 = force_string(t2);
387
 
                                r->vname = estrdup(t2->stptr, t2->stlen);       /* the subscript in parent array */
 
266
                                lhs = assoc_lookup(t1, t2);
 
267
                                unref(*lhs);
 
268
                                *lhs = r;
 
269
                                t2 = force_string(t2);
 
270
                                r->vname = estrdup(t2->stptr, t2->stlen);       /* the subscript in parent array */
 
271
 
 
272
                                /* execute post-assignment routine if any */
 
273
                                if (t1->astore != NULL)
 
274
                                        (*t1->astore)(t1, t2);
388
275
                        } else if (r->type != Node_var_array) {
389
276
                                t2 = force_string(t2);
390
277
                                fatal(_("attempt to use scalar `%s[\"%.*s\"]' as an array"),
391
278
                                                array_vname(t1), (int) t2->stlen, t2->stptr);
392
 
                        } else
393
 
                                DEREF(t2);
 
279
                        }
394
280
 
 
281
                        DEREF(t2);
395
282
                        PUSH(r);
396
283
                        break;
397
284
 
398
285
                case Op_subscript_lhs:
399
286
                        t2 = mk_sub(pc->sub_count);
400
 
                        t1 = POP_ARRAY(false);
 
287
                        t1 = POP_ARRAY();
401
288
                        if (do_lint && in_array(t1, t2) == NULL) {
402
289
                                t2 = force_string(t2);
403
 
                                if (pc->do_reference)
 
290
                                if (pc->do_reference) 
404
291
                                        lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"),
405
292
                                                array_vname(t1), (int) t2->stlen, t2->stptr);
406
293
                                if (t2->stlen == 0)
421
308
                         * be stored in SYMTAB:
422
309
                         *      1. Variables that don"t yet have a value (Node_var_new)
423
310
                         *      2. Variables that have a value (Node_var)
424
 
                         *      3. Values that awk code stuck into SYMTAB not related to variables (Node_val)
 
311
                         *      3. Values that awk code stuck into SYMTAB not related to variables (Node_value)
425
312
                         * For 1, since we are giving it a value, we have to change the type to Node_var.
426
313
                         * For 1 and 2, we have to step through the Node_var to get to the value.
427
 
                         * For 3, we fatal out. This avoids confusion on things like
428
 
                         * SYMTAB["a foo"] = 42 # variable with a space in its name?
 
314
                         * For 3, we just us the value we got from assoc_lookup(), above.
429
315
                         */
430
316
                        if (t1 == func_table)
431
317
                                fatal(_("cannot assign to elements of FUNCTAB"));
432
 
                        else if (t1 == symbol_table) {
433
 
                                if ((   (*lhs)->type == Node_var
 
318
                        else if (   t1 == symbol_table
 
319
                                 && (   (*lhs)->type == Node_var
434
320
                                     || (*lhs)->type == Node_var_new)) {
435
 
                                        update_global_values();         /* make sure stuff like NF, NR, are up to date */
436
 
                                        (*lhs)->type = Node_var;        /* in case was Node_var_new */
437
 
                                        lhs = & ((*lhs)->var_value);    /* extra level of indirection */
438
 
                                } else
439
 
                                        fatal(_("cannot assign to arbitrary elements of SYMTAB"));
 
321
                                update_global_values();         /* make sure stuff like NF, NR, are up to date */
 
322
                                (*lhs)->type = Node_var;        /* in case was Node_var_new */
 
323
                                lhs = & ((*lhs)->var_value);    /* extra level of indirection */
440
324
                        }
441
325
 
442
326
                        assert(set_idx == NULL);
456
340
                        lhs = r_get_field(t1, (Func_ptr *) 0, true);
457
341
                        decr_sp();
458
342
                        DEREF(t1);
459
 
                        r = *lhs;
460
 
                        UPREF(r);
 
343
                        r = dupnode(*lhs);     /* can't use UPREF here */
461
344
                        PUSH(r);
462
345
                        break;
463
346
 
476
359
                                        lintwarn(_("assignment used in conditional context"));
477
360
                                        break;
478
361
 
 
362
                                case LINT_no_effect:
 
363
                                        lintwarn(_("statement has no effect"));
 
364
                                        break;
 
365
 
479
366
                                default:
480
 
                                        cant_happen("unexpected lint type value %d", (int) pc->lint_type);
 
367
                                        cant_happen();
481
368
                                }
482
369
                        }
483
370
                        break;
484
371
 
485
 
                case Op_lint_plus:
486
 
                        // no need to check do_lint, this opcode won't
487
 
                        // be generated if that's not true
488
 
                        t1 = fixtype(TOP());
489
 
                        t2 = fixtype(PEEK(1));
490
 
                        if ((t1->flags & (STRING|USER_INPUT)) == STRING
491
 
                            && (t2->flags & (STRING|USER_INPUT)) == STRING)
492
 
                                lintwarn(_("operator `+' used on two string values"));
493
 
                        break;
494
 
 
495
372
                case Op_K_break:
496
373
                case Op_K_continue:
497
374
                case Op_jmp:
509
386
                case Op_jmp_true:
510
387
                        r = POP_SCALAR();
511
388
                        di = eval_condition(r);
512
 
                        DEREF(r);
 
389
                        DEREF(r);                       
513
390
                        if (di)
514
391
                                JUMPTO(pc->target_jmp);
515
392
                        break;
545
422
                        break;
546
423
 
547
424
                case Op_equal:
548
 
                        r = node_Boolean[cmp_scalars(SCALAR_EQ)];
 
425
                        r = node_Boolean[cmp_scalars() == 0];
549
426
                        UPREF(r);
550
427
                        REPLACE(r);
551
428
                        break;
552
429
 
553
430
                case Op_notequal:
554
 
                        r = node_Boolean[cmp_scalars(SCALAR_NEQ)];
 
431
                        r = node_Boolean[cmp_scalars() != 0];
555
432
                        UPREF(r);
556
433
                        REPLACE(r);
557
434
                        break;
558
435
 
559
436
                case Op_less:
560
 
                        r = node_Boolean[cmp_scalars(SCALAR_LT)];
 
437
                        r = node_Boolean[cmp_scalars() < 0];
561
438
                        UPREF(r);
562
439
                        REPLACE(r);
563
440
                        break;
564
441
 
565
442
                case Op_greater:
566
 
                        r = node_Boolean[cmp_scalars(SCALAR_GT)];
 
443
                        r = node_Boolean[cmp_scalars() > 0];
567
444
                        UPREF(r);
568
445
                        REPLACE(r);
569
446
                        break;
570
447
 
571
448
                case Op_leq:
572
 
                        r = node_Boolean[cmp_scalars(SCALAR_LE)];
 
449
                        r = node_Boolean[cmp_scalars() <= 0];
573
450
                        UPREF(r);
574
451
                        REPLACE(r);
575
452
                        break;
576
453
 
577
454
                case Op_geq:
578
 
                        r = node_Boolean[cmp_scalars(SCALAR_GE)];
 
455
                        r = node_Boolean[cmp_scalars() >= 0];
579
456
                        UPREF(r);
580
457
                        REPLACE(r);
581
458
                        break;
590
467
plus:
591
468
                        t1 = TOP_NUMBER();
592
469
                        r = make_number(t1->numbr + x2);
593
 
                        r->numbr = fix_nan_sign(t1->numbr, x2, r->numbr);
594
470
                        DEREF(t1);
595
471
                        REPLACE(r);
596
472
                        break;
601
477
                case Op_minus:
602
478
                        t2 = POP_NUMBER();
603
479
                        x2 = t2->numbr;
604
 
                        DEREF(t2);
 
480
                        DEREF(t2);                      
605
481
minus:
606
482
                        t1 = TOP_NUMBER();
607
483
                        r = make_number(t1->numbr - x2);
608
 
                        r->numbr = fix_nan_sign(t1->numbr, x2, r->numbr);
609
484
                        DEREF(t1);
610
485
                        REPLACE(r);
611
486
                        break;
652
527
                        r = make_number(t1->numbr / x2);
653
528
                        DEREF(t1);
654
529
                        REPLACE(r);
655
 
                        break;
 
530
                        break;          
656
531
 
657
532
                case Op_mod_i:
658
533
                        x2 = force_number(pc->memory)->numbr;
719
594
                        REPLACE(r);
720
595
                        break;
721
596
 
722
 
                case Op_unary_plus:
723
 
                        // Force argument to be numeric
724
 
                        t1 = TOP_NUMBER();
725
 
                        r = make_number(t1->numbr);
726
 
                        DEREF(t1);
727
 
                        REPLACE(r);
728
 
                        break;
729
 
 
730
597
                case Op_store_sub:
731
598
                        /*
732
599
                         * array[sub] assignment optimization,
745
612
                        /*
746
613
                         * Changing something in FUNCTAB is not allowed.
747
614
                         *
748
 
                         * SYMTAB is a little more messy.  Three possibilities for SYMTAB:
 
615
                         * SYMTAB is a little more messy.  Three kinds of values may
 
616
                         * be stored in SYMTAB:
749
617
                         *      1. Variables that don"t yet have a value (Node_var_new)
750
618
                         *      2. Variables that have a value (Node_var)
751
 
                         *      3. Values that awk code stuck into SYMTAB not related to variables (Node_val)
 
619
                         *      3. Values that awk code stuck into SYMTAB not related to variables (Node_value)
752
620
                         * For 1, since we are giving it a value, we have to change the type to Node_var.
753
621
                         * For 1 and 2, we have to step through the Node_var to get to the value.
754
 
                         * For 3, we fatal out. This avoids confusion on things like
755
 
                         * SYMTAB["a foo"] = 42 # variable with a space in its name?
 
622
                         * For 3, we just us the value we got from assoc_lookup(), above.
756
623
                         */
757
624
                        if (t1 == func_table)
758
625
                                fatal(_("cannot assign to elements of FUNCTAB"));
759
 
                        else if (t1 == symbol_table) {
760
 
                                if ((   (*lhs)->type == Node_var
 
626
                        else if (   t1 == symbol_table
 
627
                                 && (   (*lhs)->type == Node_var
761
628
                                     || (*lhs)->type == Node_var_new)) {
762
 
                                        update_global_values();         /* make sure stuff like NF, NR, are up to date */
763
 
                                        (*lhs)->type = Node_var;        /* in case was Node_var_new */
764
 
                                        lhs = & ((*lhs)->var_value);    /* extra level of indirection */
765
 
                                } else
766
 
                                        fatal(_("cannot assign to arbitrary elements of SYMTAB"));
 
629
                                (*lhs)->type = Node_var;        /* in case was Node_var_new */
 
630
                                lhs = & ((*lhs)->var_value);    /* extra level of indirection */
767
631
                        }
768
632
 
769
633
                        unref(*lhs);
770
 
                        r = POP_SCALAR();
771
 
                        UNFIELD(*lhs, r);
 
634
                        *lhs = POP_SCALAR();
772
635
 
773
636
                        /* execute post-assignment routine if any */
774
637
                        if (t1->astore != NULL)
782
645
                         * simple variable assignment optimization,
783
646
                         * see awkgram.y (optimize_assignment)
784
647
                         */
785
 
 
 
648
        
786
649
                        lhs = get_lhs(pc->memory, false);
787
650
                        unref(*lhs);
788
651
                        r = pc->initval;        /* constant initializer */
789
 
                        if (r != NULL) {
 
652
                        if (r == NULL)
 
653
                                *lhs = POP_SCALAR();
 
654
                        else {
790
655
                                UPREF(r);
791
656
                                *lhs = r;
792
 
                        } else {
793
 
                                r = POP_SCALAR();
794
 
                                UNFIELD(*lhs, r);
795
657
                        }
796
658
                        break;
797
659
 
798
660
                case Op_store_field:
799
 
                case Op_store_field_exp:
800
661
                {
801
662
                        /* field assignment optimization,
802
663
                         * see awkgram.y (optimize_assignment)
807
668
                        lhs = r_get_field(t1, & assign, false);
808
669
                        decr_sp();
809
670
                        DEREF(t1);
810
 
                        /*
811
 
                         * N.B. We must call assign() before unref, since
812
 
                         * we may need to copy $n values before freeing the
813
 
                         * $0 buffer.
814
 
                         */
 
671
                        unref(*lhs);
 
672
                        *lhs = POP_SCALAR();
815
673
                        assert(assign != NULL);
816
674
                        assign();
817
 
                        unref(*lhs);
818
 
                        r = POP_SCALAR();
819
 
                        UNFIELD(*lhs, r);
820
 
                        /* field variables need the string representation: */
821
 
                        force_string(*lhs);
822
 
                        if (op == Op_store_field_exp) {
823
 
                                UPREF(*lhs);
824
 
                                PUSH(*lhs);
825
 
                        }
826
675
                }
827
676
                        break;
828
677
 
834
683
 
835
684
                        if (t1 != *lhs) {
836
685
                                unref(*lhs);
837
 
                                if (t1->valref == 1)
838
 
                                        *lhs = t1;
839
 
                                else
840
 
                                        *lhs = dupnode(t1);
 
686
                                *lhs = dupnode(t1);
841
687
                        }
842
688
 
843
 
                        if (t1 != t2 && t1->valref == 1 && (t1->flags & (MALLOC|MPFN|MPZN)) == MALLOC) {
 
689
                        if (t1 != t2 && t1->valref == 1 && (t1->flags & MPFN) == 0) {
844
690
                                size_t nlen = t1->stlen + t2->stlen;
845
691
 
846
 
                                erealloc(t1->stptr, char *, nlen + 1, "r_interpret");
 
692
                                erealloc(t1->stptr, char *, nlen + 2, "r_interpret");
847
693
                                memcpy(t1->stptr + t1->stlen, t2->stptr, t2->stlen);
848
694
                                t1->stlen = nlen;
849
695
                                t1->stptr[nlen] = '\0';
850
 
                                /* clear flags except WSTRCUR (used below) */
851
 
                                t1->flags &= WSTRCUR;
852
 
                                /* configure as a string as in make_str_node */
853
 
                                t1->flags |= (MALLOC|STRING|STRCUR);
854
 
                                t1->stfmt = STFMT_UNUSED;
855
 
#ifdef HAVE_MPFR
856
 
                                t1->strndmode = MPFR_round_mode;
857
 
#endif
 
696
                                t1->flags &= ~(NUMCUR|NUMBER|NUMINT);
858
697
 
 
698
#if MBS_SUPPORT
859
699
                                if ((t1->flags & WSTRCUR) != 0 && (t2->flags & WSTRCUR) != 0) {
860
700
                                        size_t wlen = t1->wstlen + t2->wstlen;
861
701
 
862
702
                                        erealloc(t1->wstptr, wchar_t *,
863
 
                                                        sizeof(wchar_t) * (wlen + 1), "r_interpret");
864
 
                                        memcpy(t1->wstptr + t1->wstlen, t2->wstptr, t2->wstlen * sizeof(wchar_t));
 
703
                                                        sizeof(wchar_t) * (wlen + 2), "r_interpret");
 
704
                                        memcpy(t1->wstptr + t1->wstlen, t2->wstptr, t2->wstlen);
865
705
                                        t1->wstlen = wlen;
866
706
                                        t1->wstptr[wlen] = L'\0';
 
707
                                        t1->flags |= WSTRCUR;
867
708
                                } else
868
709
                                        free_wstr(*lhs);
 
710
#endif
869
711
                        } else {
870
 
                                size_t nlen = t1->stlen + t2->stlen;
 
712
                                size_t nlen = t1->stlen + t2->stlen;  
871
713
                                char *p;
872
714
 
873
 
                                emalloc(p, char *, nlen + 1, "r_interpret");
 
715
                                emalloc(p, char *, nlen + 2, "r_interpret");
874
716
                                memcpy(p, t1->stptr, t1->stlen);
875
717
                                memcpy(p + t1->stlen, t2->stptr, t2->stlen);
876
 
                                /* N.B. No NUL-termination required, since make_str_node will do it. */
877
718
                                unref(*lhs);
878
 
                                t1 = *lhs = make_str_node(p, nlen, ALREADY_MALLOCED);
 
719
                                t1 = *lhs = make_str_node(p, nlen, ALREADY_MALLOCED); 
879
720
                        }
880
721
                        DEREF(t2);
881
722
                        break;
884
725
                        lhs = POP_ADDRESS();
885
726
                        r = TOP_SCALAR();
886
727
                        unref(*lhs);
887
 
                        if (r->type == Node_elem_new) {
888
 
                                DEREF(r);
889
 
                                r = dupnode(Nnull_string);
890
 
                        }
 
728
                        *lhs = r;
891
729
                        UPREF(r);
892
 
                        UNFIELD(*lhs, r);
893
730
                        REPLACE(r);
894
731
                        break;
895
732
 
896
733
                case Op_subscript_assign:
897
 
                        /* conditionally execute post-assignment routine for an array element */
 
734
                        /* conditionally execute post-assignment routine for an array element */ 
898
735
 
899
736
                        if (set_idx != NULL) {
900
737
                                di = true;
971
808
                                t2 = TOP_SCALAR();      /* switch expression */
972
809
                                t2 = force_string(t2);
973
810
                                rp = re_update(m);
974
 
                                di = (research(rp, t2->stptr, 0, t2->stlen, RE_NO_FLAGS) >= 0);
 
811
                                di = (research(rp, t2->stptr, 0, t2->stlen,
 
812
                                                        avoid_dfa(m, t2->stptr, t2->stlen)) >= 0);
975
813
                        } else {
976
814
                                t1 = POP_SCALAR();      /* case value */
977
815
                                t2 = TOP_SCALAR();      /* switch expression */
978
 
                                di = (cmp_nodes(t2, t1, true) == 0);
 
816
                                di = (cmp_nodes(t2, t1) == 0);
979
817
                                DEREF(t1);
980
818
                        }
981
819
 
988
826
                        break;
989
827
 
990
828
                case Op_K_delete:
991
 
                        t1 = POP_ARRAY(false);
 
829
                        t1 = POP_ARRAY();
992
830
                        do_delete(t1, pc->expr_count);
993
831
                        stack_adj(-pc->expr_count);
994
832
                        break;
995
833
 
996
834
                case Op_K_delete_loop:
997
 
                        t1 = POP_ARRAY(false);
 
835
                        t1 = POP_ARRAY();
998
836
                        lhs = POP_ADDRESS();    /* item */
999
837
                        do_delete_loop(t1, lhs);
1000
838
                        break;
1001
839
 
1002
840
                case Op_in_array:
1003
 
                        t1 = POP_ARRAY(false);
 
841
                        t1 = POP_ARRAY();
1004
842
                        t2 = mk_sub(pc->expr_count);
1005
843
                        r = node_Boolean[(in_array(t1, t2) != NULL)];
1006
844
                        DEREF(t2);
1015
853
                        size_t num_elems = 0;
1016
854
                        static NODE *sorted_in = NULL;
1017
855
                        const char *how_to_sort = "@unsorted";
1018
 
                        char save;
1019
 
                        bool saved_end = false;
1020
856
 
1021
857
                        /* get the array */
1022
 
                        array = POP_ARRAY(true);
 
858
                        array = POP_ARRAY();
1023
859
 
1024
860
                        /* sanity: check if empty */
1025
861
                        num_elems = assoc_length(array);
1039
875
 
1040
876
                        if (sort_str != NULL) {
1041
877
                                sort_str = force_string(sort_str);
1042
 
                                if (sort_str->stlen > 0) {
 
878
                                if (sort_str->stlen > 0)
1043
879
                                        how_to_sort = sort_str->stptr;
1044
 
                                        str_terminate(sort_str, save);
1045
 
                                        saved_end = true;
1046
 
                                }
1047
880
                        }
1048
881
 
1049
882
                        list = assoc_list(array, how_to_sort, SORTED_IN);
1050
 
                        if (saved_end)
1051
 
                                str_restore(sort_str, save);
1052
883
 
1053
884
arrayfor:
1054
885
                        getnode(r);
1093
924
                        break;
1094
925
 
1095
926
                case Op_ext_builtin:
 
927
                case Op_old_ext_builtin:
1096
928
                {
1097
 
                        size_t arg_count = pc->expr_count;
1098
 
                        awk_ext_func_t *f = pc[1].c_function;
1099
 
                        size_t min_req = f->min_required_args;
1100
 
                        size_t max_expect = f->max_expected_args;
 
929
                        int arg_count = pc->expr_count;
1101
930
                        awk_value_t result;
1102
931
 
1103
 
                        if (arg_count < min_req)
1104
 
                                fatal(_("%s: called with %lu arguments, expecting at least %lu"),
1105
 
                                                pc[1].func_name,
1106
 
                                                (unsigned long) arg_count,
1107
 
                                                (unsigned long) min_req);
1108
 
 
1109
 
                        if (do_lint && ! f->suppress_lint && arg_count > max_expect)
1110
 
                                lintwarn(_("%s: called with %lu arguments, expecting no more than %lu"),
1111
 
                                                pc[1].func_name,
1112
 
                                                (unsigned long) arg_count,
1113
 
                                                (unsigned long) max_expect);
1114
 
 
1115
932
                        PUSH_CODE(pc);
1116
 
                        awk_value_t *ef_ret = pc->extfunc(arg_count, & result, f);
1117
 
                        r = awk_value_to_node(ef_ret);
 
933
                        if (op == Op_ext_builtin)
 
934
                                r = awk_value_to_node(pc->extfunc(arg_count, & result));
 
935
                        else
 
936
                                r = pc->builtin(arg_count);
1118
937
                        (void) POP_CODE();
1119
938
                        while (arg_count-- > 0) {
1120
939
                                t1 = POP();
1121
 
                                if (t1->type == Node_val || t1->type == Node_elem_new)
 
940
                                if (t1->type == Node_val)
1122
941
                                        DEREF(t1);
1123
942
                        }
1124
 
                        free_api_string_copies();
1125
 
 
1126
 
                        if (in_indirect_call) {
1127
 
                                // pop function name off the stack
1128
 
                                NODE *fname = POP();
1129
 
                                DEREF(fname);
1130
 
                                in_indirect_call = false;
1131
 
                        }
1132
 
 
1133
943
                        PUSH(r);
1134
944
                }
1135
945
                        break;
1157
967
                                r = POP_STRING();
1158
968
                                unref(m->re_exp);
1159
969
                                m->re_exp = r;
1160
 
                        } else if (m->type == Node_val) {
1161
 
                                assert((m->flags & REGEX) != 0);
1162
 
                                UPREF(m);
1163
970
                        }
1164
971
                        PUSH(m);
1165
972
                        break;
1166
 
 
 
973
                        
1167
974
                case Op_match_rec:
1168
975
                        m = pc->memory;
1169
976
                        t1 = *get_field(0, (Func_ptr *) 0);
1170
977
match_re:
1171
978
                        rp = re_update(m);
1172
 
                        di = research(rp, t1->stptr, 0, t1->stlen, RE_NO_FLAGS);
 
979
                        /*
 
980
                         * Any place where research() is called with a last parameter of
 
981
                         * zero, we need to use the avoid_dfa test. This appears here and
 
982
                         * in the code for Op_K_case.
 
983
                         *
 
984
                         * A new or improved dfa that distinguishes beginning/end of
 
985
                         * string from beginning/end of line will allow us to get rid of
 
986
                         * this hack.
 
987
                         *
 
988
                         * The avoid_dfa() function is in re.c; it is not very smart.
 
989
                         */
 
990
 
 
991
                        di = research(rp, t1->stptr, 0, t1->stlen,
 
992
                                                                avoid_dfa(m, t1->stptr, t1->stlen));
1173
993
                        di = (di == -1) ^ (op != Op_nomatch);
1174
994
                        if (op != Op_match_rec) {
1175
995
                                decr_sp();
1176
996
                                DEREF(t1);
1177
 
                                if (m->type == Node_dynregex) {
1178
 
                                        DEREF(m->re_exp);
1179
 
                                        m->re_exp = NULL;
1180
 
                                }
1181
997
                        }
1182
998
                        r = node_Boolean[di];
1183
999
                        UPREF(r);
1202
1018
                {
1203
1019
                        NODE *f = NULL;
1204
1020
                        int arg_count;
1205
 
                        char save;
1206
 
                        NODE *function_name;
1207
1021
 
1208
1022
                        arg_count = (pc + 1)->expr_count;
1209
1023
                        t1 = PEEK(arg_count);   /* indirect var */
1212
1026
                                fatal(_("indirect function call requires a simple scalar value"));
1213
1027
 
1214
1028
                        t1 = force_string(t1);
1215
 
                        str_terminate(t1, save);
1216
1029
                        if (t1->stlen > 0) {
1217
1030
                                /* retrieve function definition node */
1218
1031
                                f = pc->func_body;
1219
1032
                                if (f != NULL && strcmp(f->vname, t1->stptr) == 0) {
1220
1033
                                        /* indirect var hasn't been reassigned */
1221
1034
 
1222
 
                                        str_restore(t1, save);
1223
1035
                                        ni = setup_frame(pc);
1224
1036
                                        JUMPTO(ni);     /* Op_func */
1225
1037
                                }
1226
1038
                                f = lookup(t1->stptr);
1227
1039
                        }
1228
1040
 
1229
 
                        if (f == NULL) {
1230
 
                                fatal(_("`%s' is not a function, so it cannot be called indirectly"),
1231
 
                                                t1->stptr);
1232
 
                        } else if (f->type == Node_builtin_func) {
1233
 
                                int arg_count = (pc + 1)->expr_count;
1234
 
                                builtin_func_t the_func = lookup_builtin(t1->stptr);
1235
 
 
1236
 
                                assert(the_func != NULL);
1237
 
 
1238
 
                                /* call it */
1239
 
                                if (the_func == (builtin_func_t) do_sub)
1240
 
                                        r = call_sub(t1->stptr, arg_count);
1241
 
                                else if (the_func == do_match)
1242
 
                                        r = call_match(arg_count);
1243
 
                                else if (the_func == do_split || the_func == do_patsplit)
1244
 
                                        r = call_split_func(t1->stptr, arg_count);
 
1041
                        if (f == NULL || f->type != Node_func) {
 
1042
                                if (f->type == Node_ext_func || f->type == Node_old_ext_func)
 
1043
                                        fatal(_("cannot (yet) call extension functions indirectly"));
1245
1044
                                else
1246
 
                                        r = the_func(arg_count);
1247
 
                                str_restore(t1, save);
1248
 
 
1249
 
                                // Normally, setup_frame() handles getting rid of the
1250
 
                                // function name.  Since we have called the builtin directly,
1251
 
                                // we have to manually do this here.
1252
 
                                function_name = POP();
1253
 
                                DEREF(function_name);
1254
 
 
1255
 
                                PUSH(r);
1256
 
                                break;
1257
 
                        } else if (f->type != Node_func) {
1258
 
                                str_restore(t1, save);
1259
 
                                if (f->type == Node_ext_func) {
1260
 
                                        /* code copied from below, keep in sync */
1261
 
                                        INSTRUCTION *bc;
1262
 
                                        char *fname = pc->func_name;
1263
 
                                        int arg_count = (pc + 1)->expr_count;
1264
 
                                        static INSTRUCTION npc[2];
1265
 
 
1266
 
                                        npc[0] = *pc;
1267
 
 
1268
 
                                        bc = f->code_ptr;
1269
 
                                        assert(bc->opcode == Op_symbol);
1270
 
                                        npc[0].opcode = Op_ext_builtin; /* self modifying code */
1271
 
                                        npc[0].extfunc = bc->extfunc;
1272
 
                                        npc[0].expr_count = arg_count;          /* actual argument count */
1273
 
                                        npc[1] = pc[1];
1274
 
                                        npc[1].func_name = fname;       /* name of the builtin */
1275
 
                                        npc[1].c_function = bc->c_function;
1276
 
                                        in_indirect_call = true;
1277
 
                                        ni = npc;
1278
 
                                        JUMPTO(ni);
1279
 
                                } else
1280
1045
                                        fatal(_("function called indirectly through `%s' does not exist"),
1281
 
                                                        pc->func_name);
 
1046
                                                        pc->func_name); 
1282
1047
                        }
1283
1048
                        pc->func_body = f;     /* save for next call */
1284
 
                        str_restore(t1, save);
1285
1049
 
1286
1050
                        ni = setup_frame(pc);
1287
1051
                        JUMPTO(ni);     /* Op_func */
1295
1059
                        f = pc->func_body;
1296
1060
                        if (f == NULL) {
1297
1061
                                f = lookup(pc->func_name);
1298
 
                                if (f == NULL || (f->type != Node_func && f->type != Node_ext_func))
 
1062
                                if (f == NULL || (f->type != Node_func && f->type != Node_ext_func && f->type != Node_old_ext_func))
1299
1063
                                        fatal(_("function `%s' not defined"), pc->func_name);
1300
1064
                                pc->func_body = f;     /* save for next call */
1301
1065
                        }
1302
1066
 
1303
 
                        if (f->type == Node_ext_func) {
1304
 
                                /* keep in sync with indirect call code */
 
1067
                        if (f->type == Node_ext_func || f->type == Node_old_ext_func) {
1305
1068
                                INSTRUCTION *bc;
1306
1069
                                char *fname = pc->func_name;
1307
1070
                                int arg_count = (pc + 1)->expr_count;
1308
1071
 
1309
1072
                                bc = f->code_ptr;
1310
1073
                                assert(bc->opcode == Op_symbol);
1311
 
                                pc->opcode = Op_ext_builtin;    /* self modifying code */
 
1074
                                if (f->type == Node_ext_func)
 
1075
                                        pc->opcode = Op_ext_builtin;    /* self modifying code */
 
1076
                                else
 
1077
                                        pc->opcode = Op_old_ext_builtin;        /* self modifying code */
1312
1078
                                pc->extfunc = bc->extfunc;
1313
 
                                pc->expr_count = arg_count;     /* actual argument count */
 
1079
                                pc->expr_count = arg_count;             /* actual argument count */
1314
1080
                                (pc + 1)->func_name = fname;    /* name of the builtin */
1315
 
                                (pc + 1)->c_function = bc->c_function;  /* min and max args */
1316
 
                                ni = pc;
 
1081
                                (pc + 1)->expr_count = bc->expr_count;  /* defined max # of arguments */
 
1082
                                ni = pc; 
1317
1083
                                JUMPTO(ni);
1318
1084
                        }
1319
1085
 
1321
1087
                        JUMPTO(ni);     /* Op_func */
1322
1088
                }
1323
1089
 
1324
 
                case Op_K_return_from_eval:
1325
 
                        cant_happen("unexpected opcode %s", opcode2str(op));
1326
 
                        break;
1327
 
 
1328
1090
                case Op_K_return:
1329
1091
                        m = POP_SCALAR();       /* return value */
1330
1092
 
1331
1093
                        ni = pop_fcall();
1332
 
 
 
1094
        
1333
1095
                        /* put the return value back on stack */
1334
1096
                        PUSH(m);
1335
1097
 
1336
1098
                        JUMPTO(ni);
1337
1099
 
1338
1100
                case Op_K_getline_redir:
1339
 
                        r = do_getline_redir(pc->into_var, (enum redirval) pc->redir_type);
 
1101
                        if ((currule == BEGINFILE || currule == ENDFILE)
 
1102
                                        && pc->into_var == false
 
1103
                                        && pc->redir_type == redirect_input)
 
1104
                                fatal(_("`getline' invalid inside `%s' rule"), ruletab[currule]);
 
1105
                        r = do_getline_redir(pc->into_var, pc->redir_type);
1340
1106
                        PUSH(r);
1341
1107
                        break;
1342
1108
 
1354
1120
 
1355
1121
                                        /* Save execution state so that we can return to it
1356
1122
                                         * from Op_after_beginfile or Op_after_endfile.
1357
 
                                         */
 
1123
                                         */ 
1358
1124
 
1359
1125
                                        push_exec_state(pc, currule, source, stack_ptr);
1360
1126
 
1412
1178
                                execute beginfile block */
1413
1179
                }
1414
1180
                        break;
1415
 
 
1416
 
                case Op_get_record:
 
1181
                        
 
1182
                case Op_get_record:             
1417
1183
                {
1418
1184
                        int errcode = 0;
1419
1185
 
1429
1195
                                JUMPTO(ni);
1430
1196
                        }
1431
1197
 
1432
 
                        if (! inrec(curfile, & errcode)) {
1433
 
                                if (errcode > 0) {
1434
 
                                        update_ERRNO_int(errcode);
1435
 
                                        if (do_traditional || ! pc->has_endfile)
1436
 
                                                fatal(_("error reading input file `%s': %s"),
 
1198
                        if (inrec(curfile, & errcode) != 0) {
 
1199
                                if (errcode > 0 && (do_traditional || ! pc->has_endfile))
 
1200
                                        fatal(_("error reading input file `%s': %s"),
1437
1201
                                                curfile->public.name, strerror(errcode));
1438
 
                                }
1439
1202
 
1440
1203
                                JUMPTO(ni);
1441
1204
                        } /* else
1454
1217
                        ret = nextfile(& curfile, true);        /* skip current file */
1455
1218
 
1456
1219
                        if (currule == BEGINFILE) {
1457
 
                                long stack_size = 0;
 
1220
                                long stack_size;
1458
1221
 
1459
1222
                                ni = pop_exec_state(& currule, & source, & stack_size);
1460
1223
 
1471
1234
                                        JUMPTO(ni);
1472
1235
                                } else {
1473
1236
                                        /* do run ENDFILE block(s) first. */
1474
 
 
 
1237
                                        
1475
1238
                                        /* Execution state to return to in Op_after_endfile. */
1476
1239
                                        push_exec_state(ni, currule, source, stack_ptr);
1477
1240
 
1478
1241
                                        JUMPTO(pc->target_endfile);
1479
 
                                }
1480
 
                        } /* else
 
1242
                                }                               
 
1243
                        } /* else 
1481
1244
                                Start over with the first rule. */
1482
1245
 
1483
1246
                        /* empty the run-time stack to avoid memory leak */
1498
1261
                                fatal(_("`exit' cannot be called in the current context"));
1499
1262
 
1500
1263
                        exiting = true;
1501
 
                        if ((t1 = POP_NUMBER()) != Nnull_string) {
1502
 
                                exit_val = (int) get_number_si(t1);
 
1264
                        t1 = POP_NUMBER();
 
1265
                        exit_val = (int) get_number_si(t1);
 
1266
                        DEREF(t1);
1503
1267
#ifdef VMS
1504
 
                                if (exit_val == 0)
1505
 
                                        exit_val = EXIT_SUCCESS;
1506
 
                                else if (exit_val == 1)
1507
 
                                        exit_val = EXIT_FAILURE;
1508
 
                                /* else
1509
 
                                        just pass anything else on through */
 
1268
                        if (exit_val == 0)
 
1269
                                exit_val = EXIT_SUCCESS;
 
1270
                        else if (exit_val == 1)
 
1271
                                exit_val = EXIT_FAILURE;
 
1272
                        /* else
 
1273
                                just pass anything else on through */
1510
1274
#endif
1511
 
                        }
1512
 
                        DEREF(t1);
1513
1275
 
1514
1276
                        if (currule == BEGINFILE || currule == ENDFILE) {
1515
1277
 
1568
1330
                                /* not already triggered and left expression is true */
1569
1331
                                decr_sp();
1570
1332
                                ip->triggered = true;
1571
 
                                JUMPTO(ip->target_jmp); /* evaluate right expression */
 
1333
                                JUMPTO(ip->target_jmp); /* evaluate right expression */ 
1572
1334
                        }
1573
1335
 
1574
1336
                        result = ip->triggered || di;
1594
1356
                case Op_K_if:
1595
1357
                case Op_K_else:
1596
1358
                case Op_cond_exp:
1597
 
                case Op_comment:
1598
 
                case Op_parens:
1599
1359
                        break;
1600
1360
 
1601
1361
                default: