1 /* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $ */
3 * sh.set.c: Setting and Clearing of variables
6 * Copyright (c) 1980, 1991 The Regents of the University of California.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 RCSID("$tcsh: sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $")
40 #ifdef HAVE_NL_LANGINFO
44 extern int GotTermCaps;
47 static void update_vars (Char *);
48 static Char *getinx (Char *, int *);
49 static void asx (Char *, int, Char *);
50 static struct varent *getvx (Char *, int);
51 static Char *xset (Char *, Char ***);
52 static Char *operate (int, Char *, Char *);
53 static void putn1 (tcsh_number_t);
54 static struct varent *madrof (Char *, struct varent *);
55 static void unsetv1 (struct varent *);
56 static void exportpath (Char **);
57 static void balance (struct varent *, int, int);
66 if (eq(vp, STRpath)) {
67 struct varent *p = adrof(STRpath);
69 stderror(ERR_NAME | ERR_UNDVAR);
75 else if (eq(vp, STRhistchars)) {
76 Char *pn = varval(vp);
84 else if (eq(vp, STRpromptchars)) {
85 Char *pn = varval(vp);
93 else if (eq(vp, STRhistlit)) {
96 else if (eq(vp, STRuser)) {
97 tsetenv(STRKUSER, varval(vp));
98 tsetenv(STRLOGNAME, varval(vp));
100 else if (eq(vp, STRgroup)) {
101 tsetenv(STRKGROUP, varval(vp));
103 else if (eq(vp, STRwordchars)) {
104 word_chars = varval(vp);
106 else if (eq(vp, STRloginsh)) {
109 else if (eq(vp, STRanyerror)) {
112 else if (eq(vp, STRsymlinks)) {
113 Char *pn = varval(vp);
115 if (eq(pn, STRignore))
116 symlinks = SYM_IGNORE;
117 else if (eq(pn, STRexpand))
118 symlinks = SYM_EXPAND;
119 else if (eq(pn, STRchase))
120 symlinks = SYM_CHASE;
124 else if (eq(vp, STRterm)) {
125 Char *cp = varval(vp);
126 tsetenv(STRKTERM, cp);
127 #ifdef DOESNT_WORK_RIGHT
128 cp = getenv("TERMCAP");
129 if (cp && (*cp != '/')) /* if TERMCAP and not a path */
130 Unsetenv(STRTERMCAP);
131 #endif /* DOESNT_WORK_RIGHT */
133 if (noediting && Strcmp(cp, STRnetwork) != 0 &&
134 Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
139 ed_Init(); /* reset the editor */
141 else if (eq(vp, STRhome)) {
144 cp = Strsave(varval(vp)); /* get the old value back */
145 cleanup_push(cp, xfree);
148 * convert to cononical pathname (possibly resolving symlinks)
150 canon = dcanon(cp, cp);
153 cleanup_push(canon, xfree);
155 setcopy(vp, canon, VAR_READWRITE); /* have to save the new val */
157 /* and now mirror home with HOME */
158 tsetenv(STRKHOME, canon);
159 /* fix directory stack for new tilde home */
161 cleanup_until(canon);
163 else if (eq(vp, STRedit)) {
166 /* PWP: add more stuff in here later */
168 else if (eq(vp, STRshlvl)) {
169 tsetenv(STRKSHLVL, varval(vp));
171 else if (eq(vp, STRignoreeof)) {
174 for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
179 numeof = numeof * 10 + *cp - '0';
181 if (numeof <= 0) numeof = 26; /* Sanity check */
183 else if (eq(vp, STRbackslash_quote)) {
186 else if (eq(vp, STRcompat_expr)) {
189 else if (eq(vp, STRdirstack)) {
192 else if (eq(vp, STRrecognize_only_executables)) {
195 else if (eq(vp, STRkillring)) {
196 SetKillRing((int)getn(varval(vp)));
199 else if (eq(vp, STRwatch)) {
202 #endif /* HAVENOUTMP */
203 else if (eq(vp, STRimplicitcd)) {
204 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
207 else if (eq(vp, STRcolor)) {
210 #endif /* COLOR_LS_F */
211 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
212 else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
213 update_dspmbyte_vars();
217 else if (eq(vp, STRcatalog)) {
221 #if defined(FILEC) && defined(TIOCSTI)
222 else if (eq(vp, STRfilec))
225 #endif /* NLS_CATALOGS */
231 doset(Char **v, struct command *c)
238 int flags = VAR_READWRITE;
248 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
250 if (*v && eq(*v, STRmr)) {
251 flags = VAR_READONLY;
255 if (*v && eq(*v, STRmf) && !last_match) {
260 if (*v && eq(*v, STRml) && !first_match) {
268 plist(&shvhed, flags);
275 stderror(ERR_NAME | ERR_VARBEGIN);
281 p = getinx(p, &subscr);
283 if (*p != '\0' && *p != '=')
284 stderror(ERR_NAME | ERR_VARALNUM);
287 if (*p == '\0' && *v != NULL && **v == '(')
290 else if (*v && eq(*v, STRequal)) {
294 if (eq(p, STRLparen)) {
298 stderror(ERR_NAME | ERR_SYNTAX);
301 stderror(ERR_NAME | ERR_MISSING, ')');
314 set1(vp, vecp, &shvhed, flags);
322 cleanup_push(copy, xfree);
323 asx(vp, subscr, copy);
324 cleanup_ignore(copy);
328 setv(vp, Strsave(p), flags);
330 } while ((p = *v++) != NULL);
334 getinx(Char *cp, int *ip)
338 while (*cp && Isdigit(*cp))
339 *ip = *ip * 10 + *cp++ - '0';
341 stderror(ERR_NAME | ERR_SUBSCRIPT);
346 asx(Char *vp, int subscr, Char *p)
348 struct varent *v = getvx(vp, subscr);
351 if (v->v_flags & VAR_READONLY)
352 stderror(ERR_READONLY|ERR_NAME, v->v_name);
353 prev = v->vec[subscr - 1];
354 cleanup_push(prev, xfree);
355 v->vec[subscr - 1] = globone(p, G_APPEND);
359 static struct varent *
360 getvx(Char *vp, int subscr)
362 struct varent *v = adrof(vp);
366 if (subscr < 1 || subscr > blklen(v->vec))
367 stderror(ERR_NAME | ERR_RANGE);
373 dolet(Char **v, struct command *dummy)
391 for (; alnum(*p); p++)
393 if (vp == p || !letter(*vp))
394 stderror(ERR_NAME | ERR_VARBEGIN);
397 p = getinx(p, &subscr);
404 stderror(ERR_NAME | ERR_ASSIGN);
407 * if there is no expression after the '=' then print a "Syntax Error"
410 if (*p == '\0' && *v == NULL)
411 stderror(ERR_NAME | ERR_ASSIGN);
414 cleanup_push(vp, xfree);
423 stderror(ERR_NAME | ERR_UNKNOWNOP);
429 stderror(ERR_NAME | ERR_UNKNOWNOP);
430 stderror(ERR_NAME | ERR_SYNTAX);
433 stderror(ERR_NAME | ERR_UNKNOWNOP);
437 cleanup_push(p, xfree);
442 setv(vp, p, VAR_READWRITE);
446 struct varent *gv = getvx(vp, subscr);
449 val = operate(op, gv->vec[subscr - 1], p);
450 cleanup_push(val, xfree);
451 asx(vp, subscr, val);
458 val = operate(op, varval(vp), p);
459 cleanup_push(val, xfree);
460 setv(vp, val, VAR_READWRITE);
466 } while ((p = *v++) != NULL);
470 xset(Char *cp, Char ***vp)
480 return (putn(expr(vp)));
484 operate(int op, Char *vp, Char *p)
498 if (op == '<' || op == '>')
505 stderror(ERR_NAME | ERR_EXPRESSION);
512 putn(tcsh_number_t n)
514 Char nbuf[1024]; /* Enough even for octal */
523 return (Strsave(nbuf));
527 putn1(tcsh_number_t n)
531 *putp++ = (Char)(n % 10 + '0');
541 if (!cp) /* PWP: extra error checking */
542 stderror(ERR_NAME | ERR_BADNUM);
545 if (cp[0] == '+' && cp[1])
551 stderror(ERR_NAME | ERR_BADNUM);
554 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
562 if (base == 8 && *cp >= '8')
563 stderror(ERR_NAME | ERR_BADNUM);
564 n = n * base + *cp++ - '0';
567 stderror(ERR_NAME | ERR_BADNUM);
568 return (sign ? -n : n);
572 value1(Char *var, struct varent *head)
576 if (!var || !head) /* PWP: extra error checking */
579 vp = adrof1(var, head);
580 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
581 STRNULL : vp->vec[0]);
584 static struct varent *
585 madrof(Char *pat, struct varent *vp)
589 for (vp = vp->v_left; vp; vp = vp->v_right) {
590 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
592 if (Gmatch(vp->v_name, pat))
599 adrof1(const Char *name, struct varent *v)
604 while (v && ((cmp = *name - *v->v_name) != 0 ||
605 (cmp = Strcmp(name, v->v_name)) != 0))
614 setcopy(const Char *var, const Char *val, int flags)
619 cleanup_push(copy, xfree);
620 setv(var, copy, flags);
621 cleanup_ignore(copy);
626 * The caller is responsible for putting value in a safe place
629 setv(const Char *var, Char *val, int flags)
631 Char **vec = xmalloc(2 * sizeof(Char **));
635 set1(var, vec, &shvhed, flags);
639 set1(const Char *var, Char **vec, struct varent *head, int flags)
643 if ((flags & VAR_NOGLOB) == 0) {
648 vec = globall(oldv, gflag);
651 stderror(ERR_NAME | ERR_NOMATCH);
657 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
659 if ( flags & (VAR_FIRST | VAR_LAST) ) {
661 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
663 * Delete all duplicate words leaving "holes" in the word array (vec).
664 * Then remove the "holes", keeping the order of the words unchanged.
666 if (vec && vec[0] && vec[1]) { /* more than one word ? */
670 for (num_items = 0; vec[num_items]; num_items++)
672 if (flags & VAR_FIRST) {
673 /* delete duplications, keeping first occurance */
674 for (i = 1; i < num_items; i++)
675 for (j = 0; j < i; j++)
676 /* If have earlier identical item, remove i'th item */
677 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
682 } else if (flags & VAR_LAST) {
683 /* delete duplications, keeping last occurance */
684 for (i = 0; i < num_items - 1; i++)
685 for (j = i + 1; j < num_items; j++)
686 /* If have later identical item, remove i'th item */
687 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
688 /* remove identical item (the first) */
693 /* Compress items - remove empty items */
694 for (j = i = 0; i < num_items; i++)
698 /* NULL-fy remaining items */
699 for (; j < num_items; j++)
702 /* don't let the attribute propagate */
703 flags &= ~(VAR_FIRST|VAR_LAST);
705 setq(var, vec, head, flags);
710 setq(const Char *name, Char **vec, struct varent *p, int flags)
715 f = 0; /* tree hangs off the header's left link */
716 while ((c = p->v_link[f]) != 0) {
717 if ((f = *name - *c->v_name) == 0 &&
718 (f = Strcmp(name, c->v_name)) == 0) {
719 if (c->v_flags & VAR_READONLY)
720 stderror(ERR_READONLY|ERR_NAME, c->v_name);
729 p->v_link[f] = c = xmalloc(sizeof(struct varent));
730 c->v_name = Strsave(name);
733 c->v_left = c->v_right = 0;
741 unset(Char **v, struct command *c)
743 int did_roe, did_edit;
746 did_roe = adrof(STRrecognize_only_executables) != NULL;
747 did_edit = adrof(STRedit) != NULL;
750 #if defined(FILEC) && defined(TIOCSTI)
751 if (adrof(STRfilec) == 0)
753 #endif /* FILEC && TIOCSTI */
755 if (adrof(STRhistchars) == 0) {
759 if (adrof(STRignoreeof) == 0)
761 if (adrof(STRpromptchars) == 0) {
762 PRCH = tcsh ? '>' : '%';
765 if (adrof(STRhistlit) == 0)
767 if (adrof(STRloginsh) == 0)
769 if (adrof(STRanyerror) == 0)
771 if (adrof(STRwordchars) == 0)
772 word_chars = STR_WORD_CHARS;
773 if (adrof(STRedit) == 0)
775 if (adrof(STRbackslash_quote) == 0)
777 if (adrof(STRcompat_expr) == 0)
779 if (adrof(STRsymlinks) == 0)
781 if (adrof(STRimplicitcd) == 0)
783 if (adrof(STRkillring) == 0)
785 if (did_edit && noediting && adrof(STRedit) == 0)
787 if (did_roe && adrof(STRrecognize_only_executables) == 0)
790 if (adrof(STRcolor) == 0)
792 #endif /* COLOR_LS_F */
793 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
794 update_dspmbyte_vars();
799 #endif /* NLS_CATALOGS */
803 unset1(Char *v[], struct varent *head)
810 while ((vp = madrof(*v, head)) != NULL)
811 if (vp->v_flags & VAR_READONLY)
812 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
816 setname(short2str(*v));
825 if ((vp = adrof1(var, &shvhed)) == 0)
831 unsetv1(struct varent *p)
833 struct varent *c, *pp;
837 * Free associated memory first to avoid complications.
842 * If p is missing one child, then we can move the other into where p is.
843 * Otherwise, we find the predecessor of p, which is guaranteed to have no
844 * right child, copy it into p, and move it's left child into it.
848 else if (p->v_left == 0)
851 for (c = p->v_left; c->v_right; c = c->v_right)
853 p->v_name = c->v_name;
854 p->v_flags = c->v_flags;
861 * Move c into where p is.
864 f = pp->v_right == p;
865 if ((pp->v_link[f] = c) != 0)
868 * Free the deleted node, and rebalance.
874 /* Set variable name to NULL. */
876 setNS(const Char *varName)
878 setcopy(varName, STRNULL, VAR_READWRITE);
883 shift(Char **v, struct command *c)
896 if (argv == NULL || argv->vec == NULL)
898 if (argv->vec[0] == 0)
899 stderror(ERR_NAME | ERR_NOMORE);
900 lshift(argv->vec, 1);
905 exportpath(Char **val)
907 struct Strbuf buf = Strbuf_INIT;
912 Strbuf_append(&buf, *val++);
913 if (*val == 0 || eq(*val, STRRparen))
915 Strbuf_append1(&buf, PATHSEP);
917 exppath = Strbuf_finish(&buf);
918 cleanup_push(exppath, xfree);
919 tsetenv(STRKPATH, exppath);
920 cleanup_until(exppath);
925 * Lint thinks these have null effect
927 /* macros to do single rotations on node p */
928 # define rright(p) (\
930 (t)->v_parent = (p)->v_parent,\
931 (((p)->v_left = t->v_right) != NULL) ?\
932 (t->v_right->v_parent = (p)) : 0,\
933 (t->v_right = (p))->v_parent = t,\
937 ((t)->v_parent = (p)->v_parent,\
938 ((p)->v_right = t->v_left) != NULL) ? \
939 (t->v_left->v_parent = (p)) : 0,\
940 (t->v_left = (p))->v_parent = t,\
943 static struct varent *
944 rleft(struct varent *p)
948 static struct varent *
949 rright(struct varent *p)
958 * Rebalance a tree, starting at p and up.
959 * F == 0 means we've come from p's left child.
960 * D == 1 means we've just done a delete, otherwise an insert.
963 balance(struct varent *p, int f, int d)
968 struct varent *t; /* used by the rotate macros */
972 ff = 0; /* Sun's lint is dumb! */
976 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
977 * is the branch of p from which we have come; ff is the branch of pp which
980 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
981 ff = pp->v_right == p;
982 if (f ^ d) { /* right heavy */
984 case -1: /* was left heavy */
987 case 0: /* was balanced */
990 case 1: /* was already right heavy */
991 switch (p->v_right->v_bal) {
992 case 1: /* single rotate */
993 pp->v_link[ff] = rleft(p);
994 p->v_left->v_bal = 0;
997 case 0: /* single rotate */
998 pp->v_link[ff] = rleft(p);
999 p->v_left->v_bal = 1;
1002 case -1: /* double rotate */
1003 (void) rright(p->v_right);
1004 pp->v_link[ff] = rleft(p);
1006 p->v_bal < 1 ? 0 : -1;
1008 p->v_bal > -1 ? 0 : 1;
1019 else { /* left heavy */
1021 case 1: /* was right heavy */
1024 case 0: /* was balanced */
1027 case -1: /* was already left heavy */
1028 switch (p->v_left->v_bal) {
1029 case -1: /* single rotate */
1030 pp->v_link[ff] = rright(p);
1031 p->v_right->v_bal = 0;
1034 case 0: /* single rotate */
1035 pp->v_link[ff] = rright(p);
1036 p->v_right->v_bal = -1;
1039 case 1: /* double rotate */
1040 (void) rleft(p->v_left);
1041 pp->v_link[ff] = rright(p);
1043 p->v_bal < 1 ? 0 : -1;
1045 p->v_bal > -1 ? 0 : 1;
1057 * If from insert, then we terminate when p is balanced. If from
1058 * delete, then we terminate when p is unbalanced.
1060 if ((p->v_bal == 0) ^ d)
1066 plist(struct varent *p, int what)
1075 if (p->v_parent == 0) /* is it the header? */
1077 if ((p->v_flags & what) != 0) {
1079 int old_pintr_disabled;
1081 pintr_push_enable(&old_pintr_disabled);
1082 cleanup_until(&old_pintr_disabled);
1084 len = blklen(p->vec);
1085 xprintf("%S\t", p->v_name);
1100 } while (p->v_right == c);
1106 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1107 extern int dspmbyte_ls;
1110 update_dspmbyte_vars(void)
1116 /* if variable "nokanji" is set, multi-byte display is disabled */
1117 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1120 if(eq (dstr1, STRsjis))
1122 else if (eq(dstr1, STReuc))
1124 else if (eq(dstr1, STRbig5))
1126 else if (eq(dstr1, STRutf8))
1128 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1132 xprintf(CGETS(18, 2,
1133 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1136 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1140 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1144 _cmap[lp] = _cmap_mbyte[lp];
1145 _mbmap[lp] = _mbmap_sjis[lp];
1149 _cmap[lp] = _cmap_mbyte[lp];
1150 _mbmap[lp] = _mbmap_euc[lp];
1154 _cmap[lp] = _cmap_mbyte[lp];
1155 _mbmap[lp] = _mbmap_big5[lp];
1159 _cmap[lp] = _cmap_mbyte[lp];
1160 _mbmap[lp] = _mbmap_utf8[lp];
1163 xprintf(CGETS(18, 3,
1164 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1166 _cmap[lp] = _cmap_c[lp];
1167 _mbmap[lp] = 0; /* Default map all 0 */
1173 /* check original table */
1174 if (Strlen(dstr1) != 256) {
1175 xprintf(CGETS(18, 4,
1176 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1180 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1181 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1182 xprintf(CGETS(18, 4,
1183 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1189 /* set original table */
1190 for (lp = 0; lp < 256; lp++) {
1191 if (_enable_mbdisp == 1) {
1192 _cmap[lp] = _cmap_mbyte[lp];
1193 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1196 _cmap[lp] = _cmap_c[lp];
1197 _mbmap[lp] = 0; /* Default map all 0 */
1203 for (lp = 0; lp < 256; lp++) {
1204 _cmap[lp] = _cmap_c[lp];
1205 _mbmap[lp] = 0; /* Default map all 0 */
1210 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1213 for (lp = 0; lp < 256; lp++)
1214 mbmapstr[lp] = _mbmap[lp] + '0';
1216 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1218 #endif /* MBYTEMAP */
1221 /* dspkanji/dspmbyte autosetting */
1222 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1224 autoset_dspmbyte(const Char *pcp)
1227 static const struct dspm_autoset_Table {
1231 { STRLANGEUCJP, STReuc },
1232 { STRLANGEUCKR, STReuc },
1233 { STRLANGEUCZH, STReuc },
1234 { STRLANGEUCJPB, STReuc },
1235 { STRLANGEUCKRB, STReuc },
1236 { STRLANGEUCZHB, STReuc },
1238 { STRLANGEUCJPC, STReuc },
1240 { STRLANGSJIS, STRsjis },
1241 { STRLANGSJISB, STRsjis },
1242 { STRLANGBIG5, STRbig5 },
1243 { STRstarutfstar8, STRutf8 },
1246 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1247 static const struct dspm_autoset_Table dspmc[] = {
1248 { STRstarutfstar8, STRutf8 },
1250 { STRGB2312, STReuc },
1251 { STRLANGBIG5, STRbig5 },
1256 codeset = str2short(nl_langinfo(CODESET));
1257 if (*codeset != '\0') {
1258 for (i = 0; dspmc[i].n; i++) {
1260 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1261 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1262 update_dspmbyte_vars();
1272 for (i = 0; dspmt[i].n; i++) {
1274 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1275 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1276 update_dspmbyte_vars();
1281 # elif defined(AUTOSET_KANJI)
1285 char *codeset = nl_langinfo(CODESET);
1287 if (*codeset == '\0') {
1288 if (adrof(STRnokanji) == NULL)
1293 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1294 if (adrof(STRnokanji) == NULL)
1299 if (adrof(STRnokanji) != NULL)