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

  1. Newsgroups: comp.sources.unix
  2. From: prb@cray.com
  3. Subject: v27i028: REPOST runes - an implementation of setlocale(3) and all its friends, Part02/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 28
  10. Archive-Name: runes/part02
  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 2 (of 3)."
  19. # Contents:  doc/multibyte.3 doc/rune.3 include/ctype.h libc/euc.c
  20. #   libc/setlocale.c libc/table.c mklocale/lex.l mklocale/mklocale.1
  21. # Wrapped by prb@krystal.cray.com on Sun Sep  5 11:15:56 1993
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'doc/multibyte.3' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'doc/multibyte.3'\"
  25. else
  26. echo shar: Extracting \"'doc/multibyte.3'\" \(6804 characters\)
  27. sed "s/^X//" >'doc/multibyte.3' <<'END_OF_FILE'
  28. X.\" Copyright (c) 1993
  29. X.\"    The Regents of the University of California.  All rights reserved.
  30. X.\"
  31. X.\" This code is derived from software contributed to Berkeley by
  32. X.\" Donn Seeley of BSDI.
  33. X.\"
  34. X.\" Redistribution and use in source and binary forms, with or without
  35. X.\" modification, are permitted provided that the following conditions
  36. X.\" are met:
  37. X.\" 1. Redistributions of source code must retain the above copyright
  38. X.\"    notice, this list of conditions and the following disclaimer.
  39. X.\" 2. Redistributions in binary form must reproduce the above copyright
  40. X.\"    notice, this list of conditions and the following disclaimer in the
  41. X.\"    documentation and/or other materials provided with the distribution.
  42. X.\" 3. All advertising materials mentioning features or use of this software
  43. X.\"    must display the following acknowledgement:
  44. X.\"    This product includes software developed by the University of
  45. X.\"    California, Berkeley and its contributors.
  46. X.\" 4. Neither the name of the University nor the names of its contributors
  47. X.\"    may be used to endorse or promote products derived from this software
  48. X.\"    without specific prior written permission.
  49. X.\"
  50. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. X.\" SUCH DAMAGE.
  61. X.\"
  62. X.\"    @(#)multibyte.3    8.1 (Berkeley) 6/4/93
  63. X.\"
  64. X.Dd "June 4, 1993"
  65. X.Dt MULTIBYTE 3
  66. X.Os
  67. X.Sh NAME
  68. X.Nm mblen ,
  69. X.Nm mbstowcs ,
  70. X.Nm mbtowc ,
  71. X.Nm wcstombs ,
  72. X.Nm wctomb
  73. X.Nd multibyte character support for C
  74. X.Sh SYNOPSIS
  75. X.Fd #include <stdlib.h>
  76. X.Ft int
  77. X.Fn mblen "const char *mbchar" "int nbytes"
  78. X.Ft size_t
  79. X.Fn mbstowcs "wchar_t *wcstring" "const char *mbstring" "size_t nwchars"
  80. X.Ft int
  81. X.Fn mbtowc "wchar_t *wcharp" "const char *mbchar" "size_t nbytes"
  82. X.Ft size_t
  83. X.Fn wcstombs "char *mbstring" "const wchar_t *wcstring" "size_t nbytes"
  84. X.Ft int
  85. X.Fn wctomb "char *mbchar" "wchar_t wchar"
  86. X.Sh DESCRIPTION
  87. XThe basic elements of some written natural languages such as Chinese
  88. Xcannot be represented uniquely with single C
  89. X.Va char Ns s .
  90. XThe C standard supports two different ways of dealing with
  91. Xextended natural language encodings,
  92. X.Em wide
  93. Xcharacters and
  94. X.Em multibyte
  95. Xcharacters.
  96. XWide characters are an internal representation
  97. Xwhich allows each basic element to map
  98. Xto a single object of type
  99. X.Va wchar_t .
  100. XMultibyte characters are used for input and output
  101. Xand code each basic element as a sequence of C
  102. X.Va char Ns s .
  103. XIndividual basic elements may map into one or more
  104. X.Pq up to Dv MB_CHAR_MAX
  105. Xbytes in a multibyte character.
  106. X.Pp
  107. XThe current locale
  108. X.Pq Xr setlocale 3
  109. Xgoverns the interpretation of wide and multibyte characters.
  110. XThe locale category
  111. X.Dv LC_CTYPE
  112. Xspecifically controls this interpretation.
  113. XThe
  114. X.Va wchar_t
  115. Xtype is wide enough to hold the largest value
  116. Xin the wide character representations for all locales.
  117. X.Pp
  118. XMultibyte strings may contain
  119. X.Sq shift
  120. Xindicators to switch to and from
  121. Xparticular modes within the given representation.
  122. XIf explicit bytes are used to signal shifting,
  123. Xthese are not recognized as separate characters
  124. Xbut are lumped with a neighboring character.
  125. XThere is always a distinguished
  126. X.Sq initial
  127. Xshift state.
  128. XThe
  129. X.Fn mbstowcs
  130. Xand
  131. X.Fn wcstombs
  132. Xfunctions assume that multibyte strings are interpreted
  133. Xstarting from the initial shift state.
  134. XThe
  135. X.Fn mblen ,
  136. X.Fn mbtowc
  137. Xand
  138. X.Fn wctomb
  139. Xfunctions maintain static shift state internally.
  140. XA call with a null
  141. X.Fa mbchar
  142. Xpointer returns nonzero if the current locale requires shift states,
  143. Xzero otherwise;
  144. Xif shift states are required, the shift state is reset to the initial state.
  145. XThe internal shift states are undefined after a call to
  146. X.Fn setlocale
  147. Xwith the
  148. X.Dv LC_CTYPE
  149. Xor
  150. X.Dv LC_ALL
  151. Xcategories.
  152. X.Pp
  153. XFor convenience in processing,
  154. Xthe wide character with value 0
  155. X.Pq the null wide character
  156. Xis recognized as the wide character string terminator,
  157. Xand the character with value 0
  158. X.Pq the null byte
  159. Xis recognized as the multibyte character string terminator.
  160. XNull bytes are not permitted within multibyte characters.
  161. X.Pp
  162. XThe
  163. X.Fn mblen
  164. Xfunction computes the length in bytes
  165. Xof a multibyte character
  166. X.Fa mbchar .
  167. XUp to
  168. X.Fa nbytes
  169. Xbytes are examined.
  170. X.Pp
  171. XThe
  172. X.Fn mbtowc
  173. Xfunction converts a multibyte character
  174. X.Fa mbchar
  175. Xinto a wide character and stores the result
  176. Xin the object pointed to by
  177. X.Fa wcharp.
  178. XUp to
  179. X.Fa nbytes
  180. Xbytes are examined.
  181. X.Pp
  182. XThe
  183. X.Fn wctomb
  184. Xfunction converts a wide character
  185. X.Fa wchar
  186. Xinto a multibyte character and stores
  187. Xthe result in
  188. X.Fa mbchar .
  189. XThe object pointed to by
  190. X.Fa mbchar
  191. Xmust be large enough to accommodate the multibyte character.  
  192. X.Pp
  193. XThe
  194. X.Fn mbstowcs
  195. Xfunction converts a multibyte character string
  196. X.Fa mbstring
  197. Xinto a wide character string
  198. X.Fa wcstring .
  199. XNo more than
  200. X.Fa nwchars
  201. Xwide characters are stored.
  202. XA terminating null wide character is appended if there is room.
  203. X.Pp
  204. XThe
  205. X.Fn wcstombs
  206. Xfunction converts a wide character string
  207. X.Fa wcstring
  208. Xinto a multibyte character string
  209. X.Fa mbstring .
  210. XUp to
  211. X.Fa nbytes
  212. Xbytes are stored in
  213. X.Fa mbstring .
  214. XPartial multibyte characters at the end of the string are not stored.
  215. XThe multibyte character string is null terminated if there is room.
  216. X.Sh "RETURN VALUES
  217. XIf multibyte characters are not supported in the current locale,
  218. Xall of these functions will return \-1 if characters can be processed,
  219. Xotherwise 0.
  220. X.Pp
  221. XIf
  222. X.Fa mbchar
  223. Xis
  224. X.Dv NULL ,
  225. Xthe
  226. X.Fn mblen ,
  227. X.Fn mbtowc
  228. Xand
  229. X.Fn wctomb
  230. Xfunctions return nonzero if shift states are supported,
  231. Xzero otherwise.
  232. XIf
  233. X.Fa mbchar
  234. Xis valid,
  235. Xthen these functions return
  236. Xthe number of bytes processed in
  237. X.Fa mbchar ,
  238. Xor \-1 if no multibyte character
  239. Xcould be recognized or converted.
  240. X.Pp
  241. XThe
  242. X.Fn mbstowcs
  243. Xfunction returns the number of wide characters converted,
  244. Xnot counting any terminating null wide character.
  245. XThe
  246. X.Fn wcstombs
  247. Xfunction returns the number of bytes converted,
  248. Xnot counting any terminating null byte.
  249. XIf any invalid multibyte characters are encountered,
  250. Xboth functions return \-1.
  251. X.Sh "SEE ALSO
  252. X.Xr euc 4 ,
  253. X.Xr mbrune 3 ,
  254. X.Xr rune 3 ,
  255. X.Xr setlocale 3 ,
  256. X.Xr utf2 4
  257. X.Sh STANDARDS
  258. XThe
  259. X.Fn mblen ,
  260. X.Fn mbstowcs ,
  261. X.Fn mbtowc ,
  262. X.Fn wcstombs
  263. Xand
  264. X.Fn wctomb
  265. Xfunctions conform to
  266. X.St -ansiC .
  267. X.Sh BUGS
  268. XThe current implementation does not support shift states.
  269. END_OF_FILE
  270. if test 6804 -ne `wc -c <'doc/multibyte.3'`; then
  271.     echo shar: \"'doc/multibyte.3'\" unpacked with wrong size!
  272. fi
  273. # end of 'doc/multibyte.3'
  274. fi
  275. if test -f 'doc/rune.3' -a "${1}" != "-c" ; then 
  276.   echo shar: Will not clobber existing file \"'doc/rune.3'\"
  277. else
  278. echo shar: Extracting \"'doc/rune.3'\" \(6653 characters\)
  279. sed "s/^X//" >'doc/rune.3' <<'END_OF_FILE'
  280. X.\" Copyright (c) 1993
  281. X.\"    The Regents of the University of California.  All rights reserved.
  282. X.\"
  283. X.\" This code is derived from software contributed to Berkeley by
  284. X.\" Paul Borman at Krystal Technologies.
  285. X.\"
  286. X.\" Redistribution and use in source and binary forms, with or without
  287. X.\" modification, are permitted provided that the following conditions
  288. X.\" are met:
  289. X.\" 1. Redistributions of source code must retain the above copyright
  290. X.\"    notice, this list of conditions and the following disclaimer.
  291. X.\" 2. Redistributions in binary form must reproduce the above copyright
  292. X.\"    notice, this list of conditions and the following disclaimer in the
  293. X.\"    documentation and/or other materials provided with the distribution.
  294. X.\" 3. All advertising materials mentioning features or use of this software
  295. X.\"    must display the following acknowledgement:
  296. X.\"    This product includes software developed by the University of
  297. X.\"    California, Berkeley and its contributors.
  298. X.\" 4. Neither the name of the University nor the names of its contributors
  299. X.\"    may be used to endorse or promote products derived from this software
  300. X.\"    without specific prior written permission.
  301. X.\"
  302. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  303. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  304. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  305. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  306. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  307. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  308. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  309. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  310. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  311. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  312. X.\" SUCH DAMAGE.
  313. X.\"
  314. X.\"    @(#)rune.3    8.1 (Berkeley) 6/27/93
  315. X.\"
  316. X.Dd "June 27, 1993"
  317. X.Dt RUNE 3
  318. X.Os
  319. X.Sh NAME
  320. X.Nm setrunelocale ,
  321. X.Nm setinvalidrune ,
  322. X.Nm sgetrune ,
  323. X.Nm sputrune
  324. X.Nd rune support for C
  325. X.Sh SYNOPSIS
  326. X.Fd #include <rune.h>
  327. X.Fd #include <errno.h>
  328. X.Ft int
  329. X.Fn setrunelocale "char *locale"
  330. X.Ft void
  331. X.Fn setinvalidrune "rune_t rune"
  332. X.Ft rune_t
  333. X.Fn sgetrune "const char *string" "size_t n" "char const **result"
  334. X.Ft int
  335. X.Fn sputrune "rune_t rune" "char *string" "size_t n" "char **result"
  336. X.sp
  337. X.Fd #include <stdio.h>
  338. X.Ft long
  339. X.Fn fgetrune "FILE *stream"
  340. X.Ft int
  341. X.Fn fungetrune "rune_t rune" "FILE *stream"
  342. X.Ft int
  343. X.Fn fputrune "rune_t rune" "FILE *stream"
  344. X.Sh DESCRIPTION
  345. XThe
  346. X.Fn setrunelocale
  347. Xcontrols the type of encoding used to represent runes as multibyte strings
  348. Xas well as the properties of the runes as defined in
  349. X\fB<ctype.h>\fP.
  350. XThe
  351. X.Fa locale
  352. Xargument indicates the locale which to load.
  353. XIf the locale is successfully loaded,
  354. X.Dv 0
  355. Xis returned, otherwise an errno value is returned to indicate the
  356. Xtype of error.
  357. X.Pp
  358. XThe
  359. X.Fn setinvalidrune
  360. Xfunction sets the value of the global value
  361. X.Ev _INVALID_RUNE
  362. Xto be
  363. X.Fa rune.
  364. X.Pp
  365. XThe
  366. X.Fn sgetrune
  367. Xfunction tries to read a single multibyte character from
  368. X.Fa string ,
  369. Xwhich is at most
  370. X.Fa n
  371. Xbytes long.
  372. XIf
  373. X.Fn sgetrune
  374. Xis successful, the rune is returned.
  375. XIf
  376. X.Fa result
  377. Xis not
  378. X.Dv NULL ,
  379. X.Fa *result
  380. Xwill point to the first byte which was not converted in
  381. X.Fa string.
  382. XIf the first
  383. X.Fa n
  384. Xbytes of
  385. X.Fa string
  386. Xdo not describe a full multibyte character,
  387. X.Ev _INVALID_RUNE
  388. Xis returned and
  389. X.Fa *result
  390. Xwill point to
  391. X.Fa string.
  392. XIf there is an encoding error at the start of
  393. X.Fa string ,
  394. X.Ev _INVALID_RUNE
  395. Xis returned and 
  396. X.Fa *result
  397. Xwill point to the second character of
  398. X.Fa string.
  399. X.Pp
  400. Xthe
  401. X.Fn sputrune
  402. Xfunction tries to encode
  403. X.Fa rune
  404. Xas a multibyte string and store it at
  405. X.Fa string ,
  406. Xbut no more than
  407. X.Fa n
  408. Xbytes will be stored.
  409. XIf
  410. X.Fa result
  411. Xis not
  412. X.Dv NULL ,
  413. X.Fa *result
  414. Xwill be set to point to the first byte in string following the new
  415. Xmultibyte character.
  416. XIf
  417. X.Fa string
  418. Xis
  419. X.Dv NULL ,
  420. X.Fa *result
  421. Xwill point to
  422. X.Dv "(char *)0 +"
  423. X.Fa x ,
  424. Xwhere
  425. X.Fa x
  426. Xis the number of bytes that would be needed to store the multibyte value.
  427. XIf the multibyte character would consist of more than
  428. X.Fa n
  429. Xbytes and
  430. X.Fa result
  431. Xis not
  432. X.Dv NULL ,
  433. X.Fa *result
  434. Xwill be set to
  435. X.Dv NULL.
  436. XIn all cases, 
  437. X.Fn sputrune
  438. Xwill return the number of bytes which would be needed to store
  439. X.Fa rune
  440. Xas a multibyte character.
  441. X.Pp
  442. XThe
  443. X.Fn fgetrune
  444. Xfunction operates the same as
  445. X.Fn sgetrune
  446. Xwith the exception that it attempts to read enough bytes from 
  447. X.Fa stream
  448. Xto decode a single rune.  It returns either
  449. X.Ev EOF
  450. Xon end of file,
  451. X.Ev _INVALID_RUNE
  452. Xon an encoding error, or the rune decoded if all went well.
  453. X.Pp
  454. XThe
  455. X.Fn fungetrune
  456. Xfunction function pushes the multibyte encoding, as provided by
  457. X.Fn sputrune ,
  458. Xof
  459. X.Fa rune
  460. Xonto
  461. X.Fa stream 
  462. Xsuch that the next
  463. X.Fn fgetrune
  464. Xcall will return
  465. X.Fa rune .
  466. XIt returns
  467. X.Ev EOF
  468. Xif it fails and
  469. X.Dv 0
  470. Xon success.
  471. X.Pp
  472. XThe
  473. X.Fn fputrune
  474. Xfunction writes the multibyte encoding of
  475. X.Fa rune ,
  476. Xas provided by
  477. X.Fn sputrune ,
  478. Xonto
  479. X.Fa stream .
  480. XIt returns
  481. X.Ev EOF
  482. Xon failure and
  483. X.Dv 0
  484. Xon success.
  485. X.Sh RETURN VALUES
  486. XThe
  487. X.Fn setrunelocale
  488. Xfunction returns one of the following values:
  489. X.Bl -tag -width WWWWWWWW
  490. X.It Dv 0
  491. X.Fa setrunelocale was successful.
  492. X.It Ev EFAULT
  493. X.Fa locale
  494. Xwas
  495. X.Dv NULL .
  496. X.It Ev ENOENT
  497. XThe locale could not be found.
  498. X.It Ev EFTYPE
  499. XThe file found was not a valid file.
  500. X.It Ev EINVAL
  501. XThe encoding indicated by the locale was unknown.
  502. X.El
  503. X.Pp
  504. XThe
  505. X.Fn sgetrune
  506. Xfunction either returns the rune read or
  507. X.Ev _INVALID_RUNE .
  508. XThe
  509. X.Fn sputrune
  510. Xfunction returns the number of bytes needed to store
  511. X.Fa rune
  512. Xas a multibyte string.
  513. X.Sh FILES
  514. X.Bl -tag -width /usr/share/locale/locale/LC_CTYPE -compact
  515. X.It Pa $PATH_LOCALE/\fIlocale\fP/LC_CTYPE
  516. X.It Pa /usr/share/locale/\fIlocale\fP/LC_CTYPE
  517. Xbinary LC_CTYPE file for the locale \fIlocale\fP.
  518. X.El
  519. X.Sh "SEE ALSO
  520. X.Xr euc 4 ,
  521. X.Xr mbrune 3 ,
  522. X.Xr setlocale 3 ,
  523. X.Xr utf2 4
  524. X.Sh NOTE
  525. XThe ANSI C type
  526. X.Ev wchar_t
  527. Xis the same as
  528. X.Ev rune_t .
  529. X.Ev Rune_t
  530. Xwas chosen to accent the purposeful choice of not basing the
  531. Xsystem with the ANSI C
  532. Xprimitives, which were, shall we say, less aesthetic.
  533. X.Sh HISTORY
  534. XThese functions first appeared in
  535. X.Bx 4.4 .
  536. X.Pp
  537. XThe
  538. X.Fn setrunelocale
  539. Xfunction and the other non-ANSI rune functions were inspired by
  540. X.Nm Plan 9 from Bell Labs
  541. Xas a much more sane alternative to the ANSI multibyte and
  542. Xwide character support.
  543. X.\"They were conceived at the San Diego 1993 Summer USENIX conference by
  544. X.\"Paul Borman of Krystal Technologies, Keith Bostic of CSRG and Andrew Hume
  545. X.\"of Bell Labs.
  546. X.Pp
  547. XAll of the ANSI multibyte and wide character
  548. Xsupport functions are built using the rune functions.
  549. END_OF_FILE
  550. if test 6653 -ne `wc -c <'doc/rune.3'`; then
  551.     echo shar: \"'doc/rune.3'\" unpacked with wrong size!
  552. fi
  553. # end of 'doc/rune.3'
  554. fi
  555. if test -f 'include/ctype.h' -a "${1}" != "-c" ; then 
  556.   echo shar: Will not clobber existing file \"'include/ctype.h'\"
  557. else
  558. echo shar: Extracting \"'include/ctype.h'\" \(5126 characters\)
  559. sed "s/^X//" >'include/ctype.h' <<'END_OF_FILE'
  560. X/*
  561. X * Copyright (c) 1989, 1993
  562. X *    The Regents of the University of California.  All rights reserved.
  563. X *
  564. X * This code is derived from software contributed to Berkeley by
  565. X * Paul Borman at Krystal Technologies.
  566. X *
  567. X * Redistribution and use in source and binary forms, with or without
  568. X * modification, are permitted provided that the following conditions
  569. X * are met:
  570. X * 1. Redistributions of source code must retain the above copyright
  571. X *    notice, this list of conditions and the following disclaimer.
  572. X * 2. Redistributions in binary form must reproduce the above copyright
  573. X *    notice, this list of conditions and the following disclaimer in the
  574. X *    documentation and/or other materials provided with the distribution.
  575. X * 3. All advertising materials mentioning features or use of this software
  576. X *    must display the following acknowledgement:
  577. X *    This product includes software developed by the University of
  578. X *    California, Berkeley and its contributors.
  579. X * 4. Neither the name of the University nor the names of its contributors
  580. X *    may be used to endorse or promote products derived from this software
  581. X *    without specific prior written permission.
  582. X *
  583. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  584. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  585. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  586. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  587. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  588. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  589. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  590. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  591. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  592. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  593. X * SUCH DAMAGE.
  594. X *
  595. X *    @(#)ctype.h    8.1 (Berkeley) 6/6/93
  596. X */
  597. X
  598. X#ifndef    _CTYPE_H_
  599. X#define _CTYPE_H_
  600. X
  601. X#ifndef _ANSI_SOURCE
  602. X#include <runetype.h>
  603. X#endif
  604. X
  605. X#define    _A    0x00000100L        /* Alpha */
  606. X#define    _C    0x00000200L        /* Control */
  607. X#define    _D    0x00000400L        /* Digit */
  608. X#define    _G    0x00000800L        /* Graph */
  609. X#define    _L    0x00001000L        /* Lower */
  610. X#define    _P    0x00002000L        /* Punct */
  611. X#define    _S    0x00004000L        /* Space */
  612. X#define    _U    0x00008000L        /* Upper */
  613. X#define    _X    0x00010000L        /* X digit */
  614. X#define    _B    0x00020000L        /* Blank */
  615. X#define    _R    0x00040000L        /* Print */
  616. X#define    _I    0x00080000L        /* Ideogram */
  617. X#define    _T    0x00100000L        /* Special */
  618. X#define    _Q    0x00200000L        /* Phonogram */
  619. X
  620. X#define isalnum(c)      __istype((c), (_A|_D))
  621. X#define isalpha(c)      __istype((c),     _A)
  622. X#define iscntrl(c)      __istype((c),     _C)
  623. X#define isdigit(c)      __isctype((c),    _D)    /* ANSI -- locale independent */
  624. X#define isgraph(c)      __istype((c),     _G)
  625. X#define islower(c)      __istype((c),     _L)
  626. X#define isprint(c)      __istype((c),     _R)
  627. X#define ispunct(c)      __istype((c),     _P)
  628. X#define isspace(c)      __istype((c),     _S)
  629. X#define isupper(c)      __istype((c),     _U)
  630. X#define isxdigit(c)     __isctype((c),    _X)    /* ANSI -- locale independent */
  631. X
  632. X#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  633. X#define    isascii(c)    ((c & ~0x7F) == 0)
  634. X#define toascii(c)    ((c) & 0x7F)
  635. X#define    digittoint(c)    __istype((c), 0xFF)
  636. X#define    isideogram(c)    __istype((c), _I)
  637. X#define    isphonogram(c)    __istype((c), _T)
  638. X#define    isspecial(c)    __istype((c), _Q)
  639. X#define isblank(c)    __istype((c), _B)
  640. X#define    isrune(c)    __istype((c),  0xFFFFFF00L)
  641. X#define    isnumber(c)    __istype((c), _D)
  642. X#define    ishexnumber(c)    __istype((c), _X)
  643. X#endif
  644. X
  645. X/* See comments in <machine/ansi.h> about _BSD_RUNE_T_. */
  646. X__BEGIN_DECLS
  647. Xunsigned long    ___runetype __P((_BSD_RUNE_T_));
  648. X_BSD_RUNE_T_    ___tolower __P((_BSD_RUNE_T_));
  649. X_BSD_RUNE_T_    ___toupper __P((_BSD_RUNE_T_));
  650. X__END_DECLS
  651. X
  652. X/*
  653. X * If your compiler supports prototypes and inline functions,
  654. X * #define _USE_CTYPE_INLINE_.  Otherwise, use the C library
  655. X * functions.
  656. X */
  657. X#if !defined(_USE_CTYPE_CLIBRARY_) && defined(__GNUC__) || defined(__cplusplus)
  658. X#define    _USE_CTYPE_INLINE_    1
  659. X#endif
  660. X
  661. X#if defined(_USE_CTYPE_INLINE_)
  662. Xstatic inline int
  663. X__istype(_BSD_RUNE_T_ c, unsigned long f)
  664. X{
  665. X    return((((c & _CRMASK) ? ___runetype(c) :
  666. X        _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0);
  667. X}
  668. X
  669. Xstatic inline int
  670. X__isctype(_BSD_RUNE_T_ c, unsigned long f)
  671. X{
  672. X    return((((c & _CRMASK) ? 0 :
  673. X        _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0);
  674. X}
  675. X
  676. X/* _ANSI_LIBRARY is defined by lib/libc/gen/isctype.c. */
  677. X#if !defined(_ANSI_LIBRARY)
  678. Xstatic inline _BSD_RUNE_T_
  679. Xtoupper(_BSD_RUNE_T_ c)
  680. X{
  681. X    return((c & _CRMASK) ?
  682. X        ___toupper(c) : _CurrentRuneLocale->mapupper[c]);
  683. X}
  684. X
  685. Xstatic inline _BSD_RUNE_T_
  686. Xtolower(_BSD_RUNE_T_ c)
  687. X{
  688. X    return((c & _CRMASK) ?
  689. X        ___tolower(c) : _CurrentRuneLocale->maplower[c]);
  690. X}
  691. X#endif /* !_ANSI_LIBRARY */
  692. X
  693. X#else /* !_USE_CTYPE_INLINE_ */
  694. X
  695. X__BEGIN_DECLS
  696. Xint        __istype __P((_BSD_RUNE_T_, unsigned long));
  697. Xint        __isctype __P((_BSD_RUNE_T_, unsigned long));
  698. X_BSD_RUNE_T_    toupper __P((_BSD_RUNE_T_));
  699. X_BSD_RUNE_T_    tolower __P((_BSD_RUNE_T_));
  700. X__END_DECLS
  701. X#endif /* _USE_CTYPE_INLINE_ */
  702. X
  703. X#endif /* !_CTYPE_H_ */
  704. END_OF_FILE
  705. if test 5126 -ne `wc -c <'include/ctype.h'`; then
  706.     echo shar: \"'include/ctype.h'\" unpacked with wrong size!
  707. fi
  708. # end of 'include/ctype.h'
  709. fi
  710. if test -f 'libc/euc.c' -a "${1}" != "-c" ; then 
  711.   echo shar: Will not clobber existing file \"'libc/euc.c'\"
  712. else
  713. echo shar: Extracting \"'libc/euc.c'\" \(5285 characters\)
  714. sed "s/^X//" >'libc/euc.c' <<'END_OF_FILE'
  715. X/*-
  716. X * Copyright (c) 1993
  717. X *    The Regents of the University of California.  All rights reserved.
  718. X *
  719. X * This code is derived from software contributed to Berkeley by
  720. X * Paul Borman at Krystal Technologies.
  721. X *
  722. X * Redistribution and use in source and binary forms, with or without
  723. X * modification, are permitted provided that the following conditions
  724. X * are met:
  725. X * 1. Redistributions of source code must retain the above copyright
  726. X *    notice, this list of conditions and the following disclaimer.
  727. X * 2. Redistributions in binary form must reproduce the above copyright
  728. X *    notice, this list of conditions and the following disclaimer in the
  729. X *    documentation and/or other materials provided with the distribution.
  730. X * 3. All advertising materials mentioning features or use of this software
  731. X *    must display the following acknowledgement:
  732. X *    This product includes software developed by the University of
  733. X *    California, Berkeley and its contributors.
  734. X * 4. Neither the name of the University nor the names of its contributors
  735. X *    may be used to endorse or promote products derived from this software
  736. X *    without specific prior written permission.
  737. X *
  738. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  739. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  740. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  741. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  742. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  743. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  744. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  745. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  746. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  747. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  748. X * SUCH DAMAGE.
  749. X */
  750. X
  751. X#if defined(LIBC_SCCS) && !defined(lint)
  752. Xstatic char sccsid[] = "@(#)euc.c    8.1 (Berkeley) 6/4/93";
  753. X#endif /* LIBC_SCCS and not lint */
  754. X
  755. X#include <sys/types.h>
  756. X
  757. X#include <errno.h>
  758. X#include <rune.h>
  759. X#include <stddef.h>
  760. X#include <stdio.h>
  761. X#include <stdlib.h>
  762. X
  763. Xrune_t    _EUC_sgetrune __P((const char *, size_t, char const **));
  764. Xint    _EUC_sputrune __P((rune_t, char *, size_t, char **));
  765. X
  766. Xtypedef struct {
  767. X    int    count[4];
  768. X    rune_t    bits[4];
  769. X    rune_t    mask;
  770. X} _EucInfo;
  771. X
  772. Xint
  773. X_EUC_init(rl)
  774. X    _RuneLocale *rl;
  775. X{
  776. X    _EucInfo *ei;
  777. X    int x;
  778. X    char *v, *e;
  779. X
  780. X    rl->sgetrune = _EUC_sgetrune;
  781. X    rl->sputrune = _EUC_sputrune;
  782. X
  783. X    if (!rl->variable) {
  784. X        free(rl);
  785. X        return (EFTYPE);
  786. X    }
  787. X    v = (char *) rl->variable;
  788. X
  789. X    while (*v == ' ' || *v == '\t')
  790. X        ++v;
  791. X
  792. X    if ((ei = malloc(sizeof(_EucInfo))) == NULL) {
  793. X        free(rl);
  794. X        return (ENOMEM);
  795. X    }
  796. X    for (x = 0; x < 4; ++x) {
  797. X        ei->count[x] = (int) strtol(v, &e, 0);
  798. X        if (v == e || !(v = e)) {
  799. X            free(rl);
  800. X            free(ei);
  801. X            return (EFTYPE);
  802. X        }
  803. X        while (*v == ' ' || *v == '\t')
  804. X            ++v;
  805. X        ei->bits[x] = (int) strtol(v, &e, 0);
  806. X        if (v == e || !(v = e)) {
  807. X            free(rl);
  808. X            free(ei);
  809. X            return (EFTYPE);
  810. X        }
  811. X        while (*v == ' ' || *v == '\t')
  812. X            ++v;
  813. X    }
  814. X    ei->mask = (int)strtol(v, &e, 0);
  815. X    if (v == e || !(v = e)) {
  816. X        free(rl);
  817. X        free(ei);
  818. X        return (EFTYPE);
  819. X    }
  820. X    if (sizeof(_EucInfo) <= rl->variable_len) {
  821. X        memcpy(rl->variable, ei, sizeof(_EucInfo));
  822. X        free(ei);
  823. X    } else {
  824. X        rl->variable = &ei;
  825. X    }
  826. X    rl->variable_len = sizeof(_EucInfo);
  827. X    _CurrentRuneLocale = rl;
  828. X    __mb_cur_max = 3;
  829. X    return (0);
  830. X}
  831. X
  832. X#define    CEI    ((_EucInfo *)(_CurrentRuneLocale->variable))
  833. X
  834. X#define    _SS2    0x008e
  835. X#define    _SS3    0x008f
  836. X
  837. Xstatic inline int
  838. X_euc_set(c)
  839. X    u_int c;
  840. X{
  841. X    c &= 0xff;
  842. X
  843. X    return ((c & 0x80) ? c == _SS3 ? 3 : c == _SS2 ? 2 : 1 : 0);
  844. X}
  845. Xrune_t
  846. X_EUC_sgetrune(string, n, result)
  847. X    const char *string;
  848. X    size_t n;
  849. X    char const **result;
  850. X{
  851. X    rune_t rune = 0;
  852. X    int len, set;
  853. X
  854. X    if (n < 1 || (len = CEI->count[set = _euc_set(*string)]) > n) {
  855. X        if (result)
  856. X            *result = string;
  857. X        return (_INVALID_RUNE);
  858. X    }
  859. X    switch (set) {
  860. X    case 3:
  861. X    case 2:
  862. X        --len;
  863. X        ++string;
  864. X        /* FALLTHROUGH */
  865. X    case 1:
  866. X    case 0:
  867. X        while (len-- > 0)
  868. X            rune = (rune << 8) | ((u_int)(*string++) & 0xff);
  869. X        break;
  870. X    }
  871. X    if (result)
  872. X        *result = string;
  873. X    return ((rune & ~CEI->mask) | CEI->bits[set]);
  874. X}
  875. X
  876. Xint
  877. X_EUC_sputrune(c, string, n, result)
  878. X    rune_t c;
  879. X    char *string, **result;
  880. X    size_t n;
  881. X{
  882. X    rune_t m = c & CEI->mask;
  883. X    rune_t nm = c & ~m;
  884. X    int i, len;
  885. X
  886. X    if (m == CEI->bits[1]) {
  887. XCodeSet1:
  888. X        /* Codeset 1: The first byte must have 0x80 in it. */
  889. X        i = len = CEI->count[1];
  890. X        if (n >= len) {
  891. X            if (result)
  892. X                *result = string + len;
  893. X            while (i-- > 0)
  894. X                *string++ = (nm >> (i << 3)) | 0x80;
  895. X        } else
  896. X            if (result)
  897. X                *result = (char *) 0;
  898. X    } else {
  899. X        if (m == CEI->bits[0]) {
  900. X            i = len = CEI->count[0];
  901. X            if (n < len) {
  902. X                if (result)
  903. X                    *result = NULL;
  904. X                return (len);
  905. X            }
  906. X        } else
  907. X            if (m == CEI->bits[2]) {
  908. X                i = len = CEI->count[2];
  909. X                if (n < len) {
  910. X                    if (result)
  911. X                        *result = NULL;
  912. X                    return (len);
  913. X                }
  914. X                *string++ = _SS2;
  915. X                --i;
  916. X            } else
  917. X                if (m == CEI->bits[3]) {
  918. X                    i = len = CEI->count[3];
  919. X                    if (n < len) {
  920. X                        if (result)
  921. X                            *result = NULL;
  922. X                        return (len);
  923. X                    }
  924. X                    *string++ = _SS3;
  925. X                    --i;
  926. X                } else
  927. X                    goto CodeSet1;    /* Bletch */
  928. X        while (i-- > 0)
  929. X            *string++ = (nm >> (i << 3)) & 0xff;
  930. X        if (result)
  931. X            *result = string;
  932. X    }
  933. X    return (len);
  934. X}
  935. END_OF_FILE
  936. if test 5285 -ne `wc -c <'libc/euc.c'`; then
  937.     echo shar: \"'libc/euc.c'\" unpacked with wrong size!
  938. fi
  939. # end of 'libc/euc.c'
  940. fi
  941. if test -f 'libc/setlocale.c' -a "${1}" != "-c" ; then 
  942.   echo shar: Will not clobber existing file \"'libc/setlocale.c'\"
  943. else
  944. echo shar: Extracting \"'libc/setlocale.c'\" \(6317 characters\)
  945. sed "s/^X//" >'libc/setlocale.c' <<'END_OF_FILE'
  946. X/*
  947. X * Copyright (c) 1991, 1993
  948. X *    The Regents of the University of California.  All rights reserved.
  949. X *
  950. X * This code is derived from software contributed to Berkeley by
  951. X * Paul Borman at Krystal Technologies.
  952. X *
  953. X * Redistribution and use in source and binary forms, with or without
  954. X * modification, are permitted provided that the following conditions
  955. X * are met:
  956. X * 1. Redistributions of source code must retain the above copyright
  957. X *    notice, this list of conditions and the following disclaimer.
  958. X * 2. Redistributions in binary form must reproduce the above copyright
  959. X *    notice, this list of conditions and the following disclaimer in the
  960. X *    documentation and/or other materials provided with the distribution.
  961. X * 3. All advertising materials mentioning features or use of this software
  962. X *    must display the following acknowledgement:
  963. X *    This product includes software developed by the University of
  964. X *    California, Berkeley and its contributors.
  965. X * 4. Neither the name of the University nor the names of its contributors
  966. X *    may be used to endorse or promote products derived from this software
  967. X *    without specific prior written permission.
  968. X *
  969. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  970. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  971. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  972. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  973. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  974. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  975. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  976. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  977. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  978. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  979. X * SUCH DAMAGE.
  980. X */
  981. X
  982. X#if defined(LIBC_SCCS) && !defined(lint)
  983. Xstatic char sccsid[] = "@(#)setlocale.c    8.1 (Berkeley) 7/4/93";
  984. X#endif /* LIBC_SCCS and not lint */
  985. X
  986. X#include <limits.h>
  987. X#include <locale.h>
  988. X#include <rune.h>
  989. X#include <stdlib.h>
  990. X#include <string.h>
  991. X
  992. X/*
  993. X * Category names for getenv()
  994. X */
  995. Xstatic char *categories[_LC_LAST] = {
  996. X    "LC_ALL",
  997. X    "LC_COLLATE",
  998. X    "LC_CTYPE",
  999. X    "LC_MONETARY",
  1000. X    "LC_NUMERIC",
  1001. X    "LC_TIME",
  1002. X};
  1003. X
  1004. X/*
  1005. X * Current locales for each category
  1006. X */
  1007. Xstatic char current_categories[_LC_LAST][32] = {
  1008. X    "C",
  1009. X    "C",
  1010. X    "C",
  1011. X    "C",
  1012. X    "C",
  1013. X    "C",
  1014. X};
  1015. X
  1016. X/*
  1017. X * The locales we are going to try and load
  1018. X */
  1019. Xstatic char new_categories[_LC_LAST][32];
  1020. X
  1021. Xstatic char current_locale_string[_LC_LAST * 33];
  1022. Xstatic char *PathLocale;
  1023. X
  1024. Xstatic char    *currentlocale __P((void));
  1025. Xstatic char    *loadlocale __P((int));
  1026. X
  1027. Xchar *
  1028. Xsetlocale(category, locale)
  1029. X    int category;
  1030. X    const char *locale;
  1031. X{
  1032. X    int found, i, len;
  1033. X    char *env, *r;
  1034. X
  1035. X    if (!PathLocale && !(PathLocale = getenv("PATH_LOCALE")))
  1036. X        PathLocale = _PATH_LOCALE;
  1037. X
  1038. X    if (category < 0 || category >= _LC_LAST)
  1039. X        return (NULL);
  1040. X
  1041. X    if (!locale)
  1042. X        return (category ?
  1043. X            current_categories[category] : currentlocale());
  1044. X
  1045. X    /*
  1046. X     * Default to the current locale for everything.
  1047. X     */
  1048. X    for (i = 1; i < _LC_LAST; ++i)
  1049. X        (void)strcpy(new_categories[i], current_categories[i]);
  1050. X
  1051. X    /*
  1052. X     * Now go fill up new_categories from the locale argument
  1053. X     */
  1054. X    if (!*locale) {
  1055. X        env = getenv(categories[category]);
  1056. X
  1057. X        if (!env)
  1058. X            env = getenv(categories[0]);
  1059. X
  1060. X        if (!env)
  1061. X            env = getenv("LANG");
  1062. X
  1063. X        if (!env)
  1064. X            env = "C";
  1065. X
  1066. X        (void) strncpy(new_categories[category], env, 31);
  1067. X        new_categories[category][31] = 0;
  1068. X        if (!category) {
  1069. X            for (i = 1; i < _LC_LAST; ++i) {
  1070. X                if (!(env = getenv(categories[i])))
  1071. X                    env = new_categories[0];
  1072. X                (void)strncpy(new_categories[i], env, 31);
  1073. X                new_categories[i][31] = 0;
  1074. X            }
  1075. X        }
  1076. X    } else if (category)  {
  1077. X        (void)strncpy(new_categories[category], locale, 31);
  1078. X        new_categories[category][31] = 0;
  1079. X    } else {
  1080. X        if ((r = strchr(locale, '/')) == 0) {
  1081. X            for (i = 1; i < _LC_LAST; ++i) {
  1082. X                (void)strncpy(new_categories[i], locale, 31);
  1083. X                new_categories[i][31] = 0;
  1084. X            }
  1085. X        } else {
  1086. X            for (i = 1; r[1] == '/'; ++r);
  1087. X            if (!r[1])
  1088. X                return (NULL);    /* Hmm, just slashes... */
  1089. X            do {
  1090. X                len = r - locale > 31 ? 31 : r - locale;
  1091. X                (void)strncpy(new_categories[i++], locale, len);
  1092. X                new_categories[i++][len] = 0;
  1093. X                locale = r;
  1094. X                while (*locale == '/')
  1095. X                    ++locale;
  1096. X                while (*++r && *r != '/');
  1097. X            } while (*locale);
  1098. X            while (i < _LC_LAST)
  1099. X                (void)strcpy(new_categories[i],
  1100. X                    new_categories[i-1]);
  1101. X        }
  1102. X    }
  1103. X
  1104. X    if (category)
  1105. X        return (loadlocale(category));
  1106. X
  1107. X    found = 0;
  1108. X    for (i = 1; i < _LC_LAST; ++i)
  1109. X        if (loadlocale(i) != NULL)
  1110. X            found = 1;
  1111. X    if (found)
  1112. X        return (currentlocale());
  1113. X    return (NULL);
  1114. X}
  1115. X
  1116. Xstatic char *
  1117. Xcurrentlocale()
  1118. X{
  1119. X    int i;
  1120. X
  1121. X    (void)strcpy(current_locale_string, current_categories[1]);
  1122. X
  1123. X    for (i = 2; i < _LC_LAST; ++i)
  1124. X        if (strcmp(current_categories[1], current_categories[i])) {
  1125. X            (void)snprintf(current_locale_string,
  1126. X                sizeof(current_locale_string), "%s/%s/%s/%s/%s",
  1127. X                current_categories[1], current_categories[2],
  1128. X                current_categories[3], current_categories[4],
  1129. X                current_categories[5]);
  1130. X            break;
  1131. X        }
  1132. X    return (current_locale_string);
  1133. X}
  1134. X
  1135. Xstatic char *
  1136. Xloadlocale(category)
  1137. X    int category;
  1138. X{
  1139. X    char name[PATH_MAX];
  1140. X
  1141. X    if (strcmp(new_categories[category],
  1142. X        current_categories[category]) == 0)
  1143. X        return (current_categories[category]);
  1144. X
  1145. X    if (category == LC_CTYPE) {
  1146. X        if (setrunelocale(new_categories[LC_CTYPE]))
  1147. X            return (NULL);
  1148. X        (void)strcpy(current_categories[LC_CTYPE],
  1149. X            new_categories[LC_CTYPE]);
  1150. X        return (current_categories[LC_CTYPE]);
  1151. X    }
  1152. X
  1153. X    if (!strcmp(new_categories[category], "C") ||
  1154. X        !strcmp(new_categories[category], "POSIX")) {
  1155. X
  1156. X        /*
  1157. X         * Some day this will need to reset the locale to the default
  1158. X         * C locale.  Since we have no way to change them as of yet,
  1159. X         * there is no need to reset them.
  1160. X         */
  1161. X        (void)strcpy(current_categories[category],
  1162. X            new_categories[category]);
  1163. X        return (current_categories[category]);
  1164. X    }
  1165. X
  1166. X    /*
  1167. X     * Some day we will actually look at this file.
  1168. X     */
  1169. X    (void)snprintf(name, sizeof(name), "%s/%s/%s",
  1170. X        PathLocale, new_categories[category], categories[category]);
  1171. X
  1172. X    switch (category) {
  1173. X        case LC_COLLATE:
  1174. X        case LC_MONETARY:
  1175. X        case LC_NUMERIC:
  1176. X        case LC_TIME:
  1177. X            return (NULL);
  1178. X    }
  1179. X}
  1180. END_OF_FILE
  1181. if test 6317 -ne `wc -c <'libc/setlocale.c'`; then
  1182.     echo shar: \"'libc/setlocale.c'\" unpacked with wrong size!
  1183. fi
  1184. # end of 'libc/setlocale.c'
  1185. fi
  1186. if test -f 'libc/table.c' -a "${1}" != "-c" ; then 
  1187.   echo shar: Will not clobber existing file \"'libc/table.c'\"
  1188. else
  1189. echo shar: Extracting \"'libc/table.c'\" \(7312 characters\)
  1190. sed "s/^X//" >'libc/table.c' <<'END_OF_FILE'
  1191. X/*-
  1192. X * Copyright (c) 1993
  1193. X *    The Regents of the University of California.  All rights reserved.
  1194. X *
  1195. X * This code is derived from software contributed to Berkeley by
  1196. X * Paul Borman at Krystal Technologies.
  1197. X *
  1198. X * Redistribution and use in source and binary forms, with or without
  1199. X * modification, are permitted provided that the following conditions
  1200. X * are met:
  1201. X * 1. Redistributions of source code must retain the above copyright
  1202. X *    notice, this list of conditions and the following disclaimer.
  1203. X * 2. Redistributions in binary form must reproduce the above copyright
  1204. X *    notice, this list of conditions and the following disclaimer in the
  1205. X *    documentation and/or other materials provided with the distribution.
  1206. X * 3. All advertising materials mentioning features or use of this software
  1207. X *    must display the following acknowledgement:
  1208. X *    This product includes software developed by the University of
  1209. X *    California, Berkeley and its contributors.
  1210. X * 4. Neither the name of the University nor the names of its contributors
  1211. X *    may be used to endorse or promote products derived from this software
  1212. X *    without specific prior written permission.
  1213. X *
  1214. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1215. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1216. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1217. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1218. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1219. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1220. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1221. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1222. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1223. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1224. X * SUCH DAMAGE.
  1225. X */
  1226. X
  1227. X#if defined(LIBC_SCCS) && !defined(lint)
  1228. Xstatic char sccsid[] = "@(#)table.c    8.1 (Berkeley) 6/27/93";
  1229. X#endif /* LIBC_SCCS and not lint */
  1230. X
  1231. X#include <sys/types.h>
  1232. X
  1233. X#include <ctype.h>
  1234. X#include <rune.h>
  1235. X
  1236. Xextern rune_t    _none_sgetrune __P((const char *, size_t, char const **));
  1237. Xextern int    _none_sputrune __P((rune_t, char *, size_t, char **));
  1238. Xextern int    _none_init __P((char *, char **));
  1239. X
  1240. X_RuneLocale _DefaultRuneLocale = {
  1241. X    _RUNE_MAGIC_1,
  1242. X    "none",
  1243. X    _none_sgetrune,
  1244. X    _none_sputrune,
  1245. X    0xFFFD,
  1246. X
  1247. X    {    /*00*/    _C,        _C,        _C,        _C,
  1248. X        _C,        _C,        _C,        _C,
  1249. X    /*08*/    _C,        _C|_S|_B,    _C|_S,        _C|_S,
  1250. X        _C|_S,        _C|_S,        _C,        _C,
  1251. X    /*10*/    _C,        _C,        _C,        _C,
  1252. X        _C,        _C,        _C,        _C,
  1253. X    /*18*/    _C,        _C,        _C,        _C,
  1254. X        _C,        _C,        _C,        _C,
  1255. X    /*20*/    _S|_B|_R,    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,
  1256. X        _P|_R|_G,    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,
  1257. X    /*28*/    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,
  1258. X        _P|_R|_G,    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,
  1259. X    /*30*/    _D|_R|_G|_X|0,    _D|_R|_G|_X|1,    _D|_R|_G|_X|2,    _D|_R|_G|_X|3,
  1260. X        _D|_R|_G|_X|4,    _D|_R|_G|_X|5,    _D|_R|_G|_X|6,    _D|_R|_G|_X|7,
  1261. X    /*38*/    _D|_R|_G|_X|8,    _D|_R|_G|_X|9,    _P|_R|_G,    _P|_R|_G,
  1262. X        _P|_R|_G,    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,
  1263. X    /*40*/    _P|_R|_G, _U|_X|_R|_G|_A|10, _U|_X|_R|_G|_A|11, _U|_X|_R|_G|_A|12,
  1264. X        _U|_X|_R|_G|_A|13, _U|_X|_R|_G|_A|14, _U|_X|_R|_G|_A|15, _U|_R|_G|_A,
  1265. X    /*48*/    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,
  1266. X        _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,
  1267. X    /*50*/    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,
  1268. X        _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,
  1269. X    /*58*/    _U|_R|_G|_A,    _U|_R|_G|_A,    _U|_R|_G|_A,    _P|_R|_G,
  1270. X        _P|_R|_G,    _P|_R|_G,    _P|_R|_G,    _P|_R|_G,
  1271. X    /*60*/    _P|_R|_G, _L|_X|_R|_G|_A|10, _L|_X|_R|_G|_A|11, _L|_X|_R|_G|_A|12,
  1272. X        _L|_X|_R|_G|_A|13, _L|_X|_R|_G|_A|14, _L|_X|_R|_G|_A|15, _L|_R|_G|_A,
  1273. X    /*68*/    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,
  1274. X        _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,
  1275. X    /*70*/    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,
  1276. X        _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,
  1277. X    /*78*/    _L|_R|_G|_A,    _L|_R|_G|_A,    _L|_R|_G|_A,    _P|_R|_G,
  1278. X        _P|_R|_G,    _P|_R|_G,    _P|_R|_G,    _C,
  1279. X    },
  1280. X    {    0x00,    0x01,    0x02,    0x03,    0x04,    0x05,    0x06,    0x07,
  1281. X         0x08,    0x09,    0x0a,    0x0b,    0x0c,    0x0d,    0x0e,    0x0f,
  1282. X    0x10,    0x11,    0x12,    0x13,    0x14,    0x15,    0x16,    0x17,
  1283. X         0x18,    0x19,    0x1a,    0x1b,    0x1c,    0x1d,    0x1e,    0x1f,
  1284. X    0x20,    0x21,    0x22,    0x23,    0x24,    0x25,    0x26,    0x27,
  1285. X         0x28,    0x29,    0x2a,    0x2b,    0x2c,    0x2d,    0x2e,    0x2f,
  1286. X    0x30,    0x31,    0x32,    0x33,    0x34,    0x35,    0x36,    0x37,
  1287. X         0x38,    0x39,    0x3a,    0x3b,    0x3c,    0x3d,    0x3e,    0x3f,
  1288. X    0x40,    'a',    'b',    'c',    'd',    'e',    'f',    'g',
  1289. X         'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
  1290. X    'p',    'q',    'r',    's',    't',    'u',    'v',    'w',
  1291. X         'x',    'y',    'z',    0x5b,    0x5c,    0x5d,    0x5e,    0x5f,
  1292. X    0x60,    'a',    'b',    'c',    'd',    'e',    'f',    'g',
  1293. X         'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
  1294. X    'p',    'q',    'r',    's',    't',    'u',    'v',    'w',
  1295. X         'x',    'y',    'z',    0x7b,    0x7c,    0x7d,    0x7e,    0x7f,
  1296. X    0x80,    0x81,    0x82,    0x83,    0x84,    0x85,    0x86,    0x87,
  1297. X         0x88,    0x89,    0x8a,    0x8b,    0x8c,    0x8d,    0x8e,    0x8f,
  1298. X    0x90,    0x91,    0x92,    0x93,    0x94,    0x95,    0x96,    0x97,
  1299. X         0x98,    0x99,    0x9a,    0x9b,    0x9c,    0x9d,    0x9e,    0x9f,
  1300. X    0xa0,    0xa1,    0xa2,    0xa3,    0xa4,    0xa5,    0xa6,    0xa7,
  1301. X         0xa8,    0xa9,    0xaa,    0xab,    0xac,    0xad,    0xae,    0xaf,
  1302. X    0xb0,    0xb1,    0xb2,    0xb3,    0xb4,    0xb5,    0xb6,    0xb7,
  1303. X         0xb8,    0xb9,    0xba,    0xbb,    0xbc,    0xbd,    0xbe,    0xbf,
  1304. X    0xc0,    0xc1,    0xc2,    0xc3,    0xc4,    0xc5,    0xc6,    0xc7,
  1305. X         0xc8,    0xc9,    0xca,    0xcb,    0xcc,    0xcd,    0xce,    0xcf,
  1306. X    0xd0,    0xd1,    0xd2,    0xd3,    0xd4,    0xd5,    0xd6,    0xd7,
  1307. X         0xd8,    0xd9,    0xda,    0xdb,    0xdc,    0xdd,    0xde,    0xdf,
  1308. X    0xe0,    0xe1,    0xe2,    0xe3,    0xe4,    0xe5,    0xe6,    0xe7,
  1309. X         0xe8,    0xe9,    0xea,    0xeb,    0xec,    0xed,    0xee,    0xef,
  1310. X    0xf0,    0xf1,    0xf2,    0xf3,    0xf4,    0xf5,    0xf6,    0xf7,
  1311. X         0xf8,    0xf9,    0xfa,    0xfb,    0xfc,    0xfd,    0xfe,    0xff,
  1312. X    },
  1313. X    {    0x00,    0x01,    0x02,    0x03,    0x04,    0x05,    0x06,    0x07,
  1314. X         0x08,    0x09,    0x0a,    0x0b,    0x0c,    0x0d,    0x0e,    0x0f,
  1315. X    0x10,    0x11,    0x12,    0x13,    0x14,    0x15,    0x16,    0x17,
  1316. X         0x18,    0x19,    0x1a,    0x1b,    0x1c,    0x1d,    0x1e,    0x1f,
  1317. X    0x20,    0x21,    0x22,    0x23,    0x24,    0x25,    0x26,    0x27,
  1318. X         0x28,    0x29,    0x2a,    0x2b,    0x2c,    0x2d,    0x2e,    0x2f,
  1319. X    0x30,    0x31,    0x32,    0x33,    0x34,    0x35,    0x36,    0x37,
  1320. X         0x38,    0x39,    0x3a,    0x3b,    0x3c,    0x3d,    0x3e,    0x3f,
  1321. X    0x40,    'A',    'B',    'C',    'D',    'E',    'F',    'G',
  1322. X         'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',
  1323. X    'P',    'Q',    'R',    'S',    'T',    'U',    'V',    'W',
  1324. X         'X',    'Y',    'Z',    0x5b,    0x5c,    0x5d,    0x5e,    0x5f,
  1325. X    0x60,    'A',    'B',    'C',    'D',    'E',    'F',    'G',
  1326. X         'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',
  1327. X    'P',    'Q',    'R',    'S',    'T',    'U',    'V',    'W',
  1328. X         'X',    'Y',    'Z',    0x7b,    0x7c,    0x7d,    0x7e,    0x7f,
  1329. X    0x80,    0x81,    0x82,    0x83,    0x84,    0x85,    0x86,    0x87,
  1330. X         0x88,    0x89,    0x8a,    0x8b,    0x8c,    0x8d,    0x8e,    0x8f,
  1331. X    0x90,    0x91,    0x92,    0x93,    0x94,    0x95,    0x96,    0x97,
  1332. X         0x98,    0x99,    0x9a,    0x9b,    0x9c,    0x9d,    0x9e,    0x9f,
  1333. X    0xa0,    0xa1,    0xa2,    0xa3,    0xa4,    0xa5,    0xa6,    0xa7,
  1334. X         0xa8,    0xa9,    0xaa,    0xab,    0xac,    0xad,    0xae,    0xaf,
  1335. X    0xb0,    0xb1,    0xb2,    0xb3,    0xb4,    0xb5,    0xb6,    0xb7,
  1336. X         0xb8,    0xb9,    0xba,    0xbb,    0xbc,    0xbd,    0xbe,    0xbf,
  1337. X    0xc0,    0xc1,    0xc2,    0xc3,    0xc4,    0xc5,    0xc6,    0xc7,
  1338. X         0xc8,    0xc9,    0xca,    0xcb,    0xcc,    0xcd,    0xce,    0xcf,
  1339. X    0xd0,    0xd1,    0xd2,    0xd3,    0xd4,    0xd5,    0xd6,    0xd7,
  1340. X         0xd8,    0xd9,    0xda,    0xdb,    0xdc,    0xdd,    0xde,    0xdf,
  1341. X    0xe0,    0xe1,    0xe2,    0xe3,    0xe4,    0xe5,    0xe6,    0xe7,
  1342. X         0xe8,    0xe9,    0xea,    0xeb,    0xec,    0xed,    0xee,    0xef,
  1343. X    0xf0,    0xf1,    0xf2,    0xf3,    0xf4,    0xf5,    0xf6,    0xf7,
  1344. X         0xf8,    0xf9,    0xfa,    0xfb,    0xfc,    0xfd,    0xfe,    0xff,
  1345. X    },
  1346. X};
  1347. X
  1348. X_RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;
  1349. X
  1350. Xint __mb_cur_max = 1;
  1351. END_OF_FILE
  1352. if test 7312 -ne `wc -c <'libc/table.c'`; then
  1353.     echo shar: \"'libc/table.c'\" unpacked with wrong size!
  1354. fi
  1355. # end of 'libc/table.c'
  1356. fi
  1357. if test -f 'mklocale/lex.l' -a "${1}" != "-c" ; then 
  1358.   echo shar: Will not clobber existing file \"'mklocale/lex.l'\"
  1359. else
  1360. echo shar: Extracting \"'mklocale/lex.l'\" \(4487 characters\)
  1361. sed "s/^X//" >'mklocale/lex.l' <<'END_OF_FILE'
  1362. X%{
  1363. X/*-
  1364. X * Copyright (c) 1993
  1365. X *    The Regents of the University of California.  All rights reserved.
  1366. X *
  1367. X * This code is derived from software contributed to Berkeley by
  1368. X * Paul Borman at Krystal Technologies.
  1369. X *
  1370. X * Redistribution and use in source and binary forms, with or without
  1371. X * modification, are permitted provided that the following conditions
  1372. X * are met:
  1373. X * 1. Redistributions of source code must retain the above copyright
  1374. X *    notice, this list of conditions and the following disclaimer.
  1375. X * 2. Redistributions in binary form must reproduce the above copyright
  1376. X *    notice, this list of conditions and the following disclaimer in the
  1377. X *    documentation and/or other materials provided with the distribution.
  1378. X * 3. All advertising materials mentioning features or use of this software
  1379. X *    must display the following acknowledgement:
  1380. X *    This product includes software developed by the University of
  1381. X *    California, Berkeley and its contributors.
  1382. X * 4. Neither the name of the University nor the names of its contributors
  1383. X *    may be used to endorse or promote products derived from this software
  1384. X *    without specific prior written permission.
  1385. X *
  1386. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1387. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1388. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1389. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1390. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1391. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1392. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1393. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1394. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1395. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1396. X * SUCH DAMAGE.
  1397. X */
  1398. X
  1399. X#ifndef lint
  1400. Xstatic char sccsid[] = "@(#)lex.l    8.1 (Berkeley) 6/6/93";
  1401. X#endif /* not lint */
  1402. X
  1403. X#include <ctype.h>
  1404. X#include <stdio.h>
  1405. X#include <stdlib.h>
  1406. X
  1407. X#include "ldef.h"
  1408. X#include "y.tab.h"
  1409. X%}
  1410. X
  1411. XODIGIT    [0-7]
  1412. XDIGIT    [0-9]
  1413. XXDIGIT    [0-9a-fA-F]
  1414. XW    [\t\n\r ]
  1415. X
  1416. X%%
  1417. X\'.\'                { yylval.rune = yytext[1];
  1418. X                  return(RUNE); }
  1419. X
  1420. X'\\a'                { yylval.rune = '\a';
  1421. X                  return(RUNE); }
  1422. X'\\b'                { yylval.rune = '\b';
  1423. X                  return(RUNE); }
  1424. X'\\f'                { yylval.rune = '\f';
  1425. X                  return(RUNE); }
  1426. X'\\n'                { yylval.rune = '\n';
  1427. X                  return(RUNE); }
  1428. X'\\r'                { yylval.rune = '\r';
  1429. X                  return(RUNE); }
  1430. X'\\t'                { yylval.rune = '\t';
  1431. X                  return(RUNE); }
  1432. X'\\v'                { yylval.rune = '\v';
  1433. X                  return(RUNE); }
  1434. X
  1435. X0x{XDIGIT}+            { yylval.rune = strtol(yytext, 0, 16);
  1436. X                  return(RUNE); }
  1437. X0{ODIGIT}+            { yylval.rune = strtol(yytext, 0, 8);
  1438. X                  return(RUNE); }
  1439. X{DIGIT}+            { yylval.rune = strtol(yytext, 0, 10);
  1440. X                  return(RUNE); }
  1441. X
  1442. X
  1443. XMAPLOWER            { return(MAPLOWER); }
  1444. XMAPUPPER            { return(MAPUPPER); }
  1445. XTODIGIT                { return(DIGITMAP); }
  1446. XINVALID                { return(INVALID); }
  1447. X
  1448. XALPHA                { yylval.i = _A|_R|_G; return(LIST); }
  1449. XCONTROL                { yylval.i = _C; return(LIST); }
  1450. XDIGIT                { yylval.i = _D|_R|_G; return(LIST); }
  1451. XGRAPH                { yylval.i = _G|_R; return(LIST); }
  1452. XLOWER                { yylval.i = _L|_R|_G; return(LIST); }
  1453. XPUNCT                { yylval.i = _P|_R|_G; return(LIST); }
  1454. XSPACE                { yylval.i = _S; return(LIST); }
  1455. XUPPER                { yylval.i = _U|_R|_G; return(LIST); }
  1456. XXDIGIT                { yylval.i = _X|_R|_G; return(LIST); }
  1457. XBLANK                { yylval.i = _B; return(LIST); }
  1458. XPRINT                { yylval.i = _R; return(LIST); }
  1459. XIDEOGRAM            { yylval.i = _I|_R|_G; return(LIST); }
  1460. XSPECIAL                { yylval.i = _T|_R|_G; return(LIST); }
  1461. XPHONOGRAM            { yylval.i = _Q|_R|_G; return(LIST); }
  1462. X
  1463. XVARIABLE[\t ]            { static char vbuf[1024];
  1464. X                  char *v = vbuf;
  1465. X                  while ((*v = input()) && *v != '\n')
  1466. X                    ++v;
  1467. X                                  if (*v) {
  1468. X                    unput(*v);
  1469. X                    *v = 0;
  1470. X                  }
  1471. X                  yylval.str = vbuf;
  1472. X                  return(VARIABLE);
  1473. X                }
  1474. X
  1475. XENCODING            { return(ENCODING); }
  1476. X
  1477. X\".*\"                { char *e = yytext + 1;
  1478. X                  yylval.str = e;
  1479. X                  while (*e && *e != '"')
  1480. X                    ++e;
  1481. X                  *e = 0;
  1482. X                  return(STRING); }
  1483. X
  1484. X\<|\(|\[            { return(LBRK); }
  1485. X
  1486. X\>|\)|\]            { return(RBRK); }
  1487. X
  1488. X\-                { return(THRU); }
  1489. X\.\.\.                { return(THRU); }
  1490. X
  1491. X\:                { return(':'); }
  1492. X
  1493. X{W}+                ;
  1494. X
  1495. X^\#.*\n                ;
  1496. X\/\*                { char lc = 0;
  1497. X                  do {
  1498. X                    while ((lc) != '*')
  1499. X                    if ((lc = input()) == 0)
  1500. X                        break;
  1501. X                  } while((lc = input()) != '/');
  1502. X                }
  1503. X
  1504. X\\$                ;
  1505. X.                { printf("Lex is skipping '%s'\n", yytext); }
  1506. X%%
  1507. X
  1508. X#if    !defined(yywrap)
  1509. Xyywrap()
  1510. X{
  1511. X    return(1);
  1512. X}
  1513. X#endif
  1514. END_OF_FILE
  1515. if test 4487 -ne `wc -c <'mklocale/lex.l'`; then
  1516.     echo shar: \"'mklocale/lex.l'\" unpacked with wrong size!
  1517. fi
  1518. # end of 'mklocale/lex.l'
  1519. fi
  1520. if test -f 'mklocale/mklocale.1' -a "${1}" != "-c" ; then 
  1521.   echo shar: Will not clobber existing file \"'mklocale/mklocale.1'\"
  1522. else
  1523. echo shar: Extracting \"'mklocale/mklocale.1'\" \(6675 characters\)
  1524. sed "s/^X//" >'mklocale/mklocale.1' <<'END_OF_FILE'
  1525. X.\" Copyright (c) 1993
  1526. X.\"    The Regents of the University of California.  All rights reserved.
  1527. X.\"
  1528. X.\" This code is derived from software contributed to Berkeley by
  1529. X.\" Paul Borman at Krystal Technologies.
  1530. X.\"
  1531. X.\" Redistribution and use in source and binary forms, with or without
  1532. X.\" modification, are permitted provided that the following conditions
  1533. X.\" are met:
  1534. X.\" 1. Redistributions of source code must retain the above copyright
  1535. X.\"    notice, this list of conditions and the following disclaimer.
  1536. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1537. X.\"    notice, this list of conditions and the following disclaimer in the
  1538. X.\"    documentation and/or other materials provided with the distribution.
  1539. X.\" 3. All advertising materials mentioning features or use of this software
  1540. X.\"    must display the following acknowledgement:
  1541. X.\"    This product includes software developed by the University of
  1542. X.\"    California, Berkeley and its contributors.
  1543. X.\" 4. Neither the name of the University nor the names of its contributors
  1544. X.\"    may be used to endorse or promote products derived from this software
  1545. X.\"    without specific prior written permission.
  1546. X.\"
  1547. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1548. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1549. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1550. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1551. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1552. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1553. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1554. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1555. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1556. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1557. X.\" SUCH DAMAGE.
  1558. X.\"
  1559. X.\"    @(#)mklocale.1    8.1 (Berkeley) 6/6/93
  1560. X.\"
  1561. X.Dd "June 6, 1993"
  1562. X.Dt MKLOCALE 1
  1563. X.Os
  1564. X.Sh NAME
  1565. X.Nm mklocale
  1566. X.Nd make LC_CTYPE locale files
  1567. X.Sh SYNOPSIS
  1568. X.Nm mklocale
  1569. X.Ar "< src-file"
  1570. X.Ar "> language/LC_CTYPE"
  1571. X.Sh DESCRIPTION
  1572. XThe
  1573. X.Nm mklocale
  1574. Xutility reads a
  1575. X.Dv LC_CTYPE
  1576. Xsource file from standard input and produces a
  1577. X.Dv LC_CTYPE
  1578. Xbinary file on standard output suitable for placement in
  1579. X.Dv /usr/share/locale/\fIlanguage\fP/LC_CTYPE.
  1580. X.Pp
  1581. XThe format of
  1582. X.Ar src-file
  1583. Xis quite simple.
  1584. XIt consists of a series of lines which start with a keyword and have
  1585. Xassociated data following.  C style comments are used
  1586. Xto place comments in the file.
  1587. X.Pp
  1588. XBesides the keywords which will be listed below,
  1589. Xthe following are valid tokens in
  1590. X.Ar src-file :
  1591. X.Bl -tag -width literal
  1592. X.It Dv RUNE
  1593. XA
  1594. X.Dv RUNE
  1595. Xmay be any of the following:
  1596. X.Bl -tag -width 0x[0-9a-z]*
  1597. X.It Ar 'x'
  1598. XThe ascii character
  1599. X.Ar x .
  1600. X.It Ar '\ex'
  1601. XThe ANSI C character
  1602. X.Ar \ex
  1603. Xwhere
  1604. X.Ar \ex
  1605. Xis one of
  1606. X.Dv \ea ,
  1607. X.Dv \eb ,
  1608. X.Dv \ef ,
  1609. X.Dv \en ,
  1610. X.Dv \er ,
  1611. X.Dv \et ,
  1612. Xor
  1613. X.Dv \ev .
  1614. X.It Ar 0x[0-9a-z]*
  1615. XA hexadecimal number representing a rune code.
  1616. X.It Ar 0[0-7]*
  1617. XAn octal number representing a rune code.
  1618. X.It Ar [1-9][0-9]*
  1619. XA decimal number representing a rune code.
  1620. X.El
  1621. X.It Dv STRING
  1622. XA string enclosed in double quotes (").
  1623. X.It Dv THRU
  1624. XEither
  1625. X.Dv ...
  1626. Xor
  1627. X.Dv - .
  1628. XUsed to indicate ranges.
  1629. X.It Ar literal
  1630. XThe follow characters are taken literally:
  1631. X.Bl -tag -width "<\|\|(\|\|["
  1632. X.It Dv "<\|(\|["
  1633. XUsed to start a mapping.  All are equivalent.
  1634. X.It Dv ">\|\^)\|]"
  1635. XUsed to end a mapping.  All are equivalent.
  1636. X.It Dv :
  1637. XUsed as a delimiter in mappings.
  1638. X.El
  1639. X.El
  1640. X.sp
  1641. XKey words which should only appear once are:
  1642. X.Bl -tag -width PHONOGRAM
  1643. X.It Dv ENCODING
  1644. XFollowed by a
  1645. X.Dv STRING
  1646. Xwhich indicates the encoding mechanism to be used for this locale.
  1647. XThe current encodings are:
  1648. X.Bl -tag -width NONE
  1649. X.It Dv NONE
  1650. XNo translation and the default.
  1651. X.It Dv UTF2
  1652. X.Dv "Universal character set Transformation Format"
  1653. Xadopted from
  1654. X.Nm "Plan 9 from Bell Labs" .
  1655. XThis is the preferred encoding.
  1656. X.It Dv EUC
  1657. X.Dv EUC
  1658. Xencoding as used by several
  1659. Xvendors of
  1660. X.Ux
  1661. Xsystems.
  1662. X.El
  1663. X.It Dv VARIABLE
  1664. XThis keyword must be followed by a single tab or space character,
  1665. Xafter which encoding specific data is placed.
  1666. XCurrently only the 
  1667. X.Dv "EUC"
  1668. Xencoding requires variable data.
  1669. XSee 
  1670. X.Xr euc 4
  1671. Xfor further details.
  1672. X.It Dv INVALID
  1673. XA single
  1674. X.Dv RUNE
  1675. Xfollows and is used as the invalid rune for this locale.
  1676. X.El
  1677. X.sp
  1678. XThe following keywords may appear multiple times and have the following
  1679. Xformat for data:
  1680. X.in +.5i
  1681. X.Bl -tag -width "<RUNE1 THRU RUNEn : RUNE2>"
  1682. X.It Dv <RUNE1 RUNE2>
  1683. X.Dv RUNE1
  1684. Xis mapped to
  1685. X.Dv RUNE2 .
  1686. X.It Dv <RUNE1 THRU RUNEn : RUNE2>
  1687. XRunes
  1688. X.Dv RUNE1
  1689. Xthrough
  1690. X.Dv RUNEn
  1691. Xare mapped to
  1692. X.Dv RUNE2
  1693. Xthrough
  1694. X.Dv RUNE2
  1695. X+ n-1.
  1696. X.El
  1697. X.in -.5i
  1698. X.Bl -tag -width PHONOGRAM
  1699. X.It Dv MAPLOWER
  1700. XDefines the tolower mappings.
  1701. X.Dv RUNE2
  1702. Xis the lower case representatin of
  1703. X.Dv RUNE1.
  1704. X.It Dv MAPUPPER
  1705. XDefines the toupper mappings.
  1706. X.Dv RUNE2
  1707. Xis the upper case representatin of
  1708. X.Dv RUNE1.
  1709. X.It Dv TODIGIT
  1710. XDefines a map from runes to their digit value.
  1711. X.Dv RUNE2
  1712. Xis the integer value represented  by
  1713. X.Dv RUNE1 .
  1714. XFor example, the ascii character
  1715. X.Nm '0'
  1716. Xwould map to the decimal value
  1717. X.Nm 0 .
  1718. XOnly values up to
  1719. X.Nm 255
  1720. Xare allowed.
  1721. X.El
  1722. X.sp
  1723. XThe following keywords may appear multiple times and have the following
  1724. Xformat for data:
  1725. X.in +.5i
  1726. X.Bl -tag -width "RUNE1 THRU RUNEn"
  1727. X.It Dv RUNE
  1728. XThis rune has the property defined by the keyword.
  1729. X.It Dv "RUNE1 THRU RUNEn"
  1730. XAll the runes between and including
  1731. X.Dv RUNE1
  1732. Xand
  1733. X.Dv RUNEn
  1734. Xhave the property defined by the keyword.
  1735. X.El
  1736. X.in -.5i
  1737. X.Bl -tag -width PHONOGRAM
  1738. X.It Dv ALPHA
  1739. XDefines runes which are alphabetic, printable and graphic.
  1740. X.It Dv CONTROL
  1741. XDefines runes which are control characters.
  1742. X.It Dv DIGIT
  1743. XDefines runes which are decimal digits, printable and graphic.
  1744. X.It Dv GRAPH
  1745. XDefines runes which are graphic and printable.
  1746. X.It Dv LOWER
  1747. XDefines runes which are lower case, printable and graphic.
  1748. X.It Dv PUNCT
  1749. XDefines runes which are punctuation, printable and graphic.
  1750. X.It Dv SPACE
  1751. XDefines runes which are spaces.
  1752. X.It Dv UPPER
  1753. XDefines runes which are upper case, printable and graphic.
  1754. X.It Dv XDIGIT
  1755. XDefines runes which are hexadecimal digits, printable and graphic.
  1756. X.It Dv BLANK
  1757. XDefines runes which are blank.
  1758. X.It Dv PRINT
  1759. XDefines runes which are printable.
  1760. X.It Dv IDEOGRAM
  1761. XDefines runes which are ideograms, printable and graphic.
  1762. X.It Dv SPECIAL
  1763. XDefines runes which are special characters, printable and graphic.
  1764. X.It Dv PHONOGRAM
  1765. XDefines runes which are phonograms, printable and graphic.
  1766. X.El
  1767. X.Sh SEE ALSO
  1768. X.Xr mbrune 3 ,
  1769. X.Xr rune 3 ,
  1770. X.Xr setlocale 3 ,
  1771. X.Xr euc 4 ,
  1772. X.Xr utf2 4
  1773. X.Sh BUGS
  1774. XThe
  1775. X.Nm mklocale
  1776. Xutility is overly simplistic.
  1777. X.Sh HISTORY
  1778. XThe
  1779. X.Nm mklocale
  1780. Xutility first appeared in
  1781. X.Bx 4.4 .
  1782. END_OF_FILE
  1783. if test 6675 -ne `wc -c <'mklocale/mklocale.1'`; then
  1784.     echo shar: \"'mklocale/mklocale.1'\" unpacked with wrong size!
  1785. fi
  1786. # end of 'mklocale/mklocale.1'
  1787. fi
  1788. echo shar: End of archive 2 \(of 3\).
  1789. cp /dev/null ark2isdone
  1790. MISSING=""
  1791. for I in 1 2 3 ; do
  1792.     if test ! -f ark${I}isdone ; then
  1793.     MISSING="${MISSING} ${I}"
  1794.     fi
  1795. done
  1796. if test "${MISSING}" = "" ; then
  1797.     echo You have unpacked all 3 archives.
  1798.     rm -f ark[1-9]isdone
  1799. else
  1800.     echo You still need to unpack the following archives:
  1801.     echo "        " ${MISSING}
  1802. fi
  1803. ##  End of shell archive.
  1804. exit 0
  1805.