~mirabilos/mksh/MAIN

« back to all changes in this revision

Viewing changes to var.c

  • Committer: tg
  • Date: 2018-07-15 17:21:22 UTC
  • Revision ID: tg-20180715172122-32yn0jewi8a33bn0
against better judgement, allow unsetting COLUMNS:
• GNU coreutils’ test suite insists on it, even despite it can run
  successfully without doing it (WTF‽)…
• we already unspecial, explicitly commented as “hands-off” it,
  when imported from the environment
• it was already changeable (though that didn’t unspecial it on the
  command line)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <sys/sysctl.h>
29
29
#endif
30
30
 
31
 
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.225 2018/05/07 00:07:23 tg Exp $");
 
31
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.226 2018/07/15 17:21:24 tg Exp $");
32
32
 
33
33
/*-
34
34
 * Variables
54
54
static void unspecial(const char *);
55
55
static void getspec(struct tbl *);
56
56
static void setspec(struct tbl *);
57
 
static void unsetspec(struct tbl *);
 
57
static void unsetspec(struct tbl *, bool);
58
58
static int getint(struct tbl *, mksh_ari_u *, bool);
59
59
static const char *array_index_calc(const char *, bool *, uint32_t *);
60
60
 
105
105
                        if ((vq = global(vp->name))->flag & ISSET)
106
106
                                setspec(vq);
107
107
                        else
108
 
                                unsetspec(vq);
 
108
                                unsetspec(vq, false);
109
109
                }
110
110
        if (l->flags & BF_DOGETOPTS)
111
111
                user_opt = l->getopts_state;
1054
1054
        vp->flag &= SPECIAL | ((flags & 1) ? 0 : ARRAY|DEFINED);
1055
1055
        if (vp->flag & SPECIAL)
1056
1056
                /* responsible for 'unspecial'ing var */
1057
 
                unsetspec(vp);
 
1057
                unsetspec(vp, true);
1058
1058
}
1059
1059
 
1060
1060
/*
1441
1441
}
1442
1442
 
1443
1443
static void
1444
 
unsetspec(struct tbl *vp)
 
1444
unsetspec(struct tbl *vp, bool dounset)
1445
1445
{
1446
1446
        /*
1447
1447
         * AT&T ksh man page says OPTIND, OPTARG and _ lose special
1466
1466
#endif
1467
1467
        case V_IFS:
1468
1468
                set_ifs(TC_IFSWS);
1469
 
                break;
 
1469
                return;
1470
1470
        case V_PATH:
1471
1471
                afree(path, APERM);
1472
1472
                strdupx(path, def_path, APERM);
1473
1473
                /* clear tracked aliases */
1474
1474
                flushcom(true);
1475
 
                break;
 
1475
                return;
1476
1476
#ifndef MKSH_NO_CMDLINE_EDITING
1477
1477
        case V_TERM:
1478
1478
                x_initterm(null);
1484
1484
                        afree(tmpdir, APERM);
1485
1485
                        tmpdir = NULL;
1486
1486
                }
1487
 
                break;
 
1487
                return;
1488
1488
        case V_LINENO:
1489
1489
        case V_RANDOM:
1490
1490
        case V_SECONDS:
1491
1491
        case V_TMOUT:
1492
1492
                /* AT&T ksh leaves previous value in place */
1493
1493
                unspecial(vp->name);
1494
 
                break;
 
1494
                return;
1495
1495
#ifdef MKSH_EARLY_LOCALE_TRACKING
1496
1496
        case V_LANG:
1497
1497
        case V_LC_ALL:
1499
1499
                recheck_ctype();
1500
1500
                return;
1501
1501
#endif
 
1502
        /* should not become unspecial, but allow unsetting */
 
1503
        case V_COLUMNS:
 
1504
        case V_LINES:
 
1505
                if (dounset)
 
1506
                        unspecial(vp->name);
 
1507
                return;
1502
1508
        }
1503
1509
}
1504
1510