euc.c (101487) | euc.c (101498) |
---|---|
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#if defined(LIBC_SCCS) && !defined(lint) 38static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93"; 39#endif /* LIBC_SCCS and not lint */ 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#if defined(LIBC_SCCS) && !defined(lint) 38static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93"; 39#endif /* LIBC_SCCS and not lint */ 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/lib/libc/locale/euc.c 101487 2002-08-07 20:20:56Z ache $"); | 41__FBSDID("$FreeBSD: head/lib/libc/locale/euc.c 101498 2002-08-08 05:51:54Z ache $"); |
42 43#include <sys/types.h> 44 45#include <errno.h> 46#include <rune.h> 47#include <stddef.h> 48#include <stdio.h> 49#include <stdlib.h> --- 8 unchanged lines hidden (view full) --- 58 rune_t mask; 59} _EucInfo; 60 61int 62_EUC_init(rl) 63 _RuneLocale *rl; 64{ 65 _EucInfo *ei; | 42 43#include <sys/types.h> 44 45#include <errno.h> 46#include <rune.h> 47#include <stddef.h> 48#include <stdio.h> 49#include <stdlib.h> --- 8 unchanged lines hidden (view full) --- 58 rune_t mask; 59} _EucInfo; 60 61int 62_EUC_init(rl) 63 _RuneLocale *rl; 64{ 65 _EucInfo *ei; |
66 int x; | 66 int x, new__mb_cur_max; |
67 char *v, *e; 68 69 rl->sgetrune = _EUC_sgetrune; 70 rl->sputrune = _EUC_sputrune; 71 | 67 char *v, *e; 68 69 rl->sgetrune = _EUC_sgetrune; 70 rl->sputrune = _EUC_sputrune; 71 |
72 if (!rl->variable) { 73 free(rl); | 72 if (rl->variable == NULL) |
74 return (EFTYPE); | 73 return (EFTYPE); |
75 } 76 v = (char *) rl->variable; | |
77 | 74 |
75 v = (char *)rl->variable; 76 |
|
78 while (*v == ' ' || *v == '\t') 79 ++v; 80 | 77 while (*v == ' ' || *v == '\t') 78 ++v; 79 |
81 if ((ei = malloc(sizeof(_EucInfo))) == NULL) { 82 free(rl); | 80 if ((ei = malloc(sizeof(_EucInfo))) == NULL) |
83 return (ENOMEM); | 81 return (ENOMEM); |
84 } 85 __mb_cur_max = 0; | 82 83 new__mb_cur_max = 0; |
86 for (x = 0; x < 4; ++x) { | 84 for (x = 0; x < 4; ++x) { |
87 ei->count[x] = (int) strtol(v, &e, 0); | 85 ei->count[x] = (int)strtol(v, &e, 0); |
88 if (v == e || !(v = e)) { | 86 if (v == e || !(v = e)) { |
89 free(rl); | |
90 free(ei); 91 return (EFTYPE); 92 } | 87 free(ei); 88 return (EFTYPE); 89 } |
93 if (__mb_cur_max < ei->count[x]) 94 __mb_cur_max = ei->count[x]; | 90 if (new__mb_cur_max < ei->count[x]) 91 new__mb_cur_max = ei->count[x]; |
95 while (*v == ' ' || *v == '\t') 96 ++v; | 92 while (*v == ' ' || *v == '\t') 93 ++v; |
97 ei->bits[x] = (int) strtol(v, &e, 0); | 94 ei->bits[x] = (int)strtol(v, &e, 0); |
98 if (v == e || !(v = e)) { | 95 if (v == e || !(v = e)) { |
99 free(rl); | |
100 free(ei); 101 return (EFTYPE); 102 } 103 while (*v == ' ' || *v == '\t') 104 ++v; 105 } 106 ei->mask = (int)strtol(v, &e, 0); 107 if (v == e || !(v = e)) { | 96 free(ei); 97 return (EFTYPE); 98 } 99 while (*v == ' ' || *v == '\t') 100 ++v; 101 } 102 ei->mask = (int)strtol(v, &e, 0); 103 if (v == e || !(v = e)) { |
108 free(rl); | |
109 free(ei); 110 return (EFTYPE); 111 } | 104 free(ei); 105 return (EFTYPE); 106 } |
112 if (sizeof(_EucInfo) <= rl->variable_len) { 113 memcpy(rl->variable, ei, sizeof(_EucInfo)); 114 free(ei); 115 } else { 116 rl->variable = ei; 117 } | 107 rl->variable = ei; |
118 rl->variable_len = sizeof(_EucInfo); 119 _CurrentRuneLocale = rl; | 108 rl->variable_len = sizeof(_EucInfo); 109 _CurrentRuneLocale = rl; |
110 __mb_cur_max = new__mb_cur_max; |
|
120 return (0); 121} 122 123#define CEI ((_EucInfo *)(_CurrentRuneLocale->variable)) 124 125#define _SS2 0x008e 126#define _SS3 0x008f 127 --- 104 unchanged lines hidden --- | 111 return (0); 112} 113 114#define CEI ((_EucInfo *)(_CurrentRuneLocale->variable)) 115 116#define _SS2 0x008e 117#define _SS3 0x008f 118 --- 104 unchanged lines hidden --- |