<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.c, branch v2.1.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.1.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.1.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2014-06-20T17:44:43Z</updated>
<entry>
<title>refactor skip_prefix to return a boolean</title>
<updated>2014-06-20T17:44:43Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-18T19:44:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cf4fff579e02d8585d59f6c8739534b7b0d617dd'/>
<id>urn:sha1:cf4fff579e02d8585d59f6c8739534b7b0d617dd</id>
<content type='text'>
The skip_prefix() function returns a pointer to the content
past the prefix, or NULL if the prefix was not found. While
this is nice and simple, in practice it makes it hard to use
for two reasons:

  1. When you want to conditionally skip or keep the string
     as-is, you have to introduce a temporary variable.
     For example:

       tmp = skip_prefix(buf, "foo");
       if (tmp)
	       buf = tmp;

  2. It is verbose to check the outcome in a conditional, as
     you need extra parentheses to silence compiler
     warnings. For example:

       if ((cp = skip_prefix(buf, "foo"))
	       /* do something with cp */

Both of these make it harder to use for long if-chains, and
we tend to use starts_with() instead. However, the first line
of "do something" is often to then skip forward in buf past
the prefix, either using a magic constant or with an extra
strlen(3) (which is generally computed at compile time, but
means we are repeating ourselves).

This patch refactors skip_prefix() to return a simple boolean,
and to provide the pointer value as an out-parameter. If the
prefix is not found, the out-parameter is untouched. This
lets you write:

  if (skip_prefix(arg, "foo ", &amp;arg))
	  do_foo(arg);
  else if (skip_prefix(arg, "bar ", &amp;arg))
	  do_bar(arg);

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mr/opt-set-ptr'</title>
<updated>2014-04-08T19:00:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-08T19:00:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b389e04031ffe4c725161a082ff748bd33688641'/>
<id>urn:sha1:b389e04031ffe4c725161a082ff748bd33688641</id>
<content type='text'>
OPT_SET_PTR() implementation was broken on IL32P64 platforms;
it turns out that the macro is not used by any real user.

* mr/opt-set-ptr:
  parse-options: remove unused OPT_SET_PTR
  parse-options: add cast to correct pointer type to OPT_SET_PTR
  MSVC: fix t0040-parse-options crash
</content>
</entry>
<entry>
<title>parse-options: remove unused OPT_SET_PTR</title>
<updated>2014-03-31T20:01:19Z</updated>
<author>
<name>Marat Radchenko</name>
<email>marat@slonopotamus.org</email>
</author>
<published>2014-03-30T11:08:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=20d1c6528c76242581e89c271679d35884d916dc'/>
<id>urn:sha1:20d1c6528c76242581e89c271679d35884d916dc</id>
<content type='text'>
OPT_SET_PTR was never used since its creation at db7244bd
(parse-options new features., 2007-11-07).

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: make sure argh string does not have SP or _</title>
<updated>2014-03-24T17:43:35Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-03-23T23:04:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b6c2a0d45d4165dfd326bd7a28e66d9cedb8ae84'/>
<id>urn:sha1:b6c2a0d45d4165dfd326bd7a28e66d9cedb8ae84</id>
<content type='text'>
We encourage to spell an argument hint that consists of multiple
words as a single-token separated with dashes.  In order to help
catching violations added by new callers of parse-options, make sure
argh does not contain SP or _ when the code validates the option
definitions.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>use strchrnul() in place of strchr() and strlen()</title>
<updated>2014-03-10T15:35:30Z</updated>
<author>
<name>Rohit Mani</name>
<email>rohit.mani@outlook.com</email>
</author>
<published>2014-03-08T06:48:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a'/>
<id>urn:sha1:2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a</id>
<content type='text'>
Avoid scanning strings twice, once with strchr() and then with
strlen(), by using strchrnul().

Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Rohit Mani &lt;rohit.mani@outlook.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>replace {pre,suf}fixcmp() with {starts,ends}_with()</title>
<updated>2013-12-05T22:13:21Z</updated>
<author>
<name>Christian Couder</name>
<email>chriscool@tuxfamily.org</email>
</author>
<published>2013-11-30T20:55:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=59556548230e617b837343c2c07e357e688e2ca4'/>
<id>urn:sha1:59556548230e617b837343c2c07e357e688e2ca4</id>
<content type='text'>
Leaving only the function definitions and declarations so that any
new topic in flight can still make use of the old functions, replace
existing uses of the prefixcmp() and suffixcmp() with new API
functions.

The change can be recreated by mechanically applying this:

    $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
      grep -v strbuf\\.c |
      xargs perl -pi -e '
        s|!prefixcmp\(|starts_with\(|g;
        s|prefixcmp\(|!starts_with\(|g;
        s|!suffixcmp\(|ends_with\(|g;
        s|suffixcmp\(|!ends_with\(|g;
      '

on the result of preparatory changes in this series.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: add OPT_CMDMODE()</title>
<updated>2013-07-30T19:23:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2013-07-30T19:06:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1158826394e162c5d45a4043ea86b04b24215555'/>
<id>urn:sha1:1158826394e162c5d45a4043ea86b04b24215555</id>
<content type='text'>
This can be used to define a set of mutually exclusive "command
mode" options, and automatically catch use of more than one from
that set as an error.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ef/non-ascii-parse-options-error-diag'</title>
<updated>2013-02-15T00:06:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2013-02-15T00:06:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6bdecc8f56a06f085b4444dc29361a5aa80d9eef'/>
<id>urn:sha1:6bdecc8f56a06f085b4444dc29361a5aa80d9eef</id>
<content type='text'>
* ef/non-ascii-parse-options-error-diag:
  parse-options: report uncorrupted multi-byte options
</content>
</entry>
<entry>
<title>Merge branch 'jx/utf8-printf-width'</title>
<updated>2013-02-14T18:29:08Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2013-02-14T18:29:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3cc3cf970c5ce477bde78df73614d1efba2b52eb'/>
<id>urn:sha1:3cc3cf970c5ce477bde78df73614d1efba2b52eb</id>
<content type='text'>
Use a new helper that prints a message and counts its display width
to align the help messages parse-options produces.

* jx/utf8-printf-width:
  Add utf8_fprintf helper that returns correct number of columns
</content>
</entry>
<entry>
<title>parse-options: report uncorrupted multi-byte options</title>
<updated>2013-02-11T23:19:30Z</updated>
<author>
<name>Erik Faye-Lund</name>
<email>kusmabite@gmail.com</email>
</author>
<published>2013-02-11T23:13:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b141a47801d6fb2d68ec48adfe7597ec3ce49c0d'/>
<id>urn:sha1:b141a47801d6fb2d68ec48adfe7597ec3ce49c0d</id>
<content type='text'>
Because our command-line parser considers only one byte at the time
for short-options, we incorrectly report only the first byte when
multi-byte input was provided. This makes user-errors slightly
awkward to diagnose for instance under UTF-8 locale and non-English
keyboard layouts.

Report the whole argument-string when a non-ASCII short-option is
detected.

Signed-off-by: Erik Faye-Lund &lt;kusmabite@gmail.com&gt;
Improved-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
