From e639c38c760cc983777591629d9626283fb68e62 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 26 Nov 2023 05:19:20 -0800 Subject: [PATCH] Remove an alt version of 1991/cdupont cdupont.alt.c is the version with the goto label and a comment removed. cdupont.alt2.c is the beautified version. --- 1991/cdupont/.gitignore | 1 - 1991/cdupont/Makefile | 6 +-- 1991/cdupont/README.md | 19 +++++---- 1991/cdupont/cdupont.alt.c | 77 +++++++++-------------------------- 1991/cdupont/cdupont.alt2.c | 81 ++++++++++++++++++++++++++++--------- 1991/cdupont/cdupont.alt3.c | 64 ----------------------------- thanks-for-fixes.md | 18 ++++----- 7 files changed, 102 insertions(+), 164 deletions(-) delete mode 100644 1991/cdupont/cdupont.alt3.c diff --git a/1991/cdupont/.gitignore b/1991/cdupont/.gitignore index 0f34a3cb5..65fb330c0 100644 --- a/1991/cdupont/.gitignore +++ b/1991/cdupont/.gitignore @@ -1,6 +1,5 @@ cdupont cdupont.alt cdupont.alt2 -cdupont.alt3 cdupont.orig prog.orig diff --git a/1991/cdupont/Makefile b/1991/cdupont/Makefile index 358140f8f..a4cdf5600 100644 --- a/1991/cdupont/Makefile +++ b/1991/cdupont/Makefile @@ -38,7 +38,7 @@ include ../../var.mk # Common C compiler warnings to silence # -CSILENCE= -Wno-unused-label -Wno-strict-prototypes +CSILENCE= -Wno-unused-label -Wno-strict-prototypes -Wno-implicit-int # Common C compiler warning flags # @@ -111,8 +111,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= ${PROG}.alt.o ${PROG}.alt2.o ${PROG}.alt3.o -ALT_TARGET= ${PROG}.alt ${PROG}.alt2 ${PROG}.alt3 +ALT_OBJ= ${PROG}.alt.o ${PROG}.alt2.o +ALT_TARGET= ${PROG}.alt ${PROG}.alt2 ################# diff --git a/1991/cdupont/README.md b/1991/cdupont/README.md index aa54aa9c4..96c6acb83 100644 --- a/1991/cdupont/README.md +++ b/1991/cdupont/README.md @@ -4,9 +4,10 @@ make all ``` -There are three alt versions which demonstrate a problem that the code documents -(as an obfuscation technique) and what the judges document so you can see what -it looks like. See [alternate code](#alternate-code) below for more details. +There are two alt versions that demonstrate a problem that the code documents +(as an obfuscation technique) and what the judges document, respectively, so +that you can see what the results are. See [alternate code](#alternate-code) +below for more details. ## To use: @@ -18,14 +19,13 @@ it looks like. See [alternate code](#alternate-code) below for more details. ## Alternate code: -These three versions show what will happen if certain things are done that were +These two versions show what will happen if certain things are done that were warned against: if you remove a comment and more so an unused `goto` label or if you beautify it. The [cdupont.alt.c](cdupont.alt.c) is the one with both the -unused `goto` label and comments removed, the [cdupont.alt2.c](cdupont.alt2.c) -is the version that has these things removed and is also beautified and the -[cdupont.alt3.c](cdupont.alt3.c) is just beautified. This required changing the -`s` macro to be `__FILE__` as otherwise it would read in the original code which -doesn't have the modifications. +unused `goto` label and comments removed and the [cdupont.alt2.c](cdupont.alt2.c) +is beautified. This required changing the `s` macro to be `__FILE__` as +otherwise it would read in the original code which doesn't have the +modifications. ### Alternate build: @@ -42,7 +42,6 @@ make alt ```sh ./cdupont.alt ./cdupont.alt2 -./cdupont.alt3 ``` Enjoy! :-) diff --git a/1991/cdupont/cdupont.alt.c b/1991/cdupont/cdupont.alt.c index 4c53f9dcf..42b504e8e 100644 --- a/1991/cdupont/cdupont.alt.c +++ b/1991/cdupont/cdupont.alt.c @@ -1,61 +1,24 @@ /* common sense to nohonest programmer */ #include -main () -{ - int x, gi = 4, i, f, ri = 1, httxkbl = 1, m = 012; - long cd = 0x5765248d, n; - char u[0x50][032]; - FILE *ind; - ind = fopen (s, t); - for (i = 0; i < 0x1a; i++) - { - goto daswjhkls; - vhjsgfdy1l1gjhd:; - } -/*borntorun.*/ goto c0g0; -cOgO:i = 0; - fclose (ind); -c0gO: - x = u[gi][m]; - if (m == gi) - { - x = 0x70; - f = 0x68; - } - else - goto cOg0; -b:putchar (x); - if (!(n - httxkbl++)) +main(){int x ,gi=4,i,f,ri=1,httxkbl=1,m=012;long cd=0x5765248d,n; + char u[0x50][032];FILE *ind; + ind=fopen(s,t); for(i=0; i<0x1a; i++){goto daswjhkls;vhjsgfdy1l1gjhd:;} +/*borntorun.*/goto c0g0;cOgO:i=0;fclose(ind);c0gO: +x= u [gi][m]; + if( m==gi){x=0x70;f=0x68;}else goto cOg0 ; b:putchar(x); if( +!(n-httxkbl++)) #define yank(x) putchar(x) - { - httxkbl = 1; - yank (' '); - goto hxi; - } - goto bl; -daswjhkls:fgets (u[i], 0120, ind); - /*obfuscated, eh? */ goto + {httxkbl=1; yank(' ');goto + hxi;}goto bl; + daswjhkls: fgets(u[i], 0120, ind); + /*obfuscated, eh? */goto vhjsgfdy1l1gjhd; -c0g0:n = cd & 0x40000000L >> 0x1e; - goto cOgO; -g6w: - if (x != 0x2e) - { - i++; - goto c0gO; - } - else /* - injail */ - yank ('\n'); - goto vhjsgfdyl1lgjhd; -cOg0: - f = u[m][gi]; - goto b; -bl:m = (i + 1) * (4 * x + 3 * f) % 032; - gi = (i + 1) * (x + 2 * f) % 0x1a; - goto g6w; -hxi:cd ^= n = cd & (7 << 3 * (014 - ++ri)); - n >>= 3 * (12 - ri); - goto bl; -vhjsgfdyl1lgjhd:; -} + c0g0 : n=cd&0x40000000L>>0x1e; + goto cOgO; g6w: + if(x!=0x2e){i++;goto c0gO;}else /* +injail*/yank('\n');goto vhjsgfdyl1lgjhd; +cOg0 : +f=u[m][gi];goto b;bl:m=(i+1)*(4* +x+3*f)%032;gi=(i+1)*(x+2*f)%0x1a; goto g6w; + hxi:cd^= n= cd&(7<<3*(014-++ri)); +n >>=3*(12-ri); goto bl;vhjsgfdyl1lgjhd:;} diff --git a/1991/cdupont/cdupont.alt2.c b/1991/cdupont/cdupont.alt2.c index 94390b60f..6b3b72426 100644 --- a/1991/cdupont/cdupont.alt2.c +++ b/1991/cdupont/cdupont.alt2.c @@ -1,23 +1,64 @@ + /* common sense to nohonest programmer */ #include -main(){int x ,gi=4,i,f,ri=1,httxkbl=1,m=012;long cd=0x5765248d,n; - char u[0x50][032];FILE *ind; - ind=fopen(s,t); for(i=0; i<0x1a; i++){goto daswjhkls;vhjsgfdy1l1gjhd:;} -/*borntorun.*/goto c0g0;cOgO:i=0;fclose(ind);c0gO: -x= u [gi][m]; - if( m==gi){x=0x70;f=0x68;}else goto cOg0 ; b:putchar(x); if( -!(n-httxkbl++)) +main () +{ + int x, gi = 4, i, f, ri = 1, httxkbl = 1, m = 012; + long cd = 0x5765248d, n; + char u[0x50][032]; + FILE *ind; + ind = fopen (s, t); + for (i = 0; i < 0x1a; i++) + { + goto daswjhkls; + vhjsgfdy1l1gjhd:; + } +/*borntorun.*/ goto c0g0; +cOgO:i = 0; + fclose (ind); +c0gO: + x = u[gi][m]; +sorryfor_this_unused_but_very_needed_label: + if (m == gi) + { + x = 0x70; + f = 0x68; + } + else + goto cOg0; +b:putchar (x); + if (!(n - httxkbl++)) #define yank(x) putchar(x) - {httxkbl=1; yank(' ');goto - hxi;}goto bl; - daswjhkls: fgets(u[i], 0120, ind); - /*obfuscated, eh? */goto + { + httxkbl = 1; + yank (' '); + goto hxi; + } + goto bl; + /* hardlyundrstandable, but + likely to be missed if removed */ +daswjhkls:fgets (u[i], 0120, ind); + /*obfuscated, eh? */ goto vhjsgfdy1l1gjhd; - c0g0 : n=cd&0x40000000L>>0x1e; - goto cOgO; g6w: - if(x!=0x2e){i++;goto c0gO;}else /* -injail*/yank('\n');goto vhjsgfdyl1lgjhd; -cOg0 : -f=u[m][gi];goto b;bl:m=(i+1)*(4* -x+3*f)%032;gi=(i+1)*(x+2*f)%0x1a; goto g6w; - hxi:cd^= n= cd&(7<<3*(014-++ri)); -n >>=3*(12-ri); goto bl;vhjsgfdyl1lgjhd:;} +c0g0:n = cd & 0x40000000L >> 0x1e; + goto cOgO; +g6w: + if (x != 0x2e) + { + i++; + goto c0gO; + } + else /* + injail */ + yank ('\n'); + goto vhjsgfdyl1lgjhd; +cOg0: + f = u[m][gi]; + goto b; +bl:m = (i + 1) * (4 * x + 3 * f) % 032; + gi = (i + 1) * (x + 2 * f) % 0x1a; + goto g6w; +hxi:cd ^= n = cd & (7 << 3 * (014 - ++ri)); + n >>= 3 * (12 - ri); + goto bl; +vhjsgfdyl1lgjhd:; +} diff --git a/1991/cdupont/cdupont.alt3.c b/1991/cdupont/cdupont.alt3.c deleted file mode 100644 index 6b3b72426..000000000 --- a/1991/cdupont/cdupont.alt3.c +++ /dev/null @@ -1,64 +0,0 @@ - /* common sense to nohonest programmer */ -#include -main () -{ - int x, gi = 4, i, f, ri = 1, httxkbl = 1, m = 012; - long cd = 0x5765248d, n; - char u[0x50][032]; - FILE *ind; - ind = fopen (s, t); - for (i = 0; i < 0x1a; i++) - { - goto daswjhkls; - vhjsgfdy1l1gjhd:; - } -/*borntorun.*/ goto c0g0; -cOgO:i = 0; - fclose (ind); -c0gO: - x = u[gi][m]; -sorryfor_this_unused_but_very_needed_label: - if (m == gi) - { - x = 0x70; - f = 0x68; - } - else - goto cOg0; -b:putchar (x); - if (!(n - httxkbl++)) -#define yank(x) putchar(x) - { - httxkbl = 1; - yank (' '); - goto hxi; - } - goto bl; - /* hardlyundrstandable, but - likely to be missed if removed */ -daswjhkls:fgets (u[i], 0120, ind); - /*obfuscated, eh? */ goto - vhjsgfdy1l1gjhd; -c0g0:n = cd & 0x40000000L >> 0x1e; - goto cOgO; -g6w: - if (x != 0x2e) - { - i++; - goto c0gO; - } - else /* - injail */ - yank ('\n'); - goto vhjsgfdyl1lgjhd; -cOg0: - f = u[m][gi]; - goto b; -bl:m = (i + 1) * (4 * x + 3 * f) % 032; - gi = (i + 1) * (x + 2 * f) % 0x1a; - goto g6w; -hxi:cd ^= n = cd & (7 << 3 * (014 - ++ri)); - n >>= 3 * (12 - ri); - goto bl; -vhjsgfdyl1lgjhd:; -} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 688d9d332..9b3dc5e95 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1098,15 +1098,15 @@ more useful way to exit, just entering `q` followed by enter. ## [1991/cdupont](1991/cdupont/cdupont.c) ([README.md](1991/cdupont/README.md])) -Cody provided [three alternate](1991/cdupont/README.md#alternate-code) versions -that allow one to see what would happen if one were to beautify the program or -remove a `goto` label or a comment that was in the original code. This required -changing the `s` macro to be `__FILE__` (which is more reliable anyway) as -otherwise it would read in the original code and not demonstrate the problem. -[One version](1991/cdupont/cdupont.alt2.c) has the comments and unused `goto` -label removed and [the other](1991/cdupont/cdupont.alt.c) has the comments and -label removed and it is also beautified. The [third -one](1991/cdupont/cdupont.alt3.c) is just beautified. +Cody provided [two alternate](1991/cdupont/README.md#alternate-code) versions to +see what would happen if certain things were done that were warned against: [one +that has an unused `goto` label and a comment +removed](1991/cdupont/cdupont.alt.c) and [another that was +beautified](1991/cdupont/cdupont.alt2.c). + +This required changing the `s` macro to be `__FILE__` (which is more reliable +anyway) as otherwise it would read in the original code and not demonstrate the +problem. ## [1991/davidguy](1991/davidguy/davidguy.c) ([README.md](1991/davidguy/README.md]))