Code

Mechanical conversion to use prefixcmp()
authorJunio C Hamano <junkio@cox.net>
Tue, 20 Feb 2007 09:53:29 +0000 (01:53 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 21 Feb 2007 06:03:15 +0000 (22:03 -0800)
commitcc44c7655fe2dd0cfb46e841156634fe622df397
tree6829fa96174f857c90e8baf966a2a8c7b924514a
parentcff0302c14522ba7b34265ee39f23e6321a4777d
Mechanical conversion to use prefixcmp()

This mechanically converts strncmp() to use prefixcmp(), but only when
the parameters match specific patterns, so that they can be verified
easily.  Leftover from this will be fixed in a separate step, including
idiotic conversions like

    if (!strncmp("foo", arg, 3))

  =>

    if (!(-prefixcmp(arg, "foo")))

This was done by using this script in px.perl

   #!/usr/bin/perl -i.bak -p
   if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
           s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
   }
   if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
           s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
   }

and running:

   $ git grep -l strncmp -- '*.c' | xargs perl px.perl

Signed-off-by: Junio C Hamano <junkio@cox.net>
48 files changed:
builtin-apply.c
builtin-archive.c
builtin-blame.c
builtin-branch.c
builtin-checkout-index.c
builtin-describe.c
builtin-fmt-merge-msg.c
builtin-for-each-ref.c
builtin-fsck.c
builtin-grep.c
builtin-init-db.c
builtin-log.c
builtin-ls-files.c
builtin-mailinfo.c
builtin-name-rev.c
builtin-pack-objects.c
builtin-pack-refs.c
builtin-push.c
builtin-read-tree.c
builtin-reflog.c
builtin-rerere.c
builtin-rev-parse.c
builtin-shortlog.c
builtin-show-branch.c
builtin-show-ref.c
builtin-tar-tree.c
builtin-unpack-objects.c
builtin-write-tree.c
connect.c
daemon.c
diff.c
exec_cmd.c
fast-import.c
fetch-pack.c
git.c
help.c
http-fetch.c
http-push.c
index-pack.c
peek-remote.c
receive-pack.c
refs.c
revision.c
send-pack.c
setup.c
shell.c
upload-pack.c
wt-status.c