|
10 | 10 | import sys |
11 | 11 | _locale = locale |
12 | 12 |
|
13 | | -# Location of the alias file |
| 13 | +# Location of the X11 alias file. |
14 | 14 | LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias' |
| 15 | +# Location of the glibc SUPPORTED locales file. |
| 16 | +SUPPORTED = '/usr/share/i18n/SUPPORTED' |
15 | 17 |
|
16 | 18 | def parse(filename): |
17 | 19 |
|
@@ -59,10 +61,12 @@ def parse_glibc_supported(filename): |
59 | 61 | continue |
60 | 62 | if line[:1] == '#': |
61 | 63 | continue |
62 | | - if '/' not in line: |
63 | | - continue |
| 64 | + line = line.replace('/', ' ').strip() |
64 | 65 | line = line.rstrip('\\').rstrip() |
65 | | - alias, _, alias_encoding = line.partition('/') |
| 66 | + words = line.split() |
| 67 | + if len(words) != 2: |
| 68 | + continue |
| 69 | + alias, alias_encoding = words |
66 | 70 | # Lower-case locale |
67 | 71 | locale = alias.lower() |
68 | 72 | # Normalize encoding, if given |
@@ -125,13 +129,13 @@ def check(data): |
125 | 129 | parser.add_argument('--locale-alias', default=LOCALE_ALIAS, |
126 | 130 | help='location of the X11 alias file ' |
127 | 131 | '(default: %a)' % LOCALE_ALIAS) |
128 | | - parser.add_argument('--glibc-supported', |
129 | | - help='location of the glibc SUPPORTED locales file') |
| 132 | + parser.add_argument('--glibc-supported', default=SUPPORTED, |
| 133 | + help='location of the glibc SUPPORTED locales file ' |
| 134 | + '(default: %a)' % SUPPORTED) |
130 | 135 | args = parser.parse_args() |
131 | 136 |
|
132 | 137 | data = locale.locale_alias.copy() |
133 | | - if args.glibc_supported: |
134 | | - data.update(parse_glibc_supported(args.glibc_supported)) |
| 138 | + data.update(parse_glibc_supported(args.glibc_supported)) |
135 | 139 | data.update(parse(args.locale_alias)) |
136 | 140 | while True: |
137 | 141 | # Repeat optimization while the size is decreased. |
|
0 commit comments