1 /* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.89 2015/09/08 15:49:53 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.89 2015/09/08 15:49:53 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);
58 static int set_noclobber (Char **);
67 if (eq(vp, STRpath)) {
68 struct varent *p = adrof(STRpath);
70 stderror(ERR_NAME | ERR_UNDVAR);
76 else if (eq(vp, STRnoclobber)) {
77 struct varent *p = adrof(STRnoclobber);
79 stderror(ERR_NAME | ERR_UNDVAR);
81 no_clobber = set_noclobber(p->vec);
83 else if (eq(vp, STRhistchars)) {
84 Char *pn = varval(vp);
92 else if (eq(vp, STRpromptchars)) {
93 Char *pn = varval(vp);
101 else if (eq(vp, STRhistlit)) {
104 else if (eq(vp, STRuser)) {
105 tsetenv(STRKUSER, varval(vp));
106 tsetenv(STRLOGNAME, varval(vp));
108 else if (eq(vp, STRgroup)) {
109 tsetenv(STRKGROUP, varval(vp));
111 else if (eq(vp, STRwordchars)) {
112 word_chars = varval(vp);
114 else if (eq(vp, STRloginsh)) {
117 else if (eq(vp, STRanyerror)) {
120 else if (eq(vp, STRsymlinks)) {
121 Char *pn = varval(vp);
123 if (eq(pn, STRignore))
124 symlinks = SYM_IGNORE;
125 else if (eq(pn, STRexpand))
126 symlinks = SYM_EXPAND;
127 else if (eq(pn, STRchase))
128 symlinks = SYM_CHASE;
132 else if (eq(vp, STRterm)) {
133 Char *cp = varval(vp);
134 tsetenv(STRKTERM, cp);
135 #ifdef DOESNT_WORK_RIGHT
136 cp = getenv("TERMCAP");
137 if (cp && (*cp != '/')) /* if TERMCAP and not a path */
138 Unsetenv(STRTERMCAP);
139 #endif /* DOESNT_WORK_RIGHT */
141 if (noediting && Strcmp(cp, STRnetwork) != 0 &&
142 Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
147 ed_Init(); /* reset the editor */
149 else if (eq(vp, STRhome)) {
152 cp = Strsave(varval(vp)); /* get the old value back */
153 cleanup_push(cp, xfree);
156 * convert to cononical pathname (possibly resolving symlinks)
158 canon = dcanon(cp, cp);
161 cleanup_push(canon, xfree);
163 setcopy(vp, canon, VAR_READWRITE); /* have to save the new val */
165 /* and now mirror home with HOME */
166 tsetenv(STRKHOME, canon);
167 /* fix directory stack for new tilde home */
169 cleanup_until(canon);
171 else if (eq(vp, STRedit)) {
174 /* PWP: add more stuff in here later */
176 else if (eq(vp, STRvimode)) {
180 else if (eq(vp, STRshlvl)) {
181 tsetenv(STRKSHLVL, varval(vp));
183 else if (eq(vp, STRignoreeof)) {
186 for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
191 numeof = numeof * 10 + *cp - '0';
193 if (numeof <= 0) numeof = 26; /* Sanity check */
195 else if (eq(vp, STRbackslash_quote)) {
198 else if (eq(vp, STRcompat_expr)) {
201 else if (eq(vp, STRdirstack)) {
204 else if (eq(vp, STRrecognize_only_executables)) {
207 else if (eq(vp, STRkillring)) {
208 SetKillRing((int)getn(varval(vp)));
210 else if (eq(vp, STRhistory)) {
211 sethistory((int)getn(varval(vp)));
214 else if (eq(vp, STRwatch)) {
217 #endif /* HAVENOUTMP */
218 else if (eq(vp, STRimplicitcd)) {
219 implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
221 else if (eq(vp, STRcdtohome)) {
225 else if (eq(vp, STRcolor)) {
228 #endif /* COLOR_LS_F */
229 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
230 else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
231 update_dspmbyte_vars();
235 else if (eq(vp, STRcatalog)) {
239 #if defined(FILEC) && defined(TIOCSTI)
240 else if (eq(vp, STRfilec))
243 #endif /* NLS_CATALOGS */
249 doset(Char **v, struct command *c)
256 int flags = VAR_READWRITE;
266 * Readonly addition From: Tim P. Starrin <noid@cyborg.larc.nasa.gov>
268 if (*v && eq(*v, STRmr)) {
269 flags = VAR_READONLY;
273 if (*v && eq(*v, STRmf) && !last_match) {
278 if (*v && eq(*v, STRml) && !first_match) {
286 plist(&shvhed, flags);
293 stderror(ERR_NAME | ERR_VARBEGIN);
299 p = getinx(p, &subscr);
301 if (*p != '\0' && *p != '=')
302 stderror(ERR_NAME | ERR_VARALNUM);
305 if (*p == '\0' && *v != NULL && **v == '(')
308 else if (*v && eq(*v, STRequal)) {
312 if (eq(p, STRLparen)) {
316 stderror(ERR_NAME | ERR_SYNTAX);
319 stderror(ERR_NAME | ERR_MISSING, ')');
332 set1(vp, vecp, &shvhed, flags);
340 cleanup_push(copy, xfree);
341 asx(vp, subscr, copy);
342 cleanup_ignore(copy);
346 setv(vp, Strsave(p), flags);
348 } while ((p = *v++) != NULL);
352 getinx(Char *cp, int *ip)
356 while (*cp && Isdigit(*cp))
357 *ip = *ip * 10 + *cp++ - '0';
359 stderror(ERR_NAME | ERR_SUBSCRIPT);
364 asx(Char *vp, int subscr, Char *p)
366 struct varent *v = getvx(vp, subscr);
369 if (v->v_flags & VAR_READONLY)
370 stderror(ERR_READONLY|ERR_NAME, v->v_name);
371 prev = v->vec[subscr - 1];
372 cleanup_push(prev, xfree);
373 v->vec[subscr - 1] = globone(p, G_APPEND);
377 static struct varent *
378 getvx(Char *vp, int subscr)
380 struct varent *v = adrof(vp);
384 if (subscr < 1 || subscr > blklen(v->vec))
385 stderror(ERR_NAME | ERR_RANGE);
391 dolet(Char **v, struct command *dummy)
409 for (; alnum(*p); p++)
411 if (vp == p || !letter(*vp))
412 stderror(ERR_NAME | ERR_VARBEGIN);
415 p = getinx(p, &subscr);
422 stderror(ERR_NAME | ERR_ASSIGN);
425 * if there is no expression after the '=' then print a "Syntax Error"
428 if (*p == '\0' && *v == NULL)
429 stderror(ERR_NAME | ERR_ASSIGN);
432 cleanup_push(vp, xfree);
441 stderror(ERR_NAME | ERR_UNKNOWNOP);
447 stderror(ERR_NAME | ERR_UNKNOWNOP);
448 stderror(ERR_NAME | ERR_SYNTAX);
451 stderror(ERR_NAME | ERR_UNKNOWNOP);
455 cleanup_push(p, xfree);
460 setv(vp, p, VAR_READWRITE);
464 struct varent *gv = getvx(vp, subscr);
467 val = operate(op, gv->vec[subscr - 1], p);
468 cleanup_push(val, xfree);
469 asx(vp, subscr, val);
476 val = operate(op, varval(vp), p);
477 cleanup_push(val, xfree);
478 setv(vp, val, VAR_READWRITE);
484 } while ((p = *v++) != NULL);
488 xset(Char *cp, Char ***vp)
498 return (putn(expr(vp)));
502 operate(int op, Char *vp, Char *p)
516 if (op == '<' || op == '>')
523 stderror(ERR_NAME | ERR_EXPRESSION);
530 putn(tcsh_number_t n)
532 Char nbuf[1024]; /* Enough even for octal */
541 return (Strsave(nbuf));
545 putn1(tcsh_number_t n)
549 *putp++ = (Char)(n % 10 + '0');
559 if (!cp) /* PWP: extra error checking */
560 stderror(ERR_NAME | ERR_BADNUM);
563 if (cp[0] == '+' && cp[1])
569 stderror(ERR_NAME | ERR_BADNUM);
572 if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
580 if (base == 8 && *cp >= '8')
581 stderror(ERR_NAME | ERR_BADNUM);
582 n = n * base + *cp++ - '0';
585 stderror(ERR_NAME | ERR_BADNUM);
586 return (sign ? -n : n);
590 value1(Char *var, struct varent *head)
594 if (!var || !head) /* PWP: extra error checking */
597 vp = adrof1(var, head);
598 return ((vp == NULL || vp->vec == NULL || vp->vec[0] == NULL) ?
599 STRNULL : vp->vec[0]);
602 static struct varent *
603 madrof(Char *pat, struct varent *vp)
607 for (vp = vp->v_left; vp; vp = vp->v_right) {
608 if (vp->v_left && (vp1 = madrof(pat, vp)) != NULL)
610 if (Gmatch(vp->v_name, pat))
617 adrof1(const Char *name, struct varent *v)
622 while (v && ((cmp = *name - *v->v_name) != 0 ||
623 (cmp = Strcmp(name, v->v_name)) != 0))
632 setcopy(const Char *var, const Char *val, int flags)
637 cleanup_push(copy, xfree);
638 setv(var, copy, flags);
639 cleanup_ignore(copy);
644 * The caller is responsible for putting value in a safe place
647 setv(const Char *var, Char *val, int flags)
649 Char **vec = xmalloc(2 * sizeof(Char **));
653 set1(var, vec, &shvhed, flags);
657 set1(const Char *var, Char **vec, struct varent *head, int flags)
661 if ((flags & VAR_NOGLOB) == 0) {
666 vec = globall(oldv, gflag);
669 stderror(ERR_NAME | ERR_NOMATCH);
675 * Uniqueness addition from: Michael Veksler <mveksler@vnet.ibm.com>
677 if ( flags & (VAR_FIRST | VAR_LAST) ) {
679 * Code for -f (VAR_FIRST) and -l (VAR_LAST) options.
681 * Delete all duplicate words leaving "holes" in the word array (vec).
682 * Then remove the "holes", keeping the order of the words unchanged.
684 if (vec && vec[0] && vec[1]) { /* more than one word ? */
688 for (num_items = 0; vec[num_items]; num_items++)
690 if (flags & VAR_FIRST) {
691 /* delete duplications, keeping first occurance */
692 for (i = 1; i < num_items; i++)
693 for (j = 0; j < i; j++)
694 /* If have earlier identical item, remove i'th item */
695 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
700 } else if (flags & VAR_LAST) {
701 /* delete duplications, keeping last occurance */
702 for (i = 0; i < num_items - 1; i++)
703 for (j = i + 1; j < num_items; j++)
704 /* If have later identical item, remove i'th item */
705 if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
706 /* remove identical item (the first) */
711 /* Compress items - remove empty items */
712 for (j = i = 0; i < num_items; i++)
716 /* NULL-fy remaining items */
717 for (; j < num_items; j++)
720 /* don't let the attribute propagate */
721 flags &= ~(VAR_FIRST|VAR_LAST);
723 setq(var, vec, head, flags);
728 setq(const Char *name, Char **vec, struct varent *p, int flags)
733 f = 0; /* tree hangs off the header's left link */
734 while ((c = p->v_link[f]) != 0) {
735 if ((f = *name - *c->v_name) == 0 &&
736 (f = Strcmp(name, c->v_name)) == 0) {
737 if (c->v_flags & VAR_READONLY)
738 stderror(ERR_READONLY|ERR_NAME, c->v_name);
747 p->v_link[f] = c = xmalloc(sizeof(struct varent));
748 c->v_name = Strsave(name);
751 c->v_left = c->v_right = 0;
759 unset(Char **v, struct command *c)
761 int did_roe, did_edit;
764 did_roe = adrof(STRrecognize_only_executables) != NULL;
765 did_edit = adrof(STRedit) != NULL;
768 #if defined(FILEC) && defined(TIOCSTI)
769 if (adrof(STRfilec) == 0)
771 #endif /* FILEC && TIOCSTI */
773 if (adrof(STRhistchars) == 0) {
777 if (adrof(STRignoreeof) == 0)
779 if (adrof(STRpromptchars) == 0) {
780 PRCH = tcsh ? '>' : '%';
783 if (adrof(STRnoclobber) == 0)
785 if (adrof(STRhistlit) == 0)
787 if (adrof(STRloginsh) == 0)
789 if (adrof(STRanyerror) == 0)
791 if (adrof(STRwordchars) == 0)
792 word_chars = STR_WORD_CHARS;
793 if (adrof(STRedit) == 0)
795 if (adrof(STRbackslash_quote) == 0)
797 if (adrof(STRcompat_expr) == 0)
799 if (adrof(STRsymlinks) == 0)
801 if (adrof(STRimplicitcd) == 0)
803 if (adrof(STRcdtohome) == 0)
805 if (adrof(STRkillring) == 0)
807 if (did_edit && noediting && adrof(STRedit) == 0)
809 if (adrof(STRvimode) == 0)
811 if (did_roe && adrof(STRrecognize_only_executables) == 0)
813 if (adrof(STRhistory) == 0)
816 if (adrof(STRcolor) == 0)
818 #endif /* COLOR_LS_F */
819 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
820 update_dspmbyte_vars();
826 #endif /* NLS_CATALOGS */
830 unset1(Char *v[], struct varent *head)
837 while ((vp = madrof(*v, head)) != NULL)
838 if (vp->v_flags & VAR_READONLY)
839 stderror(ERR_READONLY|ERR_NAME, vp->v_name);
843 setname(short2str(*v));
852 if ((vp = adrof1(var, &shvhed)) == 0)
858 unsetv1(struct varent *p)
860 struct varent *c, *pp;
864 * Free associated memory first to avoid complications.
869 * If p is missing one child, then we can move the other into where p is.
870 * Otherwise, we find the predecessor of p, which is guaranteed to have no
871 * right child, copy it into p, and move it's left child into it.
875 else if (p->v_left == 0)
878 for (c = p->v_left; c->v_right; c = c->v_right)
880 p->v_name = c->v_name;
881 p->v_flags = c->v_flags;
888 * Move c into where p is.
891 f = pp->v_right == p;
892 if ((pp->v_link[f] = c) != 0)
895 * Free the deleted node, and rebalance.
901 /* Set variable name to NULL. */
903 setNS(const Char *varName)
905 setcopy(varName, STRNULL, VAR_READWRITE);
910 shift(Char **v, struct command *c)
923 if (argv == NULL || argv->vec == NULL)
925 if (argv->vec[0] == 0)
926 stderror(ERR_NAME | ERR_NOMORE);
927 lshift(argv->vec, 1);
932 exportpath(Char **val)
934 struct Strbuf buf = Strbuf_INIT;
939 Strbuf_append(&buf, *val++);
940 if (*val == 0 || eq(*val, STRRparen))
942 Strbuf_append1(&buf, PATHSEP);
944 exppath = Strbuf_finish(&buf);
945 cleanup_push(exppath, xfree);
946 tsetenv(STRKPATH, exppath);
947 cleanup_until(exppath);
951 set_noclobber(Char **val)
954 int nc = NOCLOBBER_DEFAULT;
959 if (*val == 0 || eq(*val, STRRparen))
964 if (eq(option, STRnotempty))
965 nc |= NOCLOBBER_NOTEMPTY;
966 else if (eq(option, STRask))
974 * Lint thinks these have null effect
976 /* macros to do single rotations on node p */
977 # define rright(p) (\
979 (t)->v_parent = (p)->v_parent,\
980 (((p)->v_left = t->v_right) != NULL) ?\
981 (t->v_right->v_parent = (p)) : 0,\
982 (t->v_right = (p))->v_parent = t,\
986 ((t)->v_parent = (p)->v_parent,\
987 ((p)->v_right = t->v_left) != NULL) ? \
988 (t->v_left->v_parent = (p)) : 0,\
989 (t->v_left = (p))->v_parent = t,\
992 static struct varent *
993 rleft(struct varent *p)
997 static struct varent *
998 rright(struct varent *p)
1007 * Rebalance a tree, starting at p and up.
1008 * F == 0 means we've come from p's left child.
1009 * D == 1 means we've just done a delete, otherwise an insert.
1012 balance(struct varent *p, int f, int d)
1017 struct varent *t; /* used by the rotate macros */
1021 ff = 0; /* Sun's lint is dumb! */
1025 * Ok, from here on, p is the node we're operating on; pp is it's parent; f
1026 * is the branch of p from which we have come; ff is the branch of pp which
1029 for (; (pp = p->v_parent) != 0; p = pp, f = ff) {
1030 ff = pp->v_right == p;
1031 if (f ^ d) { /* right heavy */
1033 case -1: /* was left heavy */
1036 case 0: /* was balanced */
1039 case 1: /* was already right heavy */
1040 switch (p->v_right->v_bal) {
1041 case 1: /* single rotate */
1042 pp->v_link[ff] = rleft(p);
1043 p->v_left->v_bal = 0;
1046 case 0: /* single rotate */
1047 pp->v_link[ff] = rleft(p);
1048 p->v_left->v_bal = 1;
1051 case -1: /* double rotate */
1052 (void) rright(p->v_right);
1053 pp->v_link[ff] = rleft(p);
1055 p->v_bal < 1 ? 0 : -1;
1057 p->v_bal > -1 ? 0 : 1;
1068 else { /* left heavy */
1070 case 1: /* was right heavy */
1073 case 0: /* was balanced */
1076 case -1: /* was already left heavy */
1077 switch (p->v_left->v_bal) {
1078 case -1: /* single rotate */
1079 pp->v_link[ff] = rright(p);
1080 p->v_right->v_bal = 0;
1083 case 0: /* single rotate */
1084 pp->v_link[ff] = rright(p);
1085 p->v_right->v_bal = -1;
1088 case 1: /* double rotate */
1089 (void) rleft(p->v_left);
1090 pp->v_link[ff] = rright(p);
1092 p->v_bal < 1 ? 0 : -1;
1094 p->v_bal > -1 ? 0 : 1;
1106 * If from insert, then we terminate when p is balanced. If from
1107 * delete, then we terminate when p is unbalanced.
1109 if ((p->v_bal == 0) ^ d)
1115 plist(struct varent *p, int what)
1124 if (p->v_parent == 0) /* is it the header? */
1126 if ((p->v_flags & what) != 0) {
1128 int old_pintr_disabled;
1130 pintr_push_enable(&old_pintr_disabled);
1131 cleanup_until(&old_pintr_disabled);
1133 len = blklen(p->vec);
1134 xprintf("%S\t", p->v_name);
1149 } while (p->v_right == c);
1155 # if defined(SHORT_STRINGS) && defined(DSPMBYTE)
1156 extern int dspmbyte_ls;
1159 update_dspmbyte_vars(void)
1165 /* if variable "nokanji" is set, multi-byte display is disabled */
1166 if ((vp = adrof(CHECK_MBYTEVAR)) && !adrof(STRnokanji)) {
1169 if(eq (dstr1, STRsjis))
1171 else if (eq(dstr1, STReuc))
1173 else if (eq(dstr1, STRbig5))
1175 else if (eq(dstr1, STRutf8))
1177 else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
1181 xprintf(CGETS(18, 2,
1182 "Warning: unknown multibyte display; using default(euc(JP))\n"));
1185 if (dstr1 && vp->vec[1] && eq(vp->vec[1], STRls))
1189 for (lp = 0; lp < 256 && iskcode > 0; lp++) {
1193 _cmap[lp] = _cmap_mbyte[lp];
1194 _mbmap[lp] = _mbmap_sjis[lp];
1198 _cmap[lp] = _cmap_mbyte[lp];
1199 _mbmap[lp] = _mbmap_euc[lp];
1203 _cmap[lp] = _cmap_mbyte[lp];
1204 _mbmap[lp] = _mbmap_big5[lp];
1208 _cmap[lp] = _cmap_mbyte[lp];
1209 _mbmap[lp] = _mbmap_utf8[lp];
1212 xprintf(CGETS(18, 3,
1213 "Warning: unknown multibyte code %d; multibyte disabled\n"),
1215 _cmap[lp] = _cmap_c[lp];
1216 _mbmap[lp] = 0; /* Default map all 0 */
1222 /* check original table */
1223 if (Strlen(dstr1) != 256) {
1224 xprintf(CGETS(18, 4,
1225 "Warning: Invalid multibyte table length (%d); multibyte disabled\n"),
1229 for (lp = 0; lp < 256 && _enable_mbdisp == 1; lp++) {
1230 if (!((dstr1[lp] - '0') >= 0 && (dstr1[lp] - '0') <= 3)) {
1231 xprintf(CGETS(18, 4,
1232 "Warning: bad multibyte code at offset +%d; multibyte diabled\n"),
1238 /* set original table */
1239 for (lp = 0; lp < 256; lp++) {
1240 if (_enable_mbdisp == 1) {
1241 _cmap[lp] = _cmap_mbyte[lp];
1242 _mbmap[lp] = (unsigned short) ((dstr1[lp] - '0') & 0x0f);
1245 _cmap[lp] = _cmap_c[lp];
1246 _mbmap[lp] = 0; /* Default map all 0 */
1252 for (lp = 0; lp < 256; lp++) {
1253 _cmap[lp] = _cmap_c[lp];
1254 _mbmap[lp] = 0; /* Default map all 0 */
1259 #ifdef MBYTEDEBUG /* Sorry, use for beta testing */
1262 for (lp = 0; lp < 256; lp++)
1263 mbmapstr[lp] = _mbmap[lp] + '0';
1265 setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
1267 #endif /* MBYTEMAP */
1270 /* dspkanji/dspmbyte autosetting */
1271 /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
1273 autoset_dspmbyte(const Char *pcp)
1276 static const struct dspm_autoset_Table {
1280 { STRLANGEUCJP, STReuc },
1281 { STRLANGEUCKR, STReuc },
1282 { STRLANGEUCZH, STReuc },
1283 { STRLANGEUCJPB, STReuc },
1284 { STRLANGEUCKRB, STReuc },
1285 { STRLANGEUCZHB, STReuc },
1287 { STRLANGEUCJPC, STReuc },
1289 { STRLANGSJIS, STRsjis },
1290 { STRLANGSJISB, STRsjis },
1291 { STRLANGBIG5, STRbig5 },
1292 { STRstarutfstar8, STRutf8 },
1295 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1296 static const struct dspm_autoset_Table dspmc[] = {
1297 { STRstarutfstar8, STRutf8 },
1299 { STRGB2312, STReuc },
1300 { STRLANGBIG5, STRbig5 },
1305 codeset = str2short(nl_langinfo(CODESET));
1306 if (*codeset != '\0') {
1307 for (i = 0; dspmc[i].n; i++) {
1309 if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
1310 setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
1311 update_dspmbyte_vars();
1321 for (i = 0; dspmt[i].n; i++) {
1323 if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
1324 setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
1325 update_dspmbyte_vars();
1330 # elif defined(AUTOSET_KANJI)
1334 char *codeset = nl_langinfo(CODESET);
1336 if (*codeset == '\0') {
1337 if (adrof(STRnokanji) == NULL)
1342 if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
1343 if (adrof(STRnokanji) == NULL)
1348 if (adrof(STRnokanji) != NULL)
1355 update_wordchars(void)
1357 if ((word_chars == STR_WORD_CHARS) || (word_chars == STR_WORD_CHARS_VI)) {
1358 word_chars = (VImode ? STR_WORD_CHARS_VI : STR_WORD_CHARS);