Re: [PATCH 24/29] grep: move two functions to avoid forward declaration

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

 



On 05/11, Ævar Arnfjörð Bjarmason wrote:
> Move the is_fixed() and has_null() functions which are currently only
> used in compile_regexp() earlier so they can be used in the PCRE
> family of functions in a later change.
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
> ---
>  grep.c | 46 +++++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/grep.c b/grep.c
> index 4507765811..5c808f8971 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -321,6 +321,29 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p,
>  	die("%s'%s': %s", where, p->pattern, error);
>  }
>  
> +static int is_fixed(const char *s, size_t len)
> +{
> +	size_t i;
> +
> +	for (i = 0; i < len; i++) {
> +		if (is_regex_special(s[i]))
> +			return 0;
> +	}
> +
> +	return 1;
> +}
> +
> +static int has_null(const char *s, size_t len)
> +{
> +	/* regcomp cannot accept patterns with NULs so when using it
> +	 * we consider any pattern containing a NUL fixed.
> +	 */

Since you're already moving these functions, mind cleaning up the
comment to conform to our style guide?

> +	if (memchr(s, 0, len))
> +		return 1;
> +
> +	return 0;
> +}
> +
>  #ifdef USE_LIBPCRE1
>  static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
>  {
> @@ -390,29 +413,6 @@ static void free_pcre1_regexp(struct grep_pat *p)
>  }
>  #endif /* !USE_LIBPCRE1 */
>  
> -static int is_fixed(const char *s, size_t len)
> -{
> -	size_t i;
> -
> -	for (i = 0; i < len; i++) {
> -		if (is_regex_special(s[i]))
> -			return 0;
> -	}
> -
> -	return 1;
> -}
> -
> -static int has_null(const char *s, size_t len)
> -{
> -	/* regcomp cannot accept patterns with NULs so when using it
> -	 * we consider any pattern containing a NUL fixed.
> -	 */
> -	if (memchr(s, 0, len))
> -		return 1;
> -
> -	return 0;
> -}
> -
>  static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)
>  {
>  	struct strbuf sb = STRBUF_INIT;
> -- 
> 2.11.0
> 

-- 
Brandon Williams



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]