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 */
150 * convert to cononical pathname (possibly resolving symlinks)
152 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, STRvimode)) {
172 else if (eq(vp, STRshlvl)) {
173 tsetenv(STRKSHLVL, varval(vp));
175 else if (eq(vp, STRignoreeof)) {
178 for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
183 numeof = numeof * 10 + *cp - '0';
185 if (numeof <= 0) numeof = 26; /* Sanity check */
187 else if (eq(vp, STRbackslash_quote)) {
190 else if (eq(vp, STRcompat_expr)) {
193 else if (eq(vp, STRdirstack)) {
196 else if (eq(vp, STRrecognize_only_executables)) {
199 else if (eq(vp, STRkillring)) {
200 SetKillRing((int)getn(varval(vp)));
202 else if (eq(vp, STRhistory)) {
203 sethistory((int)getn(varval(vp)));
206 else if (eq(vp, STRwatch)) {
209 #endif /* HAVENOUTMP */
210 else if (eq(vp, STRimplicitcd)) {
211 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
213 else if (eq(vp, STRcdtohome)) {
217 else if (eq(vp, STRcolor)) {
220 #endif /* COLOR_LS_F */
221 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
222 else if (eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
223 update_dspmbyte_vars();
227 else if (eq(vp, STRcatalog)) {
231 #if defined(FILEC) && defined(TIOCSTI)
232 else if (eq(vp, STRfilec))
235 #endif /* NLS_CATALOGS */
241 doset(Char **v, struct command *c)
248 int flags = VAR_READWRITE;
258 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
260 if (*v && eq(*v, STRmr)) {
261 flags = VAR_READONLY;
265 if (*v && eq(*v, STRmf) && !last_match) {
270 if (*v && eq(*v, STRml) && !first_match) {
278 plist(&shvhed, flags);
285 stderror(ERR_NAME | ERR_VARBEGIN);
291 p = getinx(p, &subscr);
293 if (*p != '\0' && *p != '=')
294 stderror(ERR_NAME | ERR_VARALNUM);
297 if (*p == '\0' && *v != NULL && **v == '(')
300 else if (*v && eq(*v, STRequal)) {
304 if (eq(p, STRLparen)) {
308 stderror(ERR_NAME | ERR_SYNTAX);
311 stderror(ERR_NAME | ERR_MISSING, ')');
324 set1(vp, vecp, &shvhed, flags);
332 cleanup_push(copy, xfree);
333 asx(vp, subscr, copy);
334 cleanup_ignore(copy);
338 setv(vp, Strsave(p), flags);
340 } while ((p = *v++) != NULL);
344 getinx(Char *cp, int *ip)
348 while (*cp && Isdigit(*cp))
349 *ip = *ip * 10 + *cp++ - '0';
351 stderror(ERR_NAME | ERR_SUBSCRIPT);
356 asx(Char *vp, int subscr, Char *p)
358 struct varent *v = getvx(vp, subscr);
361 if (v->v_flags & VAR_READONLY)
362 stderror(ERR_READONLY|ERR_NAME, v->v_name);
363 prev = v->vec[subscr - 1];
364 cleanup_push(prev, xfree);
365 v->vec[subscr - 1] = globone(p, G_APPEND);
369 static struct varent *
370 getvx(Char *vp, int subscr)
372 struct varent *v = adrof(vp);
376 if (subscr < 1 || subscr > blklen(v->vec))
377 stderror(ERR_NAME | ERR_RANGE);
383 dolet(Char **v, struct command *dummy)
401 for (; alnum(*p); p++)
403 if (vp == p || !letter(*vp))
404 stderror(ERR_NAME | ERR_VARBEGIN);
407 p = getinx(p, &subscr);
414 stderror(ERR_NAME | ERR_ASSIGN);
417 * if there is no expression after the '=' then print a "Syntax Error"
420 if (*p == '\0' && *v == NULL)
421 stderror(ERR_NAME | ERR_ASSIGN);
424 cleanup_push(vp, xfree);
433 stderror(ERR_NAME | ERR_UNKNOWNOP);
439 stderror(ERR_NAME | ERR_UNKNOWNOP);
440 stderror(ERR_NAME | ERR_SYNTAX);
443 stderror(ERR_NAME | ERR_UNKNOWNOP);
447 cleanup_push(p, xfree);
452 setv(vp, p, VAR_READWRITE);
456 struct varent *gv = getvx(vp, subscr);
459 val = operate(op, gv->vec[subscr - 1], p);
460 cleanup_push(val, xfree);
461 asx(vp, subscr, val);
468 val = operate(op, varval(vp), p);
469 cleanup_push(val, xfree);
470 setv(vp, val, VAR_READWRITE);
476 } while ((p = *v++) != NULL);
480 xset(Char *cp, Char ***vp)
490 return (putn(expr(vp)));
494 operate(int op, Char *vp, Char *p)
508 if (op == '<' || op == '>')
515 stderror(ERR_NAME | ERR_EXPRESSION);
522 putn(tcsh_number_t n)
524 Char nbuf[1024]; /* Enough even for octal */
533 return (Strsave(nbuf));
537 putn1(tcsh_number_t n)
541 *putp++ = (Char)(n % 10 + '0');
551 if (!cp) /* PWP: extra error checking */
552 stderror(ERR_NAME | ERR_BADNUM);
555 if (cp[0] == '+' && cp[1])
561 stderror(ERR_NAME | ERR_BADNUM);
564 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
572 if (base == 8 && *cp >= '8')
573 stderror(ERR_NAME | ERR_BADNUM);
574 n = n * base + *cp++ - '0';
577 stderror(ERR_NAME | ERR_BADNUM);
578 return (sign ? -n : n);
582 value1(Char *var, struct varent *head)
586 if (!var || !head) /* PWP: extra error checking */
589 vp = adrof1(var, head);
590 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
591 STRNULL : vp->vec[0]);
594 static struct varent *
595 madrof(Char *pat, struct varent *vp)
599 for (vp = vp->v_left; vp; vp = vp->v_right) {
600 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
602 if (Gmatch(vp->v_name, pat))
609 adrof1(const Char *name, struct varent *v)
614 while (v && ((cmp = *name - *v->v_name) != 0 ||
615 (cmp = Strcmp(name, v->v_name)) != 0))
624 setcopy(const Char *var, const Char *val, int flags)
629 cleanup_push(copy, xfree);
630 setv(var, copy, flags);
631 cleanup_ignore(copy);
636 * The caller is responsible for putting value in a safe place
639 setv(const Char *var, Char *val, int flags)
641 Char **vec = xmalloc(2 * sizeof(Char **));
645 set1(var, vec, &shvhed, flags);
649 set1(const Char *var, Char **vec, struct varent *head, int flags)
653 if ((flags & VAR_NOGLOB) == 0) {
658 vec = globall(oldv, gflag);
661 stderror(ERR_NAME | ERR_NOMATCH);
667 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
669 if ( flags & (VAR_FIRST | VAR_LAST) ) {
671 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
673 * Delete all duplicate words leaving "holes" in the word array (vec).
674 * Then remove the "holes", keeping the order of the words unchanged.
676 if (vec[0] && vec[1]) { /* more than one word ? */
680 for (num_items = 0; vec[num_items]; num_items++)
682 if (flags & VAR_FIRST) {
683 /* delete duplications, keeping first occurance */
684 for (i = 1; i < num_items; i++)
685 for (j = 0; j < i; j++)
686 /* If have earlier identical item, remove i'th item */
687 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
692 } else if (flags & VAR_LAST) {
693 /* delete duplications, keeping last occurance */
694 for (i = 0; i < num_items - 1; i++)
695 for (j = i + 1; j < num_items; j++)
696 /* If have later identical item, remove i'th item */
697 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
698 /* remove identical item (the first) */
703 /* Compress items - remove empty items */
704 for (j = i = 0; i < num_items; i++)
708 /* NULL-fy remaining items */
709 for (; j < num_items; j++)
712 /* don't let the attribute propagate */
713 flags &= ~(VAR_FIRST|VAR_LAST);
715 setq(var, vec, head, flags);
720 setq(const Char *name, Char **vec, struct varent *p, int flags)
725 f = 0; /* tree hangs off the header's left link */
726 while ((c = p->v_link[f]) != 0) {
727 if ((f = *name - *c->v_name) == 0 &&
728 (f = Strcmp(name, c->v_name)) == 0) {
729 if (c->v_flags & VAR_READONLY)
730 stderror(ERR_READONLY|ERR_NAME, c->v_name);
739 p->v_link[f] = c = xmalloc(sizeof(struct varent));
740 c->v_name = Strsave(name);
743 c->v_left = c->v_right = 0;
751 unset(Char **v, struct command *c)
753 int did_roe, did_edit;
756 did_roe = adrof(STRrecognize_only_executables) != NULL;
757 did_edit = adrof(STRedit) != NULL;
760 #if defined(FILEC) && defined(TIOCSTI)
761 if (adrof(STRfilec) == 0)
763 #endif /* FILEC && TIOCSTI */
765 if (adrof(STRhistchars) == 0) {
769 if (adrof(STRignoreeof) == 0)
771 if (adrof(STRpromptchars) == 0) {
772 PRCH = tcsh ? '>' : '%';
775 if (adrof(STRnoclobber) == 0)
777 if (adrof(STRhistlit) == 0)
779 if (adrof(STRloginsh) == 0)
781 if (adrof(STRanyerror) == 0)
783 if (adrof(STRwordchars) == 0)
784 word_chars = STR_WORD_CHARS;
785 if (adrof(STRedit) == 0)
787 if (adrof(STRbackslash_quote) == 0)
789 if (adrof(STRcompat_expr) == 0)
791 if (adrof(STRsymlinks) == 0)
793 if (adrof(STRimplicitcd) == 0)
795 if (adrof(STRcdtohome) == 0)
797 if (adrof(STRkillring) == 0)
799 if (did_edit && noediting && adrof(STRedit) == 0)
801 if (adrof(STRvimode) == 0)
803 if (did_roe && adrof(STRrecognize_only_executables) == 0)
805 if (adrof(STRhistory) == 0)
808 if (adrof(STRcolor) == 0)
810 #endif /* COLOR_LS_F */
811 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
812 update_dspmbyte_vars();
818 #endif /* NLS_CATALOGS */
822 unset1(Char *v[], struct varent *head)
829 while ((vp = madrof(*v, head)) != NULL)
830 if (vp->v_flags & VAR_READONLY)
831 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
835 setname(short2str(*v));
844 if ((vp = adrof1(var, &shvhed)) == 0)
850 unsetv1(struct varent *p)
852 struct varent *c, *pp;
856 * Free associated memory first to avoid complications.
861 * If p is missing one child, then we can move the other into where p is.
862 * Otherwise, we find the predecessor of p, which is guaranteed to have no
863 * right child, copy it into p, and move it's left child into it.
867 else if (p->v_left == 0)
870 for (c = p->v_left; c->v_right; c = c->v_right)
872 p->v_name = c->v_name;
873 p->v_flags = c->v_flags;
880 * Move c into where p is.
883 f = pp->v_right == p;
884 if ((pp->v_link[f] = c) != 0)
887 * Free the deleted node, and rebalance.
893 /* Set variable name to NULL. */
895 setNS(const Char *varName)
897 setcopy(varName, STRNULL, VAR_READWRITE);
902 shift(Char **v, struct command *c)
915 if (argv == NULL || argv->vec == NULL)
917 if (argv->vec[0] == 0)
918 stderror(ERR_NAME | ERR_NOMORE);
919 lshift(argv->vec, 1);
924 exportpath(Char **val)
926 struct Strbuf buf = Strbuf_INIT;
931 Strbuf_append(&buf, *val++);
932 if (*val == 0 || eq(*val, STRRparen))
934 Strbuf_append1(&buf, PATHSEP);
936 exppath = Strbuf_finish(&buf);
937 cleanup_push(exppath, xfree);
938 tsetenv(STRKPATH, exppath);
939 cleanup_until(exppath);
943 set_noclobber(Char **val)
946 int nc = NOCLOBBER_DEFAULT;
951 if (*val == 0 || eq(*val, STRRparen))
956 if (eq(option, STRnotempty))
957 nc |= NOCLOBBER_NOTEMPTY;
958 else if (eq(option, STRask))
966 * Lint thinks these have null effect
968 /* macros to do single rotations on node p */
969 # define rright(p) (\
971 (t)->v_parent = (p)->v_parent,\
972 (((p)->v_left = t->v_right) != NULL) ?\
973 (t->v_right->v_parent = (p)) : 0,\
974 (t->v_right = (p))->v_parent = t,\
978 ((t)->v_parent = (p)->v_parent,\
979 ((p)->v_right = t->v_left) != NULL) ? \
980 (t->v_left->v_parent = (p)) : 0,\
981 (t->v_left = (p))->v_parent = t,\
984 static struct varent *
985 rleft(struct varent *p)
989 static struct varent *
990 rright(struct varent *p)
999 * Rebalance a tree, starting at p and up.
1000 * F == 0 means we've come from p's left child.
1001 * D == 1 means we've just done a delete, otherwise an insert.
1004 balance(struct varent *p, int f, int d)
1009 struct varent *t; /* used by the rotate macros */
1013 ff = 0; /* Sun's lint is dumb! */
1017 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
1018 * is the branch of p from which we have come; ff is the branch of pp which
1021 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
1022 ff = pp->v_right == p;
1023 if (f ^ d) { /* right heavy */
1025 case -1: /* was left heavy */
1028 case 0: /* was balanced */
1031 case 1: /* was already right heavy */
1032 switch (p->v_right->v_bal) {
1033 case 1: /* single rotate */
1034 pp->v_link[ff] = rleft(p);
1035 p->v_left->v_bal = 0;
1038 case 0: /* single rotate */
1039 pp->v_link[ff] = rleft(p);
1040 p->v_left->v_bal = 1;
1043 case -1: /* double rotate */
1044 (void) rright(p->v_right);
1045 pp->v_link[ff] = rleft(p);
1047 p->v_bal < 1 ? 0 : -1;
1049 p->v_bal > -1 ? 0 : 1;
1060 else { /* left heavy */
1062 case 1: /* was right heavy */
1065 case 0: /* was balanced */
1068 case -1: /* was already left heavy */
1069 switch (p->v_left->v_bal) {
1070 case -1: /* single rotate */
1071 pp->v_link[ff] = rright(p);
1072 p->v_right->v_bal = 0;
1075 case 0: /* single rotate */
1076 pp->v_link[ff] = rright(p);
1077 p->v_right->v_bal = -1;
1080 case 1: /* double rotate */
1081 (void) rleft(p->v_left);
1082 pp->v_link[ff] = rright(p);
1084 p->v_bal < 1 ? 0 : -1;
1086 p->v_bal > -1 ? 0 : 1;
1098 * If from insert, then we terminate when p is balanced. If from
1099 * delete, then we terminate when p is unbalanced.
1101 if ((p->v_bal == 0) ^ d)
1107 plist(struct varent *p, int what)
1116 if (p->v_parent == 0) /* is it the header? */
1118 if ((p->v_flags & what) != 0) {
1120 int old_pintr_disabled;
1122 pintr_push_enable(&old_pintr_disabled);
1123 cleanup_until(&old_pintr_disabled);
1125 len = blklen(p->vec);
1126 xprintf("%S\t", p->v_name);
1141 } while (p->v_right == c);
1147 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1148 extern int dspmbyte_ls;
1151 update_dspmbyte_vars(void)
1157 /* if variable "nokanji" is set, multi-byte display is disabled */
1158 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1161 if (eq (dstr1, STRsjis))
1163 else if (eq(dstr1, STReuc))
1165 else if (eq(dstr1, STRbig5))
1167 else if (eq(dstr1, STRutf8))
1169 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1173 xprintf(CGETS(18, 2,
1174 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1177 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1181 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1185 _cmap[lp] = _cmap_mbyte[lp];
1186 _mbmap[lp] = _mbmap_sjis[lp];
1190 _cmap[lp] = _cmap_mbyte[lp];
1191 _mbmap[lp] = _mbmap_euc[lp];
1195 _cmap[lp] = _cmap_mbyte[lp];
1196 _mbmap[lp] = _mbmap_big5[lp];
1200 _cmap[lp] = _cmap_mbyte[lp];
1201 _mbmap[lp] = _mbmap_utf8[lp];
1204 xprintf(CGETS(18, 3,
1205 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1207 _cmap[lp] = _cmap_c[lp];
1208 _mbmap[lp] = 0; /* Default map all 0 */
1214 /* check original table */
1215 if (Strlen(dstr1) != 256) {
1216 xprintf(CGETS(18, 4,
1217 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1221 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1222 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1223 xprintf(CGETS(18, 4,
1224 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1230 /* set original table */
1231 for (lp = 0; lp < 256; lp++) {
1232 if (_enable_mbdisp == 1) {
1233 _cmap[lp] = _cmap_mbyte[lp];
1234 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1237 _cmap[lp] = _cmap_c[lp];
1238 _mbmap[lp] = 0; /* Default map all 0 */
1244 for (lp = 0; lp < 256; lp++) {
1245 _cmap[lp] = _cmap_c[lp];
1246 _mbmap[lp] = 0; /* Default map all 0 */
1251 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1254 for (lp = 0; lp < 256; lp++)
1255 mbmapstr[lp] = _mbmap[lp] + '0';
1257 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1259 #endif /* MBYTEMAP */
1262 /* dspkanji/dspmbyte autosetting */
1263 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1265 autoset_dspmbyte(const Char *pcp)
1268 static const struct dspm_autoset_Table {
1272 { STRLANGEUCJP, STReuc },
1273 { STRLANGEUCKR, STReuc },
1274 { STRLANGEUCZH, STReuc },
1275 { STRLANGEUCJPB, STReuc },
1276 { STRLANGEUCKRB, STReuc },
1277 { STRLANGEUCZHB, STReuc },
1279 { STRLANGEUCJPC, STReuc },
1281 { STRLANGSJIS, STRsjis },
1282 { STRLANGSJISB, STRsjis },
1283 { STRLANGBIG5, STRbig5 },
1284 { STRstarutfstar8, STRutf8 },
1287 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1288 static const struct dspm_autoset_Table dspmc[] = {
1289 { STRstarutfstar8, STRutf8 },
1291 { STRGB2312, STReuc },
1292 { STRLANGBIG5, STRbig5 },
1297 codeset = str2short(nl_langinfo(CODESET));
1298 if (*codeset != '\0') {
1299 for (i = 0; dspmc[i].n; i++) {
1301 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1302 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1303 update_dspmbyte_vars();
1313 for (i = 0; dspmt[i].n; i++) {
1315 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1316 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1317 update_dspmbyte_vars();
1322 # elif defined(AUTOSET_KANJI)
1326 char *codeset = nl_langinfo(CODESET);
1328 if (*codeset == '\0') {
1329 if (adrof(STRnokanji) == NULL)
1334 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1335 if (adrof(STRnokanji) == NULL)
1340 if (adrof(STRnokanji) != NULL)
1347 update_wordchars(void)
1349 if ((word_chars == STR_WORD_CHARS) || (word_chars == STR_WORD_CHARS_VI)) {
1350 word_chars = (VImode ? STR_WORD_CHARS_VI : STR_WORD_CHARS);