summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-19 22:32:29 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2008-11-19 22:32:29 (GMT)
commitbf48bbc8583ed2d742d8c98e6105bd559ae48890 (patch)
treefbb3cacd363b00e6522b4c956cc89c6d06fa6332
parentadcc0f9106753140a5c5feab9e243e9ecb71a4f8 (diff)
downloadiconv-bf48bbc8583ed2d742d8c98e6105bd559ae48890.tar.gz
iconv-bf48bbc8583ed2d742d8c98e6105bd559ae48890.tar.bz2
Dump the list of known encoding aliases when asked. Don't expect any kind of sort order -- that would require a level of thought I don't have right now.
svn path=/trunk/iconv/; revision=5746
-rw-r--r--module/Makefile2
-rw-r--r--module/module.c4
-rw-r--r--src/aliases.c10
-rw-r--r--src/internal.h1
4 files changed, 9 insertions, 8 deletions
diff --git a/module/Makefile b/module/Makefile
index fb618db..0b1ef05 100644
--- a/module/Makefile
+++ b/module/Makefile
@@ -78,7 +78,7 @@ endef
# Build rules for each module object
define compile_module
-$(2): $(1)
+$(2): aliases $(1)
@$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
@$$(CC) -c $$(RELEASECFLAGS) -o $$@ $(1)
diff --git a/module/module.c b/module/module.c
index 6f5a3f7..8c170f5 100644
--- a/module/module.c
+++ b/module/module.c
@@ -289,7 +289,9 @@ _kernel_oserror *do_iconv(int argc, const char *args)
}
if (list) {
- /** \todo dump aliases */
+ printf("Here's a list of all the encoding names that Iconv "
+ "knows about:.\n\n");
+ dump_alias_data();
return NULL;
}
diff --git a/src/aliases.c b/src/aliases.c
index 1292685..db20f71 100644
--- a/src/aliases.c
+++ b/src/aliases.c
@@ -23,8 +23,6 @@ static struct canon *create_canon(const char *canon, short mibenum);
static int hash_val(const char *alias);
#ifdef TEST
-static void dump_alias_data(void);
-
int main (void)
{
struct canon *c;
@@ -165,7 +163,6 @@ void free_alias_data(void)
}
}
-#ifdef TEST
/**
* Dump all alias data to stdout
*/
@@ -178,22 +175,23 @@ void dump_alias_data(void)
for (i = 0; i != HASH_SIZE; i++) {
for (c = canon_tab[i]; c; c = c->next) {
- printf("%d %s\n", i, c->name);
+ printf("%s\n", c->name);
size += offsetof(struct canon, name) + c->name_len;
}
for (a = alias_tab[i]; a; a = a->next) {
- printf("%d %s\n", i, a->name);
+ printf("%s\n", a->name);
size += offsetof(struct alias, name) + a->name_len;
}
}
+#ifdef TEST
size += (sizeof(canon_tab) / sizeof(canon_tab[0]));
size += (sizeof(alias_tab) / sizeof(alias_tab[0]));
printf("%d\n", size);
-}
#endif
+}
/**
* Create alias data from Aliases file
diff --git a/src/internal.h b/src/internal.h
index 9150efc..c1d04f3 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -56,6 +56,7 @@ struct canon {
/* in aliases.c */
int create_alias_data(const char *filename);
void free_alias_data(void);
+void dump_alias_data(void);
struct canon *alias_canonicalise(const char *alias);
short mibenum_from_name(const char *alias);
const char *mibenum_to_name(short mibenum);