]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Path printing is now much nicer: not having to put it backward
authorPavel Machek <pavel@ucw.cz>
Wed, 12 Apr 2000 10:34:45 +0000 (10:34 +0000)
committerPavel Machek <pavel@ucw.cz>
Wed, 12 Apr 2000 10:34:45 +0000 (10:34 +0000)
simplifies it. (Sorry for previous commit, cvs is naughty).

filter/filter.c

index cfb30f919abadd2422a816997a99d84510cb7dcd..f3f8c2379e611f653669464980ae5c433f29aebe 100644 (file)
@@ -9,7 +9,7 @@
  *
  */
 
-#undef LOCAL_DEBUG
+#define LOCAL_DEBUG
 
 #include "nest/bird.h"
 #include "lib/lists.h"
@@ -592,24 +592,22 @@ path_getlen(u8 *p, int len)
 }
 
 
-#define PRINTF(a...) { int l; bsnprintf( buf, 8000, a ); s -= (l = strlen(buf)); if (s<bigbuf) return "Path was much too long"; memcpy(s, buf, l); }
+#define PRINTF(a...) { int l; bsnprintf( s, bigbuf+4090-s, a ); s += strlen(s); }
 #define COMMA if (first) first = 0; else PRINTF( ", " );
 char *
 path_format(u8 *p, int len)
 {
   char bigbuf[4096];   /* Keep it smaller than buf */
-  char *s = bigbuf+4095;
-  char buf[8000];
+  char *s = bigbuf;
   int first = 1;
   int i;
   u8 *q = p+len;
-  *s-- = 0;
   while (p<q) {
     switch (*p++) {
     case 1:    /* This is a set */
       len = *p++;
       COMMA;
-      PRINTF( "}" );
+      PRINTF( "{" );
       {
        int first = 1;
        for (i=0; i<len; i++) {
@@ -618,7 +616,7 @@ path_format(u8 *p, int len)
          p+=2;
        }
       }
-      PRINTF( "{" );
+      PRINTF( "}" );
       break;
 
     case 2:    /* This is a sequence */
@@ -635,7 +633,7 @@ path_format(u8 *p, int len)
       bug("This should not be in path");
     }
   }
-  return strdup(s);
+  return strdup(bigbuf);
 }
 #undef PRINTF
 #undef COMMA