Re: [Autogen-users] 'extract' Function Sets Output Files Writable - Feature, not Bug.
Brought to you by:
bkorb
From: Eric M. <mcd...@ph...> - 2009-10-04 17:02:11
|
Thanks for the explanation, Bruce. What you say does make sense from the perspective you were approaching it. I guess I was approaching it from a slightly different angle (i.e., pulling in pieces of other files to create a generated, non-editable "Frankenfile"). Maybe there is a better approach for what I am trying to do. (There is no definitions file for the use case I have in mind - just portions of a bunch of other generated files to merge with the template.) However, it looks like --not-writable will do the trick. Thanks. Regards, Eric Bruce Korb wrote: > On Sat, Oct 3, 2009 at 4:00 PM, Eric McDonald <mcd...@ph...> wrote: >> Hi, >> >> I've noticed that the output files from templates, which use the >> 'extract' Autogen Scheme function, are set to writable. Looking at the >> 'loadExtractData' function in agen5/expExtract.c, I can see that this >> appears to be deliberate: >> >> if (! HAVE_OPT( WRITABLE )) >> SET_OPT_WRITABLE; >> >> I am having trouble understanding why this is desirable. I read the >> documentation for the 'extract' function, as well as the comments in its >> implementation, and nothing really stands out as a reason. Even if the >> output files are not going to be kept around long-term, as in the case >> of the example code mentioned in the documentation, they should still be >> able to get forcefully renamed or removed. Hence, it should be safe to >> leave them read-only by default. >> >> Any insights? > > The theory behind it is that if you are extracting something from the previous > incarnation of the same file, then your client wants to be able to edit the > text that was extracted. Witness the file agen5/cgi-fsm.c: > > case CGI_TR_NAME_EQUAL: > /* START == NAME_EQUAL == DO NOT CHANGE THIS COMMENT */ > strcpy( pzOut, "='" ); > outlen -= 2; > pzOut += 2; > /* END == NAME_EQUAL == DO NOT CHANGE THIS COMMENT */ > break; > > The code between the "START" and "END" is hand crafted. > The rest changes if my FSM state machine template changes. > This is in line with what is done by GUI code generators, for example. > If you use the option, ``--not-writable'', then loadExtractData will not > force the output to be writable. (You "have" the option and it was set > to the disabled state.) > > I will augment the doc for "extract". Thanks! Regards, Bruce |