home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!ds5000!cschmidt
- From: cschmidt@ds5000.DAC.Northeastern.edu (Christopher Schmidt)
- Newsgroups: comp.lang.pascal
- Subject: Re: LENGTH and POS in TP 5.5
- Message-ID: <7379@ds5000.DAC.Northeastern.edu>
- Date: 10 Sep 92 22:24:47 GMT
- Reply-To: cschmidt@ds5000 (Christopher Schmidt)
- Organization: Leelanau Computing Inc
- Lines: 30
-
- > > The TP 5.5 documentation says the LENGTH function returns a value
- > > of type integer. Apparently, it actually returns a value of type
- > > byte.
- >
- > Clearly the easiest fix would be to change the manuals so that Length
- > and Pos are properly documented; what would be the problem in that?
-
- Ok fine.
-
- Got several mail messages from folks wondering why this matter caused
- a problem the first place. I had written a general purpose function
- that allocates storage for a string, using the following expression to
- calculate the amount of storage required, where "s" is the formal
- parameter containing the string for which space is to be allocated:
-
- succ (length (s))
-
- This expression works fine unless the length of "s" is 255, in which
- case this expression returns zero.
-
- One of my programs uses my string-allocation function to store lines
- from an input text file. The program ran correctly until one day I
- (accidentally) used my program to read a binary file, which meant the
- input buffer sometimes contained strings of length 255, which had
- never happened when reading standard text files. The program blew up
- when it later tried to deallocate a block of memory of length zero.
-
- Christopher Schmidt
- Waltham, Massachusetts, USA
- cschmidt@lynx.northeastern.edu
-