Re: [PATCH] Allow a hyphenated range in get_options

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

 



On Tue, Oct 31, 2006 at 11:25:16AM -0600, Derek Fults wrote:
> This allows a hyphenated range of positive numbers in the string passed
> to command line helper function, get_options.

Please, find in-tree code which could use this feature. After you have
done it address comments below and resend series with this patch going
first, conversions going next.

> --- linux.orig/lib/cmdline.c
> +++ linux/lib/cmdline.c
> @@ -29,6 +29,10 @@
>   *	0 : no int in string
>   *	1 : int found, no subsequent comma
>   *	2 : int found including a subsequent comma
> + *  -(int): int found with a subsequent hyphen to denote a range.
> + *          The negative number is the number of integers in the range
> + *          used to increment the counter in the while loop.
> + *      
>   */

Comment mentions irrelevant implementations details. trailing whitespace

> @@ -44,7 +48,16 @@
>  		(*str)++;
>  		return 2;
>  	}
> +	if (**str == '-') {
> +	    int x,inc_counter= 0, upper_range = 0;
>  
> +	    (*str)++;
> +	    upper_range = simple_strtol ((*str), NULL, 0);
> +	    inc_counter = upper_range - *pint ;
> +	    for (x=*pint; x < upper_range; x++) 
> +		    *pint++ = x;
> +	    return -inc_counter;
> +	}

coding style.

> @@ -55,7 +68,8 @@
>   *	@ints: integer array
>   *
>   *	This function parses a string containing a comma-separated
> - *	list of integers.  The parse halts when the array is
> + *	list of integers, a hyphen-separated range of _positive_ integers,
> + *      or a combination of both.  The parse halts when the array is
>   *	full, or when no more numbers can be retrieved from the
>   *	string.
>   *
> @@ -75,6 +89,11 @@
>  		i++;
>  		if (res == 1)
>  			break;
> +		if (res < 0) 
> +		        /* Decrement the result by one to leave out the 
> +			   last number in the range.  The next iteration 
> +			   will handle the upper number in the range */
> +		        i += ((-res) - 1);

trailing whitespace

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux