1 /* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.86 2014/10/28 18:40:46 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.86 2014/10/28 18:40:46 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)));
198 else if (eq(vp, STRhistory)) {
199 sethistory((int)getn(varval(vp)));
202 else if (eq(vp, STRwatch)) {
205 #endif /* HAVENOUTMP */
206 else if (eq(vp, STRimplicitcd)) {
207 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
209 else if (eq(vp, STRcdtohome)) {
213 else if (eq(vp, STRcolor)) {
216 #endif /* COLOR_LS_F */
217 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
218 else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
219 update_dspmbyte_vars();
223 else if (eq(vp, STRcatalog)) {
227 #if defined(FILEC) && defined(TIOCSTI)
228 else if (eq(vp, STRfilec))
231 #endif /* NLS_CATALOGS */
237 doset(Char **v, struct command *c)
244 int flags = VAR_READWRITE;
254 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
256 if (*v && eq(*v, STRmr)) {
257 flags = VAR_READONLY;
261 if (*v && eq(*v, STRmf) && !last_match) {
266 if (*v && eq(*v, STRml) && !first_match) {
274 plist(&shvhed, flags);
281 stderror(ERR_NAME | ERR_VARBEGIN);
287 p = getinx(p, &subscr);
289 if (*p != '\0' && *p != '=')
290 stderror(ERR_NAME | ERR_VARALNUM);
293 if (*p == '\0' && *v != NULL && **v == '(')
296 else if (*v && eq(*v, STRequal)) {
300 if (eq(p, STRLparen)) {
304 stderror(ERR_NAME | ERR_SYNTAX);
307 stderror(ERR_NAME | ERR_MISSING, ')');
320 set1(vp, vecp, &shvhed, flags);
328 cleanup_push(copy, xfree);
329 asx(vp, subscr, copy);
330 cleanup_ignore(copy);
334 setv(vp, Strsave(p), flags);
336 } while ((p = *v++) != NULL);
340 getinx(Char *cp, int *ip)
344 while (*cp && Isdigit(*cp))
345 *ip = *ip * 10 + *cp++ - '0';
347 stderror(ERR_NAME | ERR_SUBSCRIPT);
352 asx(Char *vp, int subscr, Char *p)
354 struct varent *v = getvx(vp, subscr);
357 if (v->v_flags & VAR_READONLY)
358 stderror(ERR_READONLY|ERR_NAME, v->v_name);
359 prev = v->vec[subscr - 1];
360 cleanup_push(prev, xfree);
361 v->vec[subscr - 1] = globone(p, G_APPEND);
365 static struct varent *
366 getvx(Char *vp, int subscr)
368 struct varent *v = adrof(vp);
372 if (subscr < 1 || subscr > blklen(v->vec))
373 stderror(ERR_NAME | ERR_RANGE);
379 dolet(Char **v, struct command *dummy)
397 for (; alnum(*p); p++)
399 if (vp == p || !letter(*vp))
400 stderror(ERR_NAME | ERR_VARBEGIN);
403 p = getinx(p, &subscr);
410 stderror(ERR_NAME | ERR_ASSIGN);
413 * if there is no expression after the '=' then print a "Syntax Error"
416 if (*p == '\0' && *v == NULL)
417 stderror(ERR_NAME | ERR_ASSIGN);
420 cleanup_push(vp, xfree);
429 stderror(ERR_NAME | ERR_UNKNOWNOP);
435 stderror(ERR_NAME | ERR_UNKNOWNOP);
436 stderror(ERR_NAME | ERR_SYNTAX);
439 stderror(ERR_NAME | ERR_UNKNOWNOP);
443 cleanup_push(p, xfree);
448 setv(vp, p, VAR_READWRITE);
452 struct varent *gv = getvx(vp, subscr);
455 val = operate(op, gv->vec[subscr - 1], p);
456 cleanup_push(val, xfree);
457 asx(vp, subscr, val);
464 val = operate(op, varval(vp), p);
465 cleanup_push(val, xfree);
466 setv(vp, val, VAR_READWRITE);
472 } while ((p = *v++) != NULL);
476 xset(Char *cp, Char ***vp)
486 return (putn(expr(vp)));
490 operate(int op, Char *vp, Char *p)
504 if (op == '<' || op == '>')
511 stderror(ERR_NAME | ERR_EXPRESSION);
518 putn(tcsh_number_t n)
520 Char nbuf[1024]; /* Enough even for octal */
529 return (Strsave(nbuf));
533 putn1(tcsh_number_t n)
537 *putp++ = (Char)(n % 10 + '0');
547 if (!cp) /* PWP: extra error checking */
548 stderror(ERR_NAME | ERR_BADNUM);
551 if (cp[0] == '+' && cp[1])
557 stderror(ERR_NAME | ERR_BADNUM);
560 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
568 if (base == 8 && *cp >= '8')
569 stderror(ERR_NAME | ERR_BADNUM);
570 n = n * base + *cp++ - '0';
573 stderror(ERR_NAME | ERR_BADNUM);
574 return (sign ? -n : n);
578 value1(Char *var, struct varent *head)
582 if (!var || !head) /* PWP: extra error checking */
585 vp = adrof1(var, head);
586 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
587 STRNULL : vp->vec[0]);
590 static struct varent *
591 madrof(Char *pat, struct varent *vp)
595 for (vp = vp->v_left; vp; vp = vp->v_right) {
596 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
598 if (Gmatch(vp->v_name, pat))
605 adrof1(const Char *name, struct varent *v)
610 while (v && ((cmp = *name - *v->v_name) != 0 ||
611 (cmp = Strcmp(name, v->v_name)) != 0))
620 setcopy(const Char *var, const Char *val, int flags)
625 cleanup_push(copy, xfree);
626 setv(var, copy, flags);
627 cleanup_ignore(copy);
632 * The caller is responsible for putting value in a safe place
635 setv(const Char *var, Char *val, int flags)
637 Char **vec = xmalloc(2 * sizeof(Char **));
641 set1(var, vec, &shvhed, flags);
645 set1(const Char *var, Char **vec, struct varent *head, int flags)
649 if ((flags & VAR_NOGLOB) == 0) {
654 vec = globall(oldv, gflag);
657 stderror(ERR_NAME | ERR_NOMATCH);
663 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
665 if ( flags & (VAR_FIRST | VAR_LAST) ) {
667 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
669 * Delete all duplicate words leaving "holes" in the word array (vec).
670 * Then remove the "holes", keeping the order of the words unchanged.
672 if (vec && vec[0] && vec[1]) { /* more than one word ? */
676 for (num_items = 0; vec[num_items]; num_items++)
678 if (flags & VAR_FIRST) {
679 /* delete duplications, keeping first occurance */
680 for (i = 1; i < num_items; i++)
681 for (j = 0; j < i; j++)
682 /* If have earlier identical item, remove i'th item */
683 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
688 } else if (flags & VAR_LAST) {
689 /* delete duplications, keeping last occurance */
690 for (i = 0; i < num_items - 1; i++)
691 for (j = i + 1; j < num_items; j++)
692 /* If have later identical item, remove i'th item */
693 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
694 /* remove identical item (the first) */
699 /* Compress items - remove empty items */
700 for (j = i = 0; i < num_items; i++)
704 /* NULL-fy remaining items */
705 for (; j < num_items; j++)
708 /* don't let the attribute propagate */
709 flags &= ~(VAR_FIRST|VAR_LAST);
711 setq(var, vec, head, flags);
716 setq(const Char *name, Char **vec, struct varent *p, int flags)
721 f = 0; /* tree hangs off the header's left link */
722 while ((c = p->v_link[f]) != 0) {
723 if ((f = *name - *c->v_name) == 0 &&
724 (f = Strcmp(name, c->v_name)) == 0) {
725 if (c->v_flags & VAR_READONLY)
726 stderror(ERR_READONLY|ERR_NAME, c->v_name);
735 p->v_link[f] = c = xmalloc(sizeof(struct varent));
736 c->v_name = Strsave(name);
739 c->v_left = c->v_right = 0;
747 unset(Char **v, struct command *c)
749 int did_roe, did_edit;
752 did_roe = adrof(STRrecognize_only_executables) != NULL;
753 did_edit = adrof(STRedit) != NULL;
756 #if defined(FILEC) && defined(TIOCSTI)
757 if (adrof(STRfilec) == 0)
759 #endif /* FILEC && TIOCSTI */
761 if (adrof(STRhistchars) == 0) {
765 if (adrof(STRignoreeof) == 0)
767 if (adrof(STRpromptchars) == 0) {
768 PRCH = tcsh ? '>' : '%';
771 if (adrof(STRhistlit) == 0)
773 if (adrof(STRloginsh) == 0)
775 if (adrof(STRanyerror) == 0)
777 if (adrof(STRwordchars) == 0)
778 word_chars = STR_WORD_CHARS;
779 if (adrof(STRedit) == 0)
781 if (adrof(STRbackslash_quote) == 0)
783 if (adrof(STRcompat_expr) == 0)
785 if (adrof(STRsymlinks) == 0)
787 if (adrof(STRimplicitcd) == 0)
789 if (adrof(STRcdtohome) == 0)
791 if (adrof(STRkillring) == 0)
793 if (did_edit && noediting && adrof(STRedit) == 0)
795 if (did_roe && adrof(STRrecognize_only_executables) == 0)
797 if (adrof(STRhistory) == 0)
800 if (adrof(STRcolor) == 0)
802 #endif /* COLOR_LS_F */
803 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
804 update_dspmbyte_vars();
809 #endif /* NLS_CATALOGS */
813 unset1(Char *v[], struct varent *head)
820 while ((vp = madrof(*v, head)) != NULL)
821 if (vp->v_flags & VAR_READONLY)
822 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
826 setname(short2str(*v));
835 if ((vp = adrof1(var, &shvhed)) == 0)
841 unsetv1(struct varent *p)
843 struct varent *c, *pp;
847 * Free associated memory first to avoid complications.
852 * If p is missing one child, then we can move the other into where p is.
853 * Otherwise, we find the predecessor of p, which is guaranteed to have no
854 * right child, copy it into p, and move it's left child into it.
858 else if (p->v_left == 0)
861 for (c = p->v_left; c->v_right; c = c->v_right)
863 p->v_name = c->v_name;
864 p->v_flags = c->v_flags;
871 * Move c into where p is.
874 f = pp->v_right == p;
875 if ((pp->v_link[f] = c) != 0)
878 * Free the deleted node, and rebalance.
884 /* Set variable name to NULL. */
886 setNS(const Char *varName)
888 setcopy(varName, STRNULL, VAR_READWRITE);
893 shift(Char **v, struct command *c)
906 if (argv == NULL || argv->vec == NULL)
908 if (argv->vec[0] == 0)
909 stderror(ERR_NAME | ERR_NOMORE);
910 lshift(argv->vec, 1);
915 exportpath(Char **val)
917 struct Strbuf buf = Strbuf_INIT;
922 Strbuf_append(&buf, *val++);
923 if (*val == 0 || eq(*val, STRRparen))
925 Strbuf_append1(&buf, PATHSEP);
927 exppath = Strbuf_finish(&buf);
928 cleanup_push(exppath, xfree);
929 tsetenv(STRKPATH, exppath);
930 cleanup_until(exppath);
935 * Lint thinks these have null effect
937 /* macros to do single rotations on node p */
938 # define rright(p) (\
940 (t)->v_parent = (p)->v_parent,\
941 (((p)->v_left = t->v_right) != NULL) ?\
942 (t->v_right->v_parent = (p)) : 0,\
943 (t->v_right = (p))->v_parent = t,\
947 ((t)->v_parent = (p)->v_parent,\
948 ((p)->v_right = t->v_left) != NULL) ? \
949 (t->v_left->v_parent = (p)) : 0,\
950 (t->v_left = (p))->v_parent = t,\
953 static struct varent *
954 rleft(struct varent *p)
958 static struct varent *
959 rright(struct varent *p)
968 * Rebalance a tree, starting at p and up.
969 * F == 0 means we've come from p's left child.
970 * D == 1 means we've just done a delete, otherwise an insert.
973 balance(struct varent *p, int f, int d)
978 struct varent *t; /* used by the rotate macros */
982 ff = 0; /* Sun's lint is dumb! */
986 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
987 * is the branch of p from which we have come; ff is the branch of pp which
990 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
991 ff = pp->v_right == p;
992 if (f ^ d) { /* right heavy */
994 case -1: /* was left heavy */
997 case 0: /* was balanced */
1000 case 1: /* was already right heavy */
1001 switch (p->v_right->v_bal) {
1002 case 1: /* single rotate */
1003 pp->v_link[ff] = rleft(p);
1004 p->v_left->v_bal = 0;
1007 case 0: /* single rotate */
1008 pp->v_link[ff] = rleft(p);
1009 p->v_left->v_bal = 1;
1012 case -1: /* double rotate */
1013 (void) rright(p->v_right);
1014 pp->v_link[ff] = rleft(p);
1016 p->v_bal < 1 ? 0 : -1;
1018 p->v_bal > -1 ? 0 : 1;
1029 else { /* left heavy */
1031 case 1: /* was right heavy */
1034 case 0: /* was balanced */
1037 case -1: /* was already left heavy */
1038 switch (p->v_left->v_bal) {
1039 case -1: /* single rotate */
1040 pp->v_link[ff] = rright(p);
1041 p->v_right->v_bal = 0;
1044 case 0: /* single rotate */
1045 pp->v_link[ff] = rright(p);
1046 p->v_right->v_bal = -1;
1049 case 1: /* double rotate */
1050 (void) rleft(p->v_left);
1051 pp->v_link[ff] = rright(p);
1053 p->v_bal < 1 ? 0 : -1;
1055 p->v_bal > -1 ? 0 : 1;
1067 * If from insert, then we terminate when p is balanced. If from
1068 * delete, then we terminate when p is unbalanced.
1070 if ((p->v_bal == 0) ^ d)
1076 plist(struct varent *p, int what)
1085 if (p->v_parent == 0) /* is it the header? */
1087 if ((p->v_flags & what) != 0) {
1089 int old_pintr_disabled;
1091 pintr_push_enable(&old_pintr_disabled);
1092 cleanup_until(&old_pintr_disabled);
1094 len = blklen(p->vec);
1095 xprintf("%S\t", p->v_name);
1110 } while (p->v_right == c);
1116 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1117 extern int dspmbyte_ls;
1120 update_dspmbyte_vars(void)
1126 /* if variable "nokanji" is set, multi-byte display is disabled */
1127 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1130 if(eq (dstr1, STRsjis))
1132 else if (eq(dstr1, STReuc))
1134 else if (eq(dstr1, STRbig5))
1136 else if (eq(dstr1, STRutf8))
1138 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1142 xprintf(CGETS(18, 2,
1143 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1146 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1150 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1154 _cmap[lp] = _cmap_mbyte[lp];
1155 _mbmap[lp] = _mbmap_sjis[lp];
1159 _cmap[lp] = _cmap_mbyte[lp];
1160 _mbmap[lp] = _mbmap_euc[lp];
1164 _cmap[lp] = _cmap_mbyte[lp];
1165 _mbmap[lp] = _mbmap_big5[lp];
1169 _cmap[lp] = _cmap_mbyte[lp];
1170 _mbmap[lp] = _mbmap_utf8[lp];
1173 xprintf(CGETS(18, 3,
1174 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1176 _cmap[lp] = _cmap_c[lp];
1177 _mbmap[lp] = 0; /* Default map all 0 */
1183 /* check original table */
1184 if (Strlen(dstr1) != 256) {
1185 xprintf(CGETS(18, 4,
1186 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1190 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1191 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1192 xprintf(CGETS(18, 4,
1193 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1199 /* set original table */
1200 for (lp = 0; lp < 256; lp++) {
1201 if (_enable_mbdisp == 1) {
1202 _cmap[lp] = _cmap_mbyte[lp];
1203 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1206 _cmap[lp] = _cmap_c[lp];
1207 _mbmap[lp] = 0; /* Default map all 0 */
1213 for (lp = 0; lp < 256; lp++) {
1214 _cmap[lp] = _cmap_c[lp];
1215 _mbmap[lp] = 0; /* Default map all 0 */
1220 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1223 for (lp = 0; lp < 256; lp++)
1224 mbmapstr[lp] = _mbmap[lp] + '0';
1226 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1228 #endif /* MBYTEMAP */
1231 /* dspkanji/dspmbyte autosetting */
1232 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1234 autoset_dspmbyte(const Char *pcp)
1237 static const struct dspm_autoset_Table {
1241 { STRLANGEUCJP, STReuc },
1242 { STRLANGEUCKR, STReuc },
1243 { STRLANGEUCZH, STReuc },
1244 { STRLANGEUCJPB, STReuc },
1245 { STRLANGEUCKRB, STReuc },
1246 { STRLANGEUCZHB, STReuc },
1248 { STRLANGEUCJPC, STReuc },
1250 { STRLANGSJIS, STRsjis },
1251 { STRLANGSJISB, STRsjis },
1252 { STRLANGBIG5, STRbig5 },
1253 { STRstarutfstar8, STRutf8 },
1256 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1257 static const struct dspm_autoset_Table dspmc[] = {
1258 { STRstarutfstar8, STRutf8 },
1260 { STRGB2312, STReuc },
1261 { STRLANGBIG5, STRbig5 },
1266 codeset = str2short(nl_langinfo(CODESET));
1267 if (*codeset != '\0') {
1268 for (i = 0; dspmc[i].n; i++) {
1270 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1271 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1272 update_dspmbyte_vars();
1282 for (i = 0; dspmt[i].n; i++) {
1284 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1285 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1286 update_dspmbyte_vars();
1291 # elif defined(AUTOSET_KANJI)
1295 char *codeset = nl_langinfo(CODESET);
1297 if (*codeset == '\0') {
1298 if (adrof(STRnokanji) == NULL)
1303 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1304 if (adrof(STRnokanji) == NULL)
1309 if (adrof(STRnokanji) != NULL)