setrunelocale.c (118146) | setrunelocale.c (121845) |
---|---|
1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Paul Borman at Krystal Technologies. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 24 unchanged lines hidden (view full) --- 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37/* setrunelocale() is obsolete in FreeBSD 6 -- use ANSI functions instead. */ 38#define OBSOLETE_IN_6 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Paul Borman at Krystal Technologies. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 24 unchanged lines hidden (view full) --- 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37/* setrunelocale() is obsolete in FreeBSD 6 -- use ANSI functions instead. */ 38#define OBSOLETE_IN_6 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/lib/libc/locale/setrunelocale.c 118146 2003-07-29 07:52:44Z ache $"); | 41__FBSDID("$FreeBSD: head/lib/libc/locale/setrunelocale.c 121845 2003-11-01 05:13:13Z tjr $"); |
42 43#include <rune.h> 44#include <errno.h> 45#include <limits.h> 46#include <string.h> 47#include <stdio.h> 48#include <stdlib.h> 49#include <unistd.h> | 42 43#include <rune.h> 44#include <errno.h> 45#include <limits.h> 46#include <string.h> 47#include <stdio.h> 48#include <stdlib.h> 49#include <unistd.h> |
50#include <wchar.h> |
|
50#include "ldpart.h" 51#include "setlocale.h" 52 53extern int _none_init(_RuneLocale *); 54extern int _UTF2_init(_RuneLocale *); 55extern int _UTF8_init(_RuneLocale *); 56extern int _EUC_init(_RuneLocale *); 57extern int _GB18030_init(_RuneLocale *); 58extern int _GBK_init(_RuneLocale *); 59extern int _BIG5_init(_RuneLocale *); 60extern int _MSKanji_init(_RuneLocale *); 61extern _RuneLocale *_Read_RuneMagi(FILE *); 62 | 51#include "ldpart.h" 52#include "setlocale.h" 53 54extern int _none_init(_RuneLocale *); 55extern int _UTF2_init(_RuneLocale *); 56extern int _UTF8_init(_RuneLocale *); 57extern int _EUC_init(_RuneLocale *); 58extern int _GB18030_init(_RuneLocale *); 59extern int _GBK_init(_RuneLocale *); 60extern int _BIG5_init(_RuneLocale *); 61extern int _MSKanji_init(_RuneLocale *); 62extern _RuneLocale *_Read_RuneMagi(FILE *); 63 |
64extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict, 65 size_t, mbstate_t * __restrict); 66extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict); 67extern size_t __emulated_mbrtowc(wchar_t * __restrict, const char * __restrict, 68 size_t, mbstate_t * __restrict ps); 69extern size_t __emulated_wcrtomb(char * __restrict, wchar_t, 70 mbstate_t * __restrict ps); 71extern rune_t __emulated_sgetrune(const char *, size_t, const char **); 72extern int __emulated_sputrune(rune_t, char *, size_t, char **); 73 |
|
63static int __setrunelocale(const char *); 64 65__warn_references(setrunelocale, "warning: setrunelocale() is deprecated. See setrunelocale(3)."); 66int 67setrunelocale(char *encoding) 68{ 69 int ret; 70 --- 56 unchanged lines hidden (view full) --- 127 128 if ((rl = _Read_RuneMagi(fp)) == NULL) { 129 saverr = (errno == 0 ? EFTYPE : errno); 130 (void)fclose(fp); 131 return (saverr); 132 } 133 (void)fclose(fp); 134 | 74static int __setrunelocale(const char *); 75 76__warn_references(setrunelocale, "warning: setrunelocale() is deprecated. See setrunelocale(3)."); 77int 78setrunelocale(char *encoding) 79{ 80 int ret; 81 --- 56 unchanged lines hidden (view full) --- 138 139 if ((rl = _Read_RuneMagi(fp)) == NULL) { 140 saverr = (errno == 0 ? EFTYPE : errno); 141 (void)fclose(fp); 142 return (saverr); 143 } 144 (void)fclose(fp); 145 |
146 __mbrtowc = __emulated_mbrtowc; 147 __wcrtomb = __emulated_wcrtomb; 148 rl->sputrune = __emulated_sputrune; 149 rl->sgetrune = __emulated_sgetrune; |
|
135 if (strcmp(rl->encoding, "NONE") == 0) 136 ret = _none_init(rl); 137 else if (strcmp(rl->encoding, "UTF2") == 0) 138 ret = _UTF2_init(rl); 139 else if (strcmp(rl->encoding, "UTF-8") == 0) 140 ret = _UTF8_init(rl); 141 else if (strcmp(rl->encoding, "EUC") == 0) 142 ret = _EUC_init(rl); --- 38 unchanged lines hidden --- | 150 if (strcmp(rl->encoding, "NONE") == 0) 151 ret = _none_init(rl); 152 else if (strcmp(rl->encoding, "UTF2") == 0) 153 ret = _UTF2_init(rl); 154 else if (strcmp(rl->encoding, "UTF-8") == 0) 155 ret = _UTF8_init(rl); 156 else if (strcmp(rl->encoding, "EUC") == 0) 157 ret = _EUC_init(rl); --- 38 unchanged lines hidden --- |