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

Re: [PATCH] [Outreachy] git/userdiff.c fix regex pattern error

From
AMAnanya Krishna Maram <ananyakittu1997@gmail.com>
Date
Oct 4, 2018, 09:35 UTC
Message-ID
<CA+=o6KFN-p901GiJzj5BquU2RKCVTOKarGpjjuqsASN_uqGZSQ@mail.gmail.com>
In-Reply-To
<nycvar.QRO.7.76.6.1810041624290.73@tvgsbejvaqbjf.bet>

On Thu, 4 Oct 2018 at 19:56, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 15 quoted lines
>
> Hi Ananya,
>
> thank you for taking the time to write this patch!
>
> On Thu, 4 Oct 2018, Ananya Krishna Maram wrote:
>
> > the forward slash character should be escaped with backslash. Fix
> > Unescaped forward slash error in Python regex statements.
> >
> > Signed-off-by: Ananya Krishna Maram<ananyakittu1997@gmail.com>
>
> That explains pretty well what you did, but I wonder why the forward slash
> needs to be escaped? I would understand if we enclosed the pattern in
> `/<regex>/`, as it is done e.g. in Javascript, but we do not...

You are correct, the code would execute either ways. But when I came across this line, I didn't get it's meaning instantly because as per standards, forward slash has to be escaped. In fact when open source code is written according to standards, the code will be reachable to more people.

Thanks, Ananya.

Show 24 quoted lines
> Thanks,
> Johannes
>
> > ---
> >  userdiff.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/userdiff.c b/userdiff.c
> > index f565f6731..f4ff9b9e5 100644
> > --- a/userdiff.c
> > +++ b/userdiff.c
> > @@ -123,7 +123,7 @@ PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$",
> >        /* -- */
> >        "[a-zA-Z_][a-zA-Z0-9_]*"
> >        "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
> > -      "|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"),
> > +      "|[-+*\/<>%&^|=!]=|\/\/=?|<<=?|>>=?|\\*\\*=?"),
> >        /* -- */
> >  PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$",
> >        /* -- */
> > --
> > 2.17.1
> >
> >
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 9 in “[Outreachy] git/userdiff.c fix regex pattern error”
  1. [Outreachy] git/userdiff.c fix regex pattern errorAnanya Krishna Maram, Oct 4, 2018
  2. Johannes SchindelinOct 4, 2018
  3. Ananya Krishna MaramOct 4, 2018
  4. Johannes SchindelinOct 4, 2018
  5. Ananya Krishna MaramOct 4, 2018
  6. Johannes SchindelinOct 4, 2018
  7. Junio C HamanoOct 6, 2018
  8. Johannes SchindelinOct 12, 2018
  9. Junio C HamanoOct 12, 2018

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.