Article View: comp.lang.postscript
Article #1777PS Lang Help!!!!
From: John Tassi
Date: Fri, 14 Aug 1992 21:43
Date: Fri, 14 Aug 1992 21:43
50 lines
2022 bytes
2022 bytes
I need a postscript function that will duplicate the C function below. It's
an I/O test, what it does is read the standard input for an increasing
sequence of characters. If a character is out of sequence count it. Valid
characters are 0x20 to 0x7f, and it wraps around from 0x7f to 0x20. That
is, look for the sequence 20, 21, 22, 23, ..., 7e, 7f, 20, 21.....
#include <stdio.h>
#define LOW_CHAR 0x20
#define HIGH_CHAR 0x7f
main()
{
int received = 0, index = LOW_CHAR;
unsigned char ch;
int failed = 0;
while( (ch = getchar()) != EOF){
received++;
if(ch != index){
failed++;
/*
* Assume we dropped a char or two and sync up again.
*/
if( (ch >= LOW_CHAR) && (ch <= HIGH_CHAR) )
index = ch;
}
if(++index > HIGH_CHAR)
index = LOW_CHAR;
}
printf("Received %d bad chars out of a total of %d\n", failed, received);
}
Thanks in advance ...
____________ ____________
///////////// \\\\\\\\\\\\\
John Tassi /------///-/ \---\\\-----\
Senior Software Engineer /// \\\
Systech Corporation /// \\\
jt@systech.com /// \\\
/// \\\
voice (619)453-7400 __ /// \\\
Ext #239 \\\ /// _ \\\ _ __ __ *
\\\_/// | | |_| |\ | \\\ |_| |_ |_ |
\//// |_| | | | \| \\\ | | __| __| |
Technical Details
Message-ID:
<1398@systech.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!usc!news!systech!jtShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!usc!news!systech!jt From: jt@systech.com (John Tassi) Newsgroups: comp.lang.postscript Subject: PS Lang Help!!!! Message-ID: <1398@systech.com> Date: 14 Aug 92 21:43:15 GMT Organization: Systech Corp., San Diego, CA Lines: 50