clean up and document the telopt table stuff
diff --git a/libtelnet.c b/libtelnet.c
index 4559385..381e8c3 100644
--- a/libtelnet.c
+++ b/libtelnet.c
@@ -188,9 +188,16 @@
 		return 0;
 
 	/* loop unti found or end marker (us and him both 0) */
-	for (i = 0; telnet->telopts[i].telopt != -1; ++i)
-		if (telnet->telopts[i].telopt == telopt)
-			return us ? telnet->telopts[i].us : telnet->telopts[i].him;
+	for (i = 0; telnet->telopts[i].telopt != -1; ++i) {
+		if (telnet->telopts[i].telopt == telopt) {
+			if (us && telnet->telopts[i].us == TELNET_WILL)
+				return 1;
+			else if (!us && telnet->telopts[i].him == TELNET_DO)
+				return 1;
+			else
+				return 0;
+		}
+	}
 
 	/* not found, so not supported */
 	return 0;