2 * sh.set.c: Setting and Clearing of variables
5 * Copyright (c) 1980, 1991 The Regents of the University of California.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #ifdef HAVE_NL_LANGINFO
40 extern int GotTermCaps;
43 static void update_vars (Char *);
44 static Char *getinx (Char *, int *);
45 static void asx (Char *, int, Char *);
46 static struct varent *getvx (Char *, int);
47 static Char *xset (Char *, Char ***);
48 static Char *operate (int, Char *, Char *);
49 static void putn1 (tcsh_number_t);
50 static struct varent *madrof (Char *, struct varent *);
51 static void unsetv1 (struct varent *);
52 static void balance (struct varent *, int, int);
53 static int set_noclobber (Char **);
62 if (eq(vp, STRpath)) {
63 struct varent *p = adrof(STRpath);
65 stderror(ERR_NAME | ERR_UNDVAR);
71 else if (eq(vp, STRnoclobber)) {
72 struct varent *p = adrof(STRnoclobber);
74 stderror(ERR_NAME | ERR_UNDVAR);
76 no_clobber = set_noclobber(p->vec);
78 else if (eq(vp, STRhistchars)) {
79 Char *pn = varval(vp);
87 else if (eq(vp, STRpromptchars)) {
88 Char *pn = varval(vp);
96 else if (eq(vp, STRhistlit)) {
99 else if (eq(vp, STRuser)) {
100 tsetenv(STRKUSER, varval(vp));
101 tsetenv(STRLOGNAME, varval(vp));
103 else if (eq(vp, STRgroup)) {
104 tsetenv(STRKGROUP, varval(vp));
106 else if (eq(vp, STRwordchars)) {
107 word_chars = varval(vp);
109 else if (eq(vp, STRloginsh)) {
112 else if (eq(vp, STRanyerror)) {
115 else if (eq(vp, STRsymlinks)) {
116 Char *pn = varval(vp);
118 if (eq(pn, STRignore))
119 symlinks = SYM_IGNORE;
120 else if (eq(pn, STRexpand))
121 symlinks = SYM_EXPAND;
122 else if (eq(pn, STRchase))
123 symlinks = SYM_CHASE;
127 else if (eq(vp, STRterm)) {
128 Char *cp = varval(vp);
129 tsetenv(STRKTERM, cp);
130 #ifdef DOESNT_WORK_RIGHT
131 cp = getenv("TERMCAP");
132 if (cp && (*cp != '/')) /* if TERMCAP and not a path */
133 Unsetenv(STRTERMCAP);
134 #endif /* DOESNT_WORK_RIGHT */
136 if (noediting && Strcmp(cp, STRnetwork) != 0 &&
137 Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
142 ed_Init(); /* reset the editor */
144 else if (eq(vp, STRhome)) {
147 cp = Strsave(varval(vp)); /* get the old value back */
148 cleanup_push(cp, xfree);
151 * convert to cononical pathname (possibly resolving symlinks)
153 canon = dcanon(cp, cp);
156 cleanup_push(canon, xfree);
158 setcopy(vp, canon, VAR_READWRITE); /* have to save the new val */
160 /* and now mirror home with HOME */
161 tsetenv(STRKHOME, canon);
162 /* fix directory stack for new tilde home */
164 cleanup_until(canon);
166 else if (eq(vp, STRedit)) {
169 /* PWP: add more stuff in here later */
171 else if (eq(vp, STRvimode)) {
175 else if (eq(vp, STRshlvl)) {
176 tsetenv(STRKSHLVL, varval(vp));
178 else if (eq(vp, STRignoreeof)) {
181 for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
186 numeof = numeof * 10 + *cp - '0';
188 if (numeof <= 0) numeof = 26; /* Sanity check */
190 else if (eq(vp, STRbackslash_quote)) {
193 else if (eq(vp, STRcompat_expr)) {
196 else if (eq(vp, STRdirstack)) {
199 else if (eq(vp, STRrecognize_only_executables)) {
202 else if (eq(vp, STRkillring)) {
203 SetKillRing((int)getn(varval(vp)));
205 else if (eq(vp, STRhistory)) {
206 sethistory((int)getn(varval(vp)));
209 else if (eq(vp, STRwatch)) {
212 #endif /* HAVENOUTMP */
213 else if (eq(vp, STRimplicitcd)) {
214 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
216 else if (eq(vp, STRcdtohome)) {
220 else if (eq(vp, STRcolor)) {
223 #endif /* COLOR_LS_F */
224 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
225 else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
226 update_dspmbyte_vars();
230 else if (eq(vp, STRcatalog)) {
234 #if defined(FILEC) && defined(TIOCSTI)
235 else if (eq(vp, STRfilec))
238 #endif /* NLS_CATALOGS */
244 doset(Char **v, struct command *c)
251 int flags = VAR_READWRITE;
261 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
263 if (*v && eq(*v, STRmr)) {
264 flags = VAR_READONLY;
268 if (*v && eq(*v, STRmf) && !last_match) {
273 if (*v && eq(*v, STRml) && !first_match) {
281 plist(&shvhed, flags);
288 stderror(ERR_NAME | ERR_VARBEGIN);
294 p = getinx(p, &subscr);
296 if (*p != '\0' && *p != '=')
297 stderror(ERR_NAME | ERR_VARALNUM);
300 if (*p == '\0' && *v != NULL && **v == '(')
303 else if (*v && eq(*v, STRequal)) {
307 if (eq(p, STRLparen)) {
311 stderror(ERR_NAME | ERR_SYNTAX);
314 stderror(ERR_NAME | ERR_MISSING, ')');
327 set1(vp, vecp, &shvhed, flags);
335 cleanup_push(copy, xfree);
336 asx(vp, subscr, copy);
337 cleanup_ignore(copy);
341 setv(vp, Strsave(p), flags);
343 } while ((p = *v++) != NULL);
347 getinx(Char *cp, int *ip)
351 while (*cp && Isdigit(*cp))
352 *ip = *ip * 10 + *cp++ - '0';
354 stderror(ERR_NAME | ERR_SUBSCRIPT);
359 asx(Char *vp, int subscr, Char *p)
361 struct varent *v = getvx(vp, subscr);
364 if (v->v_flags & VAR_READONLY)
365 stderror(ERR_READONLY|ERR_NAME, v->v_name);
366 prev = v->vec[subscr - 1];
367 cleanup_push(prev, xfree);
368 v->vec[subscr - 1] = globone(p, G_APPEND);
372 static struct varent *
373 getvx(Char *vp, int subscr)
375 struct varent *v = adrof(vp);
379 if (subscr < 1 || subscr > blklen(v->vec))
380 stderror(ERR_NAME | ERR_RANGE);
386 dolet(Char **v, struct command *dummy)
404 for (; alnum(*p); p++)
406 if (vp == p || !letter(*vp))
407 stderror(ERR_NAME | ERR_VARBEGIN);
410 p = getinx(p, &subscr);
417 stderror(ERR_NAME | ERR_ASSIGN);
420 * if there is no expression after the '=' then print a "Syntax Error"
423 if (*p == '\0' && *v == NULL)
424 stderror(ERR_NAME | ERR_ASSIGN);
427 cleanup_push(vp, xfree);
436 stderror(ERR_NAME | ERR_UNKNOWNOP);
442 stderror(ERR_NAME | ERR_UNKNOWNOP);
443 stderror(ERR_NAME | ERR_SYNTAX);
446 stderror(ERR_NAME | ERR_UNKNOWNOP);
450 cleanup_push(p, xfree);
455 setv(vp, p, VAR_READWRITE);
459 struct varent *gv = getvx(vp, subscr);
462 val = operate(op, gv->vec[subscr - 1], p);
463 cleanup_push(val, xfree);
464 asx(vp, subscr, val);
471 val = operate(op, varval(vp), p);
472 cleanup_push(val, xfree);
473 setv(vp, val, VAR_READWRITE);
479 } while ((p = *v++) != NULL);
483 xset(Char *cp, Char ***vp)
493 return (putn(expr(vp)));
497 operate(int op, Char *vp, Char *p)
511 if (op == '<' || op == '>')
518 stderror(ERR_NAME | ERR_EXPRESSION);
525 putn(tcsh_number_t n)
527 Char nbuf[1024]; /* Enough even for octal */
536 return (Strsave(nbuf));
540 putn1(tcsh_number_t n)
544 *putp++ = (Char)(n % 10 + '0');
554 if (!cp) /* PWP: extra error checking */
555 stderror(ERR_NAME | ERR_BADNUM);
558 if (cp[0] == '+' && cp[1])
564 stderror(ERR_NAME | ERR_BADNUM);
567 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
575 if (base == 8 && *cp >= '8')
576 stderror(ERR_NAME | ERR_BADNUM);
577 n = n * base + *cp++ - '0';
580 stderror(ERR_NAME | ERR_BADNUM);
581 return (sign ? -n : n);
585 value1(Char *var, struct varent *head)
589 if (!var || !head) /* PWP: extra error checking */
592 vp = adrof1(var, head);
593 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
594 STRNULL : vp->vec[0]);
597 static struct varent *
598 madrof(Char *pat, struct varent *vp)
602 for (vp = vp->v_left; vp; vp = vp->v_right) {
603 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
605 if (Gmatch(vp->v_name, pat))
612 adrof1(const Char *name, struct varent *v)
617 while (v && ((cmp = *name - *v->v_name) != 0 ||
618 (cmp = Strcmp(name, v->v_name)) != 0))
627 setcopy(const Char *var, const Char *val, int flags)
632 cleanup_push(copy, xfree);
633 setv(var, copy, flags);
634 cleanup_ignore(copy);
639 * The caller is responsible for putting value in a safe place
642 setv(const Char *var, Char *val, int flags)
644 Char **vec = xmalloc(2 * sizeof(Char **));
648 set1(var, vec, &shvhed, flags);
652 set1(const Char *var, Char **vec, struct varent *head, int flags)
656 if ((flags & VAR_NOGLOB) == 0) {
661 vec = globall(oldv, gflag);
664 stderror(ERR_NAME | ERR_NOMATCH);
670 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
672 if ( flags & (VAR_FIRST | VAR_LAST) ) {
674 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
676 * Delete all duplicate words leaving "holes" in the word array (vec).
677 * Then remove the "holes", keeping the order of the words unchanged.
679 if (vec && vec[0] && vec[1]) { /* more than one word ? */
683 for (num_items = 0; vec[num_items]; num_items++)
685 if (flags & VAR_FIRST) {
686 /* delete duplications, keeping first occurance */
687 for (i = 1; i < num_items; i++)
688 for (j = 0; j < i; j++)
689 /* If have earlier identical item, remove i'th item */
690 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
695 } else if (flags & VAR_LAST) {
696 /* delete duplications, keeping last occurance */
697 for (i = 0; i < num_items - 1; i++)
698 for (j = i + 1; j < num_items; j++)
699 /* If have later identical item, remove i'th item */
700 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
701 /* remove identical item (the first) */
706 /* Compress items - remove empty items */
707 for (j = i = 0; i < num_items; i++)
711 /* NULL-fy remaining items */
712 for (; j < num_items; j++)
715 /* don't let the attribute propagate */
716 flags &= ~(VAR_FIRST|VAR_LAST);
718 setq(var, vec, head, flags);
723 setq(const Char *name, Char **vec, struct varent *p, int flags)
728 f = 0; /* tree hangs off the header's left link */
729 while ((c = p->v_link[f]) != 0) {
730 if ((f = *name - *c->v_name) == 0 &&
731 (f = Strcmp(name, c->v_name)) == 0) {
732 if (c->v_flags & VAR_READONLY)
733 stderror(ERR_READONLY|ERR_NAME, c->v_name);
742 p->v_link[f] = c = xmalloc(sizeof(struct varent));
743 c->v_name = Strsave(name);
746 c->v_left = c->v_right = 0;
754 unset(Char **v, struct command *c)
756 int did_roe, did_edit;
759 did_roe = adrof(STRrecognize_only_executables) != NULL;
760 did_edit = adrof(STRedit) != NULL;
763 #if defined(FILEC) && defined(TIOCSTI)
764 if (adrof(STRfilec) == 0)
766 #endif /* FILEC && TIOCSTI */
768 if (adrof(STRhistchars) == 0) {
772 if (adrof(STRignoreeof) == 0)
774 if (adrof(STRpromptchars) == 0) {
775 PRCH = tcsh ? '>' : '%';
778 if (adrof(STRnoclobber) == 0)
780 if (adrof(STRhistlit) == 0)
782 if (adrof(STRloginsh) == 0)
784 if (adrof(STRanyerror) == 0)
786 if (adrof(STRwordchars) == 0)
787 word_chars = STR_WORD_CHARS;
788 if (adrof(STRedit) == 0)
790 if (adrof(STRbackslash_quote) == 0)
792 if (adrof(STRcompat_expr) == 0)
794 if (adrof(STRsymlinks) == 0)
796 if (adrof(STRimplicitcd) == 0)
798 if (adrof(STRcdtohome) == 0)
800 if (adrof(STRkillring) == 0)
802 if (did_edit && noediting && adrof(STRedit) == 0)
804 if (adrof(STRvimode) == 0)
806 if (did_roe && adrof(STRrecognize_only_executables) == 0)
808 if (adrof(STRhistory) == 0)
811 if (adrof(STRcolor) == 0)
813 #endif /* COLOR_LS_F */
814 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
815 update_dspmbyte_vars();
821 #endif /* NLS_CATALOGS */
825 unset1(Char *v[], struct varent *head)
832 while ((vp = madrof(*v, head)) != NULL)
833 if (vp->v_flags & VAR_READONLY)
834 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
838 setname(short2str(*v));
847 if ((vp = adrof1(var, &shvhed)) == 0)
853 unsetv1(struct varent *p)
855 struct varent *c, *pp;
859 * Free associated memory first to avoid complications.
864 * If p is missing one child, then we can move the other into where p is.
865 * Otherwise, we find the predecessor of p, which is guaranteed to have no
866 * right child, copy it into p, and move it's left child into it.
870 else if (p->v_left == 0)
873 for (c = p->v_left; c->v_right; c = c->v_right)
875 p->v_name = c->v_name;
876 p->v_flags = c->v_flags;
883 * Move c into where p is.
886 f = pp->v_right == p;
887 if ((pp->v_link[f] = c) != 0)
890 * Free the deleted node, and rebalance.
896 /* Set variable name to NULL. */
898 setNS(const Char *varName)
900 setcopy(varName, STRNULL, VAR_READWRITE);
905 shift(Char **v, struct command *c)
918 if (argv == NULL || argv->vec == NULL)
920 if (argv->vec[0] == 0)
921 stderror(ERR_NAME | ERR_NOMORE);
922 lshift(argv->vec, 1);
927 exportpath(Char **val)
929 struct Strbuf buf = Strbuf_INIT;
934 Strbuf_append(&buf, *val++);
935 if (*val == 0 || eq(*val, STRRparen))
937 Strbuf_append1(&buf, PATHSEP);
939 exppath = Strbuf_finish(&buf);
940 cleanup_push(exppath, xfree);
941 tsetenv(STRKPATH, exppath);
942 cleanup_until(exppath);
946 set_noclobber(Char **val)
949 int nc = NOCLOBBER_DEFAULT;
954 if (*val == 0 || eq(*val, STRRparen))
959 if (eq(option, STRnotempty))
960 nc |= NOCLOBBER_NOTEMPTY;
961 else if (eq(option, STRask))
969 * Lint thinks these have null effect
971 /* macros to do single rotations on node p */
972 # define rright(p) (\
974 (t)->v_parent = (p)->v_parent,\
975 (((p)->v_left = t->v_right) != NULL) ?\
976 (t->v_right->v_parent = (p)) : 0,\
977 (t->v_right = (p))->v_parent = t,\
981 ((t)->v_parent = (p)->v_parent,\
982 ((p)->v_right = t->v_left) != NULL) ? \
983 (t->v_left->v_parent = (p)) : 0,\
984 (t->v_left = (p))->v_parent = t,\
987 static struct varent *
988 rleft(struct varent *p)
992 static struct varent *
993 rright(struct varent *p)
1002 * Rebalance a tree, starting at p and up.
1003 * F == 0 means we've come from p's left child.
1004 * D == 1 means we've just done a delete, otherwise an insert.
1007 balance(struct varent *p, int f, int d)
1012 struct varent *t; /* used by the rotate macros */
1016 ff = 0; /* Sun's lint is dumb! */
1020 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
1021 * is the branch of p from which we have come; ff is the branch of pp which
1024 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
1025 ff = pp->v_right == p;
1026 if (f ^ d) { /* right heavy */
1028 case -1: /* was left heavy */
1031 case 0: /* was balanced */
1034 case 1: /* was already right heavy */
1035 switch (p->v_right->v_bal) {
1036 case 1: /* single rotate */
1037 pp->v_link[ff] = rleft(p);
1038 p->v_left->v_bal = 0;
1041 case 0: /* single rotate */
1042 pp->v_link[ff] = rleft(p);
1043 p->v_left->v_bal = 1;
1046 case -1: /* double rotate */
1047 (void) rright(p->v_right);
1048 pp->v_link[ff] = rleft(p);
1050 p->v_bal < 1 ? 0 : -1;
1052 p->v_bal > -1 ? 0 : 1;
1063 else { /* left heavy */
1065 case 1: /* was right heavy */
1068 case 0: /* was balanced */
1071 case -1: /* was already left heavy */
1072 switch (p->v_left->v_bal) {
1073 case -1: /* single rotate */
1074 pp->v_link[ff] = rright(p);
1075 p->v_right->v_bal = 0;
1078 case 0: /* single rotate */
1079 pp->v_link[ff] = rright(p);
1080 p->v_right->v_bal = -1;
1083 case 1: /* double rotate */
1084 (void) rleft(p->v_left);
1085 pp->v_link[ff] = rright(p);
1087 p->v_bal < 1 ? 0 : -1;
1089 p->v_bal > -1 ? 0 : 1;
1101 * If from insert, then we terminate when p is balanced. If from
1102 * delete, then we terminate when p is unbalanced.
1104 if ((p->v_bal == 0) ^ d)
1110 plist(struct varent *p, int what)
1119 if (p->v_parent == 0) /* is it the header? */
1121 if ((p->v_flags & what) != 0) {
1123 int old_pintr_disabled;
1125 pintr_push_enable(&old_pintr_disabled);
1126 cleanup_until(&old_pintr_disabled);
1128 len = blklen(p->vec);
1129 xprintf("%S\t", p->v_name);
1144 } while (p->v_right == c);
1150 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1151 extern int dspmbyte_ls;
1154 update_dspmbyte_vars(void)
1160 /* if variable "nokanji" is set, multi-byte display is disabled */
1161 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1164 if(eq (dstr1, STRsjis))
1166 else if (eq(dstr1, STReuc))
1168 else if (eq(dstr1, STRbig5))
1170 else if (eq(dstr1, STRutf8))
1172 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1176 xprintf(CGETS(18, 2,
1177 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1180 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1184 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1188 _cmap[lp] = _cmap_mbyte[lp];
1189 _mbmap[lp] = _mbmap_sjis[lp];
1193 _cmap[lp] = _cmap_mbyte[lp];
1194 _mbmap[lp] = _mbmap_euc[lp];
1198 _cmap[lp] = _cmap_mbyte[lp];
1199 _mbmap[lp] = _mbmap_big5[lp];
1203 _cmap[lp] = _cmap_mbyte[lp];
1204 _mbmap[lp] = _mbmap_utf8[lp];
1207 xprintf(CGETS(18, 3,
1208 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1210 _cmap[lp] = _cmap_c[lp];
1211 _mbmap[lp] = 0; /* Default map all 0 */
1217 /* check original table */
1218 if (Strlen(dstr1) != 256) {
1219 xprintf(CGETS(18, 4,
1220 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1224 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1225 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1226 xprintf(CGETS(18, 4,
1227 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1233 /* set original table */
1234 for (lp = 0; lp < 256; lp++) {
1235 if (_enable_mbdisp == 1) {
1236 _cmap[lp] = _cmap_mbyte[lp];
1237 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1240 _cmap[lp] = _cmap_c[lp];
1241 _mbmap[lp] = 0; /* Default map all 0 */
1247 for (lp = 0; lp < 256; lp++) {
1248 _cmap[lp] = _cmap_c[lp];
1249 _mbmap[lp] = 0; /* Default map all 0 */
1254 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1257 for (lp = 0; lp < 256; lp++)
1258 mbmapstr[lp] = _mbmap[lp] + '0';
1260 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1262 #endif /* MBYTEMAP */
1265 /* dspkanji/dspmbyte autosetting */
1266 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1268 autoset_dspmbyte(const Char *pcp)
1271 static const struct dspm_autoset_Table {
1275 { STRLANGEUCJP, STReuc },
1276 { STRLANGEUCKR, STReuc },
1277 { STRLANGEUCZH, STReuc },
1278 { STRLANGEUCJPB, STReuc },
1279 { STRLANGEUCKRB, STReuc },
1280 { STRLANGEUCZHB, STReuc },
1282 { STRLANGEUCJPC, STReuc },
1284 { STRLANGSJIS, STRsjis },
1285 { STRLANGSJISB, STRsjis },
1286 { STRLANGBIG5, STRbig5 },
1287 { STRstarutfstar8, STRutf8 },
1290 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1291 static const struct dspm_autoset_Table dspmc[] = {
1292 { STRstarutfstar8, STRutf8 },
1294 { STRGB2312, STReuc },
1295 { STRLANGBIG5, STRbig5 },
1300 codeset = str2short(nl_langinfo(CODESET));
1301 if (*codeset != '\0') {
1302 for (i = 0; dspmc[i].n; i++) {
1304 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1305 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1306 update_dspmbyte_vars();
1316 for (i = 0; dspmt[i].n; i++) {
1318 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1319 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1320 update_dspmbyte_vars();
1325 # elif defined(AUTOSET_KANJI)
1329 char *codeset = nl_langinfo(CODESET);
1331 if (*codeset == '\0') {
1332 if (adrof(STRnokanji) == NULL)
1337 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1338 if (adrof(STRnokanji) == NULL)
1343 if (adrof(STRnokanji) != NULL)
1350 update_wordchars(void)
1352 if ((word_chars == STR_WORD_CHARS) || (word_chars == STR_WORD_CHARS_VI)) {
1353 word_chars = (VImode ? STR_WORD_CHARS_VI : STR_WORD_CHARS);