[comp.sources.games] v08i079: travesty - make a travesty of the input, Patch1

billr@saab.CNA.TEK.COM (Bill Randle) (01/06/90)

Submitted-by: Dan Bernstein <brnstnd@stealth.acf.nyu.edu>
Posting-number: Volume 8, Issue 79
Archive-name: travesty/Patch1
Patch-To: travesty: Volume 8, Issue 75

	[This patch fixes the non-portable bcmp used in version 1.0.
	 It now works correctly on BSD based machines.  -br]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  patches01
# Wrapped by billr@saab on Fri Jan  5 13:15:32 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'patches01' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patches01'\"
else
echo shar: Extracting \"'patches01'\" \(6907 characters\)
sed "s/^X//" >'patches01' <<'END_OF_FILE'
X*** ../../travesty/CHANGES	Wed Dec 20 10:05:45 1989
X--- CHANGES	Thu Jan  4 16:09:38 1990
X***************
X*** 1 ****
X--- 1,5 ----
X+ travesty version 1.1, 12/23/89.
X+ 
X+ Changed cmp() to a slow, portable, inline version. Is ctoi() guaranteed?
X+ 
X  travesty version 1.0, 12/17/89.
X*** ../../travesty/README	Wed Dec 20 10:05:46 1989
X--- README	Thu Jan  4 16:09:39 1990
X***************
X*** 1,10 ****
X  travesty - make a travesty of the input
X  
X! travesty version 1.0, 12/17/89.
X  Copyright (c) 1989, Daniel J. Bernstein.
X  All rights reserved.
X  
X! This distribution packaged 12/17/89.
X  
X  Files:
X  CHANGES         Description of changes since first distributed version
X--- 1,10 ----
X  travesty - make a travesty of the input
X  
X! travesty version 1.1, 12/23/89.
X  Copyright (c) 1989, Daniel J. Bernstein.
X  All rights reserved.
X  
X! This distribution packaged 12/23/89.
X  
X  Files:
X  CHANGES         Description of changes since first distributed version
X*** ../../travesty/travesty.c	Wed Dec 20 10:05:49 1989
X--- travesty.c	Thu Jan  4 16:09:41 1990
X***************
X*** 7,22 ****
X  Internet address: brnstnd@acf10.nyu.edu.\n";
X  
X  static char travestyversion[] = 
X! "travesty version 1.0, 12/17/89.\n\
X  Copyright (c) 1989, Daniel J. Bernstein.\n\
X  All rights reserved.\n";
X  
X  static char travestycopyright[] =
X! "travesty version 1.0, 12/17/89.\n\
X  Copyright (c) 1989, Daniel J. Bernstein.\n\
X  All rights reserved.\n\
X  \n\
X! Until January 1, 1993, you are granted the following rights: A. To make\n\
X  copies of this work in original form, so long as (1) the copies are exact\n\
X  and complete; (2) the copies include the copyright notice, this paragraph,\n\
X  and the disclaimer of warranty in their entirety. B. To distribute this\n\
X--- 7,22 ----
X  Internet address: brnstnd@acf10.nyu.edu.\n";
X  
X  static char travestyversion[] = 
X! "travesty version 1.1, 12/23/89.\n\
X  Copyright (c) 1989, Daniel J. Bernstein.\n\
X  All rights reserved.\n";
X  
X  static char travestycopyright[] =
X! "travesty version 1.1, 12/23/89.\n\
X  Copyright (c) 1989, Daniel J. Bernstein.\n\
X  All rights reserved.\n\
X  \n\
X! Until January 1, 1994, you are granted the following rights: A. To make\n\
X  copies of this work in original form, so long as (1) the copies are exact\n\
X  and complete; (2) the copies include the copyright notice, this paragraph,\n\
X  and the disclaimer of warranty in their entirety. B. To distribute this\n\
X***************
X*** 26,32 ****
X  includes the copyright notice, this paragraph, and the disclaimer of\n\
X  warranty in their entirety. These rights are temporary and revocable upon\n\
X  written, oral, or other notice by Daniel J. Bernstein. These rights are\n\
X! automatically revoked on January 1, 1993. This copyright notice shall be\n\
X  governed by the laws of the state of New York.\n\
X  \n\
X  If you have questions about travesty or about this copyright notice,\n\
X--- 26,32 ----
X  includes the copyright notice, this paragraph, and the disclaimer of\n\
X  warranty in their entirety. These rights are temporary and revocable upon\n\
X  written, oral, or other notice by Daniel J. Bernstein. These rights are\n\
X! automatically revoked on January 1, 1994. This copyright notice shall be\n\
X  governed by the laws of the state of New York.\n\
X  \n\
X  If you have questions about travesty or about this copyright notice,\n\
X***************
X*** 89,99 ****
X  #include "djbatoi.h"
X  
X  /* The following macro had better make chars into ints from 0 thru 255. */
X- 
X  #define ctoi(x) ((unsigned int) (x))
X  #define copy(s,t,len) bcopy(s,t,len)
X- #define cmp(s,t,len) bcmp(s,t,len) /* had better return signed value! */
X  
X  #define ran(n) (((random() % n) + n) % n) /* idiotic % can be negative */
X  
X  #define MAXORD 20
X--- 89,111 ----
X  #include "djbatoi.h"
X  
X  /* The following macro had better make chars into ints from 0 thru 255. */
X  #define ctoi(x) ((unsigned int) (x))
X+ 
X  #define copy(s,t,len) bcopy(s,t,len)
X  
X+ int cmp(s,t,len) /* needs to return a signed value; bcmp() not portable */
X+ register char *s;
X+ register char *t;
X+ register int len;
X+ {
X+  while (len--)
X+    if (*s != *t)
X+      return((ctoi(*s) > ctoi(*t)) * 2 - 1);
X+    else
X+      s++,t++;
X+  return(0);
X+ }
X+ 
X  #define ran(n) (((random() % n) + n) % n) /* idiotic % can be negative */
X  
X  #define MAXORD 20
X***************
X*** 104,110 ****
X  int ord1;
X  int seed;
X  
X! int s[MAXORD + 1][257];
X  char *c;
X  int curc;
X  int *p;
X--- 116,122 ----
X  int ord1;
X  int seed;
X  
X! int s[MAXORD + 1][257]; /* dynamic? not worth it */
X  char *c;
X  int curc;
X  int *p;
X***************
X*** 143,178 ****
X      }
X  }
X  
X! sort(l,u,m)
X  register int l,u; /* we are useless if l == u; we crash if l > u */
X  register int m;
X  {
X   register int i;
X   register int ch;
X  
X   if (m > ord)
X     return;
X  
X   for (ch = 0; ch < 256; ch++)
X!    s[m][ch] = 0;
X  
X   for (i = l; i <= u; i++)
X!    s[m][ctoi(c[p[i] * ord1 + m])]++;
X  
X!  s[m][0] += l - 1;
X   for (ch = 1; ch < 256; ch++)
X!    s[m][ch] += s[m][ch - 1];
X  
X   for (i = u; i >= l; i--)
X!    q[s[m][ctoi(c[p[i] * ord1 + m])]--] = p[i]; /* trust me. */
X  
X   for (i = l; i <= u; i++)
X     p[i] = q[i];
X  
X!  s[m][256] = u;
X   for (ch = 0; ch < 256; ch++)
X!    if (s[m][ch] + 1 < s[m][ch + 1]) /* anything to save a procedure call */
X!      sort(s[m][ch] + 1,s[m][ch + 1],m + 1);
X  }
X  
X  zeroq()
X--- 155,191 ----
X      }
X  }
X  
X! sort(l,u,m) /* recursive */
X  register int l,u; /* we are useless if l == u; we crash if l > u */
X  register int m;
X  {
X   register int i;
X   register int ch;
X+  register int *sm = s[m];
X  
X   if (m > ord)
X     return;
X  
X   for (ch = 0; ch < 256; ch++)
X!    sm[ch] = 0;
X  
X   for (i = l; i <= u; i++)
X!    sm[ctoi(c[p[i] * ord1 + m])]++;
X  
X!  sm[0] += l - 1;
X   for (ch = 1; ch < 256; ch++)
X!    sm[ch] += sm[ch - 1];
X  
X   for (i = u; i >= l; i--)
X!    q[sm[ctoi(c[p[i] * ord1 + m])]--] = p[i]; /* trust me. */
X  
X   for (i = l; i <= u; i++)
X     p[i] = q[i];
X  
X!  sm[256] = u;
X   for (ch = 0; ch < 256; ch++)
X!    if (sm[ch] + 1 < sm[ch + 1]) /* anything to save a procedure call */
X!      sort(sm[ch] + 1,sm[ch + 1],m + 1);
X  }
X  
X  zeroq()
X***************
X*** 185,192 ****
X  
X  sigalrm()
X  {
X!  fprintf(stderr,"Seed: %d\n",seed);
X!  fflush(stderr);
X  }
X  
X  main(argc,argv,envp)
X--- 198,205 ----
X  
X  sigalrm()
X  {
X!  (void) fprintf(stderr,"Seed: %d\n",seed);
X!  (void) fflush(stderr);
X  }
X  
X  main(argc,argv,envp)
X*** ../../travesty/travesty.man	Wed Dec 20 10:05:48 1989
X--- travesty.man	Thu Jan  4 16:09:40 1990
X***************
X*** 109,115 ****
X  has been tested
X  on an Astronautics ZS-2 running ZSUnix.
X  .SH VERSION
X! travesty version 1.0, dated 12/17/89.
X  .SH AUTHOR
X  Copyright 1989, Daniel J. Bernstein.
X  .SH "SEE ALSO"
X--- 109,115 ----
X  has been tested
X  on an Astronautics ZS-2 running ZSUnix.
X  .SH VERSION
X! travesty version 1.1, dated 12/23/89.
X  .SH AUTHOR
X  Copyright 1989, Daniel J. Bernstein.
X  .SH "SEE ALSO"
END_OF_FILE
if test 6907 -ne `wc -c <'patches01'`; then
    echo shar: \"'patches01'\" unpacked with wrong size!
fi
# end of 'patches01'
fi
echo shar: End of shell archive.
exit 0