From b531a87f6520f70721cba7fc06d29158ba96d838 Mon Sep 17 00:00:00 2001 From: Eric Wheeler Date: Mon, 20 Jul 2026 15:36:25 -0700 Subject: [PATCH] c_geometry: write parsed fields back on trailing-field cards The shared geometry card parser only wrote its output pointers inside the in-loop end-of-string guards, so a card carrying more numeric fields than the two integers and seven reals it consumes returned without writing. The caller reuses one parse state across every card, so a GM move card took its repeat count from the preceding GA arc segment count and replicated the whole structure, exploding the segment total. The regression came from 220977d, which extracted the shared parser and dropped the unconditional write-back that the nec2c and xnec2c ancestors retain. Reproduce with cebik 84-8.nec, whose 12-field GM card after two 90-segment GA arcs yields 16380 segments instead of 180 and runs multi-hour at 8 GB: CM 2-element circular quad beam CM https://antenna2.github.io/cebik/books/Antenna-Modeling-Notes-Models-Vol-1-4.zip { /Vol-4/nec/84-8.nec } CE GA 1 90 .1572 0 360 .001 GA 2 90 .1722 0 360 .001 GM 0 0 0 0 0 0 .1665 0 2 0 0 0 GE 0 -1 0 EX 0 1 68 0 1.0 0.0 FR 0 1 0 0 299.8 1 RP 0 1 361 1000 90 0 1 1 EN - restore unconditional write-back of the parsed integers and reals at the normal loop-exit of the shared geometry card parser, repairing every geometry card type that carries trailing fields Signed-off-by: Eric Wheeler --- src/c_geometry.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/c_geometry.cpp b/src/c_geometry.cpp index cbcfea46..7efbd773 100644 --- a/src/c_geometry.cpp +++ b/src/c_geometry.cpp @@ -2455,6 +2455,18 @@ void c_geometry::parse_geometry_card_line(const char* line_buf, char *gm, return; } } + + /* + * Write the parsed fields back on normal loop exit. A card carrying more + * numeric fields than the two integers and seven reals this reader consumes + * leaves line_idx short of the terminator, so the in-loop end-of-string + * writes never fire; without this the caller's reused parse state retains the + * previous card's values. + */ + *in_i1= integer_params[0]; *in_i2= integer_params[1]; + *in_x1= real_params[0]; *in_y1= real_params[1]; *in_z1= real_params[2]; + *in_x2= real_params[3]; *in_y2= real_params[4]; *in_z2= real_params[5]; + *in_rad= real_params[6]; } void c_geometry::read_geometry_card(FILE* input_fp, char *gm,