[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] Re: [PATCH] gfs2: better code for translating characters



Hi,

On Mon, 2007-08-13 at 17:19 +0800, rae l wrote:
> On 8/13/07, H. Peter Anvin <hpa zytor com> 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.
The common case is for there to be a few '/' characters since the table
name is often the name of the device upon which the fs is mounted,
e.g. /dev/sda so it general its not going to be a long string or have
many '/' in it,

Steve.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]