1 | /* $Header: /afs/dev.mit.edu/source/repository/third/tcsh/tc.nls.h,v 1.1.1.1 2005-06-03 14:35:27 ghudson Exp $ */ |
---|
2 | /* |
---|
3 | * tc.nls.h: NLS support |
---|
4 | * |
---|
5 | */ |
---|
6 | /*- |
---|
7 | * Copyright (c) 1980, 1991 The Regents of the University of California. |
---|
8 | * All rights reserved. |
---|
9 | * |
---|
10 | * Redistribution and use in source and binary forms, with or without |
---|
11 | * modification, are permitted provided that the following conditions |
---|
12 | * are met: |
---|
13 | * 1. Redistributions of source code must retain the above copyright |
---|
14 | * notice, this list of conditions and the following disclaimer. |
---|
15 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
16 | * notice, this list of conditions and the following disclaimer in the |
---|
17 | * documentation and/or other materials provided with the distribution. |
---|
18 | * 3. Neither the name of the University nor the names of its contributors |
---|
19 | * may be used to endorse or promote products derived from this software |
---|
20 | * without specific prior written permission. |
---|
21 | * |
---|
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
---|
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
---|
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
32 | * SUCH DAMAGE. |
---|
33 | */ |
---|
34 | #ifndef _h_tc_nls |
---|
35 | #define _h_tc_nls |
---|
36 | |
---|
37 | #include "sh.h" |
---|
38 | |
---|
39 | #define NLSZEROT ((size_t)-1) |
---|
40 | |
---|
41 | #ifdef WIDE_STRINGS |
---|
42 | |
---|
43 | # define NLSSize(s, l) 1 |
---|
44 | # define NLSFrom(s, l, cp) (USE (l), (*(cp) = *(s) & CHAR), 1) |
---|
45 | # define NLSFinished(s, l, c) (l != 0 && c != CHAR_ERR ? 2 : 1) |
---|
46 | # define NLSChars(s) Strlen(s) |
---|
47 | # define NLSQuote(s) |
---|
48 | # define TRIM_AND_EXTEND(s, c) (c &= TRIM) |
---|
49 | |
---|
50 | extern int NLSWidth __P((NLSChar)); |
---|
51 | extern int NLSStringWidth __P((Char *)); |
---|
52 | |
---|
53 | #define NLS_ILLEGAL INVALID_BYTE |
---|
54 | |
---|
55 | #else |
---|
56 | # ifdef SHORT_STRINGS |
---|
57 | |
---|
58 | extern int NLSFrom __P((const Char *, size_t, NLSChar *)); |
---|
59 | extern int NLSFinished __P((Char *, size_t, eChar)); |
---|
60 | extern int NLSChars __P((Char *)); |
---|
61 | extern int NLSStringWidth __P((Char *)); |
---|
62 | extern int NLSWidth __P((NLSChar)); |
---|
63 | extern int NLSTo __P((Char *, NLSChar)); |
---|
64 | extern void NLSQuote __P((Char *)); |
---|
65 | |
---|
66 | #define NLSSize(s, l) NLSFrom(s, l, (NLSChar *)0) |
---|
67 | #define TRIM_AND_EXTEND(s, c) (s += NLSFrom(s - 1, NLSZEROT, &c) - 1) |
---|
68 | #define NLS_ILLEGAL 0x40000000 |
---|
69 | |
---|
70 | |
---|
71 | # else |
---|
72 | # define NLSSize(s, l) 1 |
---|
73 | # define NLSFrom(s, l, cp) (USE (l), (*(cp) = *(s) & CHAR), 1) |
---|
74 | # define NLSFinished(s, l, c) (l != 0 && c != CHAR_ERR ? 2 : 1) |
---|
75 | # define NLSChars(s) Strlen(s) |
---|
76 | # define NLSStringWidth(s) Strlen(s) |
---|
77 | # define NLSWidth(c) 1 |
---|
78 | # define NLSQuote(s) |
---|
79 | |
---|
80 | # define TRIM_AND_EXTEND(s, c) (c &= TRIM) |
---|
81 | # define NLS_ILLEGAL 0x40000000 |
---|
82 | # endif |
---|
83 | #endif |
---|
84 | |
---|
85 | extern int NLSExtend __P((Char *, int, int)); |
---|
86 | extern Char *NLSChangeCase __P((Char *, int)); |
---|
87 | extern int NLSClassify __P((NLSChar, int)); |
---|
88 | |
---|
89 | #define NLSCLASS_CTRL (-1) |
---|
90 | #define NLSCLASS_TAB (-2) |
---|
91 | #define NLSCLASS_NL (-3) |
---|
92 | #define NLSCLASS_ILLEGAL (-4) |
---|
93 | #define NLSCLASS_ILLEGAL2 (-5) |
---|
94 | #define NLSCLASS_ILLEGAL3 (-6) |
---|
95 | #define NLSCLASS_ILLEGAL4 (-7) |
---|
96 | |
---|
97 | #define NLSCLASS_ILLEGAL_SIZE(x) (-(x) - (-(NLSCLASS_ILLEGAL) - 1)) |
---|
98 | |
---|
99 | #endif |
---|