--- a/idx2index.c Mon Aug 13 23:45:46 2007 +0200
+++ b/idx2index.c Tue Aug 14 22:18:46 2007 +0200
@@ -8,49 +8,7 @@
* ./idx2index < file.idx | LC_ALL=POSIX sort > file.index
* */
-static char num_to_ia5char(int n)
-{
- /* From RFC 1421 */
- if (n >= 0 && n <= 25)
- return 'A' + n;
- else if (n >= 26 && n <= 51)
- return 'a' + (n - 26);
- else if (n >= 52 && n <= 61)
- return '0' + (n - 52);
- else if (n == 62)
- return '+';
- else if (n == 63)
- return '-';
- else
- return '!'; /* Error */
-}
-
-static int num_to_ia5(char *dest, int n)
-{
- char tmp[20];
-
- int i, max;
-
- for(i =0; i <= 10; ++i)
- {
- tmp[i] = num_to_ia5char(n % 64);
- if (n < 64)
- break;
- n /= 64;
- }
-
- max = i;
-
- /* reverse the number */
- for (i=0; i<=max; ++i)
- dest[i] = tmp[max-i];
-
- /* Ending '\0' */
- dest[max+1] = '\0';
- return max;
-}
-
-static int get_int()
+static int get_raw_int()
{
int i;
fread(&i, sizeof(int) , 1, stdin);
@@ -58,7 +16,7 @@
return i;
}
-static int get_word(char * word)
+static int get_raw_word(char * word)
{
int c;
int count = 0;
@@ -84,12 +42,12 @@
int res;
char c_offset[20], c_length[20];
- res = get_word(word);
+ res = get_raw_word(word);
if (res == 0)
break;
- offset = get_int();
+ offset = get_raw_int();
num_to_ia5(c_offset, offset);
- length = get_int();
+ length = get_raw_int();
num_to_ia5(c_length, length);
printf("%s\t%s\t%s\n", word, c_offset, c_length);
} while(1);