From: "Joseph S. Myers" <joseph@codesourcery.com>
To: Shujing Zhao <pearly.zhao@oracle.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Paolo Carlini <paolo.carlini@oracle.com>
Subject: Re: [PATCH PR/42686] Align the help text output
Date: Wed, 10 Mar 2010 17:19:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.64.1003101656110.12539@digraph.polyomino.org.uk> (raw)
In-Reply-To: <4B976D51.8010705@oracle.com>
On Wed, 10 Mar 2010, Shujing Zhao wrote:
> +/* Expand the ROOM when the number of bytes of MSGSTR is larger than
> + the width in columns. */
> +
> +unsigned int
> +get_col_width (const char *msgstr, unsigned int room)
The comment on this function makes no sense to me at all. What does
"Expand the ROOM" mean? It sounds as if ROOM is a parameter passed by
reference that might be changed by the function - but that clearly isn't
the case for a parameter of type unsigned int. What are the semantics of
the operand ROOM? What are the semantics of the return value? (But see
below on how "the number of bytes of MSGSTR is larger than the width in
columns" is itself not a sensible concept for the code to be considering
in the first place.)
> + if (screen_cols != nbytes)
This comparison is conceptually confused. In logical terms, "columns" and
"bytes" are different data types that it does not make sense to compare.
It so happens that in the present C code they have the same static type so
the host compiler doesn't give an error for this comparison - but it is
still confused, and you need to arrange the code so it doesn't try to mix
different types like this. This means having a very clear notion of
whether a particular variable counts columns, bytes or characters, and of
how you do explicit computations of the number of each kind of object in a
particular part of a string, and no comparisons between counts of
different things.
--
Joseph S. Myers
joseph@codesourcery.com
next prev parent reply other threads:[~2010-03-10 17:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-25 10:32 Shujing Zhao
2010-02-25 16:34 ` Joseph S. Myers
2010-03-10 10:26 ` Shujing Zhao
2010-03-10 17:19 ` Joseph S. Myers [this message]
2010-03-12 11:34 ` Shujing Zhao
2010-03-12 17:09 ` Joseph S. Myers
2010-03-15 9:28 ` Shujing Zhao
2010-03-15 10:58 ` Shujing Zhao
2010-03-15 11:42 ` Joseph S. Myers
2010-03-17 7:57 ` Shujing Zhao
2010-03-17 12:50 ` Joseph S. Myers
2010-03-18 11:48 ` Shujing Zhao
2010-03-18 17:54 ` Joseph S. Myers
2010-03-19 11:43 ` Shujing Zhao
2010-03-19 13:44 ` Joseph S. Myers
2010-03-22 9:17 ` Shujing Zhao
2010-03-31 7:03 ` Shujing Zhao
2010-04-06 16:56 ` Joseph S. Myers
2010-04-13 11:32 ` Shujing Zhao
2010-04-15 21:54 ` Joseph S. Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.1003101656110.12539@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=paolo.carlini@oracle.com \
--cc=pearly.zhao@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).