123338178SMark Peek /* $Header: /src/pub/tcsh/tc.nls.h,v 3.9 2005/03/03 15:52:20 kim Exp $ */ 223338178SMark Peek /* 323338178SMark Peek * tc.nls.h: NLS support 423338178SMark Peek * 523338178SMark Peek */ 623338178SMark Peek /*- 723338178SMark Peek * Copyright (c) 1980, 1991 The Regents of the University of California. 823338178SMark Peek * All rights reserved. 923338178SMark Peek * 1023338178SMark Peek * Redistribution and use in source and binary forms, with or without 1123338178SMark Peek * modification, are permitted provided that the following conditions 1223338178SMark Peek * are met: 1323338178SMark Peek * 1. Redistributions of source code must retain the above copyright 1423338178SMark Peek * notice, this list of conditions and the following disclaimer. 1523338178SMark Peek * 2. Redistributions in binary form must reproduce the above copyright 1623338178SMark Peek * notice, this list of conditions and the following disclaimer in the 1723338178SMark Peek * documentation and/or other materials provided with the distribution. 1823338178SMark Peek * 3. Neither the name of the University nor the names of its contributors 1923338178SMark Peek * may be used to endorse or promote products derived from this software 2023338178SMark Peek * without specific prior written permission. 2123338178SMark Peek * 2223338178SMark Peek * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2323338178SMark Peek * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2423338178SMark Peek * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2523338178SMark Peek * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2623338178SMark Peek * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2723338178SMark Peek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2823338178SMark Peek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2923338178SMark Peek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3023338178SMark Peek * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3123338178SMark Peek * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3223338178SMark Peek * SUCH DAMAGE. 3323338178SMark Peek */ 3423338178SMark Peek #ifndef _h_tc_nls 3523338178SMark Peek #define _h_tc_nls 3623338178SMark Peek 3723338178SMark Peek #include "sh.h" 3823338178SMark Peek 3923338178SMark Peek #define NLSZEROT ((size_t)-1) 4023338178SMark Peek 4123338178SMark Peek #ifdef WIDE_STRINGS 4223338178SMark Peek 4323338178SMark Peek # define NLSSize(s, l) 1 4423338178SMark Peek # define NLSFrom(s, l, cp) (USE (l), (*(cp) = *(s) & CHAR), 1) 4523338178SMark Peek # define NLSFinished(s, l, c) (l != 0 && c != CHAR_ERR ? 2 : 1) 4623338178SMark Peek # define NLSChars(s) Strlen(s) 4723338178SMark Peek # define NLSQuote(s) 4823338178SMark Peek # define TRIM_AND_EXTEND(s, c) (c &= TRIM) 4923338178SMark Peek 5023338178SMark Peek extern int NLSWidth __P((NLSChar)); 5123338178SMark Peek extern int NLSStringWidth __P((Char *)); 5223338178SMark Peek 5323338178SMark Peek #define NLS_ILLEGAL INVALID_BYTE 5423338178SMark Peek 5523338178SMark Peek #else 5623338178SMark Peek # ifdef SHORT_STRINGS 5723338178SMark Peek 5823338178SMark Peek extern int NLSFrom __P((const Char *, size_t, NLSChar *)); 5923338178SMark Peek extern int NLSFinished __P((Char *, size_t, eChar)); 6023338178SMark Peek extern int NLSChars __P((Char *)); 6123338178SMark Peek extern int NLSStringWidth __P((Char *)); 6223338178SMark Peek extern int NLSWidth __P((NLSChar)); 6323338178SMark Peek extern int NLSTo __P((Char *, NLSChar)); 6423338178SMark Peek extern void NLSQuote __P((Char *)); 6523338178SMark Peek 6623338178SMark Peek #define NLSSize(s, l) NLSFrom(s, l, (NLSChar *)0) 6723338178SMark Peek #define TRIM_AND_EXTEND(s, c) (s += NLSFrom(s - 1, NLSZEROT, &c) - 1) 6823338178SMark Peek #define NLS_ILLEGAL 0x40000000 6923338178SMark Peek 7023338178SMark Peek 7123338178SMark Peek # else 7223338178SMark Peek # define NLSSize(s, l) 1 7323338178SMark Peek # define NLSFrom(s, l, cp) (USE (l), (*(cp) = *(s) & CHAR), 1) 7423338178SMark Peek # define NLSFinished(s, l, c) (l != 0 && c != CHAR_ERR ? 2 : 1) 7523338178SMark Peek # define NLSChars(s) Strlen(s) 7623338178SMark Peek # define NLSStringWidth(s) Strlen(s) 7723338178SMark Peek # define NLSWidth(c) 1 7823338178SMark Peek # define NLSQuote(s) 7923338178SMark Peek 8023338178SMark Peek # define TRIM_AND_EXTEND(s, c) (c &= TRIM) 8123338178SMark Peek # define NLS_ILLEGAL 0x40000000 8223338178SMark Peek # endif 8323338178SMark Peek #endif 8423338178SMark Peek 8523338178SMark Peek extern int NLSExtend __P((Char *, int, int)); 8623338178SMark Peek extern Char *NLSChangeCase __P((Char *, int)); 8723338178SMark Peek extern int NLSClassify __P((NLSChar, int)); 8823338178SMark Peek 8923338178SMark Peek #define NLSCLASS_CTRL (-1) 9023338178SMark Peek #define NLSCLASS_TAB (-2) 9123338178SMark Peek #define NLSCLASS_NL (-3) 9223338178SMark Peek #define NLSCLASS_ILLEGAL (-4) 9323338178SMark Peek #define NLSCLASS_ILLEGAL2 (-5) 9423338178SMark Peek #define NLSCLASS_ILLEGAL3 (-6) 9523338178SMark Peek #define NLSCLASS_ILLEGAL4 (-7) 9623338178SMark Peek 9723338178SMark Peek #define NLSCLASS_ILLEGAL_SIZE(x) (-(x) - (-(NLSCLASS_ILLEGAL) - 1)) 9823338178SMark Peek 9923338178SMark Peek #endif 100