[Info-vax] Whither VMS?
Tim E. Sneddon
tim.sneddon at bigpond.com
Tue Oct 6 00:34:50 EDT 2009
glen herrmannsfeldt wrote:
> JF Mezei <jfmezei.spamnot at vaxination.ca> wrote:
> < Re: C and buffer overflows.
>
> < Is there a language which keeps 2 values for each string: amount
> < allocated and amount currently in use ?
As Glen points out PL/I does support this as part of the language.
VMS also has the descriptor type of DSC$K_DTYPE_VT. This is a
descriptor that keeps the maximum length in DSC$W_LENGTH while
maintaining the actual length as the first word of the buffer
pointed at by DSC$A_POINTER.
>
> < Without such 2 values, you can't have totally save "read" and "write"
> < into that variable. When you write, you need to know how many bytes you
> < can write, and when you read, you need to know how many bytes were
> < written to it.
>
> I believe that PL/I does it. In the implementations that I know of,
> as well as I remember, the allocated length is known in the procedure
> and passed in a descriptor (dope vector) on calls. The current
> length is at the beginning of the string. Note, for example, that
> for an array (in most languages) all elements have the same
> allocated length but possibly different current length.
Correct. For OpenVMS the format of a varying string matches
that used by other languages, like Pascal. The layout is
detailed here:
http://www.kednos.com/pli/docs/REFERENCE_MANUAL/6291pro_009.html#vary_data
The built-in function LENGTH(string) provides the current length
of string. Whereas MAXLENGTH(string) returns the maximum. To
get this functionality the string needs to be declared with
the VARYING attribute.
Tim.
More information about the Info-vax
mailing list