Sisyphus repository
Last update: 16 september 2021 | SRPMs: 17377 | Visits: 21881508
en ru br
ALT Linux repos
S:0.5.0-alt2

Group :: System/Libraries
RPM: libsmi

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: libsmi-0.5.0-alt2.patch
Download


 lib/Makefile.am     |   4 +-
 lib/parser-sming.y  |   2 +-
 lib/scanner-smi.h   |   2 +-
 lib/scanner-sming.h |   2 +
 lib/scanner-yang.h  |   3 +-
 tools/smicache.1.in |   8 ++--
 tools/smistrip.in   | 126 +++++++++++++++++++++++++++++++++++-----------------
 7 files changed, 97 insertions(+), 50 deletions(-)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 8c5980f5..47657c39 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -48,10 +48,10 @@ libsmi_la_LDFLAGS	= -version-info @VERSION_LIBTOOL@
 parser-smi.c parser-smi.tab.h: parser-smi.y scanner-smi.h parser-smi.h error.h
 	$(BISON) --defines=parser-smi.tab.h -t -psmi -o parser-smi.c parser-smi.y
 
-parser-sming.c: parser-sming.y scanner-sming.h parser-sming.h error.h
+parser-sming.c parser-sming.tab.h: parser-sming.y scanner-sming.h parser-sming.h error.h
 	$(BISON) --defines=parser-sming.tab.h -t -psming -o parser-sming.c parser-sming.y
 
-parser-yang.c: parser-yang.y scanner-yang.h parser-yang.h error.h
+parser-yang.c parser-yang.tab.h: parser-yang.y scanner-yang.h parser-yang.h error.h
 	$(BISON) --defines=parser-yang.tab.h -t -pyang -o parser-yang.c parser-yang.y
 
 scanner-smi.c: scanner-smi.l scanner-smi.h parser-smi.tab.h
