Menu ▾ ▴

#893 .lib section line with an end-of-line comment: its .include lines are skipped (since 3d4bf79ab)

v1.0 (example)
open
nobody
None
5
6 days ago
6 days ago
No

Version: pre-master-48 8077acf20. ngspice-45.2 loads the deck below.

A library section whose opening line has a comment behind the name loses its .include lines.

1-lib.lib:

  • a library whose section line has a comment behind the name
    .lib tt $ typical
    .include 1-part.inc
    .endl tt

1-part.inc:
.param rval=2k

1-section-comment.cir:
a library section with a comment behind its name
v1 1 0 1
r1 1 2 1k
r2 2 0 {rval}
.lib '1-lib.lib' tt
.control
op
print v(2)
.endc
.end

8077acf20: "Undefined parameter [rval]", exit 1.
ngspice-45.2: v(2) = 6.666667e-01.
Without the comment both load. The same happens with ";" and "//" in place of "$".

The cause, from the code: since 3d4bf79ab inp_read() follows an .include line of a library only inside the section that was asked for, and it decides that with is_section_definition() on the line as it was read. That function takes ".lib <name>" with nothing behind the name, so with a comment the line opens no section and the .include is skipped. The comments are stripped at the end of inp_read(); find_section_definition() then does find the section, without the content of the file. I did not build the parent of 3d4bf79ab; "since" is from git log -S in_lib_section.</name>

Patch attached, against 8077acf20. It tests the line without its end-of-line comment, with inp_stripcomments_line() on a copy. With it the deck gives v(2) = 6.666667e-01. It adds tests/regression/lib-processing/ex5a.cir, which fails without the change ("Undefined parameter [rc1]").

One case the patch leaves as it is: when the section opens on the very first line of the library file and has a comment behind its name, the section is not found at all ("section definition ... not found"). That is older, ngspice-45.2 does the same, because the comment strip at the end of inp_read() skips the first card.

make -k check with DISPLAY unset: 79 PASS and 1 FAIL (alter-1.cmd) on 8077acf20. I ran it once with this patch and the patch of my other report of today together: 81 PASS and the same FAIL, the two more being the tests the two patches add.

I checked this with help from an AI coding assistant (Claude); I have NOT reviewed the results.

1 Attachments

Discussion

  • ananthsforge

    ananthsforge - 6 days ago

    other files needed

     

Log in to post a comment.