Terminology concerning strings
Roland Illig
roland.illig at gmx.de
Wed Apr 6 16:53:05 UTC 2005
Roland Illig wrote:
> Hi all,
>
> in the last time I have programmed a bit with strings, and I have found
> four properties of them which need to be distinguished and which should
> be named consistently throughout the whole Midnight Commander.
>
> * the _size_ of a string (as well as for other objects) is the number of
> bytes that is allocated for it. For arrays, it is the number of
> entries of the array. For strings it is at least _length_ + 1.
To clarify this item: I want to continue using '\0'-terminated strings,
and I also want to regard them as arrays. The second sentence above is a
bit misleading, so here's a second try.
* the _size_ of a string (which is regarded as an array of an arbitrary
character type) is the number of array elements that may be accessed.
> Currently these differences are not recognized by most of the code.
> Therefore I'd like to rename all matching variables according to this
> scheme: For the string variable s, the _size_ is called ssize, the
> _length_ is called slen, the _width_ is called swidth, and the _height_
> is called sheight.
Actually you are all right that s_size, s_length, s_width, and s_height
look better than without underscores. The idea of leaving out the
underscore originated in ecs_strlcpy, where I had the variables dst and
dstsize. In that case, the short name was not as hard to read as in
"real life" examples.
Roland
More information about the mc-devel
mailing list