isnmtoken(), istoken():  Fix to ensure the regex has to match the
	entire attribute value.

Add ability to save list of "empty" elements to a file -- enabled by
constant in the code.
diff --git a/Doc/tools/sgmlconv/esis2sgml.py b/Doc/tools/sgmlconv/esis2sgml.py
index 07ca571..b8050c8 100755
--- a/Doc/tools/sgmlconv/esis2sgml.py
+++ b/Doc/tools/sgmlconv/esis2sgml.py
@@ -9,12 +9,17 @@
 
 import errno
 import esistools
+import os
 import re
 import string
 
 from xml.utils import escape
 
 
+EMPTIES_FILENAME = "../sgml/empties.dat"
+LIST_EMPTIES = 0
+
+
 def format_attrs(attrs, xml=0):
     attrs = attrs.items()
     attrs.sort()
@@ -33,11 +38,11 @@
     return s
 
 
-_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*", re.IGNORECASE)
+_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*$", re.IGNORECASE)
 def isnmtoken(s):
     return _nmtoken_rx.match(s) is not None
 
-_token_rx = re.compile("[a-z0-9][-._a-z0-9]*", re.IGNORECASE)
+_token_rx = re.compile("[a-z0-9][-._a-z0-9]*$", re.IGNORECASE)
 def istoken(s):
     return _token_rx.match(s) is not None
 
@@ -99,6 +104,16 @@
         elif type == "e":
             knownempty = 1
 
+    if LIST_EMPTIES:
+        knownempties.append("")
+        if os.path.isfile(EMPTIES_FILENAME):
+            mode = "a"
+        else:
+            mode = "w"
+        fp = open(EMPTIES_FILENAME, mode)
+        fp.write(string.join(knownempties, "\n"))
+        fp.close()
+
 
 def sgml_convert(ifp, ofp):
     return do_convert(ifp, ofp, xml=0)