From 86d9cd69f7a5f9053a78b7d6a1f03c41fc2cfd8c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:05:34 -0700 Subject: [PATCH] Update thanks for 1990/dg + format README.md I had never put my name in the README.md file so this was not in the thanks file either. This has been corrected. Format fixed the README.md file. Plus add -Wno-implicit-int to the CSILENCE in the Makefile. --- 1990/dg/Makefile | 2 +- 1990/dg/README.md | 28 +++++++++++++++------------- 1990/dg/dg.c | 2 ++ thanks-for-fixes.md | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/1990/dg/Makefile b/1990/dg/Makefile index 71ed320fb..15d2450f6 100644 --- a/1990/dg/Makefile +++ b/1990/dg/Makefile @@ -38,7 +38,7 @@ include ../../var.mk # Common C compiler warnings to silence # -CSILENCE= -Wno-invalid-pp-token -Wno-strict-prototypes +CSILENCE= -Wno-invalid-pp-token -Wno-strict-prototypes -Wno-implicit-int # Common C compiler warning flags # diff --git a/1990/dg/README.md b/1990/dg/README.md index 247ebb880..2aa8133aa 100644 --- a/1990/dg/README.md +++ b/1990/dg/README.md @@ -49,23 +49,25 @@ which we have done for the wider audience. If my preprocessor could hack it, I could write this as one single line rather than 4, but when I do that I get a complaint "defines nested too deeply". -Spoiler: (rot13 to read) +### Obfuscation spoiler: - Guvf vf nabgure ebg13 wbo (oryvrir vg be abg) - gur #qrsvarf ner n - abiry jnl bs nqqvat gbxraf: '#qrsvar o12(k) 12 k' zrnaf gung ng - fbzr cbvag va gur fbhepr n 12 vf sbyybjrq ol gur pbzcerffrq arfgrq - qrsvarf. Gur o12 trgf gur cerivbhf pbzcerffvba nf na nethzrag, naq - cercraqf gur 12, guhf znxvat nabgure fgrc va gur erperngvba bs gur - fbhepr. Gur nkk() qrsvarf qb gur fnzr, ohg nqq gbxraf nsgre. +This is another rot13 job (believe it or not) - the `#defines` are a +novel way of adding tokens: `#define b12(x) 12 x` means that at +some point in the source a `12` is followed by the compressed nested +`#define`s. The `b12` gets the previous compression as an argument, and +prepends the `12`, thus making another step in the recreation of the +source. The `axx()` `#define`s do the same, but add tokens after. - Nf sbe gur ebg13 nytbevguz, vg eryvrf ba vaqrk() gb svaq vs gur - punenpgre vf va gur frg N-Mn-m. y[] vf na neenl gung trgf svyyrq - jvgu: +As for the rot13 algorithm, it relies on `index(3)` to find if the +character is in the set `A-Za-z`. `l[]` is an array that gets filled +with: - "abcdefghijklmmmmnopqrstuvwxyzzzzABCDEFGHIJKLMMMMNOPQRSTUVWXYZZZZ" +``` +"nopqrstuvwxyzzzzabcdefghijklmmmmNOPQRSTUVWXYZZZZABCDEFGHIJKLMMMM" +``` - Vs vaqrk() fnlf gur pune vf va gur nycunorg, gura kbe gur bssfrg - jvgu 16 gb genafyngr, naq bhgchg, bgurejvfr cnff vg hapunatrq. +If `index(3)` says the char is in the alphabet, then XOR the offset +with `16` to translate, and output, otherwise pass it unchanged. ## Copyright and CC BY-SA 4.0 License: diff --git a/1990/dg/dg.c b/1990/dg/dg.c index ccbb6fa29..8b1c7bae3 100644 --- a/1990/dg/dg.c +++ b/1990/dg/dg.c @@ -1,5 +1,7 @@ #include +#define d define + #define b12(x) 12 x #define a13(x) x 13 #define a16(x) x 16 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index b8101a153..ef865b9d3 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -661,6 +661,26 @@ links and the user executes does that make the compiler the jury, the linker the judge and user the executioner? :-) +## [1990/dg](1990/dg/dg.c) ([README.md](1990/dg/README.md])) + +Cody fixed this for modern systems. There were two problems to be resolved. + +One can no longer do: + +```c +#define d define + +#d b12(x) 12 x + +/* etc. */ +``` + +so the use of `#d` is now instead `#define` (the macro was originally deleted +but later Cody added it back to make it more like the original). + +The second problem was suggested by the judges at the time of judging, to do +with if the C preprocessor botches single quotes in cpp expansion. + ## [1990/dds](1990/dds/dds.c) ([README.md](1990/dds/README.md])) Yusuke and Cody in conjunction fixed this for modern systems (both fixed a