Sujet : Re: Writing own source disk
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.cDate : 04. Jun 2024, 00:35:44
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3lk0g$3d35$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 03/06/2024 13:37, bart wrote:
On 03/06/2024 12:58, Ben Bacarisse wrote:
That it is not very interesting. Using #embed applied to a program's only source code I think opens up some intriguing possibilities.
Whereas a pure quine, which can require ingenuity, to me is just a puzzle.
No, it' not that hard, nce you now the trick.
The program babyfs_dirtoxml, which seem to be stable and works, writes a directory as a FileSystem XML file. So the nautral thing to do is to use it ot packaage up the souce, and include in inthe ptoram as a string. However of course the string cannot include itself.
So what you do is say that there is a special file called source.c which defines a global character pointer called "source", which points to the source. However when you package up the directory, of course you delete the real source.c and replace it with a small placeholder. Then you generte the real source.c from the FileSystem XML file you havt just created. And then you compile.
And of currsethere are tfunctions t parse an XML fileSystem file, mnipulate the hieraxty, and write it back out.
So what you do is replace the placeholder source.c with the real one. And then, on command, you write the source out. And it's a quine. And a really powerful and easy to make quine. Ih's just a bit fiddly at the moment, but I have got things working.
-- Check out Basic Algorithms and my other books:https://www.lulu.com/spotlight/bgy1mm