diff --git a/lib/parser-sming.y b/lib/parser-sming.y
index ec25328b..fefeee91 100644
--- a/lib/parser-sming.y
+++ b/lib/parser-sming.y
@@ -1550,7 +1550,7 @@ identityStatement:	identityKeyword sep lcIdentifier
 			referenceStatement_stmtsep_01
 			{
 				setIdentityReference(identityPtr, $14, 
-									 thisParserPtr)
+									 thisParserPtr);
 			}
 			'}' optsep ';'
 			{
diff --git a/lib/scanner-smi.h b/lib/scanner-smi.h
index 2507aa05..d4b0fa82 100644
--- a/lib/scanner-smi.h
+++ b/lib/scanner-smi.h
@@ -21,7 +21,7 @@
 #define YY_NO_UNPUT
 
 extern char *yytext;
-#if 0
+#ifndef yyleng
 extern int yyleng;
 #endif
 
diff --git a/lib/scanner-sming.h b/lib/scanner-sming.h
index 96e99a54..3ac53509 100644
--- a/lib/scanner-sming.h
+++ b/lib/scanner-sming.h
@@ -21,7 +21,9 @@
 #define YY_NO_UNPUT
 
 extern char *yytext;
+#ifndef yyleng
 extern int yyleng;
+#endif
 
 extern int smingEnterLexRecursion(FILE *file);
 extern void smingLeaveLexRecursion();
diff --git a/lib/scanner-yang.h b/lib/scanner-yang.h
index 3915e3b3..65f468b5 100644
--- a/lib/scanner-yang.h
+++ b/lib/scanner-yang.h
@@ -21,8 +21,7 @@
 #define YY_NO_UNPUT
 
 extern char *yytext;
-#if 0
-/* this does not seem to be needed with flex 2.5.35 and in fact conflicts */
+#ifndef yyleng
 extern int yyleng;
 #endif
 
diff --git a/tools/smicache.1.in b/tools/smicache.1.in
index 6a42390f..54cf8baf 100644
--- a/tools/smicache.1.in
+++ b/tools/smicache.1.in
@@ -45,13 +45,13 @@ you have to care about permissions in multi-user environments.
 global configuration file:
 .nf
 
-  cache /usr/local/share/mibs/cache \\
-    /usr/local/bin/smicache \\
-    -d /usr/local/share/mibs/cache \\
+  cache /usr/share/mibs/cache \\
+    /usr/bin/smicache \\
+    -d /usr/share/mibs/cache \\
     -p http://www.ibr.cs.tu-bs.de/projects/libsmi/smicache/
 
 .fi
-You might want to chmod 1777 /usr/local/share/mibs/cache.
+You might want to chmod 1777 /usr/share/mibs/cache.
 .SH "SEE ALSO"
 The
 .BR libsmi (3)
diff --git a/tools/smistrip.in b/tools/smistrip.in
index b5223bac..848a0965 100644
--- a/tools/smistrip.in
+++ b/tools/smistrip.in
@@ -5,6 +5,13 @@
 #	Extract MIB and PIB modules from text files, like RFCs or I-Ds.
 #
 # Copyright (c) 1999 Frank Strauss, Technical University of Braunschweig.
+# Copyright (c) Niels Baggesen, Jochen Friedrich
+#
+# Modified by Niels Baggesen to be somewhat more aggressive in suppressing
+# blank lines, and support the -x option.
+#
+# Modified by Jochen Friedrich to merge the changes of libsmi back in and
+# make the aggressive suppressing of blank lines optional.
 #
 # See the file "COPYING" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -27,13 +34,17 @@ do_version () {
 
 
 do_usage () {
-    echo "Usage: smistrip [-Vhn] [-i dir] [-d dir] [-m module] file1 [file2 [...]]"
+    echo "Usage: smistrip [-Vvhna] [-i dir] [-d dir] [-s suffix] [-m modules] file1 [file2 [...]]"
     echo "-V         show version and license information"
+    echo "-v         verbose"
     echo "-h         show usage information"
     echo "-n         do not write module files"
+    echo "-a         strip blank lines more aggressively"
     echo "-i dir     try to read files from directory dir"
     echo "-d dir     write module to directory dir"
-    echo "-m module  strip only the specified module"
+    echo "-x suffix  append suffix to the module file name"
+    echo "-m modules strip only the specified modules. For a list of modules"
+    echo "           use : as a separator"
     echo "file1 ...  input files to parse (RFCs, I-Ds, ...)"
 }
 
@@ -57,65 +68,90 @@ do_strip () {
 
     $CMD "$FILE" | \
     tr -d '\015' | \
-    grep -i -v '^[ ]*Internet[ \-]Draft' | \
-    $AWK -vtest="$test" -vdir="$dir" -vsingle="$single" '
+    $AWK -vtest="$test" -vdir="$dir" -vsingle="$single" -vsuffix="$suffix" -vverbose="$verbose" -vaggressive="$aggressive" '
+
+    BEGIN {
+	if (length(single) != 0) {
+	    single = ":"single":"
+	}
+	else {
+	    single = ""
+	}
+    }
+
+    END {
+	if (single != "" && single != ":") {
+	    gsub(":", " ", single)
+	    print "WARNING: Module(s) not found:" single
+	}
+    }
 
     # start of module
     /^[ \t]*[A-Za-z0-9-]* *(PIB-)?DEFINITIONS *(::=)? *(BEGIN)? *$/ {
 	module = $1
-	skip = 9
-	skipped = -1
+	collect = 1
 	macro = 0
+	skip = 0
 	n = 0
     }
 
-    # process each line
-    {
-	# at the end of a page we go back one line (which is expected to
-	# be a separator line), and start the counter skipped to skip the
-	# next few lines.
-	if ($0 ~ /\[[pP]age [iv0-9]*\] */) {
-            # some drafts do not use that separator line. so keep it if
-            # there are non-blank characters.
-            if (!(line[n] ~ /^[ \t]*$/)) { print "WARNING: the line ::"line[n]":: should be a separator before a page break. It was kept. " ; n-- }
-	    skipped = 0
+    # at the end of a page we go back one line (which is expected to
+    # be a separator line), and start the counter skipped to skip the
+    # next few lines.
+    /\[[pP]age [iv0-9]*\] */ {
+	# some drafts do not use that separator line. so keep it if
+	# there are non-blank characters.
+	if (!aggressive && n && collect) {
+	    if (!(line[n-1] == ""))
+		print "WARNING: the line ::"line[n-1]":: should be a separator before a page break. It was kept. ";
+	    else n--;
+	    skip = 3
 	}
+	collect = 0
+	next
+    }
 
-	# if we are skipping...
-	if (skipped >= 0) {
-	    skipped++
+    /^[ \t]*(::=|DESCRIPTION|SYNTAX|MAX-ACCESS|MIN-ACCESS|ACCESS|STATUS|REFERENCE|INDEX|AUGMENTS|DEFVAL|UNITS|DISPLAY|")/ {
+	skip = 0
+	if (collect && aggressive)
+	    if (line[n-1] == "") n--
+    }
 
-	    # if we have skipped enough lines to the top of the next page...
-	    if (skipped >= skip) {
-		skipped = -1
-	    } else {
-    
-	    	# finish skipping, if we find a non-empty line, but not before
-	    	# we have skipped four lines. remember the miminum of lines
-	    	# we have ever skipped to keep empty lines in a modules that
-	    	# appear near the top of a page.
-	    	if ((skipped >= 4) && ($0 ~ /[^ \t]/)) {
-		    if (skipped < skip) { skip = skipped }
-		    skipped = -1
-	    	}   
+    # a blank line - suppress multiple
+    /^[ \t\r]*$/ {
+        if (collect && (skip == 0)) {
+	    if (aggressive && n) {
+                if (line[n-1] != "" && line[n-1] !~ /,[ \t\r]*$/) line[n++] = ""
 	    }
+	    else line[n++] = ""
 	}
+	if (skip > 0) skip--;
+        next
+    }
 
-	# so, if we are not skipping and inside a module, remember the line.
-        if ((skipped == -1) && (length(module) > 0)) {
-	    line[n++] = $0
+    # collect non-blank line when inside mib module
+    /[^ \f\t]/ {
+	if (length(module) > 0) {
+	    if (!collect)
+		collect = 1     # page header, stop skipping
+	    else if (skip == 0)
+		line[n++] = $0
 	}
+	if (skip > 0) skip--;
     }
 
     # remember when we enter a macro definition
     /^[ \t]*[A-Za-z0-9-]* *MACRO *::=/ {
 	macro = 1
+	skip = 0
     }
 
     # end of module
     /^[ \t]*END[ \t]*$/ {
+	skip = 0
 	if (macro == 0) {
-	    if ((length(single) == 0) || (single == module)) {
+	    if (single == "" || match(single, ":"module":")) {
+	        sub(":"module, "", single)
 		strip = 99
 		for (i=0 ; i < n ; i++) {
 		    # find the minimum column that contains non-blank characters
@@ -129,17 +165,21 @@ do_strip () {
     
 		if (test != "1") {
 		    if (dir) {
-		       f = dir"/"module
+		       f = dir"/"module suffix
 		    } else {
-		       f = module
+		       f = module suffix
 		    }
 		    for (i=0 ; i < n ; i++) {
 			print substr(line[i], strip) >f
 		    }
 		}
+		if (verbose) {
+		    print module ": " n " lines."
+		}
     
-		print module ": " n " lines."
 	    }
+	    else
+		print "NOTE: " module ": ignored."
 	    module = ""
 	} else {
 	    macro = 0
@@ -150,16 +190,22 @@ do_strip () {
 
 
 
-while $GETOPTS Vhnm:i:d: c ; do
+while $GETOPTS Vvhnam:i:d:x: c ; do
     case $c in
+	v)	verbose=1
+		;;
 	n)	test=1
 		;;
+	a)	aggressive=1
+		;;
 	m)	single=$OPTARG
 		;;
 	i)	indir=$OPTARG
 		;;
 	d)	dir=$OPTARG
 		;;
+	x)	suffix=$OPTARG
+		;;
 	h)	do_usage
 		exit 0
 		;;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin