error_message.c, init_et.c: Segregate error tables registered
	via add_error_table() and the other dynamic methods from
	the ones allocated via initialize_xxx_error_table() so
	that we won't fail even for error tables created using old
	versions of compile_et.  Thanks to Nalin Dahyabhai for
	this suggested patch.

diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog
index aa4880f..72f8687 100644
--- a/lib/et/ChangeLog
+++ b/lib/et/ChangeLog
@@ -1,5 +1,12 @@
 2005-06-20  Theodore Ts'o  <tytso@mit.edu>
 
+	* error_message.c, init_et.c: Segregate error tables registered
+		via add_error_table() and the other dynamic methods from
+		the ones allocated via initialize_xxx_error_table() so
+		that we won't fail even for error tables created using old
+		versions of compile_et.  Thanks to Nalin Dahyabhai for
+		this suggested patch.
+
 	* et_c.awk: Use a dynamically allocated structure in
 		initialize_xxx_error_table(), to prevent segfaults if an
 		old library calls initialize_xxx_error_table, and another
diff --git a/lib/et/error_message.c b/lib/et/error_message.c
index 9326308..90d63c4 100644
--- a/lib/et/error_message.c
+++ b/lib/et/error_message.c
@@ -27,6 +27,7 @@
 static char buffer[25];
 
 struct et_list * _et_list = (struct et_list *) NULL;
+struct et_list * _et_dynamic_list = (struct et_list *) NULL;
 
 
 const char * error_message (errcode_t code)
@@ -61,6 +62,14 @@
 	    return(et->table->msgs[offset]);
 	}
     }
+    for (et = _et_dynamic_list; et; et = et->next) {
+	if (et->table->base == table_num) {
+	    /* This is the right table */
+	    if (et->table->n_msgs <= offset)
+		goto oops;
+	    return(et->table->msgs[offset]);
+	}
+    }
 oops:
     strcpy (buffer, "Unknown code ");
     if (table_num) {
@@ -88,20 +97,14 @@
  */
 errcode_t add_error_table(const struct error_table * et)
 {
-	struct et_list *el = _et_list;
-
-	while (el) {
-		if (el->table->base == et->base)
-			return EEXIST;
-		el = el->next;
-	}
+	struct et_list *el;
 
 	if (!(el = (struct et_list *) malloc(sizeof(struct et_list))))
 		return ENOMEM;
 
 	el->table = et;
-	el->next = _et_list;
-	_et_list = el;
+	el->next = _et_dynamic_list;
+	_et_dynamic_list = el;
 
 	return 0;
 }
@@ -111,7 +114,7 @@
  */
 errcode_t remove_error_table(const struct error_table * et)
 {
-	struct et_list *el = _et_list;
+	struct et_list *el = _et_dynamic_list;
 	struct et_list *el2 = 0;
 
 	while (el) {
@@ -119,7 +122,7 @@
 			if (el2)	/* Not the beginning of the list */
 				el2->next = el->next;
 			else
-				_et_list = el->next;
+				_et_dynamic_list = el->next;
 			(void) free(el);
 			return 0;
 		}
diff --git a/lib/et/init_et.c b/lib/et/init_et.c
index 075d26a..bf27da1 100644
--- a/lib/et/init_et.c
+++ b/lib/et/init_et.c
@@ -29,7 +29,7 @@
     struct error_table et;
 };
 
-extern struct et_list * _et_list;
+extern struct et_list * _et_dynamic_list;
 
 int init_error_table(const char * const *msgs, long base, int count)
 {
@@ -46,7 +46,7 @@
     new_et->et.base = base;
     new_et->et.n_msgs= count;
 
-    new_et->etl.next = _et_list;
-    _et_list = &new_et->etl;
+    new_et->etl.next = _et_dynamic_list;
+    _et_dynamic_list = &new_et->etl;
     return 0;
 }