Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/memcasecmp.c @ 14379:2330aac2ae54
maint: adjust cpp indentation to reflect nesting depth
I.e., in a block of code that begins with an unnested "#if",
put one space between the "#" in column 1 and following token.
For example,
-#include <sys/vfs.h>
+# include <sys/vfs.h>
Do this only in .c files that are part of a module I maintain.
* lib/linkat.c: Filter through cppi.
* lib/nanosleep.c: Likewise.
* lib/openat.c: Likewise.
* lib/openat-die.c: Likewise.
* lib/dup3.c: Likewise.
* lib/fchownat.c: Likewise.
* lib/flock.c: Likewise.
* lib/fsync.c: Likewise.
* lib/fts.c: Likewise.
* lib/getpass.c: Likewise.
* lib/gettimeofday.c: Likewise.
* lib/userspec.c: Likewise.
* Makefile (sc_cpp_indent_check): New rule, to check this.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sun, 20 Feb 2011 23:02:43 +0100 |
parents | 97fc9a21a8fb |
children | b427a1938336 |
rev | line source |
---|---|
597 | 1 /* Case-insensitive buffer comparator. |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
2 Copyright (C) 1996-1997, 2000, 2003, 2006, 2009-2011 Free Software |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
3 Foundation, Inc. |
597 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
597 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
8 (at your option) any later version. |
597 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
597 | 17 |
2088
85b906992e67
Use `#if' instead of `#ifdef' for `HAVE_CONFIG_H'.
Jim Meyering <jim@meyering.net>
parents:
1084
diff
changeset
|
18 /* Written by Jim Meyering. */ |
597 | 19 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6927
diff
changeset
|
20 #include <config.h> |
583 | 21 |
6927
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
22 #include "memcasecmp.h" |
583 | 23 |
6927
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
24 #include <ctype.h> |
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
25 #include <limits.h> |
583 | 26 |
1084 | 27 /* Like memcmp, but ignore differences in case. |
28 Convert to upper case (not lower) before comparing so that | |
29 join -i works with sort -f. */ | |
583 | 30 |
31 int | |
2088
85b906992e67
Use `#if' instead of `#ifdef' for `HAVE_CONFIG_H'.
Jim Meyering <jim@meyering.net>
parents:
1084
diff
changeset
|
32 memcasecmp (const void *vs1, const void *vs2, size_t n) |
583 | 33 { |
4547
8f5277cd7865
* memcasecmp.c: Remove unnecessary parentheses after 'defined'.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
34 size_t i; |
8f5277cd7865
* memcasecmp.c: Remove unnecessary parentheses after 'defined'.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
35 char const *s1 = vs1; |
8f5277cd7865
* memcasecmp.c: Remove unnecessary parentheses after 'defined'.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
36 char const *s2 = vs2; |
583 | 37 for (i = 0; i < n; i++) |
38 { | |
4547
8f5277cd7865
* memcasecmp.c: Remove unnecessary parentheses after 'defined'.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
39 unsigned char u1 = s1[i]; |
8f5277cd7865
* memcasecmp.c: Remove unnecessary parentheses after 'defined'.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
40 unsigned char u2 = s2[i]; |
6927
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
41 int U1 = toupper (u1); |
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
42 int U2 = toupper (u2); |
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
43 int diff = (UCHAR_MAX <= INT_MAX ? U1 - U2 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
44 : U1 < U2 ? -1 : U2 < U1); |
4547
8f5277cd7865
* memcasecmp.c: Remove unnecessary parentheses after 'defined'.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
45 if (diff) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
46 return diff; |
583 | 47 } |
48 return 0; | |
49 } |