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

Re: [PATCH v4 03/13] parseopt: make OPT_INTEGER support hexadecimal as well

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 4, 2012, 05:32 UTC
Message-ID
<7vobtfjh9d.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CACsJy8Ba2qxyT4XqeRmUv63Z3rT1-FmBkZ3tB6YMh6qrXjLP1Q@mail.gmail.com>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
Show 13 quoted lines
> 2012/2/4 Junio C Hamano <gitster@pobox.com>:
>> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>>
>>> -             *(int *)opt->value = strtol(arg, (char **)&s, 10);
>>> +             if (!prefixcmp(arg, "0x") || !prefixcmp(arg, "0X"))
>>> +                     *(int *)opt->value = strtol(arg + 2, (char **)&s, 16);
>>> +             else
>>> +                     *(int *)opt->value = strtol(arg, (char **)&s, 10);
>>
>> Can't you just do "strtol(arg, (char **)&s, 0)" instead?
>
> I could but that means "01234" is now in base 8 and that's currently
> accepted as base 10.

Yes, but I wonder if that is a problem in practice. Who in the right mind would give 00001000 to tell git that they want one thousand?

Previous: Nguyen Thai Ngoc DuyNext: Nguyen Thai Ngoc Duy
Message 9 of 43 in “Column display again”
  1. 00/13 Column display againNguyễn Thái Ngọc Duy, Feb 3, 2012
  2. 01/13 Save terminal width before setting up pagerNguyễn Thái Ngọc Duy, Feb 3, 2012
  3. 02/13 column: add API to print items in columnsNguyễn Thái Ngọc Duy, Feb 3, 2012
  4. Junio C HamanoFeb 3, 2012
  5. Junio C HamanoFeb 3, 2012
  6. 03/13 parseopt: make OPT_INTEGER support hexadecimal as wellNguyễn Thái Ngọc Duy, Feb 3, 2012
  7. Junio C HamanoFeb 3, 2012
  8. Nguyen Thai Ngoc DuyFeb 4, 2012
  9. Junio C HamanoFeb 4, 2012
  10. Nguyen Thai Ngoc DuyFeb 4, 2012
  11. 04/13 Add git-column and column mode parsingNguyễn Thái Ngọc Duy, Feb 3, 2012
  12. 05/13 Stop starting pager recursivelyNguyễn Thái Ngọc Duy, Feb 3, 2012
  13. 06/13 column: add columnar layoutNguyễn Thái Ngọc Duy, Feb 3, 2012
  14. 07/13 column: support columns with different widthsNguyễn Thái Ngọc Duy, Feb 3, 2012
  15. 08/13 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Feb 3, 2012
  16. Junio C HamanoFeb 3, 2012
  17. 09/13 help: reuse print_columns() for help -aNguyễn Thái Ngọc Duy, Feb 3, 2012
  18. Junio C HamanoFeb 3, 2012
  19. 10/13 branch: add --columnNguyễn Thái Ngọc Duy, Feb 3, 2012
  20. Junio C HamanoFeb 3, 2012
  21. Nguyen Thai Ngoc DuyFeb 4, 2012
  22. 11/13 status: add --columnNguyễn Thái Ngọc Duy, Feb 3, 2012
  23. Junio C HamanoFeb 3, 2012
  24. 12/13 column: support piping stdout to external git-column processNguyễn Thái Ngọc Duy, Feb 3, 2012
  25. 13/13 tag: add --columnNguyễn Thái Ngọc Duy, Feb 3, 2012
  26. Junio C HamanoFeb 3, 2012
  27. 00/12 Column displayNguyễn Thái Ngọc Duy, Feb 4, 2012
  28. 01/12 Save terminal width before setting up pagerNguyễn Thái Ngọc Duy, Feb 4, 2012
  29. 02/12 column: add API to print items in columnsNguyễn Thái Ngọc Duy, Feb 4, 2012
  30. 03/12 Add git-column and column mode parsingNguyễn Thái Ngọc Duy, Feb 4, 2012
  31. 03/12 Add git-column and column mode parsingNguyễn Thái Ngọc Duy, Feb 4, 2012
  32. 04/12 Stop starting pager recursivelyNguyễn Thái Ngọc Duy, Feb 4, 2012
  33. 05/12 column: add columnar layoutNguyễn Thái Ngọc Duy, Feb 4, 2012
  34. 06/12 column: support columns with different widthsNguyễn Thái Ngọc Duy, Feb 4, 2012
  35. 07/12 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Feb 4, 2012
  36. 07/12 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Feb 4, 2012
  37. 08/12 help: reuse print_columns() for help -aNguyễn Thái Ngọc Duy, Feb 4, 2012
  38. 09/12 branch: add --columnNguyễn Thái Ngọc Duy, Feb 4, 2012
  39. Junio C HamanoFeb 6, 2012
  40. 10/12 status: add --columnNguyễn Thái Ngọc Duy, Feb 4, 2012
  41. 11/12 column: support piping stdout to external git-column processNguyễn Thái Ngọc Duy, Feb 4, 2012
  42. 12/12 tag: add --columnNguyễn Thái Ngọc Duy, Feb 4, 2012
  43. Junio C HamanoFeb 6, 2012

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.