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 balance (struct varent *, int, int);
65 if (eq(vp, STRpath)) {
66 struct varent *p = adrof(STRpath);
68 stderror(ERR_NAME | ERR_UNDVAR);
74 else if (eq(vp, STRhistchars)) {
75 Char *pn = varval(vp);
83 else if (eq(vp, STRpromptchars)) {
84 Char *pn = varval(vp);
92 else if (eq(vp, STRhistlit)) {
95 else if (eq(vp, STRuser)) {
96 tsetenv(STRKUSER, varval(vp));
97 tsetenv(STRLOGNAME, varval(vp));
99 else if (eq(vp, STRgroup)) {
100 tsetenv(STRKGROUP, varval(vp));
102 else if (eq(vp, STRwordchars)) {
103 word_chars = varval(vp);
105 else if (eq(vp, STRloginsh)) {
108 else if (eq(vp, STRanyerror)) {
111 else if (eq(vp, STRsymlinks)) {
112 Char *pn = varval(vp);
114 if (eq(pn, STRignore))
115 symlinks = SYM_IGNORE;
116 else if (eq(pn, STRexpand))
117 symlinks = SYM_EXPAND;
118 else if (eq(pn, STRchase))
119 symlinks = SYM_CHASE;
123 else if (eq(vp, STRterm)) {
124 Char *cp = varval(vp);
125 tsetenv(STRKTERM, cp);
126 #ifdef DOESNT_WORK_RIGHT
127 cp = getenv("TERMCAP");
128 if (cp && (*cp != '/')) /* if TERMCAP and not a path */
129 Unsetenv(STRTERMCAP);
130 #endif /* DOESNT_WORK_RIGHT */
132 if (noediting && Strcmp(cp, STRnetwork) != 0 &&
133 Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
138 ed_Init(); /* reset the editor */
140 else if (eq(vp, STRhome)) {
143 cp = Strsave(varval(vp)); /* get the old value back */
144 cleanup_push(cp, xfree);
147 * convert to cononical pathname (possibly resolving symlinks)
149 canon = dcanon(cp, cp);
152 cleanup_push(canon, xfree);
154 setcopy(vp, canon, VAR_READWRITE); /* have to save the new val */
156 /* and now mirror home with HOME */
157 tsetenv(STRKHOME, canon);
158 /* fix directory stack for new tilde home */
160 cleanup_until(canon);
162 else if (eq(vp, STRedit)) {
165 /* PWP: add more stuff in here later */
167 else if (eq(vp, STRshlvl)) {
168 tsetenv(STRKSHLVL, varval(vp));
170 else if (eq(vp, STRignoreeof)) {
173 for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
178 numeof = numeof * 10 + *cp - '0';
180 if (numeof <= 0) numeof = 26; /* Sanity check */
182 else if (eq(vp, STRbackslash_quote)) {
185 else if (eq(vp, STRcompat_expr)) {
188 else if (eq(vp, STRdirstack)) {
191 else if (eq(vp, STRrecognize_only_executables)) {
194 else if (eq(vp, STRkillring)) {
195 SetKillRing((int)getn(varval(vp)));
198 else if (eq(vp, STRwatch)) {
201 #endif /* HAVENOUTMP */
202 else if (eq(vp, STRimplicitcd)) {
203 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
206 else if (eq(vp, STRcolor)) {
209 #endif /* COLOR_LS_F */
210 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
211 else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
212 update_dspmbyte_vars();
216 else if (eq(vp, STRcatalog)) {
220 #if defined(FILEC) && defined(TIOCSTI)
221 else if (eq(vp, STRfilec))
224 #endif /* NLS_CATALOGS */
230 doset(Char **v, struct command *c)
237 int flags = VAR_READWRITE;
247 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
249 if (*v && eq(*v, STRmr)) {
250 flags = VAR_READONLY;
254 if (*v && eq(*v, STRmf) && !last_match) {
259 if (*v && eq(*v, STRml) && !first_match) {
267 plist(&shvhed, flags);
274 stderror(ERR_NAME | ERR_VARBEGIN);
280 p = getinx(p, &subscr);
282 if (*p != '\0' && *p != '=')
283 stderror(ERR_NAME | ERR_VARALNUM);
286 if (*p == '\0' && *v != NULL && **v == '(')
289 else if (*v && eq(*v, STRequal)) {
293 if (eq(p, STRLparen)) {
297 stderror(ERR_NAME | ERR_SYNTAX);
300 stderror(ERR_NAME | ERR_MISSING, ')');
313 set1(vp, vecp, &shvhed, flags);
321 cleanup_push(copy, xfree);
322 asx(vp, subscr, copy);
323 cleanup_ignore(copy);
327 setv(vp, Strsave(p), flags);
329 } while ((p = *v++) != NULL);
333 getinx(Char *cp, int *ip)
337 while (*cp && Isdigit(*cp))
338 *ip = *ip * 10 + *cp++ - '0';
340 stderror(ERR_NAME | ERR_SUBSCRIPT);
345 asx(Char *vp, int subscr, Char *p)
347 struct varent *v = getvx(vp, subscr);
350 if (v->v_flags & VAR_READONLY)
351 stderror(ERR_READONLY|ERR_NAME, v->v_name);
352 prev = v->vec[subscr - 1];
353 cleanup_push(prev, xfree);
354 v->vec[subscr - 1] = globone(p, G_APPEND);
358 static struct varent *
359 getvx(Char *vp, int subscr)
361 struct varent *v = adrof(vp);
365 if (subscr < 1 || subscr > blklen(v->vec))
366 stderror(ERR_NAME | ERR_RANGE);
372 dolet(Char **v, struct command *dummy)
390 for (; alnum(*p); p++)
392 if (vp == p || !letter(*vp))
393 stderror(ERR_NAME | ERR_VARBEGIN);
396 p = getinx(p, &subscr);
403 stderror(ERR_NAME | ERR_ASSIGN);
406 * if there is no expression after the '=' then print a "Syntax Error"
409 if (*p == '\0' && *v == NULL)
410 stderror(ERR_NAME | ERR_ASSIGN);
413 cleanup_push(vp, xfree);
422 stderror(ERR_NAME | ERR_UNKNOWNOP);
428 stderror(ERR_NAME | ERR_UNKNOWNOP);
429 stderror(ERR_NAME | ERR_SYNTAX);
432 stderror(ERR_NAME | ERR_UNKNOWNOP);
436 cleanup_push(p, xfree);
441 setv(vp, p, VAR_READWRITE);
445 struct varent *gv = getvx(vp, subscr);
448 val = operate(op, gv->vec[subscr - 1], p);
449 cleanup_push(val, xfree);
450 asx(vp, subscr, val);
457 val = operate(op, varval(vp), p);
458 cleanup_push(val, xfree);
459 setv(vp, val, VAR_READWRITE);
465 } while ((p = *v++) != NULL);
469 xset(Char *cp, Char ***vp)
479 return (putn(expr(vp)));
483 operate(int op, Char *vp, Char *p)
497 if (op == '<' || op == '>')
504 stderror(ERR_NAME | ERR_EXPRESSION);
511 putn(tcsh_number_t n)
513 Char nbuf[1024]; /* Enough even for octal */
522 return (Strsave(nbuf));
526 putn1(tcsh_number_t n)
530 *putp++ = (Char)(n % 10 + '0');
540 if (!cp) /* PWP: extra error checking */
541 stderror(ERR_NAME | ERR_BADNUM);
544 if (cp[0] == '+' && cp[1])
550 stderror(ERR_NAME | ERR_BADNUM);
553 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
561 if (base == 8 && *cp >= '8')
562 stderror(ERR_NAME | ERR_BADNUM);
563 n = n * base + *cp++ - '0';
566 stderror(ERR_NAME | ERR_BADNUM);
567 return (sign ? -n : n);
571 value1(Char *var, struct varent *head)
575 if (!var || !head) /* PWP: extra error checking */
578 vp = adrof1(var, head);
579 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
580 STRNULL : vp->vec[0]);
583 static struct varent *
584 madrof(Char *pat, struct varent *vp)
588 for (vp = vp->v_left; vp; vp = vp->v_right) {
589 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
591 if (Gmatch(vp->v_name, pat))
598 adrof1(const Char *name, struct varent *v)
603 while (v && ((cmp = *name - *v->v_name) != 0 ||
604 (cmp = Strcmp(name, v->v_name)) != 0))
613 setcopy(const Char *var, const Char *val, int flags)
618 cleanup_push(copy, xfree);
619 setv(var, copy, flags);
620 cleanup_ignore(copy);
625 * The caller is responsible for putting value in a safe place
628 setv(const Char *var, Char *val, int flags)
630 Char **vec = xmalloc(2 * sizeof(Char **));
634 set1(var, vec, &shvhed, flags);
638 set1(const Char *var, Char **vec, struct varent *head, int flags)
642 if ((flags & VAR_NOGLOB) == 0) {
647 vec = globall(oldv, gflag);
650 stderror(ERR_NAME | ERR_NOMATCH);
656 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
658 if ( flags & (VAR_FIRST | VAR_LAST) ) {
660 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
662 * Delete all duplicate words leaving "holes" in the word array (vec).
663 * Then remove the "holes", keeping the order of the words unchanged.
665 if (vec && vec[0] && vec[1]) { /* more than one word ? */
669 for (num_items = 0; vec[num_items]; num_items++)
671 if (flags & VAR_FIRST) {
672 /* delete duplications, keeping first occurance */
673 for (i = 1; i < num_items; i++)
674 for (j = 0; j < i; j++)
675 /* If have earlier identical item, remove i'th item */
676 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
681 } else if (flags & VAR_LAST) {
682 /* delete duplications, keeping last occurance */
683 for (i = 0; i < num_items - 1; i++)
684 for (j = i + 1; j < num_items; j++)
685 /* If have later identical item, remove i'th item */
686 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
687 /* remove identical item (the first) */
692 /* Compress items - remove empty items */
693 for (j = i = 0; i < num_items; i++)
697 /* NULL-fy remaining items */
698 for (; j < num_items; j++)
701 /* don't let the attribute propagate */
702 flags &= ~(VAR_FIRST|VAR_LAST);
704 setq(var, vec, head, flags);
709 setq(const Char *name, Char **vec, struct varent *p, int flags)
714 f = 0; /* tree hangs off the header's left link */
715 while ((c = p->v_link[f]) != 0) {
716 if ((f = *name - *c->v_name) == 0 &&
717 (f = Strcmp(name, c->v_name)) == 0) {
718 if (c->v_flags & VAR_READONLY)
719 stderror(ERR_READONLY|ERR_NAME, c->v_name);
728 p->v_link[f] = c = xmalloc(sizeof(struct varent));
729 c->v_name = Strsave(name);
732 c->v_left = c->v_right = 0;
740 unset(Char **v, struct command *c)
742 int did_roe, did_edit;
745 did_roe = adrof(STRrecognize_only_executables) != NULL;
746 did_edit = adrof(STRedit) != NULL;
749 #if defined(FILEC) && defined(TIOCSTI)
750 if (adrof(STRfilec) == 0)
752 #endif /* FILEC && TIOCSTI */
754 if (adrof(STRhistchars) == 0) {
758 if (adrof(STRignoreeof) == 0)
760 if (adrof(STRpromptchars) == 0) {
761 PRCH = tcsh ? '>' : '%';
764 if (adrof(STRhistlit) == 0)
766 if (adrof(STRloginsh) == 0)
768 if (adrof(STRanyerror) == 0)
770 if (adrof(STRwordchars) == 0)
771 word_chars = STR_WORD_CHARS;
772 if (adrof(STRedit) == 0)
774 if (adrof(STRbackslash_quote) == 0)
776 if (adrof(STRcompat_expr) == 0)
778 if (adrof(STRsymlinks) == 0)
780 if (adrof(STRimplicitcd) == 0)
782 if (adrof(STRkillring) == 0)
784 if (did_edit && noediting && adrof(STRedit) == 0)
786 if (did_roe && adrof(STRrecognize_only_executables) == 0)
789 if (adrof(STRcolor) == 0)
791 #endif /* COLOR_LS_F */
792 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
793 update_dspmbyte_vars();
798 #endif /* NLS_CATALOGS */
802 unset1(Char *v[], struct varent *head)
809 while ((vp = madrof(*v, head)) != NULL)
810 if (vp->v_flags & VAR_READONLY)
811 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
815 setname(short2str(*v));
824 if ((vp = adrof1(var, &shvhed)) == 0)
830 unsetv1(struct varent *p)
832 struct varent *c, *pp;
836 * Free associated memory first to avoid complications.
841 * If p is missing one child, then we can move the other into where p is.
842 * Otherwise, we find the predecessor of p, which is guaranteed to have no
843 * right child, copy it into p, and move it's left child into it.
847 else if (p->v_left == 0)
850 for (c = p->v_left; c->v_right; c = c->v_right)
852 p->v_name = c->v_name;
853 p->v_flags = c->v_flags;
860 * Move c into where p is.
863 f = pp->v_right == p;
864 if ((pp->v_link[f] = c) != 0)
867 * Free the deleted node, and rebalance.
873 /* Set variable name to NULL. */
875 setNS(const Char *varName)
877 setcopy(varName, STRNULL, VAR_READWRITE);
882 shift(Char **v, struct command *c)
895 if (argv == NULL || argv->vec == NULL)
897 if (argv->vec[0] == 0)
898 stderror(ERR_NAME | ERR_NOMORE);
899 lshift(argv->vec, 1);
904 exportpath(Char **val)
906 struct Strbuf buf = Strbuf_INIT;
911 Strbuf_append(&buf, *val++);
912 if (*val == 0 || eq(*val, STRRparen))
914 Strbuf_append1(&buf, PATHSEP);
916 exppath = Strbuf_finish(&buf);
917 cleanup_push(exppath, xfree);
918 tsetenv(STRKPATH, exppath);
919 cleanup_until(exppath);
924 * Lint thinks these have null effect
926 /* macros to do single rotations on node p */
927 # define rright(p) (\
929 (t)->v_parent = (p)->v_parent,\
930 (((p)->v_left = t->v_right) != NULL) ?\
931 (t->v_right->v_parent = (p)) : 0,\
932 (t->v_right = (p))->v_parent = t,\
936 ((t)->v_parent = (p)->v_parent,\
937 ((p)->v_right = t->v_left) != NULL) ? \
938 (t->v_left->v_parent = (p)) : 0,\
939 (t->v_left = (p))->v_parent = t,\
942 static struct varent *
943 rleft(struct varent *p)
947 static struct varent *
948 rright(struct varent *p)
957 * Rebalance a tree, starting at p and up.
958 * F == 0 means we've come from p's left child.
959 * D == 1 means we've just done a delete, otherwise an insert.
962 balance(struct varent *p, int f, int d)
967 struct varent *t; /* used by the rotate macros */
971 ff = 0; /* Sun's lint is dumb! */
975 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
976 * is the branch of p from which we have come; ff is the branch of pp which
979 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
980 ff = pp->v_right == p;
981 if (f ^ d) { /* right heavy */
983 case -1: /* was left heavy */
986 case 0: /* was balanced */
989 case 1: /* was already right heavy */
990 switch (p->v_right->v_bal) {
991 case 1: /* single rotate */
992 pp->v_link[ff] = rleft(p);
993 p->v_left->v_bal = 0;
996 case 0: /* single rotate */
997 pp->v_link[ff] = rleft(p);
998 p->v_left->v_bal = 1;
1001 case -1: /* double rotate */
1002 (void) rright(p->v_right);
1003 pp->v_link[ff] = rleft(p);
1005 p->v_bal < 1 ? 0 : -1;
1007 p->v_bal > -1 ? 0 : 1;
1018 else { /* left heavy */
1020 case 1: /* was right heavy */
1023 case 0: /* was balanced */
1026 case -1: /* was already left heavy */
1027 switch (p->v_left->v_bal) {
1028 case -1: /* single rotate */
1029 pp->v_link[ff] = rright(p);
1030 p->v_right->v_bal = 0;
1033 case 0: /* single rotate */
1034 pp->v_link[ff] = rright(p);
1035 p->v_right->v_bal = -1;
1038 case 1: /* double rotate */
1039 (void) rleft(p->v_left);
1040 pp->v_link[ff] = rright(p);
1042 p->v_bal < 1 ? 0 : -1;
1044 p->v_bal > -1 ? 0 : 1;
1056 * If from insert, then we terminate when p is balanced. If from
1057 * delete, then we terminate when p is unbalanced.
1059 if ((p->v_bal == 0) ^ d)
1065 plist(struct varent *p, int what)
1074 if (p->v_parent == 0) /* is it the header? */
1076 if ((p->v_flags & what) != 0) {
1078 int old_pintr_disabled;
1080 pintr_push_enable(&old_pintr_disabled);
1081 cleanup_until(&old_pintr_disabled);
1083 len = blklen(p->vec);
1084 xprintf("%S\t", p->v_name);
1099 } while (p->v_right == c);
1105 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1106 extern int dspmbyte_ls;
1109 update_dspmbyte_vars(void)
1115 /* if variable "nokanji" is set, multi-byte display is disabled */
1116 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1119 if(eq (dstr1, STRsjis))
1121 else if (eq(dstr1, STReuc))
1123 else if (eq(dstr1, STRbig5))
1125 else if (eq(dstr1, STRutf8))
1127 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1131 xprintf(CGETS(18, 2,
1132 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1135 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1139 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1143 _cmap[lp] = _cmap_mbyte[lp];
1144 _mbmap[lp] = _mbmap_sjis[lp];
1148 _cmap[lp] = _cmap_mbyte[lp];
1149 _mbmap[lp] = _mbmap_euc[lp];
1153 _cmap[lp] = _cmap_mbyte[lp];
1154 _mbmap[lp] = _mbmap_big5[lp];
1158 _cmap[lp] = _cmap_mbyte[lp];
1159 _mbmap[lp] = _mbmap_utf8[lp];
1162 xprintf(CGETS(18, 3,
1163 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1165 _cmap[lp] = _cmap_c[lp];
1166 _mbmap[lp] = 0; /* Default map all 0 */
1172 /* check original table */
1173 if (Strlen(dstr1) != 256) {
1174 xprintf(CGETS(18, 4,
1175 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1179 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1180 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1181 xprintf(CGETS(18, 4,
1182 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1188 /* set original table */
1189 for (lp = 0; lp < 256; lp++) {
1190 if (_enable_mbdisp == 1) {
1191 _cmap[lp] = _cmap_mbyte[lp];
1192 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1195 _cmap[lp] = _cmap_c[lp];
1196 _mbmap[lp] = 0; /* Default map all 0 */
1202 for (lp = 0; lp < 256; lp++) {
1203 _cmap[lp] = _cmap_c[lp];
1204 _mbmap[lp] = 0; /* Default map all 0 */
1209 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1212 for (lp = 0; lp < 256; lp++)
1213 mbmapstr[lp] = _mbmap[lp] + '0';
1215 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1217 #endif /* MBYTEMAP */
1220 /* dspkanji/dspmbyte autosetting */
1221 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1223 autoset_dspmbyte(const Char *pcp)
1226 static const struct dspm_autoset_Table {
1230 { STRLANGEUCJP, STReuc },
1231 { STRLANGEUCKR, STReuc },
1232 { STRLANGEUCZH, STReuc },
1233 { STRLANGEUCJPB, STReuc },
1234 { STRLANGEUCKRB, STReuc },
1235 { STRLANGEUCZHB, STReuc },
1237 { STRLANGEUCJPC, STReuc },
1239 { STRLANGSJIS, STRsjis },
1240 { STRLANGSJISB, STRsjis },
1241 { STRLANGBIG5, STRbig5 },
1242 { STRstarutfstar8, STRutf8 },
1245 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1246 static const struct dspm_autoset_Table dspmc[] = {
1247 { STRstarutfstar8, STRutf8 },
1249 { STRGB2312, STReuc },
1250 { STRLANGBIG5, STRbig5 },
1255 codeset = str2short(nl_langinfo(CODESET));
1256 if (*codeset != '\0') {
1257 for (i = 0; dspmc[i].n; i++) {
1259 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1260 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1261 update_dspmbyte_vars();
1271 for (i = 0; dspmt[i].n; i++) {
1273 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1274 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1275 update_dspmbyte_vars();
1280 # elif defined(AUTOSET_KANJI)
1284 char *codeset = nl_langinfo(CODESET);
1286 if (*codeset == '\0') {
1287 if (adrof(STRnokanji) == NULL)
1292 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1293 if (adrof(STRnokanji) == NULL)
1298 if (adrof(STRnokanji) != NULL)