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

Re: [PATCH 1/1] Fix date checking in case if time was not initialized.

From
Mike Gorchak <mike.gorchak.qnx@gmail.com>
Date
Feb 25, 2013, 19:32 UTC
Message-ID
<CAHXAxrOjSS5jGLcCw4KTxP_F_uRQhi0cPSvzbx58jx9dP25XPA@mail.gmail.com>
In-Reply-To
<7vr4k4xlie.fsf@alter.siamese.dyndns.org>
> The thing that puzzles me is that nobody reported that the following
> fail on their platforms (and they do not fail for me on platforms I
> have to test in my real/virtual boxes).

Ok, check_parse calls function parse_date(), it calls parse_date_basic(), where following code is present:

	memset(&tm, 0, sizeof(tm));
	tm.tm_year = -1;
	tm.tm_mon = -1;
	tm.tm_mday = -1;
	tm.tm_isdst = -1;
	tm.tm_hour = -1;
	tm.tm_min = -1;
	tm.tm_sec = -1;

Almost all fields are set to -1. A bit later match_multi_number() is called. It parses the date and calls is_date() with partially filled tm structure, where all time fields: tm_hour, tm_min, tm_sec are set to -1. tm_to_time_t() function is called by is_date() and has special check:

	if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_sec < 0)
		return -1;

So is_date() always return negative result for the text string where date is placed before time like '2008-02-14 20:30:45'. It must fail on other platforms as well.

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 9 in “Fix date checking in case if time was not initialized.”
  1. 1/1 Fix date checking in case if time was not initialized.Mike Gorchak, Feb 25, 2013
  2. Junio C HamanoFeb 25, 2013
  3. Mike GorchakFeb 25, 2013
  4. Junio C HamanoFeb 25, 2013
  5. Mike GorchakFeb 25, 2013
  6. Junio C HamanoFeb 25, 2013
  7. Mike GorchakFeb 25, 2013
  8. Junio C HamanoFeb 25, 2013
  9. Mike GorchakFeb 26, 2013

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.