Re: Terminology concerning strings
- From: Pavel Tsekov <ptsekov gmx net>
- To: Roland Illig <roland illig gmx de>
- Cc: MC Devel <mc-devel gnome org>
- Subject: Re: Terminology concerning strings
- Date: Mon, 28 Mar 2005 18:39:13 +0300
Hello,
On Mon, 4 Apr 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.
>
> * the _length_ of a string is the number of characters in it, excluding
> the terminating '\0'.
Wow! Btw you speak of null terminated strings here. The length of the
string is always the number of characters in it no matter how do you
represent a string. As about the size it depends on the string
implementation.
> 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.
>
> Example:
> char *fname = g_strdup (s);
> size_t fnamewidth, fnameheight, fnamesize, fnamelen;
My personal preference is to prepend an underscore to the property
tag i.e:
`fname_width' instead of `fnamewidth'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]