home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / runes / part03 < prev    next >
Text File  |  1993-09-06  |  48KB  |  1,790 lines

  1. Newsgroups: comp.sources.unix
  2. From: prb@cray.com
  3. Subject: v27i029: REPOST runes - an implementation of setlocale(3) and all its friends, Part03/03
  4. References: <9309071427.AA14351@krystal.cray.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: prb@cray.com
  9. Posting-Number: Volume 27, Issue 29
  10. Archive-Name: runes/part03
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 3 (of 3)."
  19. # Contents:  doc/euc.4 doc/setlocale.3 libc/rune.c mklocale/yacc.y
  20. # Wrapped by prb@krystal.cray.com on Sun Sep  5 11:15:56 1993
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'doc/euc.4' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'doc/euc.4'\"
  24. else
  25. echo shar: Extracting \"'doc/euc.4'\" \(7430 characters\)
  26. sed "s/^X//" >'doc/euc.4' <<'END_OF_FILE'
  27. X.\" Copyright (c) 1993
  28. X.\"    The Regents of the University of California.  All rights reserved.
  29. X.\"
  30. X.\" This code is derived from software contributed to Berkeley by
  31. X.\" Paul Borman at Krystal Technologies.
  32. X.\"
  33. X.\" Redistribution and use in source and binary forms, with or without
  34. X.\" modification, are permitted provided that the following conditions
  35. X.\" are met:
  36. X.\" 1. Redistributions of source code must retain the above copyright
  37. X.\"    notice, this list of conditions and the following disclaimer.
  38. X.\" 2. Redistributions in binary form must reproduce the above copyright
  39. X.\"    notice, this list of conditions and the following disclaimer in the
  40. X.\"    documentation and/or other materials provided with the distribution.
  41. X.\" 3. All advertising materials mentioning features or use of this software
  42. X.\"    must display the following acknowledgement:
  43. X.\"    This product includes software developed by the University of
  44. X.\"    California, Berkeley and its contributors.
  45. X.\" 4. Neither the name of the University nor the names of its contributors
  46. X.\"    may be used to endorse or promote products derived from this software
  47. X.\"    without specific prior written permission.
  48. X.\"
  49. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. X.\" SUCH DAMAGE.
  60. X.\"
  61. X.\"    @(#)euc.4    8.1 (Berkeley) 6/4/93
  62. X.\"
  63. X.Dd "June 4, 1993"
  64. X.Dt EUC 4
  65. X.Os
  66. X.Sh NAME
  67. X.Nm EUC
  68. X.Nd EUC encoding of runes
  69. X.Sh SYNOPSIS
  70. X\fBENCODING "EUC"\fP
  71. X.br
  72. X\fBVARIABLE \fP\fIlen1 mask1 len2 mask2 len3 mask3 len4 mask4 mask\fP
  73. X.Sh DESCRIPTION
  74. XThe
  75. X.Nm EUC
  76. Xencoding is provided for compatibility with
  77. X.Ux
  78. Xbased systems.
  79. XSee
  80. X.Xr mklocale 1
  81. Xfor a complete description of the
  82. X.Ev LC_CTYPE
  83. Xsource file format.
  84. X.Pp
  85. X.Nm EUC
  86. Ximplements a system of 4 multibyte codesets.
  87. XA multibyte character in the first codeset consists of
  88. X.Ar len1
  89. Xbytes starting with a byte in the range of 0x00 to 0x7f.
  90. XTo allow use of ASCII,
  91. X.Ar len1
  92. Xis always 1.
  93. XA multibyte character in the second codeset consists of
  94. X.Ar len2
  95. Xbytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f.
  96. XA multibyte character in the third codeset consists of
  97. X.Ar len3
  98. Xbytes starting with the byte 0x8e.
  99. XA multibyte character in the fourth codeset consists of
  100. X.Ar len4
  101. Xbytes starting with the byte 0x8f.
  102. X.Pp
  103. XThe 
  104. X.Ev rune_t
  105. Xencoding of
  106. X.Nm EUC
  107. Xmultibyte characters is dependent on the
  108. X.Ar len
  109. Xand
  110. X.Ar mask
  111. Xarguments.
  112. XFirst, the bytes are moved into a
  113. X.Ev rune_t
  114. Xas follows:
  115. X.Bd -literal
  116. Xbyte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1
  117. X.Ed
  118. X.sp
  119. XThe result is then ANDed with
  120. X.Ar ~mask
  121. Xand ORed with
  122. X.Ar mask\fPN.
  123. XCodesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is
  124. Xfirst removed and the
  125. X.Ar len\fPN
  126. Xargument is reduced by 1.
  127. X.sp
  128. XFor example, the Japanese locale has the following
  129. X.Ev VARIABLE
  130. Xline:
  131. X.Bd -literal
  132. XVARIABLE    1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
  133. X.Ed
  134. X.sp
  135. XCodeset 1 consists of the values 0x0000 - 0x007f.
  136. X.sp
  137. XCodeset 2 consists of the values who have the bits 0x8080 set.
  138. X.sp
  139. XCodeset 3 consists of the values 0x0080 - 0x00ff.
  140. X.sp
  141. XCodeset 4 consists of the values 0x8000 - 0xff7f excluding the values
  142. Xwhich have the 0x0080 bit set.
  143. X.sp
  144. XNotice that the global
  145. X.Ar mask
  146. Xis set to 0x8080, this implies that from those 2 bits the codeset can
  147. Xbe determined.
  148. X.Sh "EXAMPLE - Japanese Locale"
  149. XThis is a complete example of an
  150. X.Ev LC_CTYPE
  151. Xsource file for the Japanese locale
  152. X.Bd -literal
  153. X/*
  154. X * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets
  155. X */
  156. X
  157. XENCODING    "EUC"
  158. X
  159. X/*        JIS     JIS      JIS            */
  160. X/*        X201     X208      X201             */
  161. X/*        00-7f          84-fe            */
  162. X
  163. XVARIABLE    1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
  164. X
  165. X/*
  166. X * Code Set 1
  167. X */
  168. XALPHA        'A' - 'Z' 'a' - 'z'
  169. XCONTROL        0x00 - 0x1f 0x7f
  170. XDIGIT        '0' - '9'
  171. XGRAPH        0x21 - 0x7e
  172. XLOWER        'a' - 'z'
  173. XPUNCT        0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
  174. XSPACE        0x09 - 0x0d 0x20
  175. XUPPER        'A' - 'Z'
  176. XXDIGIT        'a' - 'f' 'A' - 'F'
  177. XBLANK        ' ' '\t'
  178. XPRINT        0x20 - 0x7e
  179. X
  180. XMAPLOWER    < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' >
  181. XMAPUPPER    < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' >
  182. XTODIGIT        < '0' - '9' : 0 >
  183. XTODIGIT        < 'A' - 'F' : 10 > < 'a' - 'f' : 10 >
  184. X
  185. X/*
  186. X * Code Set 2
  187. X */
  188. X
  189. XSPACE        0xa1a1
  190. XPHONOGRAM    0xa1bc
  191. XSPECIAL        0xa1a2 - 0xa1fe
  192. XPUNCT        0xa1a2 - 0xa1f8        /* A few too many in here... */
  193. X
  194. XSPECIAL        0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea
  195. XSPECIAL        0xa2f2 - 0xa2f9 0xa2fe
  196. X
  197. XDIGIT        0xa3b0 - 0xa3b9
  198. XUPPER        0xa3c1 - 0xa3da                /* Romaji */
  199. XLOWER        0xa3e1 - 0xa3fa                /* Romaji */
  200. XMAPLOWER    < 0xa3c1 - 0xa3da : 0xa3e1 >            /* English */
  201. XMAPLOWER    < 0xa3e1 - 0xa3fa : 0xa3e1 >            /* English */
  202. XMAPUPPER    < 0xa3c1 - 0xa3da : 0xa3c1 >
  203. XMAPUPPER    < 0xa3e1 - 0xa3fa : 0xa3c1 >
  204. X
  205. XXDIGIT        0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6
  206. X
  207. XTODIGIT        < 0xa3b0 - 0xa3b9 : 0 >
  208. XTODIGIT        < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 >
  209. X
  210. XPHONOGRAM    0xa4a1 - 0xa4f3
  211. XPHONOGRAM    0xa5a1 - 0xa5f6
  212. X
  213. XUPPER        0xa6a1 - 0xa6b8                /* Greek */
  214. XLOWER        0xa6c1 - 0xa6d8                /* Greek */
  215. XMAPLOWER    < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 >
  216. XMAPUPPER    < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 >
  217. X
  218. XUPPER        0xa7a1 - 0xa7c1                /* Cyrillic */
  219. XLOWER        0xa7d1 - 0xa7f1                /* Cyrillic */
  220. XMAPLOWER    < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 >
  221. XMAPUPPER    < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 >
  222. X
  223. XSPECIAL        0xa8a1 - 0xa8c0
  224. X
  225. XIDEOGRAM    0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe
  226. XIDEOGRAM    0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe
  227. XIDEOGRAM    0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe
  228. XIDEOGRAM    0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe
  229. XIDEOGRAM    0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe
  230. XIDEOGRAM    0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe
  231. XIDEOGRAM    0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe
  232. XIDEOGRAM    0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe
  233. XIDEOGRAM    0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe
  234. XIDEOGRAM    0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe
  235. XIDEOGRAM    0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe
  236. XIDEOGRAM    0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe
  237. XIDEOGRAM    0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe
  238. XIDEOGRAM    0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe
  239. XIDEOGRAM    0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe
  240. XIDEOGRAM    0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe
  241. XIDEOGRAM    0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe
  242. XIDEOGRAM    0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe
  243. XIDEOGRAM    0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe
  244. XIDEOGRAM    0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe
  245. XIDEOGRAM    0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe
  246. XIDEOGRAM    0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe
  247. XIDEOGRAM    0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4
  248. X/*
  249. X * This is for Code Set 3, half-width kana
  250. X */
  251. XSPECIAL        0xa1 - 0xdf
  252. XPHONOGRAM    0xa1 - 0xdf
  253. XCONTROL        0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe
  254. X.Ed
  255. X.Sh "SEE ALSO"
  256. X.Xr mklocale 1 ,
  257. X.Xr setlocale 3
  258. END_OF_FILE
  259. if test 7430 -ne `wc -c <'doc/euc.4'`; then
  260.     echo shar: \"'doc/euc.4'\" unpacked with wrong size!
  261. fi
  262. # end of 'doc/euc.4'
  263. fi
  264. if test -f 'doc/setlocale.3' -a "${1}" != "-c" ; then 
  265.   echo shar: Will not clobber existing file \"'doc/setlocale.3'\"
  266. else
  267. echo shar: Extracting \"'doc/setlocale.3'\" \(8646 characters\)
  268. sed "s/^X//" >'doc/setlocale.3' <<'END_OF_FILE'
  269. X.\" Copyright (c) 1993
  270. X.\"    The Regents of the University of California.  All rights reserved.
  271. X.\"
  272. X.\" This code is derived from software contributed to Berkeley by
  273. X.\" Donn Seeley at BSDI.
  274. X.\"
  275. X.\" Redistribution and use in source and binary forms, with or without
  276. X.\" modification, are permitted provided that the following conditions
  277. X.\" are met:
  278. X.\" 1. Redistributions of source code must retain the above copyright
  279. X.\"    notice, this list of conditions and the following disclaimer.
  280. X.\" 2. Redistributions in binary form must reproduce the above copyright
  281. X.\"    notice, this list of conditions and the following disclaimer in the
  282. X.\"    documentation and/or other materials provided with the distribution.
  283. X.\" 3. All advertising materials mentioning features or use of this software
  284. X.\"    must display the following acknowledgement:
  285. X.\"    This product includes software developed by the University of
  286. X.\"    California, Berkeley and its contributors.
  287. X.\" 4. Neither the name of the University nor the names of its contributors
  288. X.\"    may be used to endorse or promote products derived from this software
  289. X.\"    without specific prior written permission.
  290. X.\"
  291. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  292. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  293. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  294. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  295. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  296. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  297. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  298. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  299. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  300. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  301. X.\" SUCH DAMAGE.
  302. X.\"
  303. X.\"    @(#)setlocale.3    8.1 (Berkeley) 6/9/93
  304. X.\"
  305. X.Dd June 9, 1993
  306. X.Dt SETLOCALE 3
  307. X.Os
  308. X.Sh NAME
  309. X.Nm setlocale ,
  310. X.Nm localeconv
  311. X.Nd natural language formatting for C
  312. X.Sh SYNOPSIS
  313. X.Fd #include <locale.h>
  314. X.Ft char *
  315. X.Fn setlocale "int category" "const char *locale"
  316. X.Ft struct lconv *
  317. X.Fn localeconv "void"
  318. X.Sh DESCRIPTION
  319. XThe
  320. X.Fn setlocale
  321. Xfunction sets the C library's notion
  322. Xof natural language formatting style
  323. Xfor particular sets of routines.
  324. XEach such style is called a
  325. X.Sq locale
  326. Xand is invoked using an appropriate name passed as a C string.
  327. XThe
  328. X.Fn localeconv
  329. Xroutine returns the current locale's parameters
  330. Xfor formatting numbers.
  331. X.Pp
  332. XThe
  333. X.Fn setlocale
  334. Xfunction recognizes several categories of routines.
  335. XThese are the categories and the sets of routines they select:
  336. X.Pp
  337. X.Bl -tag -width LC_MONETARY
  338. X.It Dv LC_ALL
  339. XSet the entire locale generically.
  340. X.It Dv LC_COLLATE
  341. XSet a locale for string collation routines.
  342. XThis controls alphabetic ordering in
  343. X.Fn strcoll
  344. Xand
  345. X.Fn strxfrm .
  346. X.It Dv LC_CTYPE
  347. XSet a locale for the
  348. X.Xr ctype 3 ,
  349. X.Xr mbrune 3 ,
  350. X.Xr multibyte 3
  351. Xand
  352. X.Xr rune 3
  353. Xfunctions.
  354. XThis controls recognition of upper and lower case,
  355. Xalphabetic or non-alphabetic characters,
  356. Xand so on.  The real work is done by the
  357. X.Fn setrunelocale
  358. Xfunction.
  359. X.It Dv LC_MONETARY
  360. XSet a locale for formatting monetary values;
  361. Xthis affects the
  362. X.Fn localeconv
  363. Xfunction.
  364. X.It Dv LC_NUMERIC
  365. XSet a locale for formatting numbers.
  366. XThis controls the formatting of decimal points
  367. Xin input and output of floating point numbers
  368. Xin functions such as
  369. X.Fn printf
  370. Xand
  371. X.Fn scanf ,
  372. Xas well as values returned by
  373. X.Fn localeconv .
  374. X.It Dv LC_TIME
  375. XSet a locale for formatting dates and times using the
  376. X.Fn strftime
  377. Xfunction.
  378. X.El
  379. X.Pp
  380. XOnly three locales are defined by default,
  381. Xthe empty string
  382. X.Li "\&""\|""
  383. Xwhich denotes the native environment, and the
  384. X.Li "\&""C""
  385. Xand
  386. X.LI "\&""POSIX""
  387. Xlocales, which denote the C language environment.
  388. XA
  389. X.Fa locale
  390. Xargument of
  391. X.Dv NULL
  392. Xcauses
  393. X.Fn setlocale
  394. Xto return the current locale.
  395. XBy default, C programs start in the
  396. X.Li "\&""C""
  397. Xlocale.
  398. XThe only function in the library that sets the locale is
  399. X.Fn setlocale ;
  400. Xthe locale is never changed as a side effect of some other routine.
  401. X.Pp
  402. XThe
  403. X.Fn localeconv
  404. Xfunction returns a pointer to a structure
  405. Xwhich provides parameters for formatting numbers,
  406. Xespecially currency values:
  407. X.Bd -literal -offset indent
  408. Xstruct lconv {
  409. X    char    *decimal_point;
  410. X    char    *thousands_sep;
  411. X    char    *grouping;
  412. X    char    *int_curr_symbol;
  413. X    char    *currency_symbol;
  414. X    char    *mon_decimal_point;
  415. X    char    *mon_thousands_sep;
  416. X    char    *mon_grouping;
  417. X    char    *positive_sign;
  418. X    char    *negative_sign;
  419. X    char    int_frac_digits;
  420. X    char    frac_digits;
  421. X    char    p_cs_precedes;
  422. X    char    p_sep_by_space;
  423. X    char    n_cs_precedes;
  424. X    char    n_sep_by_space;
  425. X    char    p_sign_posn;
  426. X    char    n_sign_posn;
  427. X};
  428. X.Ed
  429. X.Pp
  430. XThe individual fields have the following meanings:
  431. X.Pp
  432. X.Bl -tag -width mon_decimal_point
  433. X.It Fa decimal_point
  434. XThe decimal point character, except for currency values.
  435. X.It Fa thousands_sep
  436. XThe separator between groups of digits
  437. Xbefore the decimal point, except for currency values.
  438. X.It Fa grouping
  439. XThe sizes of the groups of digits, except for currency values.
  440. XThis is a pointer to a vector of integers, each of size
  441. X.Va char ,
  442. Xrepresenting group size from low order digit groups
  443. Xto high order (right to left).
  444. XThe list may be terminated with 0 or
  445. X.Dv CHAR_MAX .
  446. XIf the list is terminated with 0,
  447. Xthe last group size before the 0 is repeated to account for all the digits.
  448. XIf the list is terminated with
  449. X.Dv CHAR_MAX ,
  450. Xno more grouping is performed.
  451. X.It Fa int_curr_symbol
  452. XThe standardized international currency symbol.
  453. X.It Fa currency_symbol
  454. XThe local currency symbol.
  455. X.It Fa mon_decimal_point
  456. XThe decimal point character for currency values.
  457. X.It Fa mon_thousands_sep
  458. XThe separator for digit groups in currency values.
  459. X.It Fa mon_grouping
  460. XLike
  461. X.Fa grouping
  462. Xbut for currency values.
  463. X.It Fa positive_sign
  464. XThe character used to denote nonnegative currency values,
  465. Xusually the empty string.
  466. X.It Fa negative_sign
  467. XThe character used to denote negative currency values,
  468. Xusually a minus sign.
  469. X.It Fa int_frac_digits
  470. XThe number of digits after the decimal point
  471. Xin an international-style currency value.
  472. X.It Fa frac_digits
  473. XThe number of digits after the decimal point
  474. Xin the local style for currency values.
  475. X.It Fa p_cs_precedes
  476. X1 if the currency symbol precedes the currency value
  477. Xfor nonnegative values, 0 if it follows.
  478. X.It Fa p_sep_by_space
  479. X1 if a space is inserted between the currency symbol
  480. Xand the currency value for nonnegative values, 0 otherwise.
  481. X.It Fa n_cs_precedes
  482. XLike
  483. X.Fa p_cs_precedes
  484. Xbut for negative values.
  485. X.It Fa n_sep_by_space
  486. XLike
  487. X.Fa p_sep_by_space
  488. Xbut for negative values.
  489. X.It Fa p_sign_posn
  490. XThe location of the
  491. X.Fa positive_sign
  492. Xwith respect to a nonnegative quantity and the
  493. X.Fa currency_symbol ,
  494. Xcoded as follows:
  495. X.Bl -tag -width 3n -compact
  496. X.It Li 0
  497. XParentheses around the entire string.
  498. X.It Li 1
  499. XBefore the string.
  500. X.It Li 2
  501. XAfter the string.
  502. X.It Li 3
  503. XJust before
  504. X.Fa currency_symbol .
  505. X.It Li 4
  506. XJust after
  507. X.Fa currency_symbol .
  508. X.El
  509. X.It Fa n_sign_posn
  510. XLike
  511. X.Fa p_sign_posn
  512. Xbut for negative currency values.
  513. X.El
  514. X.Pp
  515. XUnless mentioned above,
  516. Xan empty string as a value for a field
  517. Xindicates a zero length result or
  518. Xa value that is not in the current locale.
  519. XA
  520. X.Dv CHAR_MAX
  521. Xresult similarly denotes an unavailable value.
  522. X.Sh "RETURN VALUES
  523. XThe
  524. X.Fn setlocale
  525. Xfunction returns
  526. X.Dv NULL
  527. Xand fails to change the locale
  528. Xif the given combination of
  529. X.Fa category
  530. Xand
  531. X.Fa locale
  532. Xmakes no sense.
  533. XThe
  534. X.Fn localeconv
  535. Xfunction returns a pointer to a static object
  536. Xwhich may be altered by later calls to
  537. X.Fn setlocale
  538. Xor
  539. X.Fn localeconv .
  540. X.Sh FILES
  541. X.Bl -tag -width /usr/share/locale/locale/category -compact
  542. X.It Pa $PATH_LOCALE/\fIlocale\fP/\fIcategory\fP
  543. X.It Pa /usr/share/locale/\fIlocale\fP/\fIcategory\fP
  544. Xlocale file for the locale \fIlocale\fP
  545. Xand the category \fIcategory\fP.
  546. X.El
  547. X.Sh "SEE ALSO
  548. X.Xr euc 4 ,
  549. X.Xr mbrune 3 ,
  550. X.Xr multibyte 3 ,
  551. X.Xr rune 3 ,
  552. X.Xr strcoll 3 ,
  553. X.Xr strxfrm 3 ,
  554. X.Xr utf2 4
  555. X.Sh STANDARDS
  556. XThe
  557. X.Fn setlocale
  558. Xand
  559. X.Fn localeconv
  560. Xfunctions conform to
  561. X.St -ansiC .
  562. X.Sh HISTORY
  563. XThe
  564. X.Fn setlocale
  565. Xand
  566. X.Fn localeconv
  567. Xfunctions first appeared in 4.4BSD.
  568. X.Sh BUGS
  569. XThe current implementation supports only the
  570. X.Li "\&""C""
  571. Xand
  572. X.Li "\&""POSIX""
  573. Xlocales for all but the LC_CTYPE locale.
  574. X.Pp
  575. XIn spite of the gnarly currency support in
  576. X.Fn localeconv ,
  577. Xthe standards don't include any functions
  578. Xfor generalized currency formatting.
  579. X.Pp
  580. X.Dv LC_COLLATE
  581. Xdoes not make sense for many languages.
  582. XUse of
  583. X.Dv LC_MONETARY
  584. Xcould lead to misleading results until we have a real time currency
  585. Xconversion function.
  586. X.Dv LC_NUMERIC
  587. Xand
  588. X.Dv LC_TIME
  589. Xare personal choices and should not be wrapped up with the other categories.
  590. END_OF_FILE
  591. if test 8646 -ne `wc -c <'doc/setlocale.3'`; then
  592.     echo shar: \"'doc/setlocale.3'\" unpacked with wrong size!
  593. fi
  594. # end of 'doc/setlocale.3'
  595. fi
  596. if test -f 'libc/rune.c' -a "${1}" != "-c" ; then 
  597.   echo shar: Will not clobber existing file \"'libc/rune.c'\"
  598. else
  599. echo shar: Extracting \"'libc/rune.c'\" \(7949 characters\)
  600. sed "s/^X//" >'libc/rune.c' <<'END_OF_FILE'
  601. X/*-
  602. X * Copyright (c) 1993
  603. X *    The Regents of the University of California.  All rights reserved.
  604. X *
  605. X * This code is derived from software contributed to Berkeley by
  606. X * Paul Borman at Krystal Technologies.
  607. X *
  608. X * Redistribution and use in source and binary forms, with or without
  609. X * modification, are permitted provided that the following conditions
  610. X * are met:
  611. X * 1. Redistributions of source code must retain the above copyright
  612. X *    notice, this list of conditions and the following disclaimer.
  613. X * 2. Redistributions in binary form must reproduce the above copyright
  614. X *    notice, this list of conditions and the following disclaimer in the
  615. X *    documentation and/or other materials provided with the distribution.
  616. X * 3. All advertising materials mentioning features or use of this software
  617. X *    must display the following acknowledgement:
  618. X *    This product includes software developed by the University of
  619. X *    California, Berkeley and its contributors.
  620. X * 4. Neither the name of the University nor the names of its contributors
  621. X *    may be used to endorse or promote products derived from this software
  622. X *    without specific prior written permission.
  623. X *
  624. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  625. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  626. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  627. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  628. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  629. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  630. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  631. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  632. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  633. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  634. X * SUCH DAMAGE.
  635. X */
  636. X
  637. X#if defined(LIBC_SCCS) && !defined(lint)
  638. Xstatic char sccsid[] = "@(#)rune.c    8.1 (Berkeley) 6/4/93";
  639. X#endif /* LIBC_SCCS and not lint */
  640. X
  641. X#include <sys/types.h>
  642. X#include <sys/stat.h>
  643. X
  644. X#include <ctype.h>
  645. X#include <errno.h>
  646. X#include <limits.h>
  647. X#include <rune.h>
  648. X#include <stdio.h>
  649. X#include <stdlib.h>
  650. X
  651. Xextern int        _none_init __P((_RuneLocale *));
  652. Xextern int        _UTF2_init __P((_RuneLocale *));
  653. Xextern int        _EUC_init __P((_RuneLocale *));
  654. Xstatic _RuneLocale    *_Read_RuneMagi __P((FILE *));
  655. X
  656. Xstatic char *PathLocale = 0;
  657. X
  658. Xint
  659. Xsetrunelocale(encoding)
  660. X    char *encoding;
  661. X{
  662. X    FILE *fp;
  663. X    char name[PATH_MAX];
  664. X    _RuneLocale *rl;
  665. X
  666. X    if (!encoding)
  667. X        return(EFAULT);
  668. X
  669. X    /*
  670. X     * The "C" and "POSIX" locale are always here.
  671. X     */
  672. X    if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) {
  673. X        _CurrentRuneLocale = &_DefaultRuneLocale;
  674. X        return(0);
  675. X    }
  676. X
  677. X    if (!PathLocale && !(PathLocale = getenv("PATH_LOCALE")))
  678. X        PathLocale = _PATH_LOCALE;
  679. X
  680. X    sprintf(name, "%s/%s/LC_CTYPE", PathLocale, encoding);
  681. X
  682. X    if ((fp = fopen(name, "r")) == NULL)
  683. X        return(ENOENT);
  684. X
  685. X    if ((rl = _Read_RuneMagi(fp)) == 0) {
  686. X        fclose(fp);
  687. X        return(EFTYPE);
  688. X    }
  689. X
  690. X    if (!rl->encoding[0] || !strcmp(rl->encoding, "UTF2")) {
  691. X        return(_UTF2_init(rl));
  692. X    } else if (!strcmp(rl->encoding, "NONE")) {
  693. X        return(_none_init(rl));
  694. X    } else if (!strcmp(rl->encoding, "EUC")) {
  695. X        return(_EUC_init(rl));
  696. X    } else
  697. X        return(EINVAL);
  698. X}
  699. X
  700. Xvoid
  701. Xsetinvalidrune(ir)
  702. X    rune_t ir;
  703. X{
  704. X    _INVALID_RUNE = ir;
  705. X}
  706. X
  707. Xstatic _RuneLocale *
  708. X_Read_RuneMagi(fp)
  709. X    FILE *fp;
  710. X{
  711. X    char *data;
  712. X    void *np;
  713. X    void *lastp;
  714. X    _RuneLocale *rl;
  715. X    _RuneEntry *rr;
  716. X    struct stat sb;
  717. X    int x;
  718. X
  719. X    if (fstat(fileno(fp), &sb) < 0)
  720. X        return(0);
  721. X
  722. X    if (sb.st_size < sizeof(_RuneLocale))
  723. X        return(0);
  724. X
  725. X    if ((data = malloc(sb.st_size)) == NULL)
  726. X        return(0);
  727. X
  728. X    rewind(fp); /* Someone might have read the magic number once already */
  729. X
  730. X    if (fread(data, sb.st_size, 1, fp) != 1) {
  731. X        free(data);
  732. X        return(0);
  733. X    }
  734. X
  735. X    rl = (_RuneLocale *)data;
  736. X    lastp = data + sb.st_size;
  737. X
  738. X    rl->variable = rl + 1;
  739. X
  740. X    if (memcmp(rl->magic, _RUNE_MAGIC_1, sizeof(rl->magic))) {
  741. X        free(data);
  742. X        return(0);
  743. X    }
  744. X
  745. X    rl->invalid_rune = ntohl(rl->invalid_rune);
  746. X    rl->variable_len = ntohl(rl->variable_len);
  747. X    rl->runetype_ext.nranges = ntohl(rl->runetype_ext.nranges);
  748. X    rl->maplower_ext.nranges = ntohl(rl->maplower_ext.nranges);
  749. X    rl->mapupper_ext.nranges = ntohl(rl->mapupper_ext.nranges);
  750. X
  751. X    for (x = 0; x < _CACHED_RUNES; ++x) {
  752. X        rl->runetype[x] = ntohl(rl->runetype[x]);
  753. X        rl->maplower[x] = ntohl(rl->maplower[x]);
  754. X        rl->mapupper[x] = ntohl(rl->mapupper[x]);
  755. X    }
  756. X
  757. X    rl->runetype_ext.ranges = (_RuneEntry *)rl->variable;
  758. X    rl->variable = rl->runetype_ext.ranges + rl->runetype_ext.nranges;
  759. X    if (rl->variable > lastp) {
  760. X        free(data);
  761. X        return(0);
  762. X    }
  763. X
  764. X    rl->maplower_ext.ranges = (_RuneEntry *)rl->variable;
  765. X    rl->variable = rl->maplower_ext.ranges + rl->maplower_ext.nranges;
  766. X    if (rl->variable > lastp) {
  767. X        free(data);
  768. X        return(0);
  769. X    }
  770. X
  771. X    rl->mapupper_ext.ranges = (_RuneEntry *)rl->variable;
  772. X    rl->variable = rl->mapupper_ext.ranges + rl->mapupper_ext.nranges;
  773. X    if (rl->variable > lastp) {
  774. X        free(data);
  775. X        return(0);
  776. X    }
  777. X
  778. X    for (x = 0; x < rl->runetype_ext.nranges; ++x) {
  779. X        rr = rl->runetype_ext.ranges;
  780. X
  781. X        rr[x].min = ntohl(rr[x].min);
  782. X        rr[x].max = ntohl(rr[x].max);
  783. X        if ((rr[x].map = ntohl(rr[x].map)) == 0) {
  784. X            int len = rr[x].max - rr[x].min + 1;
  785. X            rr[x].types = rl->variable;
  786. X            rl->variable = rr[x].types + len;
  787. X            if (rl->variable > lastp) {
  788. X                free(data);
  789. X                return(0);
  790. X            }
  791. X            while (len-- > 0)
  792. X                rr[x].types[len] = ntohl(rr[x].types[len]);
  793. X        } else
  794. X            rr[x].types = 0;
  795. X    }
  796. X
  797. X    for (x = 0; x < rl->maplower_ext.nranges; ++x) {
  798. X        rr = rl->maplower_ext.ranges;
  799. X
  800. X        rr[x].min = ntohl(rr[x].min);
  801. X        rr[x].max = ntohl(rr[x].max);
  802. X        rr[x].map = ntohl(rr[x].map);
  803. X    }
  804. X
  805. X    for (x = 0; x < rl->mapupper_ext.nranges; ++x) {
  806. X        rr = rl->mapupper_ext.ranges;
  807. X
  808. X        rr[x].min = ntohl(rr[x].min);
  809. X        rr[x].max = ntohl(rr[x].max);
  810. X        rr[x].map = ntohl(rr[x].map);
  811. X    }
  812. X    if (((char *)rl->variable) + rl->variable_len > (char *)lastp) {
  813. X        free(data);
  814. X        return(0);
  815. X    }
  816. X
  817. X    /*
  818. X     * Go out and zero pointers that should be zero.
  819. X     */
  820. X    if (!rl->variable_len)
  821. X        rl->variable = 0;
  822. X
  823. X    if (!rl->runetype_ext.nranges)
  824. X        rl->runetype_ext.ranges = 0;
  825. X
  826. X    if (!rl->maplower_ext.nranges)
  827. X        rl->maplower_ext.ranges = 0;
  828. X
  829. X    if (!rl->mapupper_ext.nranges)
  830. X        rl->mapupper_ext.ranges = 0;
  831. X        
  832. X    return(rl);
  833. X}
  834. X
  835. Xunsigned long
  836. X___runetype(c)
  837. X    _BSD_RUNE_T_ c;
  838. X{
  839. X    int x;
  840. X    _RuneRange *rr = &_CurrentRuneLocale->runetype_ext;
  841. X    _RuneEntry *re = rr->ranges;
  842. X
  843. X    if (c == EOF)
  844. X        return(0);
  845. X    for (x = 0; x < rr->nranges; ++x, ++re) {
  846. X        if (c < re->min)
  847. X            return(0L);
  848. X        if (c <= re->max) {
  849. X            if (re->types)
  850. X                return(re->types[c - re->min]);
  851. X            else
  852. X                return(re->map);
  853. X        }
  854. X    }
  855. X    return(0L);
  856. X}
  857. X
  858. X_BSD_RUNE_T_
  859. X___toupper(c)
  860. X    _BSD_RUNE_T_ c;
  861. X{
  862. X    int x;
  863. X    _RuneRange *rr = &_CurrentRuneLocale->mapupper_ext;
  864. X    _RuneEntry *re = rr->ranges;
  865. X
  866. X    if (c == EOF)
  867. X        return(EOF);
  868. X    for (x = 0; x < rr->nranges; ++x, ++re) {
  869. X        if (c < re->min)
  870. X            return(c);
  871. X        if (c <= re->max)
  872. X            return(re->map + c - re->min);
  873. X    }
  874. X    return(c);
  875. X}
  876. X
  877. X_BSD_RUNE_T_
  878. X___tolower(c)
  879. X    _BSD_RUNE_T_ c;
  880. X{
  881. X    int x;
  882. X    _RuneRange *rr = &_CurrentRuneLocale->maplower_ext;
  883. X    _RuneEntry *re = rr->ranges;
  884. X
  885. X    if (c == EOF)
  886. X        return(EOF);
  887. X    for (x = 0; x < rr->nranges; ++x, ++re) {
  888. X        if (c < re->min)
  889. X            return(c);
  890. X        if (c <= re->max)
  891. X            return(re->map + c - re->min);
  892. X    }
  893. X    return(c);
  894. X}
  895. X
  896. X
  897. X#if !defined(_USE_CTYPE_INLINE_) && !defined(_USE_CTYPE_MACROS_)
  898. X/*
  899. X * See comments in <machine/ansi.h>
  900. X */
  901. Xint
  902. X__istype(c, f)
  903. X    _BSD_RUNE_T_ c;
  904. X    unsigned long f;
  905. X{
  906. X    return ((((c & _CRMASK) ? ___runetype(c)
  907. X           : _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0);
  908. X}
  909. X
  910. Xint
  911. X__isctype(_BSD_RUNE_T_ c, unsigned long f)
  912. X    _BSD_RUNE_T_ c;
  913. X    unsigned long f;
  914. X{
  915. X    return ((((c & _CRMASK) ? 0
  916. X           : _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0);
  917. X}
  918. X
  919. X_BSD_RUNE_T_
  920. Xtoupper(c)
  921. X    _BSD_RUNE_T_ c;
  922. X{
  923. X    return ((c & _CRMASK) ?
  924. X        ___toupper(c) : _CurrentRuneLocale->mapupper[c]);
  925. X}
  926. X
  927. X_BSD_RUNE_T_
  928. Xtolower(c)
  929. X    _BSD_RUNE_T_ c;
  930. X{
  931. X    return ((c & _CRMASK) ?
  932. X        ___tolower(c) : _CurrentRuneLocale->maplower[c]);
  933. X}
  934. X#endif
  935. END_OF_FILE
  936. if test 7949 -ne `wc -c <'libc/rune.c'`; then
  937.     echo shar: \"'libc/rune.c'\" unpacked with wrong size!
  938. fi
  939. # end of 'libc/rune.c'
  940. fi
  941. if test -f 'mklocale/yacc.y' -a "${1}" != "-c" ; then 
  942.   echo shar: Will not clobber existing file \"'mklocale/yacc.y'\"
  943. else
  944. echo shar: Extracting \"'mklocale/yacc.y'\" \(19494 characters\)
  945. sed "s/^X//" >'mklocale/yacc.y' <<'END_OF_FILE'
  946. X%{
  947. X/*-
  948. X * Copyright (c) 1993
  949. X *    The Regents of the University of California.  All rights reserved.
  950. X *
  951. X * This code is derived from software contributed to Berkeley by
  952. X * Paul Borman at Krystal Technologies.
  953. X *
  954. X * Redistribution and use in source and binary forms, with or without
  955. X * modification, are permitted provided that the following conditions
  956. X * are met:
  957. X * 1. Redistributions of source code must retain the above copyright
  958. X *    notice, this list of conditions and the following disclaimer.
  959. X * 2. Redistributions in binary form must reproduce the above copyright
  960. X *    notice, this list of conditions and the following disclaimer in the
  961. X *    documentation and/or other materials provided with the distribution.
  962. X * 3. All advertising materials mentioning features or use of this software
  963. X *    must display the following acknowledgement:
  964. X *    This product includes software developed by the University of
  965. X *    California, Berkeley and its contributors.
  966. X * 4. Neither the name of the University nor the names of its contributors
  967. X *    may be used to endorse or promote products derived from this software
  968. X *    without specific prior written permission.
  969. X *
  970. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  971. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  972. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  973. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  974. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  975. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  976. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  977. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  978. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  979. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  980. X * SUCH DAMAGE.
  981. X */
  982. X
  983. X#ifndef lint
  984. Xstatic char sccsid[] = "@(#)yacc.y    8.1 (Berkeley) 6/6/93";
  985. X#endif /* not lint */
  986. X
  987. X#include <ctype.h>
  988. X#include <rune.h>
  989. X#include <stddef.h>
  990. X#include <stdio.h>
  991. X#include <stdlib.h>
  992. X
  993. X#include "ldef.h"
  994. X
  995. Xchar    *locale_file = "<stdout>";
  996. X
  997. Xrune_map    maplower = { 0, };
  998. Xrune_map    mapupper = { 0, };
  999. Xrune_map    types = { 0, };
  1000. X
  1001. X_RuneLocale    new_locale = { 0, };
  1002. X
  1003. Xvoid set_map __P((rune_map *, rune_list *, u_long));
  1004. Xvoid set_digitmap __P((rune_map *, rune_list *));
  1005. Xvoid add_map __P((rune_map *, rune_list *, u_long));
  1006. X%}
  1007. X
  1008. X%union    {
  1009. X    rune_t    rune;
  1010. X    int        i;
  1011. X    char    *str;
  1012. X
  1013. X    rune_list    *list;
  1014. X}
  1015. X
  1016. X%token    <rune>    RUNE
  1017. X%token        LBRK
  1018. X%token        RBRK
  1019. X%token        THRU
  1020. X%token        MAPLOWER
  1021. X%token        MAPUPPER
  1022. X%token        DIGITMAP
  1023. X%token    <i>    LIST
  1024. X%token    <str>    VARIABLE
  1025. X%token        ENCODING
  1026. X%token        INVALID
  1027. X%token    <str>    STRING
  1028. X
  1029. X%type    <list>    list
  1030. X%type    <list>    map
  1031. X
  1032. X
  1033. X%%
  1034. X
  1035. Xlocale    :    /* empty */
  1036. X    |    table
  1037. X            { dump_tables(); }
  1038. X    ;
  1039. X
  1040. Xtable    :    entry
  1041. X    |    table entry
  1042. X    ;
  1043. X
  1044. Xentry    :    ENCODING STRING
  1045. X        { strncpy(new_locale.encoding, $2, sizeof(new_locale.encoding)); }
  1046. X    |    VARIABLE
  1047. X        { new_locale.variable_len = strlen($1) + 1;
  1048. X          new_locale.variable = malloc(new_locale.variable_len);
  1049. X          strcpy((char *)new_locale.variable, $1);
  1050. X        }
  1051. X    |    INVALID RUNE
  1052. X        { new_locale.invalid_rune = $2; }
  1053. X    |    LIST list
  1054. X        { set_map(&types, $2, $1); }
  1055. X    |    MAPLOWER map
  1056. X        { set_map(&maplower, $2, 0); }
  1057. X    |    MAPUPPER map
  1058. X        { set_map(&mapupper, $2, 0); }
  1059. X    |    DIGITMAP map
  1060. X        { set_digitmap(&types, $2); }
  1061. X    ;
  1062. X
  1063. Xlist    :    RUNE
  1064. X        {
  1065. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1066. X            $$->min = $1;
  1067. X            $$->max = $1;
  1068. X            $$->next = 0;
  1069. X        }
  1070. X    |    RUNE THRU RUNE
  1071. X        {
  1072. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1073. X            $$->min = $1;
  1074. X            $$->max = $3;
  1075. X            $$->next = 0;
  1076. X        }
  1077. X    |    list RUNE
  1078. X        {
  1079. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1080. X            $$->min = $2;
  1081. X            $$->max = $2;
  1082. X            $$->next = $1;
  1083. X        }
  1084. X    |    list RUNE THRU RUNE
  1085. X        {
  1086. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1087. X            $$->min = $2;
  1088. X            $$->max = $4;
  1089. X            $$->next = $1;
  1090. X        }
  1091. X    ;
  1092. X
  1093. Xmap    :    LBRK RUNE RUNE RBRK
  1094. X        {
  1095. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1096. X            $$->min = $2;
  1097. X            $$->max = $2;
  1098. X            $$->map = $3;
  1099. X            $$->next = 0;
  1100. X        }
  1101. X    |    map LBRK RUNE RUNE RBRK
  1102. X        {
  1103. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1104. X            $$->min = $3;
  1105. X            $$->max = $3;
  1106. X            $$->map = $4;
  1107. X            $$->next = $1;
  1108. X        }
  1109. X    |    LBRK RUNE THRU RUNE ':' RUNE RBRK
  1110. X        {
  1111. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1112. X            $$->min = $2;
  1113. X            $$->max = $4;
  1114. X            $$->map = $6;
  1115. X            $$->next = 0;
  1116. X        }
  1117. X    |    map LBRK RUNE THRU RUNE ':' RUNE RBRK
  1118. X        {
  1119. X            $$ = (rune_list *)malloc(sizeof(rune_list));
  1120. X            $$->min = $3;
  1121. X            $$->max = $5;
  1122. X            $$->map = $7;
  1123. X            $$->next = $1;
  1124. X        }
  1125. X    ;
  1126. X%%
  1127. X
  1128. Xint debug = 0;
  1129. XFILE *fp = stdout;
  1130. X
  1131. Xmain(ac, av)
  1132. X    int ac;
  1133. X    char *av[];
  1134. X{
  1135. X    int x;
  1136. X
  1137. X    extern char *optarg;
  1138. X    extern int optind;
  1139. X
  1140. X    while ((x = getopt(ac, av, "do:")) != EOF) {
  1141. X    switch(x) {
  1142. X    case 'd':
  1143. X        debug = 1;
  1144. X        break;
  1145. X    case 'o':
  1146. X        locale_file = optarg;
  1147. X        if ((fp = fopen(locale_file, "w")) == 0) {
  1148. X        perror(locale_file);
  1149. X        exit(1);
  1150. X        }
  1151. X        break;
  1152. X    default:
  1153. X    usage:
  1154. X        fprintf(stderr, "Usage: mklocale [-d] [-o output] [source]\n");
  1155. X        exit(1);
  1156. X    }
  1157. X    }
  1158. X
  1159. X    switch (ac - optind) {
  1160. X    case 0:
  1161. X    break;
  1162. X    case 1:
  1163. X    if (freopen(av[optind], "r", stdin) == 0) {
  1164. X        perror(av[optind]);
  1165. X        exit(1);
  1166. X    }
  1167. X    break;
  1168. X    default:
  1169. X    goto usage;
  1170. X    }
  1171. X    for (x = 0; x < _CACHED_RUNES; ++x) {
  1172. X    mapupper.map[x] = x;
  1173. X    maplower.map[x] = x;
  1174. X    }
  1175. X    new_locale.invalid_rune = _INVALID_RUNE;
  1176. X    memcpy(new_locale.magic, _RUNE_MAGIC_1, sizeof(new_locale.magic));
  1177. X
  1178. X    yyparse();
  1179. X}
  1180. X
  1181. Xyyerror(s)
  1182. X    char *s;
  1183. X{
  1184. X    fprintf(stderr, "%s\n", s);
  1185. X}
  1186. X
  1187. Xvoid *
  1188. Xxmalloc(sz)
  1189. X    unsigned int sz;
  1190. X{
  1191. X    void *r = malloc(sz);
  1192. X    if (!r) {
  1193. X    perror("xmalloc");
  1194. X    abort();
  1195. X    }
  1196. X    return(r);
  1197. X}
  1198. X
  1199. Xu_long *
  1200. Xxlalloc(sz)
  1201. X    unsigned int sz;
  1202. X{
  1203. X    u_long *r = (u_long *)malloc(sz * sizeof(u_long));
  1204. X    if (!r) {
  1205. X    perror("xlalloc");
  1206. X    abort();
  1207. X    }
  1208. X    return(r);
  1209. X}
  1210. X
  1211. Xu_long *
  1212. Xxrelalloc(old, sz)
  1213. X    u_long *old;
  1214. X    unsigned int sz;
  1215. X{
  1216. X    u_long *r = (u_long *)realloc((char *)old, sz * sizeof(u_long));
  1217. X    if (!r) {
  1218. X    perror("xrelalloc");
  1219. X    abort();
  1220. X    }
  1221. X    return(r);
  1222. X}
  1223. X
  1224. Xvoid
  1225. Xset_map(map, list, flag)
  1226. X    rune_map *map;
  1227. X    rune_list *list;
  1228. X    u_long flag;
  1229. X{
  1230. X    while (list) {
  1231. X    rune_list *nlist = list->next;
  1232. X    add_map(map, list, flag);
  1233. X    list = nlist;
  1234. X    }
  1235. X}
  1236. X
  1237. Xvoid
  1238. Xset_digitmap(map, list)
  1239. X    rune_map *map;
  1240. X    rune_list *list;
  1241. X{
  1242. X    rune_t i;
  1243. X
  1244. X    while (list) {
  1245. X    rune_list *nlist = list->next;
  1246. X    for (i = list->min; i <= list->max; ++i) {
  1247. X        if (list->map + (i - list->min)) {
  1248. X        rune_list *tmp = (rune_list *)xmalloc(sizeof(rune_list));
  1249. X        tmp->min = i;
  1250. X        tmp->max = i;
  1251. X        add_map(map, tmp, list->map + (i - list->min));
  1252. X        }
  1253. X    }
  1254. X    free(list);
  1255. X    list = nlist;
  1256. X    }
  1257. X}
  1258. X
  1259. Xvoid
  1260. Xadd_map(map, list, flag)
  1261. X    rune_map *map;
  1262. X    rune_list *list;
  1263. X    u_long flag;
  1264. X{
  1265. X    rune_t i;
  1266. X    rune_list *lr = 0;
  1267. X    rune_list *r;
  1268. X    rune_t run;
  1269. X
  1270. X    while (list->min < _CACHED_RUNES && list->min <= list->max) {
  1271. X    if (flag)
  1272. X        map->map[list->min++] |= flag;
  1273. X    else
  1274. X        map->map[list->min++] = list->map++;
  1275. X    }
  1276. X
  1277. X    if (list->min > list->max) {
  1278. X    free(list);
  1279. X    return;
  1280. X    }
  1281. X
  1282. X    run = list->max - list->min + 1;
  1283. X
  1284. X    if (!(r = map->root) || (list->max < r->min - 1)
  1285. X             || (!flag && list->max == r->min - 1)) {
  1286. X    if (flag) {
  1287. X        list->types = xlalloc(run);
  1288. X        for (i = 0; i < run; ++i)
  1289. X        list->types[i] = flag;
  1290. X    }
  1291. X    list->next = map->root;
  1292. X    map->root = list;
  1293. X    return;
  1294. X    }
  1295. X
  1296. X    for (r = map->root; r && r->max + 1 < list->min; r = r->next)
  1297. X    lr = r;
  1298. X
  1299. X    if (!r) {
  1300. X    /*
  1301. X     * We are off the end.
  1302. X     */
  1303. X    if (flag) {
  1304. X        list->types = xlalloc(run);
  1305. X        for (i = 0; i < run; ++i)
  1306. X        list->types[i] = flag;
  1307. X    }
  1308. X    list->next = 0;
  1309. X    lr->next = list;
  1310. X    return;
  1311. X    }
  1312. X
  1313. X    if (list->max < r->min - 1) {
  1314. X    /*
  1315. X     * We come before this range and we do not intersect it.
  1316. X     * We are not before the root node, it was checked before the loop
  1317. X     */
  1318. X    if (flag) {
  1319. X        list->types = xlalloc(run);
  1320. X        for (i = 0; i < run; ++i)
  1321. X        list->types[i] = flag;
  1322. X    }
  1323. X    list->next = lr->next;
  1324. X    lr->next = list;
  1325. X    return;
  1326. X    }
  1327. X
  1328. X    /*
  1329. X     * At this point we have found that we at least intersect with
  1330. X     * the range pointed to by `r', we might intersect with one or
  1331. X     * more ranges beyond `r' as well.
  1332. X     */
  1333. X
  1334. X    if (!flag && list->map - list->min != r->map - r->min) {
  1335. X    /*
  1336. X     * There are only two cases when we are doing case maps and
  1337. X     * our maps needn't have the same offset.  When we are adjoining
  1338. X     * but not intersecting.
  1339. X     */
  1340. X    if (list->max + 1 == r->min) {
  1341. X        lr->next = list;
  1342. X        list->next = r;
  1343. X        return;
  1344. X    }
  1345. X    if (list->min - 1 == r->max) {
  1346. X        list->next = r->next;
  1347. X        r->next = list;
  1348. X        return;
  1349. X    }
  1350. X    fprintf(stderr, "Error: conflicting map entries\n");
  1351. X    exit(1);
  1352. X    }
  1353. X
  1354. X    if (list->min >= r->min && list->max <= r->max) {
  1355. X    /*
  1356. X     * Subset case.
  1357. X     */
  1358. X
  1359. X    if (flag) {
  1360. X        for (i = list->min; i <= list->max; ++i)
  1361. X        r->types[i - r->min] |= flag;
  1362. X    }
  1363. X    free(list);
  1364. X    return;
  1365. X    }
  1366. X    if (list->min <= r->min && list->max >= r->max) {
  1367. X    /*
  1368. X     * Superset case.  Make him big enough to hold us.
  1369. X     * We might need to merge with the guy after him.
  1370. X     */
  1371. X    if (flag) {
  1372. X        list->types = xlalloc(list->max - list->min + 1);
  1373. X
  1374. X        for (i = list->min; i <= list->max; ++i)
  1375. X        list->types[i - list->min] = flag;
  1376. X
  1377. X        for (i = r->min; i <= r->max; ++i)
  1378. X        list->types[i - list->min] |= r->types[i - r->min];
  1379. X
  1380. X        free(r->types);
  1381. X        r->types = list->types;
  1382. X    } else {
  1383. X        r->map = list->map;
  1384. X    }
  1385. X    r->min = list->min;
  1386. X    r->max = list->max;
  1387. X    free(list);
  1388. X    } else if (list->min < r->min) {
  1389. X    /*
  1390. X     * Our tail intersects his head.
  1391. X     */
  1392. X    if (flag) {
  1393. X        list->types = xlalloc(r->max - list->min + 1);
  1394. X
  1395. X        for (i = r->min; i <= r->max; ++i)
  1396. X        list->types[i - list->min] = r->types[i - r->min];
  1397. X
  1398. X        for (i = list->min; i < r->min; ++i)
  1399. X        list->types[i - list->min] = flag;
  1400. X
  1401. X        for (i = r->min; i <= list->max; ++i)
  1402. X        list->types[i - list->min] |= flag;
  1403. X
  1404. X        free(r->types);
  1405. X        r->types = list->types;
  1406. X    } else {
  1407. X        r->map = list->map;
  1408. X    }
  1409. X    r->min = list->min;
  1410. X    free(list);
  1411. X    return;
  1412. X    } else {
  1413. X    /*
  1414. X     * Our head intersects his tail.
  1415. X     * We might need to merge with the guy after him.
  1416. X     */
  1417. X    if (flag) {
  1418. X        r->types = xrelalloc(r->types, list->max - r->min + 1);
  1419. X
  1420. X        for (i = list->min; i <= r->max; ++i)
  1421. X        r->types[i - r->min] |= flag;
  1422. X
  1423. X        for (i = r->max+1; i <= list->max; ++i)
  1424. X        r->types[i - r->min] = flag;
  1425. X    }
  1426. X    r->max = r->max;
  1427. X    free(list);
  1428. X    }
  1429. X
  1430. X    /*
  1431. X     * Okay, check to see if we grew into the next guy(s)
  1432. X     */
  1433. X    while ((lr = r->next) && r->max >= lr->min) {
  1434. X    if (flag) {
  1435. X        if (r->max >= lr->max) {
  1436. X        /*
  1437. X         * Good, we consumed all of him.
  1438. X         */
  1439. X        for (i = lr->min; i <= lr->max; ++i)
  1440. X            r->types[i - r->min] |= lr->types[i - lr->min];
  1441. X        } else {
  1442. X        /*
  1443. X         * "append" him on to the end of us.
  1444. X         */
  1445. X        r->types = xrelalloc(r->types, lr->max - r->min + 1);
  1446. X
  1447. X        for (i = lr->min; i <= r->max; ++i)
  1448. X            r->types[i - r->min] |= lr->types[i - lr->min];
  1449. X
  1450. X        for (i = r->max+1; i <= lr->max; ++i)
  1451. X            r->types[i - r->min] = lr->types[i - lr->min];
  1452. X
  1453. X        r->max = lr->max;
  1454. X        }
  1455. X    } else {
  1456. X        if (lr->max > r->max)
  1457. X        r->max = lr->max;
  1458. X    }
  1459. X
  1460. X    r->next = lr->next;
  1461. X
  1462. X    if (flag)
  1463. X        free(lr->types);
  1464. X    free(lr);
  1465. X    }
  1466. X}
  1467. X
  1468. Xvoid
  1469. Xdump_tables()
  1470. X{
  1471. X    int x;
  1472. X    rune_list *list;
  1473. X
  1474. X    /*
  1475. X     * See if we can compress some of the istype arrays
  1476. X     */
  1477. X    for(list = types.root; list; list = list->next) {
  1478. X    list->map = list->types[0];
  1479. X    for (x = 1; x < list->max - list->min + 1; ++x) {
  1480. X        if (list->types[x] != list->map) {
  1481. X        list->map = 0;
  1482. X        break;
  1483. X        }
  1484. X    }
  1485. X    }
  1486. X
  1487. X    new_locale.invalid_rune = htonl(new_locale.invalid_rune);
  1488. X
  1489. X    /*
  1490. X     * Fill in our tables.  Do this in network order so that
  1491. X     * diverse machines have a chance of sharing data.
  1492. X     * (Machines like Crays cannot share with little machines due to
  1493. X     *  word size.  Sigh.  We tried.)
  1494. X     */
  1495. X    for (x = 0; x < _CACHED_RUNES; ++x) {
  1496. X    new_locale.runetype[x] = htonl(types.map[x]);
  1497. X    new_locale.maplower[x] = htonl(maplower.map[x]);
  1498. X    new_locale.mapupper[x] = htonl(mapupper.map[x]);
  1499. X    }
  1500. X
  1501. X    /*
  1502. X     * Count up how many ranges we will need for each of the extents.
  1503. X     */
  1504. X    list = types.root;
  1505. X
  1506. X    while (list) {
  1507. X    new_locale.runetype_ext.nranges++;
  1508. X    list = list->next;
  1509. X    }
  1510. X    new_locale.runetype_ext.nranges = htonl(new_locale.runetype_ext.nranges);
  1511. X
  1512. X    list = maplower.root;
  1513. X
  1514. X    while (list) {
  1515. X    new_locale.maplower_ext.nranges++;
  1516. X    list = list->next;
  1517. X    }
  1518. X    new_locale.maplower_ext.nranges = htonl(new_locale.maplower_ext.nranges);
  1519. X
  1520. X    list = mapupper.root;
  1521. X
  1522. X    while (list) {
  1523. X    new_locale.mapupper_ext.nranges++;
  1524. X    list = list->next;
  1525. X    }
  1526. X    new_locale.mapupper_ext.nranges = htonl(new_locale.mapupper_ext.nranges);
  1527. X
  1528. X    new_locale.variable_len = htonl(new_locale.variable_len);
  1529. X
  1530. X    /*
  1531. X     * Okay, we are now ready to write the new locale file.
  1532. X     */
  1533. X
  1534. X    /*
  1535. X     * PART 1: The _RuneLocale structure
  1536. X     */
  1537. X    if (fwrite((char *)&new_locale, sizeof(new_locale), 1, fp) != 1) {
  1538. X    perror(locale_file);
  1539. X    exit(1);
  1540. X    }
  1541. X    /*
  1542. X     * PART 2: The runetype_ext structures (not the actual tables)
  1543. X     */
  1544. X    list = types.root;
  1545. X
  1546. X    while (list) {
  1547. X    _RuneEntry re;
  1548. X
  1549. X    re.min = htonl(list->min);
  1550. X    re.max = htonl(list->max);
  1551. X    re.map = htonl(list->map);
  1552. X
  1553. X    if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
  1554. X        perror(locale_file);
  1555. X        exit(1);
  1556. X    }
  1557. X
  1558. X        list = list->next;
  1559. X    }
  1560. X    /*
  1561. X     * PART 3: The maplower_ext structures
  1562. X     */
  1563. X    list = maplower.root;
  1564. X
  1565. X    while (list) {
  1566. X    _RuneEntry re;
  1567. X
  1568. X    re.min = htonl(list->min);
  1569. X    re.max = htonl(list->max);
  1570. X    re.map = htonl(list->map);
  1571. X
  1572. X    if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
  1573. X        perror(locale_file);
  1574. X        exit(1);
  1575. X    }
  1576. X
  1577. X        list = list->next;
  1578. X    }
  1579. X    /*
  1580. X     * PART 4: The mapupper_ext structures
  1581. X     */
  1582. X    list = mapupper.root;
  1583. X
  1584. X    while (list) {
  1585. X    _RuneEntry re;
  1586. X
  1587. X    re.min = htonl(list->min);
  1588. X    re.max = htonl(list->max);
  1589. X    re.map = htonl(list->map);
  1590. X
  1591. X    if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
  1592. X        perror(locale_file);
  1593. X        exit(1);
  1594. X    }
  1595. X
  1596. X        list = list->next;
  1597. X    }
  1598. X    /*
  1599. X     * PART 5: The runetype_ext tables
  1600. X     */
  1601. X    list = types.root;
  1602. X
  1603. X    while (list) {
  1604. X    for (x = 0; x < list->max - list->min + 1; ++x)
  1605. X        list->types[x] = htonl(list->types[x]);
  1606. X
  1607. X    if (!list->map) {
  1608. X        if (fwrite((char *)&list->types,
  1609. X        (list->max - list->min + 1)*sizeof(u_long), 1, fp) != 1) {
  1610. X        perror(locale_file);
  1611. X        exit(1);
  1612. X        }
  1613. X    }
  1614. X        list = list->next;
  1615. X    }
  1616. X    /*
  1617. X     * PART 5: And finally the variable data
  1618. X     */
  1619. X    if (fwrite((char *)new_locale.variable,
  1620. X           ntohl(new_locale.variable_len), 1, fp) != 1) {
  1621. X    perror(locale_file);
  1622. X    exit(1);
  1623. X    }
  1624. X    fclose(fp);
  1625. X
  1626. X    if (!debug)
  1627. X    return;
  1628. X
  1629. X    if (new_locale.encoding[0])
  1630. X    fprintf(stderr, "ENCODING    %s\n", new_locale.encoding);
  1631. X    if (new_locale.variable)
  1632. X    fprintf(stderr, "VARIABLE    %s\n", new_locale.variable);
  1633. X
  1634. X    fprintf(stderr, "\nMAPLOWER:\n\n");
  1635. X
  1636. X    for (x = 0; x < _CACHED_RUNES; ++x) {
  1637. X    if (isprint(maplower.map[x]))
  1638. X        fprintf(stderr, " '%c'", maplower.map[x]);
  1639. X    else if (maplower.map[x])
  1640. X        fprintf(stderr, "%04x", maplower.map[x]);
  1641. X    else
  1642. X        fprintf(stderr, "%4x", 0);
  1643. X    if ((x & 0xf) == 0xf)
  1644. X        fprintf(stderr, "\n");
  1645. X    else
  1646. X        fprintf(stderr, " ");
  1647. X    }
  1648. X    fprintf(stderr, "\n");
  1649. X
  1650. X    for (list = maplower.root; list; list = list->next)
  1651. X    fprintf(stderr, "\t%04x - %04x : %04x\n", list->min, list->max, list->map);
  1652. X
  1653. X    fprintf(stderr, "\nMAPUPPER:\n\n");
  1654. X
  1655. X    for (x = 0; x < _CACHED_RUNES; ++x) {
  1656. X    if (isprint(mapupper.map[x]))
  1657. X        fprintf(stderr, " '%c'", mapupper.map[x]);
  1658. X    else if (mapupper.map[x])
  1659. X        fprintf(stderr, "%04x", mapupper.map[x]);
  1660. X    else
  1661. X        fprintf(stderr, "%4x", 0);
  1662. X    if ((x & 0xf) == 0xf)
  1663. X        fprintf(stderr, "\n");
  1664. X    else
  1665. X        fprintf(stderr, " ");
  1666. X    }
  1667. X    fprintf(stderr, "\n");
  1668. X
  1669. X    for (list = mapupper.root; list; list = list->next)
  1670. X    fprintf(stderr, "\t%04x - %04x : %04x\n", list->min, list->max, list->map);
  1671. X
  1672. X
  1673. X    fprintf(stderr, "\nTYPES:\n\n");
  1674. X
  1675. X    for (x = 0; x < _CACHED_RUNES; ++x) {
  1676. X    u_long r = types.map[x];
  1677. X
  1678. X    if (r) {
  1679. X        if (isprint(x))
  1680. X        fprintf(stderr, " '%c': %2d", x, r & 0xff);
  1681. X        else
  1682. X        fprintf(stderr, "%04x: %2d", x, r & 0xff);
  1683. X
  1684. X        fprintf(stderr, " %4s", (r & _A) ? "alph" : "");
  1685. X        fprintf(stderr, " %4s", (r & _C) ? "ctrl" : "");
  1686. X        fprintf(stderr, " %4s", (r & _D) ? "dig" : "");
  1687. X        fprintf(stderr, " %4s", (r & _G) ? "graf" : "");
  1688. X        fprintf(stderr, " %4s", (r & _L) ? "low" : "");
  1689. X        fprintf(stderr, " %4s", (r & _P) ? "punc" : "");
  1690. X        fprintf(stderr, " %4s", (r & _S) ? "spac" : "");
  1691. X        fprintf(stderr, " %4s", (r & _U) ? "upp" : "");
  1692. X        fprintf(stderr, " %4s", (r & _X) ? "xdig" : "");
  1693. X        fprintf(stderr, " %4s", (r & _B) ? "blnk" : "");
  1694. X        fprintf(stderr, " %4s", (r & _R) ? "prnt" : "");
  1695. X        fprintf(stderr, " %4s", (r & _I) ? "ideo" : "");
  1696. X        fprintf(stderr, " %4s", (r & _T) ? "spec" : "");
  1697. X        fprintf(stderr, " %4s", (r & _Q) ? "phon" : "");
  1698. X        fprintf(stderr, "\n");
  1699. X    }
  1700. X    }
  1701. X
  1702. X    for (list = types.root; list; list = list->next) {
  1703. X    if (list->map && list->min + 3 < list->max) {
  1704. X        u_long r = list->map;
  1705. X
  1706. X        fprintf(stderr, "%04x: %2d", list->min, r & 0xff);
  1707. X
  1708. X        fprintf(stderr, " %4s", (r & _A) ? "alph" : "");
  1709. X        fprintf(stderr, " %4s", (r & _C) ? "ctrl" : "");
  1710. X        fprintf(stderr, " %4s", (r & _D) ? "dig" : "");
  1711. X        fprintf(stderr, " %4s", (r & _G) ? "graf" : "");
  1712. X        fprintf(stderr, " %4s", (r & _L) ? "low" : "");
  1713. X        fprintf(stderr, " %4s", (r & _P) ? "punc" : "");
  1714. X        fprintf(stderr, " %4s", (r & _S) ? "spac" : "");
  1715. X        fprintf(stderr, " %4s", (r & _U) ? "upp" : "");
  1716. X        fprintf(stderr, " %4s", (r & _X) ? "xdig" : "");
  1717. X        fprintf(stderr, " %4s", (r & _B) ? "blnk" : "");
  1718. X        fprintf(stderr, " %4s", (r & _R) ? "prnt" : "");
  1719. X        fprintf(stderr, " %4s", (r & _I) ? "ideo" : "");
  1720. X        fprintf(stderr, " %4s", (r & _T) ? "spec" : "");
  1721. X        fprintf(stderr, " %4s", (r & _Q) ? "phon" : "");
  1722. X        fprintf(stderr, "\n...\n");
  1723. X
  1724. X        fprintf(stderr, "%04x: %2d", list->max, r & 0xff);
  1725. X
  1726. X        fprintf(stderr, " %4s", (r & _A) ? "alph" : "");
  1727. X        fprintf(stderr, " %4s", (r & _C) ? "ctrl" : "");
  1728. X        fprintf(stderr, " %4s", (r & _D) ? "dig" : "");
  1729. X        fprintf(stderr, " %4s", (r & _G) ? "graf" : "");
  1730. X        fprintf(stderr, " %4s", (r & _L) ? "low" : "");
  1731. X        fprintf(stderr, " %4s", (r & _P) ? "punc" : "");
  1732. X        fprintf(stderr, " %4s", (r & _S) ? "spac" : "");
  1733. X        fprintf(stderr, " %4s", (r & _U) ? "upp" : "");
  1734. X        fprintf(stderr, " %4s", (r & _X) ? "xdig" : "");
  1735. X        fprintf(stderr, " %4s", (r & _B) ? "blnk" : "");
  1736. X        fprintf(stderr, " %4s", (r & _R) ? "prnt" : "");
  1737. X        fprintf(stderr, " %4s", (r & _I) ? "ideo" : "");
  1738. X        fprintf(stderr, " %4s", (r & _T) ? "spec" : "");
  1739. X        fprintf(stderr, " %4s", (r & _Q) ? "phon" : "");
  1740. X        fprintf(stderr, "\n");
  1741. X    } else 
  1742. X    for (x = list->min; x <= list->max; ++x) {
  1743. X        u_long r = ntohl(list->types[x - list->min]);
  1744. X
  1745. X        if (r) {
  1746. X        fprintf(stderr, "%04x: %2d", x, r & 0xff);
  1747. X
  1748. X        fprintf(stderr, " %4s", (r & _A) ? "alph" : "");
  1749. X        fprintf(stderr, " %4s", (r & _C) ? "ctrl" : "");
  1750. X        fprintf(stderr, " %4s", (r & _D) ? "dig" : "");
  1751. X        fprintf(stderr, " %4s", (r & _G) ? "graf" : "");
  1752. X        fprintf(stderr, " %4s", (r & _L) ? "low" : "");
  1753. X        fprintf(stderr, " %4s", (r & _P) ? "punc" : "");
  1754. X        fprintf(stderr, " %4s", (r & _S) ? "spac" : "");
  1755. X        fprintf(stderr, " %4s", (r & _U) ? "upp" : "");
  1756. X        fprintf(stderr, " %4s", (r & _X) ? "xdig" : "");
  1757. X        fprintf(stderr, " %4s", (r & _B) ? "blnk" : "");
  1758. X        fprintf(stderr, " %4s", (r & _R) ? "prnt" : "");
  1759. X        fprintf(stderr, " %4s", (r & _I) ? "ideo" : "");
  1760. X        fprintf(stderr, " %4s", (r & _T) ? "spec" : "");
  1761. X        fprintf(stderr, " %4s", (r & _Q) ? "phon" : "");
  1762. X        fprintf(stderr, "\n");
  1763. X        }
  1764. X    }
  1765. X    }
  1766. X}
  1767. END_OF_FILE
  1768. if test 19494 -ne `wc -c <'mklocale/yacc.y'`; then
  1769.     echo shar: \"'mklocale/yacc.y'\" unpacked with wrong size!
  1770. fi
  1771. # end of 'mklocale/yacc.y'
  1772. fi
  1773. echo shar: End of archive 3 \(of 3\).
  1774. cp /dev/null ark3isdone
  1775. MISSING=""
  1776. for I in 1 2 3 ; do
  1777.     if test ! -f ark${I}isdone ; then
  1778.     MISSING="${MISSING} ${I}"
  1779.     fi
  1780. done
  1781. if test "${MISSING}" = "" ; then
  1782.     echo You have unpacked all 3 archives.
  1783.     rm -f ark[1-9]isdone
  1784. else
  1785.     echo You still need to unpack the following archives:
  1786.     echo "        " ${MISSING}
  1787. fi
  1788. ##  End of shell archive.
  1789. exit 0
  1790.