Make the format of LC_COLLATE files architecture independent.

This commit is contained in:
Ruslan Ermilov 2005-02-27 20:31:13 +00:00
parent cd147cba52
commit edc431123e
5 changed files with 43 additions and 14 deletions

View File

@ -775,6 +775,10 @@ _groff= gnu/usr.bin/groff/tmac
_cap_mkdb= usr.bin/cap_mkdb
.endif
.if ${BOOTSTRAPPING} < 600018
_colldef= usr.bin/colldef
.endif
.if ${BOOTSTRAPPING} < 600017
_gencat= usr.bin/gencat
.endif
@ -795,7 +799,7 @@ bootstrap-tools:
${_groff} \
gnu/usr.bin/texinfo \
${_cap_mkdb} \
usr.bin/colldef \
${_colldef} \
${_gencat} \
usr.bin/lorder \
usr.bin/makewhatis \

View File

@ -99,7 +99,7 @@ __collate_load_tables(const char *encoding)
chains = -1;
if (strcmp(strbuf, COLLATE_VERSION) == 0)
chains = 0;
else if (strcmp(strbuf, COLLATE_VERSION1_1) == 0)
else if (strcmp(strbuf, COLLATE_VERSION1_2) == 0)
chains = 1;
if (chains < 0) {
(void)fclose(fp);
@ -172,10 +172,21 @@ __collate_load_tables(const char *encoding)
if (__collate_char_pri_table_ptr != NULL)
free(__collate_char_pri_table_ptr);
__collate_char_pri_table_ptr = TMP_char_pri_table;
for (i = 0; i < UCHAR_MAX + 1; i++) {
__collate_char_pri_table[i].prim =
ntohl(__collate_char_pri_table[i].prim);
__collate_char_pri_table[i].sec =
ntohl(__collate_char_pri_table[i].sec);
}
if (__collate_chain_pri_table != NULL)
free(__collate_chain_pri_table);
__collate_chain_pri_table = TMP_chain_pri_table;
for (i = 0; i < chains; i++) {
__collate_chain_pri_table[i].prim =
ntohl(__collate_chain_pri_table[i].prim);
__collate_chain_pri_table[i].sec =
ntohl(__collate_chain_pri_table[i].sec);
}
__collate_substitute_nontrivial = 0;
for (i = 0; i < UCHAR_MAX + 1; i++) {
if (__collate_substitute_table[i][0] != i ||

View File

@ -37,7 +37,7 @@
#define STR_LEN 10
#define TABLE_SIZE 100
#define COLLATE_VERSION "1.0\n"
#define COLLATE_VERSION1_1 "1.1\n"
#define COLLATE_VERSION1_2 "1.2\n"
struct __collate_st_char_pri {
int prim, sec;

View File

@ -57,7 +57,7 @@
* is created, otherwise 1.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 600017 /* Master, propagated to newvers */
#define __FreeBSD_version 600018 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>

View File

@ -58,7 +58,7 @@ 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_chain_pri *__collate_chain_pri_table;
int chain_index;
int chain_index = 0;
int prim_pri = 1, sec_pri = 1;
#ifdef COLLATE_DEBUG
int debug;
@ -122,11 +122,15 @@ order : ORDER order_list {
sizeof(__collate_chain_pri_table[0]));
chain_index++;
#ifdef COLLATE_DEBUG
if (debug)
collate_print_tables();
#endif
if ((fp = fopen(out_file, "w")) == NULL)
err(EX_UNAVAILABLE, "can't open destination file %s",
out_file);
strcpy(__collate_version, COLLATE_VERSION1_1);
strcpy(__collate_version, COLLATE_VERSION1_2);
if (fwrite(__collate_version, sizeof(__collate_version), 1, fp) != 1)
err(EX_IOERR,
"IO error writting collate version to destination file %s",
@ -141,11 +145,23 @@ order : ORDER order_list {
err(EX_IOERR,
"IO error writting substitute table to destination file %s",
out_file);
for (ch = 0; ch < UCHAR_MAX + 1; ch++) {
__collate_char_pri_table[ch].prim =
htonl(__collate_char_pri_table[ch].prim);
__collate_char_pri_table[ch].sec =
htonl(__collate_char_pri_table[ch].sec);
}
if (fwrite(__collate_char_pri_table,
sizeof(__collate_char_pri_table), 1, fp) != 1)
err(EX_IOERR,
"IO error writting char table to destination file %s",
out_file);
for (ch = 0; ch < chain_index; ch++) {
__collate_chain_pri_table[ch].prim =
htonl(__collate_chain_pri_table[ch].prim);
__collate_chain_pri_table[ch].sec =
htonl(__collate_chain_pri_table[ch].sec);
}
if (fwrite(__collate_chain_pri_table,
sizeof(*__collate_chain_pri_table), chain_index, fp) !=
(size_t)chain_index)
@ -155,10 +171,6 @@ order : ORDER order_list {
if (fclose(fp) != 0)
err(EX_IOERR, "IO error closing destination file %s",
out_file);
#ifdef COLLATE_DEBUG
if (debug)
collate_print_tables();
#endif
exit(EX_OK);
}
;
@ -351,7 +363,6 @@ static void
collate_print_tables(void)
{
int i;
struct __collate_st_chain_pri *p2;
printf("Substitute table:\n");
for (i = 0; i < UCHAR_MAX + 1; i++)
@ -359,8 +370,11 @@ collate_print_tables(void)
printf("\t'%c' --> \"%s\"\n", i,
__collate_substitute_table[i]);
printf("Chain priority table:\n");
for (p2 = __collate_chain_pri_table; p2->str[0] != '\0'; p2++)
printf("\t\"%s\" : %d %d\n", p2->str, p2->prim, p2->sec);
for (i = 0; i < chain_index - 1; i++)
printf("\t\"%s\" : %d %d\n",
__collate_chain_pri_table[i].str,
__collate_chain_pri_table[i].prim,
__collate_chain_pri_table[i].sec);
printf("Char priority table:\n");
for (i = 0; i < UCHAR_MAX + 1; i++)
printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim,