1*946379e7Schristos /* Determine the number of screen columns needed for a string. 2*946379e7Schristos Copyright (C) 2000-2004 Free Software Foundation, Inc. 3*946379e7Schristos 4*946379e7Schristos This program is free software; you can redistribute it and/or modify 5*946379e7Schristos it under the terms of the GNU General Public License as published by 6*946379e7Schristos the Free Software Foundation; either version 2, or (at your option) 7*946379e7Schristos any later version. 8*946379e7Schristos 9*946379e7Schristos This program is distributed in the hope that it will be useful, 10*946379e7Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 11*946379e7Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*946379e7Schristos GNU General Public License for more details. 13*946379e7Schristos 14*946379e7Schristos You should have received a copy of the GNU General Public License 15*946379e7Schristos along with this program; if not, write to the Free Software Foundation, 16*946379e7Schristos Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 17*946379e7Schristos 18*946379e7Schristos #include <stddef.h> 19*946379e7Schristos 20*946379e7Schristos /* Avoid a clash of our mbswidth() with a function of the same name defined 21*946379e7Schristos in UnixWare 7.1.1 <wchar.h>. We need this #include before the #define 22*946379e7Schristos below. 23*946379e7Schristos However, we don't want to #include <wchar.h> on all platforms because 24*946379e7Schristos - Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 25*946379e7Schristos <wchar.h>. 26*946379e7Schristos - BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before 27*946379e7Schristos <wchar.h>. */ 28*946379e7Schristos #if HAVE_DECL_MBSWIDTH_IN_WCHAR_H 29*946379e7Schristos # include <wchar.h> 30*946379e7Schristos #endif 31*946379e7Schristos 32*946379e7Schristos 33*946379e7Schristos #ifdef __cplusplus 34*946379e7Schristos extern "C" { 35*946379e7Schristos #endif 36*946379e7Schristos 37*946379e7Schristos 38*946379e7Schristos /* Optional flags to influence mbswidth/mbsnwidth behavior. */ 39*946379e7Schristos 40*946379e7Schristos /* If this bit is set, return -1 upon finding an invalid or incomplete 41*946379e7Schristos character. Otherwise, assume invalid characters have width 1. */ 42*946379e7Schristos #define MBSW_REJECT_INVALID 1 43*946379e7Schristos 44*946379e7Schristos /* If this bit is set, return -1 upon finding a non-printable character. 45*946379e7Schristos Otherwise, assume unprintable characters have width 0 if they are 46*946379e7Schristos control characters and 1 otherwise. */ 47*946379e7Schristos #define MBSW_REJECT_UNPRINTABLE 2 48*946379e7Schristos 49*946379e7Schristos 50*946379e7Schristos /* Returns the number of screen columns needed for STRING. */ 51*946379e7Schristos #define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */ 52*946379e7Schristos extern int mbswidth (const char *string, int flags); 53*946379e7Schristos 54*946379e7Schristos /* Returns the number of screen columns needed for the NBYTES bytes 55*946379e7Schristos starting at BUF. */ 56*946379e7Schristos extern int mbsnwidth (const char *buf, size_t nbytes, int flags); 57*946379e7Schristos 58*946379e7Schristos 59*946379e7Schristos #ifdef __cplusplus 60*946379e7Schristos } 61*946379e7Schristos #endif 62