I know, I know, GIGO, and why am I using -k?
(I am using -k because some of the problems that force
using -k will still produce perfectly useful output.
I suspect fixing this would require re-evaluating
the severity of quite a few errors; using -k is
way easier.))
I have several poorly-extracted MIBs where an I-D header
ended up in the middle of the IMPORTS clause, causing a
syntax error and several smiImport data structures with
a null module ID. Since lastModule==NULL was used as a
flag for "did I ever print anything", and strcmp has
unpredictable handling for being passed NULL, I just
skipped the inside of the loop if the current import's
module is NULL.
Diff follows.
Bill
--- dump-perl.c (revision 6635)
+++ dump-perl.c (working copy)
@@ -617,11 +617,12 @@
for (i = 0, smiImport = smiGetFirstImport(smiModule);
smiImport;
i++,
- lastModule = smiImport->module,
smiImport = smiGetNextImport(smiImport)) {
if (i == 0) {
fprintSegment(f, INDENT, "\"imports\" => [\n", 0);
}
+ if (smiImport->module == NULL)
+ continue;
if ( lastModule == NULL || strcmp(lastModule, smiImport->module)) {
if ( lastModule ) {
@@ -636,6 +637,7 @@
}
fprintSegment(f, 4 * INDENT, "", 0);
fprint(f, "\"%s\",\n", smiImport->name);
+ lastModule = smiImport->module;
}
if (lastModule) {
fprintSegment(f, 3 * INDENT, "],\n", 0);