From f882ea84dd356fd39d78f4136ceed190eae3fe6b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 19 Oct 2023 05:19:58 -0700 Subject: [PATCH] Fix infinite loop in 1989/ovdluhe As Landon said it is a bug (after I asked about it) I have fixed it. Without this fix the program printed the same thing over and over again in some cases. The problem was a for() loop that didn't always have the pointer incremented. It looks like I could have got away with just updating the increment part of the loop but I didn't do that as I didn't see it at first. The optimiser was disabled. That might not be strictly necessary but I had it disabled for a time so I have kept it disabled. Also I removed my name in the README.md: this was missed when the much better idea of a general thanks file was come up with. When testing the fix I came across part of my name which made me check. I have not yet typo/format checked this file or any of 1989 so that was not done. That might or might not happen in part or in whole later today but either way it'll be started soon. --- 1989/ovdluhe/Makefile | 2 +- 1989/ovdluhe/README.md | 4 ++-- 1989/ovdluhe/ovdluhe.alt.c | 2 +- 1989/ovdluhe/ovdluhe.c | 2 +- thanks-for-fixes.md | 12 ++++++++++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/1989/ovdluhe/Makefile b/1989/ovdluhe/Makefile index e8f7941c4..547c1cb8a 100644 --- a/1989/ovdluhe/Makefile +++ b/1989/ovdluhe/Makefile @@ -68,7 +68,7 @@ CINCLUDE= # Optimization # -OPT= -O3 +OPT= # Default flags for ANSI C compilation # diff --git a/1989/ovdluhe/README.md b/1989/ovdluhe/README.md index 47cd148e4..1f8b6959a 100644 --- a/1989/ovdluhe/README.md +++ b/1989/ovdluhe/README.md @@ -38,8 +38,7 @@ by chance or is killed. ### Alternate code: The author suggested that one varies the definition of `P` from 2 through 10. As -it's a `#define` it's easy to set up which [Cody Boone -Ferguson](/winners.html#Cody_Boone_Ferguson) did for us. To use try: +it's a `#define` it's easy to set up. To use try: ```sh make CFLAGS="-DP=9" clobber alt @@ -47,6 +46,7 @@ make CFLAGS="-DP=9" clobber alt Use `ovdluhe.alt` as you would `ovdluhe`. + ## Judges' remarks: Run this program using your favorite text file as input. Files diff --git a/1989/ovdluhe/ovdluhe.alt.c b/1989/ovdluhe/ovdluhe.alt.c index 9aad1945e..d830af7db 100644 --- a/1989/ovdluhe/ovdluhe.alt.c +++ b/1989/ovdluhe/ovdluhe.alt.c @@ -20,7 +20,7 @@ main(){ape pe,*ep=a;srand((EP)time((long)E)); while(((*(ep++)=getchar())!=-A)&&((ep-a)