$NetBSD: patch-cx,v 1.3 2009/03/15 20:10:36 spz Exp $

--- src/irr/irr.cc.orig	2006-10-01 13:23:32.000000000 +0200
+++ src/irr/irr.cc
@@ -210,6 +210,10 @@ Cache<ASt,   MPPrefixRanges *> expandASC
 Cache<SymID, MPPrefixRanges *> expandRSSetCache;
 Cache<SymID, MPPrefixRanges *> expandRtrSetCache;
 
+bool IRR::queryCache(SymID setID, Set *&set) {
+   return (SetCache.query(setID, set));
+}
+
 void IRR::initCache(char *objectText, int objectLength, char *clss) {
    Buffer b(objectText, objectLength);
    Set *o = new Set(b);
@@ -312,13 +316,20 @@ const AutNum *IRR::getAutNum(ASt as) {
    AutNum *result = NULL;
 
    if (! AutNumCache.query(as, result)) {
-      sprintf(buffer, "AS%d", as);
+      asnum_string_dot(buffer, as); // try asdotted
       if (getAutNum(buffer, text, len)) {
 	 Buffer b(text, len);
 	 result = new AutNum(b);
 	 AutNumCache.add(as, result);
-      } else
-	 AutNumCache.add(as, NULL); // a negative object
+      } else {
+         asnum_string_plain(buffer, as); // try asplain before giving up
+         if (getAutNum(buffer, text, len)) {
+	    Buffer b(text, len);
+	    result = new AutNum(b);
+	    AutNumCache.add(as, result);
+         } else
+	    AutNumCache.add(as, NULL); // a negative object
+      }
    }
 
    return result;
@@ -365,7 +376,7 @@ void IRR::getRoute(Route *&route, Prefix
    char *text;
    int  len;
 
-   sprintf(buffer, "AS%d", as);
+   asnum_string_dot(buffer, as);
    if (getRoute(rt->get_text(), buffer, text, len)) {
       Buffer b(text, len);
       route = new Route(b);
@@ -379,12 +390,18 @@ void IRR::getRoute(Route *&route, char *
   char *text;
   int  len;
 
-  sprintf(buffer, "AS%d", as);
+  asnum_string_dot(buffer, as);
   if (getRoute(rt, buffer, text, len)) {
      Buffer b(text, len);
      route = new Route(b);
-  } else
-     route = NULL;
+  } else {
+     asnum_string_plain(buffer, as);
+     if (getRoute(rt, buffer, text, len)) {
+        Buffer b(text, len);
+        route = new Route(b);
+     } else
+        route = NULL;
+  }
 }
 
 const InetRtr *IRR::getInetRtr(SymID inetRtr)
@@ -419,11 +436,14 @@ const MPPrefixRanges *IRR::expandAS(ASt 
       // we insert the set to the cache before expanding
       // this is needed to avoid recursion if sets are recursively defined
       expandASCache.add(as, result);
-      sprintf(buffer, "AS%d", as);
+      asnum_string_dot(buffer, as); // try asdotted
       if (!expandAS(buffer, result)) {
-   expandASCache.nullify(as);
-  delete result;
-  result = NULL; // A negative cache
+         asnum_string_plain(buffer, as); // that failed, try asplained
+         if (!expandAS(buffer, result)) {
+            expandASCache.nullify(as);
+            delete result;
+            result = NULL; // A negative cache
+         }
       }
    }
 
