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 exportpath (Char **);
53 static void balance (struct varent *, int, int);
54 static int set_noclobber (Char **);
63 if (eq(vp, STRpath)) {
64 struct varent *p = adrof(STRpath);
66 stderror(ERR_NAME | ERR_UNDVAR);
72 else if (eq(vp, STRnoclobber)) {
73 struct varent *p = adrof(STRnoclobber);
75 stderror(ERR_NAME | ERR_UNDVAR);
77 no_clobber = set_noclobber(p->vec);
79 else if (eq(vp, STRhistchars)) {
80 Char *pn = varval(vp);
88 else if (eq(vp, STRpromptchars)) {
89 Char *pn = varval(vp);
97 else if (eq(vp, STRhistlit)) {
100 else if (eq(vp, STRuser)) {
101 tsetenv(STRKUSER, varval(vp));
102 tsetenv(STRLOGNAME, varval(vp));
104 else if (eq(vp, STRgroup)) {
105 tsetenv(STRKGROUP, varval(vp));
107 else if (eq(vp, STRwordchars)) {
108 word_chars = varval(vp);
110 else if (eq(vp, STRloginsh)) {
113 else if (eq(vp, STRanyerror)) {
116 else if (eq(vp, STRsymlinks)) {
117 Char *pn = varval(vp);
119 if (eq(pn, STRignore))
120 symlinks = SYM_IGNORE;
121 else if (eq(pn, STRexpand))
122 symlinks = SYM_EXPAND;
123 else if (eq(pn, STRchase))
124 symlinks = SYM_CHASE;
128 else if (eq(vp, STRterm)) {
129 Char *cp = varval(vp);
130 tsetenv(STRKTERM, cp);
131 #ifdef DOESNT_WORK_RIGHT
132 cp = getenv("TERMCAP");
133 if (cp && (*cp != '/')) /* if TERMCAP and not a path */
134 Unsetenv(STRTERMCAP);
135 #endif /* DOESNT_WORK_RIGHT */
137 if (noediting && Strcmp(cp, STRnetwork) != 0 &&
138 Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
143 ed_Init(); /* reset the editor */
145 else if (eq(vp, STRhome)) {
148 cp = Strsave(varval(vp)); /* get the old value back */
149 cleanup_push(cp, xfree);
152 * convert to cononical pathname (possibly resolving symlinks)
154 canon = dcanon(cp, cp);
157 cleanup_push(canon, xfree);
159 setcopy(vp, canon, VAR_READWRITE); /* have to save the new val */
161 /* and now mirror home with HOME */
162 tsetenv(STRKHOME, canon);
163 /* fix directory stack for new tilde home */
165 cleanup_until(canon);
167 else if (eq(vp, STRedit)) {
170 /* PWP: add more stuff in here later */
172 else if (eq(vp, STRvimode)) {
176 else if (eq(vp, STRshlvl)) {
177 tsetenv(STRKSHLVL, varval(vp));
179 else if (eq(vp, STRignoreeof)) {
182 for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
187 numeof = numeof * 10 + *cp - '0';
189 if (numeof <= 0) numeof = 26; /* Sanity check */
191 else if (eq(vp, STRbackslash_quote)) {
194 else if (eq(vp, STRcompat_expr)) {
197 else if (eq(vp, STRdirstack)) {
200 else if (eq(vp, STRrecognize_only_executables)) {
203 else if (eq(vp, STRkillring)) {
204 SetKillRing((int)getn(varval(vp)));
206 else if (eq(vp, STRhistory)) {
207 sethistory((int)getn(varval(vp)));
210 else if (eq(vp, STRwatch)) {
213 #endif /* HAVENOUTMP */
214 else if (eq(vp, STRimplicitcd)) {
215 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
217 else if (eq(vp, STRcdtohome)) {
221 else if (eq(vp, STRcolor)) {
224 #endif /* COLOR_LS_F */
225 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
226 else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
227 update_dspmbyte_vars();
231 else if (eq(vp, STRcatalog)) {
235 #if defined(FILEC) && defined(TIOCSTI)
236 else if (eq(vp, STRfilec))
239 #endif /* NLS_CATALOGS */
245 doset(Char **v, struct command *c)
252 int flags = VAR_READWRITE;
262 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
264 if (*v && eq(*v, STRmr)) {
265 flags = VAR_READONLY;
269 if (*v && eq(*v, STRmf) && !last_match) {
274 if (*v && eq(*v, STRml) && !first_match) {
282 plist(&shvhed, flags);
289 stderror(ERR_NAME | ERR_VARBEGIN);
295 p = getinx(p, &subscr);
297 if (*p != '\0' && *p != '=')
298 stderror(ERR_NAME | ERR_VARALNUM);
301 if (*p == '\0' && *v != NULL && **v == '(')
304 else if (*v && eq(*v, STRequal)) {
308 if (eq(p, STRLparen)) {
312 stderror(ERR_NAME | ERR_SYNTAX);
315 stderror(ERR_NAME | ERR_MISSING, ')');
328 set1(vp, vecp, &shvhed, flags);
336 cleanup_push(copy, xfree);
337 asx(vp, subscr, copy);
338 cleanup_ignore(copy);
342 setv(vp, Strsave(p), flags);
344 } while ((p = *v++) != NULL);
348 getinx(Char *cp, int *ip)
352 while (*cp && Isdigit(*cp))
353 *ip = *ip * 10 + *cp++ - '0';
355 stderror(ERR_NAME | ERR_SUBSCRIPT);
360 asx(Char *vp, int subscr, Char *p)
362 struct varent *v = getvx(vp, subscr);
365 if (v->v_flags & VAR_READONLY)
366 stderror(ERR_READONLY|ERR_NAME, v->v_name);
367 prev = v->vec[subscr - 1];
368 cleanup_push(prev, xfree);
369 v->vec[subscr - 1] = globone(p, G_APPEND);
373 static struct varent *
374 getvx(Char *vp, int subscr)
376 struct varent *v = adrof(vp);
380 if (subscr < 1 || subscr > blklen(v->vec))
381 stderror(ERR_NAME | ERR_RANGE);
387 dolet(Char **v, struct command *dummy)
405 for (; alnum(*p); p++)
407 if (vp == p || !letter(*vp))
408 stderror(ERR_NAME | ERR_VARBEGIN);
411 p = getinx(p, &subscr);
418 stderror(ERR_NAME | ERR_ASSIGN);
421 * if there is no expression after the '=' then print a "Syntax Error"
424 if (*p == '\0' && *v == NULL)
425 stderror(ERR_NAME | ERR_ASSIGN);
428 cleanup_push(vp, xfree);
437 stderror(ERR_NAME | ERR_UNKNOWNOP);
443 stderror(ERR_NAME | ERR_UNKNOWNOP);
444 stderror(ERR_NAME | ERR_SYNTAX);
447 stderror(ERR_NAME | ERR_UNKNOWNOP);
451 cleanup_push(p, xfree);
456 setv(vp, p, VAR_READWRITE);
460 struct varent *gv = getvx(vp, subscr);
463 val = operate(op, gv->vec[subscr - 1], p);
464 cleanup_push(val, xfree);
465 asx(vp, subscr, val);
472 val = operate(op, varval(vp), p);
473 cleanup_push(val, xfree);
474 setv(vp, val, VAR_READWRITE);
480 } while ((p = *v++) != NULL);
484 xset(Char *cp, Char ***vp)
494 return (putn(expr(vp)));
498 operate(int op, Char *vp, Char *p)
512 if (op == '<' || op == '>')
519 stderror(ERR_NAME | ERR_EXPRESSION);
526 putn(tcsh_number_t n)
528 Char nbuf[1024]; /* Enough even for octal */
537 return (Strsave(nbuf));
541 putn1(tcsh_number_t n)
545 *putp++ = (Char)(n % 10 + '0');
555 if (!cp) /* PWP: extra error checking */
556 stderror(ERR_NAME | ERR_BADNUM);
559 if (cp[0] == '+' && cp[1])
565 stderror(ERR_NAME | ERR_BADNUM);
568 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
576 if (base == 8 && *cp >= '8')
577 stderror(ERR_NAME | ERR_BADNUM);
578 n = n * base + *cp++ - '0';
581 stderror(ERR_NAME | ERR_BADNUM);
582 return (sign ? -n : n);
586 value1(Char *var, struct varent *head)
590 if (!var || !head) /* PWP: extra error checking */
593 vp = adrof1(var, head);
594 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
595 STRNULL : vp->vec[0]);
598 static struct varent *
599 madrof(Char *pat, struct varent *vp)
603 for (vp = vp->v_left; vp; vp = vp->v_right) {
604 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
606 if (Gmatch(vp->v_name, pat))
613 adrof1(const Char *name, struct varent *v)
618 while (v && ((cmp = *name - *v->v_name) != 0 ||
619 (cmp = Strcmp(name, v->v_name)) != 0))
628 setcopy(const Char *var, const Char *val, int flags)
633 cleanup_push(copy, xfree);
634 setv(var, copy, flags);
635 cleanup_ignore(copy);
640 * The caller is responsible for putting value in a safe place
643 setv(const Char *var, Char *val, int flags)
645 Char **vec = xmalloc(2 * sizeof(Char **));
649 set1(var, vec, &shvhed, flags);
653 set1(const Char *var, Char **vec, struct varent *head, int flags)
657 if ((flags & VAR_NOGLOB) == 0) {
662 vec = globall(oldv, gflag);
665 stderror(ERR_NAME | ERR_NOMATCH);
671 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
673 if ( flags & (VAR_FIRST | VAR_LAST) ) {
675 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
677 * Delete all duplicate words leaving "holes" in the word array (vec).
678 * Then remove the "holes", keeping the order of the words unchanged.
680 if (vec && vec[0] && vec[1]) { /* more than one word ? */
684 for (num_items = 0; vec[num_items]; num_items++)
686 if (flags & VAR_FIRST) {
687 /* delete duplications, keeping first occurance */
688 for (i = 1; i < num_items; i++)
689 for (j = 0; j < i; j++)
690 /* If have earlier identical item, remove i'th item */
691 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
696 } else if (flags & VAR_LAST) {
697 /* delete duplications, keeping last occurance */
698 for (i = 0; i < num_items - 1; i++)
699 for (j = i + 1; j < num_items; j++)
700 /* If have later identical item, remove i'th item */
701 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
702 /* remove identical item (the first) */
707 /* Compress items - remove empty items */
708 for (j = i = 0; i < num_items; i++)
712 /* NULL-fy remaining items */
713 for (; j < num_items; j++)
716 /* don't let the attribute propagate */
717 flags &= ~(VAR_FIRST|VAR_LAST);
719 setq(var, vec, head, flags);
724 setq(const Char *name, Char **vec, struct varent *p, int flags)
729 f = 0; /* tree hangs off the header's left link */
730 while ((c = p->v_link[f]) != 0) {
731 if ((f = *name - *c->v_name) == 0 &&
732 (f = Strcmp(name, c->v_name)) == 0) {
733 if (c->v_flags & VAR_READONLY)
734 stderror(ERR_READONLY|ERR_NAME, c->v_name);
743 p->v_link[f] = c = xmalloc(sizeof(struct varent));
744 c->v_name = Strsave(name);
747 c->v_left = c->v_right = 0;
755 unset(Char **v, struct command *c)
757 int did_roe, did_edit;
760 did_roe = adrof(STRrecognize_only_executables) != NULL;
761 did_edit = adrof(STRedit) != NULL;
764 #if defined(FILEC) && defined(TIOCSTI)
765 if (adrof(STRfilec) == 0)
767 #endif /* FILEC && TIOCSTI */
769 if (adrof(STRhistchars) == 0) {
773 if (adrof(STRignoreeof) == 0)
775 if (adrof(STRpromptchars) == 0) {
776 PRCH = tcsh ? '>' : '%';
779 if (adrof(STRnoclobber) == 0)
781 if (adrof(STRhistlit) == 0)
783 if (adrof(STRloginsh) == 0)
785 if (adrof(STRanyerror) == 0)
787 if (adrof(STRwordchars) == 0)
788 word_chars = STR_WORD_CHARS;
789 if (adrof(STRedit) == 0)
791 if (adrof(STRbackslash_quote) == 0)
793 if (adrof(STRcompat_expr) == 0)
795 if (adrof(STRsymlinks) == 0)
797 if (adrof(STRimplicitcd) == 0)
799 if (adrof(STRcdtohome) == 0)
801 if (adrof(STRkillring) == 0)
803 if (did_edit && noediting && adrof(STRedit) == 0)
805 if (adrof(STRvimode) == 0)
807 if (did_roe && adrof(STRrecognize_only_executables) == 0)
809 if (adrof(STRhistory) == 0)
812 if (adrof(STRcolor) == 0)
814 #endif /* COLOR_LS_F */
815 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
816 update_dspmbyte_vars();
822 #endif /* NLS_CATALOGS */
826 unset1(Char *v[], struct varent *head)
833 while ((vp = madrof(*v, head)) != NULL)
834 if (vp->v_flags & VAR_READONLY)
835 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
839 setname(short2str(*v));
848 if ((vp = adrof1(var, &shvhed)) == 0)
854 unsetv1(struct varent *p)
856 struct varent *c, *pp;
860 * Free associated memory first to avoid complications.
865 * If p is missing one child, then we can move the other into where p is.
866 * Otherwise, we find the predecessor of p, which is guaranteed to have no
867 * right child, copy it into p, and move it's left child into it.
871 else if (p->v_left == 0)
874 for (c = p->v_left; c->v_right; c = c->v_right)
876 p->v_name = c->v_name;
877 p->v_flags = c->v_flags;
884 * Move c into where p is.
887 f = pp->v_right == p;
888 if ((pp->v_link[f] = c) != 0)
891 * Free the deleted node, and rebalance.
897 /* Set variable name to NULL. */
899 setNS(const Char *varName)
901 setcopy(varName, STRNULL, VAR_READWRITE);
906 shift(Char **v, struct command *c)
919 if (argv == NULL || argv->vec == NULL)
921 if (argv->vec[0] == 0)
922 stderror(ERR_NAME | ERR_NOMORE);
923 lshift(argv->vec, 1);
928 exportpath(Char **val)
930 struct Strbuf buf = Strbuf_INIT;
935 Strbuf_append(&buf, *val++);
936 if (*val == 0 || eq(*val, STRRparen))
938 Strbuf_append1(&buf, PATHSEP);
940 exppath = Strbuf_finish(&buf);
941 cleanup_push(exppath, xfree);
942 tsetenv(STRKPATH, exppath);
943 cleanup_until(exppath);
947 set_noclobber(Char **val)
950 int nc = NOCLOBBER_DEFAULT;
955 if (*val == 0 || eq(*val, STRRparen))
960 if (eq(option, STRnotempty))
961 nc |= NOCLOBBER_NOTEMPTY;
962 else if (eq(option, STRask))
970 * Lint thinks these have null effect
972 /* macros to do single rotations on node p */
973 # define rright(p) (\
975 (t)->v_parent = (p)->v_parent,\
976 (((p)->v_left = t->v_right) != NULL) ?\
977 (t->v_right->v_parent = (p)) : 0,\
978 (t->v_right = (p))->v_parent = t,\
982 ((t)->v_parent = (p)->v_parent,\
983 ((p)->v_right = t->v_left) != NULL) ? \
984 (t->v_left->v_parent = (p)) : 0,\
985 (t->v_left = (p))->v_parent = t,\
988 static struct varent *
989 rleft(struct varent *p)
993 static struct varent *
994 rright(struct varent *p)
1003 * Rebalance a tree, starting at p and up.
1004 * F == 0 means we've come from p's left child.
1005 * D == 1 means we've just done a delete, otherwise an insert.
1008 balance(struct varent *p, int f, int d)
1013 struct varent *t; /* used by the rotate macros */
1017 ff = 0; /* Sun's lint is dumb! */
1021 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
1022 * is the branch of p from which we have come; ff is the branch of pp which
1025 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
1026 ff = pp->v_right == p;
1027 if (f ^ d) { /* right heavy */
1029 case -1: /* was left heavy */
1032 case 0: /* was balanced */
1035 case 1: /* was already right heavy */
1036 switch (p->v_right->v_bal) {
1037 case 1: /* single rotate */
1038 pp->v_link[ff] = rleft(p);
1039 p->v_left->v_bal = 0;
1042 case 0: /* single rotate */
1043 pp->v_link[ff] = rleft(p);
1044 p->v_left->v_bal = 1;
1047 case -1: /* double rotate */
1048 (void) rright(p->v_right);
1049 pp->v_link[ff] = rleft(p);
1051 p->v_bal < 1 ? 0 : -1;
1053 p->v_bal > -1 ? 0 : 1;
1064 else { /* left heavy */
1066 case 1: /* was right heavy */
1069 case 0: /* was balanced */
1072 case -1: /* was already left heavy */
1073 switch (p->v_left->v_bal) {
1074 case -1: /* single rotate */
1075 pp->v_link[ff] = rright(p);
1076 p->v_right->v_bal = 0;
1079 case 0: /* single rotate */
1080 pp->v_link[ff] = rright(p);
1081 p->v_right->v_bal = -1;
1084 case 1: /* double rotate */
1085 (void) rleft(p->v_left);
1086 pp->v_link[ff] = rright(p);
1088 p->v_bal < 1 ? 0 : -1;
1090 p->v_bal > -1 ? 0 : 1;
1102 * If from insert, then we terminate when p is balanced. If from
1103 * delete, then we terminate when p is unbalanced.
1105 if ((p->v_bal == 0) ^ d)
1111 plist(struct varent *p, int what)
1120 if (p->v_parent == 0) /* is it the header? */
1122 if ((p->v_flags & what) != 0) {
1124 int old_pintr_disabled;
1126 pintr_push_enable(&old_pintr_disabled);
1127 cleanup_until(&old_pintr_disabled);
1129 len = blklen(p->vec);
1130 xprintf("%S\t", p->v_name);
1145 } while (p->v_right == c);
1151 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1152 extern int dspmbyte_ls;
1155 update_dspmbyte_vars(void)
1161 /* if variable "nokanji" is set, multi-byte display is disabled */
1162 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1165 if(eq (dstr1, STRsjis))
1167 else if (eq(dstr1, STReuc))
1169 else if (eq(dstr1, STRbig5))
1171 else if (eq(dstr1, STRutf8))
1173 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1177 xprintf(CGETS(18, 2,
1178 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1181 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1185 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1189 _cmap[lp] = _cmap_mbyte[lp];
1190 _mbmap[lp] = _mbmap_sjis[lp];
1194 _cmap[lp] = _cmap_mbyte[lp];
1195 _mbmap[lp] = _mbmap_euc[lp];
1199 _cmap[lp] = _cmap_mbyte[lp];
1200 _mbmap[lp] = _mbmap_big5[lp];
1204 _cmap[lp] = _cmap_mbyte[lp];
1205 _mbmap[lp] = _mbmap_utf8[lp];
1208 xprintf(CGETS(18, 3,
1209 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1211 _cmap[lp] = _cmap_c[lp];
1212 _mbmap[lp] = 0; /* Default map all 0 */
1218 /* check original table */
1219 if (Strlen(dstr1) != 256) {
1220 xprintf(CGETS(18, 4,
1221 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1225 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1226 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1227 xprintf(CGETS(18, 4,
1228 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1234 /* set original table */
1235 for (lp = 0; lp < 256; lp++) {
1236 if (_enable_mbdisp == 1) {
1237 _cmap[lp] = _cmap_mbyte[lp];
1238 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1241 _cmap[lp] = _cmap_c[lp];
1242 _mbmap[lp] = 0; /* Default map all 0 */
1248 for (lp = 0; lp < 256; lp++) {
1249 _cmap[lp] = _cmap_c[lp];
1250 _mbmap[lp] = 0; /* Default map all 0 */
1255 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1258 for (lp = 0; lp < 256; lp++)
1259 mbmapstr[lp] = _mbmap[lp] + '0';
1261 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1263 #endif /* MBYTEMAP */
1266 /* dspkanji/dspmbyte autosetting */
1267 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1269 autoset_dspmbyte(const Char *pcp)
1272 static const struct dspm_autoset_Table {
1276 { STRLANGEUCJP, STReuc },
1277 { STRLANGEUCKR, STReuc },
1278 { STRLANGEUCZH, STReuc },
1279 { STRLANGEUCJPB, STReuc },
1280 { STRLANGEUCKRB, STReuc },
1281 { STRLANGEUCZHB, STReuc },
1283 { STRLANGEUCJPC, STReuc },
1285 { STRLANGSJIS, STRsjis },
1286 { STRLANGSJISB, STRsjis },
1287 { STRLANGBIG5, STRbig5 },
1288 { STRstarutfstar8, STRutf8 },
1291 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1292 static const struct dspm_autoset_Table dspmc[] = {
1293 { STRstarutfstar8, STRutf8 },
1295 { STRGB2312, STReuc },
1296 { STRLANGBIG5, STRbig5 },
1301 codeset = str2short(nl_langinfo(CODESET));
1302 if (*codeset != '\0') {
1303 for (i = 0; dspmc[i].n; i++) {
1305 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1306 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1307 update_dspmbyte_vars();
1317 for (i = 0; dspmt[i].n; i++) {
1319 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1320 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1321 update_dspmbyte_vars();
1326 # elif defined(AUTOSET_KANJI)
1330 char *codeset = nl_langinfo(CODESET);
1332 if (*codeset == '\0') {
1333 if (adrof(STRnokanji) == NULL)
1338 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1339 if (adrof(STRnokanji) == NULL)
1344 if (adrof(STRnokanji) != NULL)
1351 update_wordchars(void)
1353 if ((word_chars == STR_WORD_CHARS) || (word_chars == STR_WORD_CHARS_VI)) {
1354 word_chars = (VImode ? STR_WORD_CHARS_VI : STR_WORD_CHARS);