nikhilgupta10 / GridLAB-D

Other
1 stars 0 forks source link

#629 Line numbering is incorrect, #2372

Closed nikhilgupta10 closed 8 years ago

nikhilgupta10 commented 8 years ago

When macros are processed, line numbers are getting messed up. See test_seq.glm for example.

,

nikhilgupta10 commented 8 years ago

nikhilgupta10 imported these comments from Sourceforge: The user dchassin does not exist anymore. Therefore assigning this to afisher1. "mhauer": * attachment _testseq.glm added

Relevant test file.

,

"mhauer":Unable to duplicate. The print statement is claiming line #11 in v3.0, which is correct (according to Textpad).

,

"dchassin":It looks like the test_seq.glm file was checked in after being changed in way that doesn't exhibit the problem. However, if you add

#print This is line 12

to the end of the file and run the command

host% gridlabd --warn -D suppress_repeat_messages=0 test_seq.glm

you get the following output:

test_seq.glm(11): 10 houses created.
test_seq.glm(15): This is line 12

which obviously is not correct.

Note that this test was done on a Mac (GridLAB-D 3.0.0-4873 (Hassayampa) 64-bit MACOSX RELEASE).

,

"mhauer": * status changed from new to accepted

Additionally,

...

print ${SEQ_A} houses created.

set suppress_repeat_messages=0

print this is line 13

object house{

name House_plus;

}

print the is line 17

results in

test_seq.glm(11): 10 houses created.
test_seq.glm(20): this is line 13
test_seq.glm(29): the is line 17
ERROR [INIT] : An object named 'House_plus' already exists!
test_seq.glm(30): property name House_plus could not be used
test_seq.glm(29): load failed at or near 'object house...'
ERROR [INIT] : unable to load 'test_seq.glm': No such file or directory

This implies that something is going absolutely sideways in the loader. Commenting out all print statements winds up clearing up all loader errors, though prevents debugging the original error.

,

"dchassin":That would explain something else I observed when I added line 12: a bunch of extra suppressed repeat messages came up, suggesting that the objects were defined more than once.

,

"mhauer":Current hypothesis is that the loader buffer is not being cleared when the print macro is processed.

,

"mhauer":buffer_load_alt logic was as follows:
if macro, strcat(buffer, line)
if normal line, strcpy(buffer, subst)
if suppressed, strcpy(buffer, \ )

Using strcpy for 'if macro' fixes both the line numbers and the duplicate house glitch. Indicates the problems observed in previous comments stem from the buffer variable not being flushed when a macro is read in.

Testing use of strcpy before committing the change, since this one runs pretty deep.

,

"mhauer": * owner changed from mhauer to dchassin

No change in --validate results. Significantly fewer 'scanned directories', however. Change posted in r3700.

Reassigning to dchassin for validation.

,

"dchassin": * status changed from assigned to closed

Confirm fixed.

,