Implementation notes Double quine ---------------------------------------------------------------------- 0. Concept It's just a quine, using the same run-length encoding that I have used in a few other entries before. But since I haven't been making ASCII art for a while, I have decided to write two quines at the same time. ---------------------------------------------------------------------- 1. Implementation The technique and encoding used for Serval is pretty much identical to what was used for Yoshino: http://uguu.org/src_yoshino_c.html Basically: duplicate code and data using preprocessor macros, and choose a different layout based on some compile time input. Actual implementation for Serval is much more straightforward, selecting between two layouts based on last digit of compile time. This layout selection heuristic was done to make one layout less likely than the other, to convey the sense that Tsuchinoko is more rare than Serval. Unlike other quines where I just compile and run to get the formatted output, this time I formatted the two quines manually to make sure that they would tokenize properly and recorded the process. In other words, everything I have done for Serval is very much not new, although I am more methodic in doing it now. ---------------------------------------------------------------------- 2. Testing Verified to work on: - gcc 6.4.0 on cygwin - gcc 6.1.0 on jslinux - gcc 4.9.2 on linux - gcc 4.8.4 on linux - clang 4.0.1 on cygwin - clang 3.5.0-10 on linux Does *not* work with TCC 0.9.25. This is because TCC's preprocessor does two things differently from other preprocessors in its stringizing operation: - Insert backslash before single quotes. - Escape \0 as \000. If it was just the single quotes then I would have worked around that, but the \000 bits is something that I wasn't prepared for, so unfortunately Serval doesn't work with TCC. Other than preprocessor bits, Serval depends on puts() having the standard signature, since Serval doesn't bother including stdio.h. On systems that define puts() as a macro, Serval probably doesn't work. ---------------------------------------------------------------------- 3. Finally... In recent years, I have picked up other hobbies that reward much faster than writing code, so I have allocated most of my coding time to work rather than personal projects. Still, you lose every skill you don't use, and ASCII art is a skill that I don't want to lose. It's questionable whether it's a useful skill or not, but it's appears to be a rare skill that is near extinction, and extinction of anything is a real shame.