summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-10-15 21:53:23 +0000
committerache <ache@FreeBSD.org>1996-10-15 21:53:23 +0000
commit5b6e3c50cb4801e4ad7b4c615bb5e03d748ea841 (patch)
treec0232a8cb3db60ee553058ceddb50f33fc8d27f3
parenta849187a71a5dfdf69df3baaad35c0cda8a2906f (diff)
downloadFreeBSD-src-5b6e3c50cb4801e4ad7b4c615bb5e03d748ea841.zip
FreeBSD-src-5b6e3c50cb4801e4ad7b4c615bb5e03d748ea841.tar.gz
Save half of space in LC_COLLATE and remove unneded code.
This change is not compatible with previous variant, however proper error code returned in both cases. Colldef changes will follows.
-rw-r--r--lib/libc/locale/collate.c35
-rw-r--r--lib/libc/locale/collate.h10
2 files changed, 10 insertions, 35 deletions
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index 20adda3..d068333 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: collate.c,v 1.5 1995/10/23 20:08:24 ache Exp $
+ * $Id: collate.c,v 1.6 1996/09/14 02:57:25 bde Exp $
*/
#include <rune.h>
@@ -38,10 +38,9 @@
char *_PathLocale;
int __collate_load_error = 1;
-u_char __collate_charmap_table[UCHAR_MAX + 1][STR_LEN];
+char __collate_version[STR_LEN];
u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN];
struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1];
-struct __collate_st_name_pri __collate_name_pri_table[TABLE_SIZE];
struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE];
#define FREAD(a, b, c, d) \
@@ -80,15 +79,17 @@ __collate_load_tables(encoding)
__collate_load_error = save_load_error;
return -1;
}
- FREAD(__collate_charmap_table, sizeof(__collate_charmap_table), 1, fp);
+ FREAD(__collate_version, sizeof(__collate_version), 1, fp);
+ if (strcmp(__collate_version, COLLATE_VERSION) != 0) {
+ fclose(fp);
+ return -1;
+ }
FREAD(__collate_substitute_table, sizeof(__collate_substitute_table),
1, fp);
FREAD(__collate_char_pri_table, sizeof(__collate_char_pri_table), 1,
fp);
FREAD(__collate_chain_pri_table, sizeof(__collate_chain_pri_table), 1,
fp);
- FREAD(__collate_name_pri_table, sizeof(__collate_name_pri_table), 1,
- fp);
fclose(fp);
__collate_load_error = 0;
return 0;
@@ -124,22 +125,10 @@ __collate_lookup(t, len, prim, sec)
u_char *t;
int *len, *prim, *sec;
{
- struct __collate_st_name_pri *p;
struct __collate_st_chain_pri *p2;
*len = 1;
*prim = *sec = 0;
- if(__collate_charmap_table[*t][0]) {
- for(p = __collate_name_pri_table; p->str[0]; p++) {
- if(strncmp(__collate_charmap_table[*t], p->str, strlen(p->str))
- == 0) {
- *prim = p->prim;
- *sec = p->sec;
- return;
- }
- }
- return;
- }
for(p2 = __collate_chain_pri_table; p2->str[0]; p2++) {
if(strncmp(t, p2->str, strlen(p2->str)) == 0) {
*len = strlen(p2->str);
@@ -187,22 +176,12 @@ void
__collate_print_tables()
{
int i;
- struct __collate_st_name_pri *p;
struct __collate_st_chain_pri *p2;
printf("Substitute table:\n");
for (i = 0; i < UCHAR_MAX + 1; i++)
printf("\t'%c' --> \"%s\"\n", i,
__collate_substitute_table[i]);
- printf("Charmap table:\n");
- for (i = 0; i < UCHAR_MAX + 1; i++) {
- if (__collate_charmap_table[i][0])
- printf("\t\\x%02x --> \"%s\"\n", i,
- __collate_charmap_table[i]);
- }
- printf("Name priority table:\n");
- for (p = __collate_name_pri_table; p->str[0]; p++)
- printf("\t\"%s\" : %d %d\n\n", p->str, p->prim, p->sec);
printf("Chain priority table:\n");
for (p2 = __collate_chain_pri_table; p2->str[0]; p2++)
printf("\t\"%s\" : %d %d\n\n", p2->str, p2->prim, p2->sec);
diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h
index b083734..aab9b67 100644
--- a/lib/libc/locale/collate.h
+++ b/lib/libc/locale/collate.h
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: collate.h,v 1.2 1996/08/12 03:40:36 ache Exp $
+ * $Id: collate.h,v 1.3 1996/08/12 19:18:46 ache Exp $
*/
#ifndef COLLATE_H_INCLUDED
@@ -36,24 +36,20 @@
#define STR_LEN 10
#define TABLE_SIZE 100
+#define COLLATE_VERSION "1.0\n"
struct __collate_st_char_pri {
int prim, sec;
};
-struct __collate_st_name_pri {
- u_char str[STR_LEN];
- int prim, sec;
-};
struct __collate_st_chain_pri {
u_char str[STR_LEN];
int prim, sec;
};
extern int __collate_load_error;
-extern u_char __collate_charmap_table[UCHAR_MAX + 1][STR_LEN];
+extern char __collate_version[STR_LEN];
extern u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN];
extern struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1];
-extern struct __collate_st_name_pri __collate_name_pri_table[TABLE_SIZE];
extern struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE];
__BEGIN_DECLS
OpenPOWER on IntegriCloud