Path printing is now much nicer: not having to put it backward
simplifies it. (Sorry for previous commit, cvs is naughty).
This commit is contained in:
parent
f7d534cf2e
commit
78c6217c1e
1 changed files with 6 additions and 8 deletions
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#undef LOCAL_DEBUG
|
#define LOCAL_DEBUG
|
||||||
|
|
||||||
#include "nest/bird.h"
|
#include "nest/bird.h"
|
||||||
#include "lib/lists.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( ", " );
|
#define COMMA if (first) first = 0; else PRINTF( ", " );
|
||||||
char *
|
char *
|
||||||
path_format(u8 *p, int len)
|
path_format(u8 *p, int len)
|
||||||
{
|
{
|
||||||
char bigbuf[4096]; /* Keep it smaller than buf */
|
char bigbuf[4096]; /* Keep it smaller than buf */
|
||||||
char *s = bigbuf+4095;
|
char *s = bigbuf;
|
||||||
char buf[8000];
|
|
||||||
int first = 1;
|
int first = 1;
|
||||||
int i;
|
int i;
|
||||||
u8 *q = p+len;
|
u8 *q = p+len;
|
||||||
*s-- = 0;
|
|
||||||
while (p<q) {
|
while (p<q) {
|
||||||
switch (*p++) {
|
switch (*p++) {
|
||||||
case 1: /* This is a set */
|
case 1: /* This is a set */
|
||||||
len = *p++;
|
len = *p++;
|
||||||
COMMA;
|
COMMA;
|
||||||
PRINTF( "}" );
|
PRINTF( "{" );
|
||||||
{
|
{
|
||||||
int first = 1;
|
int first = 1;
|
||||||
for (i=0; i<len; i++) {
|
for (i=0; i<len; i++) {
|
||||||
|
@ -618,7 +616,7 @@ path_format(u8 *p, int len)
|
||||||
p+=2;
|
p+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PRINTF( "{" );
|
PRINTF( "}" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* This is a sequence */
|
case 2: /* This is a sequence */
|
||||||
|
@ -635,7 +633,7 @@ path_format(u8 *p, int len)
|
||||||
bug("This should not be in path");
|
bug("This should not be in path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strdup(s);
|
return strdup(bigbuf);
|
||||||
}
|
}
|
||||||
#undef PRINTF
|
#undef PRINTF
|
||||||
#undef COMMA
|
#undef COMMA
|
||||||
|
|
Loading…
Reference in a new issue