SCOUG-Programming Mailing List Archives
Return to [ 02 |
June |
1998 ]
<< Previous Message <<
>> Next Message >>
Content Type: text/plain
Emerson, Tom # GPS-MDI wrote:
A lot. But it summarizes to "the heck with what's in the buffer, what
does getline() give us?"
Personally, I prefer to receive two character strings -- the "line" and
the delimiter string that followed the line (NL, CR-LF, FF, also I
sometimes see CR-CR-LF and LF-CR, and of course EOF or TIMEOUT [thanks
Tom, I would have missed TIMEOUT had you not mentioned it]). Note that
NL and CR are the same hex character, so you need to "look ahead" to see
how long your delimiter string really is.
When I've written code to pull strings out of buffers, I set up a table
of all possible delimiter strings, arrange the table longest-to-shortest
(so I won't have any "dangling delimiters" which you can get if you
check for NL before you check for CR-LF because the LF will be left
behind), and return the line string and the delimiter string. Code
would be a little faster if you used if-then-else logic to extract the
delimiter string (although if somebody sent you CR-CR-CR-CR-LF that's
technically one line only from a TT viewpoint). If you're lazy, just
check for any character less than 20h, and then extract all characters
that are less than 20h (i.e. getstring() returns all ASCII display
characters plus RUBOUT and above, plus a delimiter string of all
characters less than SP [SPACE]).
And what if somebody else is writing an FTP client, and they send you BS
(backspace) characters? Should we handle them in getstring(), or just
blow out the command as containing an invalid character, or what?
Tom says, quite correctly, that we need a definition. We can each write
our own version of getstring() (the code is quite simple), but we should
at least all agree on the options and then implement just what we
individually want.
I think you should at least allow (in the options) for multiple lines
and implementation of BS (backspace). The delimiter string can be any
string of one or more of {0Dh, 0Ah, 0Ch}, and any other control
characters (which includes 7Fh) or characters >= 80h are simply
discarded. This does mean a character-by-character examination of the
buffer data.
- Peter Skye
=====================================================
To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".
For problems, contact the list owner at
"rollin@scoug.com".
=====================================================
<< Previous Message <<
>> Next Message >>
Return to [ 02 |
June |
1998 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|