Re: [PATCH v3 1/2] t/helper: teach test-regex to report pattern errors (like REG_ILLSEQ)

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

 



Carlo Marcelo Arenas Belón  <carenas@xxxxxxxxx> writes:

> Based-on-patch-by: Junio C Hamano <gitster@xxxxxxxxx>

This is sufficiently different from what I suggested that I do not
deserve the above line, I would think.

> +	ret = regcomp(&r, pat, flags);
> +	if (ret) {
> +		if (silent)
> +			return ret;
> +
> +		regerror(ret, &r, errbuf, sizeof(errbuf));
> +		die("failed regcomp() for pattern '%s' (%s)", pat, errbuf);

Nice.

> +	}
> +	if (!str)
> +		return 0;
> +
> +	ret = regexec(&r, str, 1, m, 0);
> +	if (ret) {
> +		if (silent || ret == REG_NOMATCH)
> +			return ret;
> +
> +		regerror(ret, &r, errbuf, sizeof(errbuf));
> +		die("failed regexec() for subject '%s' (%s)", str, errbuf);
> +	}
>  
>  	return 0;
> +usage:
> +	usage("\ttest-tool regex --bug\n"
> +	      "\ttest-tool regex [--silent] <pattern>\n"
> +	      "\ttest-tool regex [--silent] <pattern> <string> [<options>]");
> +	return -1;
>  }




[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]

  Powered by Linux