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

Re: [PATCH] general style: replaces memcmp() with starts_with()

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 12, 2014, 13:51 UTC
Message-ID
<CACsJy8DUhqn_ESzT-KpAdrWvWcLbPUiXDmBZXu7UtHU+M0GLgw@mail.gmail.com>
In-Reply-To
<1394631854-11208-1-git-send-email-quintus.public@gmail.com>

On Wed, Mar 12, 2014 at 8:44 PM, Quint Guvernator <quintus.public@gmail.com> wrote:

Show 13 quoted lines
> diff --git a/builtin/apply.c b/builtin/apply.c
> index a7e72d5..8f21957 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -846,8 +846,8 @@ static int has_epoch_timestamp(const char *nameline)
>          * YYYY-MM-DD hh:mm:ss must be from either 1969-12-31
>          * (west of GMT) or 1970-01-01 (east of GMT)
>          */
> -       if ((zoneoffset < 0 && memcmp(timestamp, "1969-12-31", 10)) ||
> -           (0 <= zoneoffset && memcmp(timestamp, "1970-01-01", 10)))
> +       if ((zoneoffset < 0 && starts_with(timestamp, "1969-12-31")) ||
> +           (0 <= zoneoffset && starts_with(timestamp, "1970-01-01")))
>                 return 0;

It is not a plain search/replace. starts_with(..) == !memcmp(...). So you need to negate every replacement.

-- 
Duy
Previous: Quint GuvernatorNext: Quint Guvernator
Message 2 of 10 in “general style: replaces memcmp() with starts_with()”
  1. general style: replaces memcmp() with starts_with()Quint Guvernator, Mar 12, 2014
  2. Duy NguyenMar 12, 2014
  3. Quint GuvernatorMar 12, 2014
  4. Michael HaggertyMar 13, 2014
  5. Quint GuvernatorMar 14, 2014
  6. Jens LehmannMar 12, 2014
  7. Quint GuvernatorMar 12, 2014
  8. Jens LehmannMar 12, 2014
  9. Jeff KingMar 12, 2014
  10. Duy NguyenMar 12, 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.