Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch 'dev/osr/fixes_plus_vty_keywords' #5

Merged
merged 13 commits into from
Dec 16, 2016
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ build
*.loT
m4/*.m4
!m4/ax_sys_weak_alias.m4
!m4/ax_compare_version.m4
debian/autoreconf.after
debian/autoreconf.before
debian/files
Expand Down
2 changes: 2 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7477,6 +7477,8 @@ bgp_config_write (struct vty *vty)
void
bgp_master_init (void)
{
qobj_init ();

memset (&bgp_master, 0, sizeof (struct bgp_master));

bm = &bgp_master;
Expand Down
61 changes: 55 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ AC_CANONICAL_TARGET()

# Disable portability warnings -- our automake code (in particular
# common.am) uses some constructs specific to gmake.
AM_INIT_AUTOMAKE([1.6 -Wno-portability])
AM_INIT_AUTOMAKE([1.12 -Wno-portability])
m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
AM_SILENT_RULES([yes])
AC_CONFIG_HEADERS(config.h)
Expand Down Expand Up @@ -1413,13 +1413,62 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,
dnl --------------------------------------
dnl checking for flex and bison
dnl --------------------------------------

AM_PROG_LEX
if test "x$LEX" != xflex; then
LEX="$SHELL $missing_dir/missing flex"
AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
AC_SUBST([LEXLIB], [''])
fi
AC_MSG_CHECKING(version of flex)
quagga_ac_flex_version="$(eval $LEX -V | grep flex | head -n 1)"
quagga_ac_flex_version="${quagga_ac_flex_version##* }"
AC_MSG_RESULT([$quagga_ac_flex_version])
AX_COMPARE_VERSION([$quagga_ac_flex_version], [lt], [2.5.20], [
LEX="$SHELL $missing_dir/missing flex"
if test -f "${srcdir}/lib/command_lex.c" -a -f "${srcdir}/lib/command_lex.h"; then
AC_MSG_WARN([using pregenerated flex output files])
else
AC_MSG_ERROR([flex failure and pregenerated files not included (probably a git build)])
fi
AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
AC_SUBST([LEXLIB], [''])
])

AC_PROG_YACC
dnl thanks GNU bison for this b*llshit...
AC_MSG_CHECKING(version of bison)
quagga_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)"
quagga_ac_bison_version="${quagga_ac_bison_version##* }"
quagga_ac_bison_missing="false"
case "x${quagga_ac_bison_version}" in
x2.7*)
BISON_OPENBRACE='"'
BISON_CLOSEBRACE='"'
AC_MSG_RESULT([$quagga_ac_bison_version - 2.7 or older])
;;
x2.*|x1.*)
AC_MSG_RESULT([$quagga_ac_bison_version])
AC_MSG_WARN([installed bison is too old. Please install GNU bison 2.7.x or newer.])
quagga_ac_bison_missing="true"
;;
x)
AC_MSG_RESULT([none])
AC_MSG_WARN([could not determine bison version. Please install GNU bison 2.7.x or newer.])
quagga_ac_bison_missing="true"
;;
*)
BISON_OPENBRACE='{'
BISON_CLOSEBRACE='}'
AC_MSG_RESULT([$quagga_ac_bison_version - 3.0 or newer])
;;
esac
AC_SUBST(BISON_OPENBRACE)
AC_SUBST(BISON_CLOSEBRACE)

if $quagga_ac_bison_missing; then
YACC="$SHELL $missing_dir/missing bison -y"
if test -f "${srcdir}/lib/command_parse.c" -a -f "${srcdir}/lib/command_parse.h"; then
AC_MSG_WARN([using pregenerated bison output files])
else
AC_MSG_ERROR([bison failure and pregenerated files not included (probably a git build)])
fi
fi

dnl -------------------
dnl capabilities checks
Expand Down
7 changes: 6 additions & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
AM_CFLAGS = $(WERROR)
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
AM_YFLAGS = -d
AM_YFLAGS = -d -Dapi.prefix=@BISON_OPENBRACE@cmd_yy@BISON_CLOSEBRACE@

command_lex.h: command_lex.c
@if test ! -f $@; then rm -f command_lex.c; else :; fi
Expand Down Expand Up @@ -51,6 +51,11 @@ pkginclude_HEADERS = \
noinst_HEADERS = \
plist_int.h

noinst_PROGRAMS = grammar_sandbox

grammar_sandbox_SOURCES = grammar_sandbox.c
grammar_sandbox_LDADD = libzebra.la

EXTRA_DIST = \
queue.h \
command_lex.h \
Expand Down
13 changes: 13 additions & 0 deletions lib/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,19 @@ cmd_complete_command (vector vline, struct vty *vty, int *status)
}
vector_free (initial_comps);

// since we filtered results, we need to re-set status code
switch (vector_active (comps))
{
case 0:
*status = CMD_ERR_NO_MATCH;
break;
case 1:
*status = CMD_COMPLETE_FULL_MATCH;
break;
default:
*status = CMD_COMPLETE_LIST_MATCH;
}

// copy completions text into an array of char*
ret = XMALLOC (MTYPE_TMP, (vector_active (comps)+1) * sizeof (char *));
unsigned int i;
Expand Down
2 changes: 2 additions & 0 deletions lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ struct cmd_token
{
enum cmd_token_type type; // token type
u_char attr; // token attributes
bool allowrepeat; // matcher allowed to match token repetively?

char *text; // token text
char *desc; // token description
long long min, max; // for ranges
Expand Down
1 change: 0 additions & 1 deletion lib/command_lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

%{
#include "command_parse.h"
#define YYSTYPE CMD_YYSTYPE
%}

WORD (\-|\+)?[a-z\*][-+_a-zA-Z0-9\*]*
Expand Down
Loading