source: trunk/essentials/app-shells/bash/lib/glob/xmbsrtowcs.c@ 3253

Last change on this file since 3253 was 3231, checked in by bird, 19 years ago

eol style.

  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
1/* xmbsrtowcs.c -- replacement function for mbsrtowcs */
2
3/* Copyright (C) 2002-2004 Free Software Foundation, Inc.
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
20#include <config.h>
21
22#include <bashansi.h>
23
24/* <wchar.h>, <wctype.h> and <stdlib.h> are included in "shmbutil.h".
25 If <wchar.h>, <wctype.h>, mbsrtowcs(), exist, HANDLE_MULTIBYTE
26 is defined as 1. */
27#include <shmbutil.h>
28
29#if HANDLE_MULTIBYTE
30/* On some locales (ex. ja_JP.sjis), mbsrtowc doesn't convert 0x5c to U<0x5c>.
31 So, this function is made for converting 0x5c to U<0x5c>. */
32
33static mbstate_t local_state;
34static int local_state_use = 0;
35
36size_t
37xmbsrtowcs (dest, src, len, pstate)
38 wchar_t *dest;
39 const char **src;
40 size_t len;
41 mbstate_t *pstate;
42{
43 mbstate_t *ps;
44 size_t mblength, wclength, n;
45
46 ps = pstate;
47 if (pstate == NULL)
48 {
49 if (!local_state_use)
50 {