Merge pull request #24 from xexyl/1987-heckbert

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-03-01 22:32:38 -08:00
commit 2ccc4486f5
4 files changed
+27 -34

No files matched your search

+3
View File
@@ -1,4 +1,7 @@
bar
bar.c
foo
foo.c
heckbert
ph
ph.c
+1 -9
View File
@@ -179,21 +179,13 @@ ALT_TARGET= ${PROG}.orig
all: ${DATA} ${TARGET}
@${TRUE}
.PHONY: alt data everything clean clobber nuke dist_clean \
.PHONY: data everything clean clobber nuke dist_clean \
install build love haste waste make easter_egg \
supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# alternative executable
#
alt: ${DATA} ${ALT_TARGET}
@${TRUE}
${PROG}.orig: ${PROG}.orig.c
@echo "NOTE: The original source may not compile using modern compilers."
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# data files
#
+23 -7
View File
@@ -7,23 +7,39 @@ Pixar
make all
NOTE: The original entry may be built with "make alt".
On System V systems, we had to compile with `-Dindex=strchr`.
To compile on a 16 bit machine, change 300000 to 30000.
## Judges' comments:
### Try:
ph 40 < ph.c > foo.c; cc foo.c -o ph
ph 20 < a_C_prog.c > bar.c; cc bar.c
./heckbert 40 < heckbert.c > ph.c; make ph
./ph 21 < heckbert.c > bar.c; make bar
# or more generally fold some other file at a positive column:
./ph col < file
Ask yourself what happens to `foo.md` if you try:
./ph 40 < README.md > foo.md
Folding at the wrong length may be equivalent to a "Spindle or Mutilate" operation. For example:
./heckbert 40 < heckbert.c > ph.c ; make ph ; ./ph 20 < heckbert.c > bar.c ; make bar
Try not to
[Fold, Spindle or Mutilate](https://repository.library.brown.edu/studio/item/bdr:788264/PDF/)
files. :-)
The judges used this program to fold up very long lines which the
BSD fold(1) was unable to process. This program has been added
to the contest tool chest.
On System V systems, compile with: `-Dindex=strchr`
To compile on a 16 bit machine, change 300000's to 30000.
NOTE: This entry requires a non-standard K&R C compiler to compile.
Copyright (c) 1987, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
-18
View File
@@ -1,18 +0,0 @@
#include <ctype.h>
#include <stdio.h>
#define _ define
#_ A putchar
#_ B return
#_ C index
char*r,c[300001],*d=">=<=!===||&&->++-->><<",*i,*l,*j,*m,*k,*n,*h,*y;e,u=1,v,w,
f=1,p,s,x;main(a,b)char**b;{p=a>1?atoi(b[1]):79;r=c+read(0,j=l=i=c,300000);v=g(
j,&m);for(k=m;v!=2;j=k,m=n,v=w,k=m){w=g(k,&n);if(v==1&&m-j==1&&*j==35)e&&A(10),
e=f=0;if(!f&&v==3&&(char*)C(j,10)<m)A(10),e=0,f=1;else if(v>2&&(u||w)&&(f||u)&&
(l-i>1||*i!=61||n-k>1||!C("-*&",*k)))continue;else if(v==3)if(f&&e+1+n-k>p&&e)A
(10),e=0;else A(32),e++;else{if(f&&e+m-j>p&&e)A(10),e=0;e+=m-j;k=j;while(k<m)A(
*k++);}i=j;l=m;u=v;}e&&A(10);}g(j,m)char*j,**m;{if(j>=r)B*m=j,2;s=isdigit(*j)||
*j==46&&isdigit(j[1]);for(h=j;h<r;h++)if(!isalnum(*h)&&*h!=95&&(!s||*h!=46)&&(!
s||h[-1]!=101&&h[-1]!=69||!C("+-",*h)))break;if(h>j)B*m=h,0;x=1;for(h=j;h<r&&C(
" \t\n",*h);h++);if(h>j)h--,x=3;if(*j==34||*j==39)for(h=j+1;h<r&&*h!=*j;h++)if(
*h==92)h++;for(y=d;*y&&strncmp(y,j,2);y+=2);if(*y)h=j+1;if(!strncmp("/*",j,2)){
h=j+2;while(*++h!=42||*++h!=47);x=4;}*m=h+1;B x;}