From mboxrd@z Thu Jan 1 00:00:00 1970 From: rae l Date: Mon, 13 Aug 2007 17:19:41 +0800 Subject: [Cluster-devel] Re: [PATCH] gfs2: better code for translating characters In-Reply-To: <46BFF179.8060308@zytor.com> References: <11869741183677-git-send-email-crquan@gmail.com> <91b13c310708122008w27b86359n5b135df3e229e616@mail.gmail.com> <46BFDDBB.2020104@zytor.com> <91b13c310708122206v5e4023f2w7464611a96ae67d9@mail.gmail.com> <46BFF179.8060308@zytor.com> Message-ID: <91b13c310708130219j170190f6r100c47171f92077@mail.gmail.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 8/13/07, H. Peter Anvin wrote: > You seem to have confused modern compiled C with an old BASIC interpreter. > > Consider the code in point: > > - while ((table = strchr(sdp->sd_table_name, '/'))) > + table = sdp->sd_table_name; > + while ((table = strchr(table, '/'))) > *table = '_'; Sorry, I just mean for call to strchr, things are different, especially for multiple '/' chars appeared. The while loop's purpose is to translate all '/' chars appeared in sdp->sd_table_name to '_' chars, consider the string: 'a////aa/a/a/...' if strchr called with sdp->sd_table_name, every strchr would begun at index 0 of the string, but if called with table, every strchr begun at the last searched position. So I wonder the common case is no existence of '/', or just one or multiple existence? Things are different for these cases.