On Sun, Apr 04, 2010 at 10:55:26AM -0000, dan...@apache.org wrote:
> Author: dannas
> Date: Sun Apr  4 10:55:25 2010
> New Revision: 930662
> 
> URL: http://svn.apache.org/viewvc?rev=930662&view=rev
> Log:
> Make 'svn patch' able to remove dirs beeing empty after patching, taking
> into account both versioned and unversioned files and dirs.
> 

> +
> +/* Compare A and B and return an integer greater than, equal to, or less
> + * than 0, according to whether A has less subdirs, just as many or more
> + * subdir than B. That means that the path with the most subdirs is placed
> + * first. */
> +static int
> +sort_compare_nr_of_path_elements(const svn_sort__item_t *a, 
> +                                 const svn_sort__item_t *b)
> +{
> +  const char *astr, *bstr;
> +  int n_a = 0, n_b = 0, i;
> +  
> +  astr = a->key;
> +  bstr = b->key;
> +
> +  for (i = 0; i < a->klen; i++)
> +    if (astr[i] == '/')
> +      n_a++;

Drive-by review (will look more closely later):

Maybe use svn_path_component_count() here?
And rename sort_compare_nr_of_path_elements() to
sort_compare_path_component_count()? (I tend to prefer function names
consisting of proper words...)

Stefan

> +
> +  for (i = 0; i < b->klen; i++)
> +    if (bstr[i] == '/')
> +      n_b++;
> +
> +  if (n_a > n_b)
> +    return -1;
> +  else if (n_a == n_b)
> +    return 0;
> +  else
> +    return 1;
> +}

Reply via email to