OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [intl/] [explodename.c] - Blame information for rev 357

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
#include <newlib.h>
2
 
3
#ifdef _MB_CAPABLE
4
 
5
/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
6
   This file is part of the GNU C Library.
7
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
8
 
9
   The GNU C Library is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU Lesser General Public
11
   License as published by the Free Software Foundation; either
12
   version 2.1 of the License, or (at your option) any later version.
13
 
14
   The GNU C Library is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   Lesser General Public License for more details.
18
 
19
   You should have received a copy of the GNU Lesser General Public
20
   License along with the GNU C Library; if not, write to the Free
21
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307 USA.  */
23
 
24
#ifdef HAVE_CONFIG_H
25
# include <config.h>
26
#endif
27
 
28
#if defined STDC_HEADERS || defined _LIBC
29
# include <stdlib.h>
30
#endif
31
 
32
#if defined HAVE_STRING_H || defined _LIBC
33
# include <string.h>
34
#else
35
# include <strings.h>
36
#endif
37
#include <sys/types.h>
38
 
39
#include "loadinfo.h"
40
 
41
/* On some strange systems still no definition of NULL is found.  Sigh!  */
42
#ifndef NULL
43
# if defined __STDC__ && __STDC__
44
#  define NULL ((void *) 0)
45
# else
46
#  define NULL 0
47
# endif
48
#endif
49
 
50
/* @@ end of prolog @@ */
51
 
52
char *
53
_nl_find_language (name)
54
     const char *name;
55
{
56
  while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
57
         && name[0] != '+' && name[0] != ',')
58
    ++name;
59
 
60
  return (char *) name;
61
}
62
 
63
 
64
int
65
_nl_explode_name (name, language, modifier, territory, codeset,
66
                  normalized_codeset, special, sponsor, revision)
67
     char *name;
68
     const char **language;
69
     const char **modifier;
70
     const char **territory;
71
     const char **codeset;
72
     const char **normalized_codeset;
73
     const char **special;
74
     const char **sponsor;
75
     const char **revision;
76
{
77
  enum { undecided, xpg, cen } syntax;
78
  char *cp;
79
  int mask;
80
 
81
  *modifier = NULL;
82
  *territory = NULL;
83
  *codeset = NULL;
84
  *normalized_codeset = NULL;
85
  *special = NULL;
86
  *sponsor = NULL;
87
  *revision = NULL;
88
 
89
  /* Now we determine the single parts of the locale name.  First
90
     look for the language.  Termination symbols are `_' and `@' if
91
     we use XPG4 style, and `_', `+', and `,' if we use CEN syntax.  */
92
  mask = 0;
93
  syntax = undecided;
94
  *language = cp = name;
95
  cp = _nl_find_language (*language);
96
 
97
  if (*language == cp)
98
    /* This does not make sense: language has to be specified.  Use
99
       this entry as it is without exploding.  Perhaps it is an alias.  */
100
    cp = strchr (*language, '\0');
101
  else if (cp[0] == '_')
102
    {
103
      /* Next is the territory.  */
104
      cp[0] = '\0';
105
      *territory = ++cp;
106
 
107
      while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
108
             && cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
109
        ++cp;
110
 
111
      mask |= TERRITORY;
112
 
113
      if (cp[0] == '.')
114
        {
115
          /* Next is the codeset.  */
116
          syntax = xpg;
117
          cp[0] = '\0';
118
          *codeset = ++cp;
119
 
120
          while (cp[0] != '\0' && cp[0] != '@')
121
            ++cp;
122
 
123
          mask |= XPG_CODESET;
124
 
125
          if (*codeset != cp && (*codeset)[0] != '\0')
126
            {
127
              *normalized_codeset = _nl_normalize_codeset (*codeset,
128
                                                           cp - *codeset);
129
              if (strcmp (*codeset, *normalized_codeset) == 0)
130
                free ((char *) *normalized_codeset);
131
              else
132
                mask |= XPG_NORM_CODESET;
133
            }
134
        }
135
    }
136
 
137
  if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
138
    {
139
      /* Next is the modifier.  */
140
      syntax = cp[0] == '@' ? xpg : cen;
141
      cp[0] = '\0';
142
      *modifier = ++cp;
143
 
144
      while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
145
             && cp[0] != ',' && cp[0] != '_')
146
        ++cp;
147
 
148
      mask |= XPG_MODIFIER | CEN_AUDIENCE;
149
    }
150
 
151
  if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
152
    {
153
      syntax = cen;
154
 
155
      if (cp[0] == '+')
156
        {
157
          /* Next is special application (CEN syntax).  */
158
          cp[0] = '\0';
159
          *special = ++cp;
160
 
161
          while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
162
            ++cp;
163
 
164
          mask |= CEN_SPECIAL;
165
        }
166
 
167
      if (cp[0] == ',')
168
        {
169
          /* Next is sponsor (CEN syntax).  */
170
          cp[0] = '\0';
171
          *sponsor = ++cp;
172
 
173
          while (cp[0] != '\0' && cp[0] != '_')
174
            ++cp;
175
 
176
          mask |= CEN_SPONSOR;
177
        }
178
 
179
      if (cp[0] == '_')
180
        {
181
          /* Next is revision (CEN syntax).  */
182
          cp[0] = '\0';
183
          *revision = ++cp;
184
 
185
          mask |= CEN_REVISION;
186
        }
187
    }
188
 
189
  /* For CEN syntax values it might be important to have the
190
     separator character in the file name, not for XPG syntax.  */
191
  if (syntax == xpg)
192
    {
193
      if (*territory != NULL && (*territory)[0] == '\0')
194
        mask &= ~TERRITORY;
195
 
196
      if (*codeset != NULL && (*codeset)[0] == '\0')
197
        mask &= ~XPG_CODESET;
198
 
199
      if (*modifier != NULL && (*modifier)[0] == '\0')
200
        mask &= ~XPG_MODIFIER;
201
    }
202
 
203
  return mask;
204
}
205
 
206
#endif /* _MB_CAPABLE */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.