git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] userdiff: update Ada patterns

From
Adrian Johnson <ajohnson@redneon.com>
Date
Feb 3, 2014, 11:30 UTC
Message-ID
<52EF7DC4.8060200@redneon.com>
In-Reply-To
<20140202233531.GE16196@sigill.intra.peff.net>
On 03/02/14 10:05, Jeff King wrote:
Show 13 quoted lines
> On Sun, Feb 02, 2014 at 09:21:56PM +1030, Adrian Johnson wrote:
>> - Fix bug in word regex for numbers
>> -	 "|[0-9][-+0-9#_.eE]"
>> +	 "|[-+0-9#_.eE]+"
> 
> This makes "E" or "_" a number. Is that right?
> 
> I think the intent of the original was "starts with a digit, and then
> has one or more of these other things after it". You do not describe the
> bug, but I guess it would be that it does not match obvious things like
> "5". Should it be "zero or more" instead, like:
> 
>   [0-9][-+0-9#_.eE]*
Yes, the original was missing the '*' at the end. 

I changed it to be similar to the number regexes used by the other builtin patterns which are of the form '[-+0-9#_.eE]+'.

> 
> ? Also, should -/+ be hoisted to the front?
> 
>   [-+]?[0-9][0-9#_.eE]*

The other builtins don't do this. But it is probably better to have [-+]?[0-9] at the front.

> Again, I am just guessing, as I am not familiar enough with Ada.
Ada numbers have the form:
- integers and reals eg 123, 1.23, 1e-2 ('.' can not be first)
- a '_' may be used between digits to improve readability eg 123_456
- base n (2 <= n <= 16) is of the form n#digits# eg 16#FFEF#
- base n numbers can include a radix point and/or an exponent
  eg 16#FF12.8#e-2
- Ada is case insensitive

After having another look I noticed it was missing the hex characters. The new number regex I am proposing is:

[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?

I kept exponents containing a +/- sign separate from the digits to prevent things like '1+2' from matching. I'll send an updated patch.

Show 7 quoted lines
> 
> -Peff
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Previous: Jeff KingNext: Adrian Johnson
Message 3 of 8 in “userdiff: update Ada patterns”
  1. userdiff: update Ada patternsAdrian Johnson, Feb 2, 2014
  2. Jeff KingFeb 2, 2014
  3. Adrian JohnsonFeb 3, 2014
  4. userdiff: update Ada patternsAdrian Johnson, Feb 3, 2014
  5. Junio C HamanoFeb 3, 2014
  6. Adrian JohnsonFeb 5, 2014
  7. Junio C HamanoFeb 5, 2014
  8. Jeff KingFeb 5, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.