build: update to latest gnulib and adapt

* tests/binary: Reverse arguments to compare to avoid failure of
new syntax-check rule.
* configure.ac: Use -Wno-format-nonliteral.
Mark functions as pure of const, per recommendations enabled by
new gcc -W options.  Use _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST.
* lib/cmpbuf.h (buffer_lcm, block_compare):
Apply pure and/or const attributes.
* src/cmp.c (block_compare): Likewise.
* src/context.c (find_hunk): Likewise.
* src/diff.h (lines_differ): Likewise.
* src/diff3.c (skipwhite): Likewise.
* src/dir.c (dir_loop): Likewise.
* src/util.c (find_change, find_reverse_change): Likewise.
(translate_line_number): Likewise.
This commit is contained in:
Jim Meyering 2011-12-14 14:28:47 +01:00
parent 439286a937
commit c88c3b6b2a
10 changed files with 12 additions and 11 deletions

View File

@ -96,6 +96,7 @@ if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wno-format-nonliteral])
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c

2
gnulib

@ -1 +1 @@
Subproject commit 996ce97a8f8572ae9bade6c7df1aa364bd0e259f
Subproject commit 443bc5ffcf7429e557f4a371b0661abe98ddbc13

View File

@ -16,4 +16,4 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
size_t block_read (int, char *, size_t);
size_t buffer_lcm (size_t, size_t, size_t);
size_t buffer_lcm (size_t, size_t, size_t) _GL_ATTRIBUTE_CONST;

View File

@ -51,7 +51,7 @@
static int cmp (void);
static off_t file_position (int);
static size_t block_compare (word const *, word const *);
static size_t block_compare (word const *, word const *) _GL_ATTRIBUTE_PURE;
static size_t block_compare_and_count (word const *, word const *, off_t *);
static void sprintc (char *, unsigned char);

View File

@ -394,7 +394,7 @@ pr_unidiff_hunk (struct change *hunk)
2*CONTEXT unchanged lines appear, and return a pointer
to the `struct change' for the last change before those lines. */
static struct change *
static struct change * _GL_ATTRIBUTE_PURE
find_hunk (struct change *start)
{
struct change *prev;

View File

@ -361,7 +361,7 @@ extern void print_sdiff_script (struct change *);
extern char const change_letter[4];
extern char const pr_program[];
extern char *concat (char const *, char const *, char const *);
extern bool lines_differ (char const *, char const *);
extern bool lines_differ (char const *, char const *) _GL_ATTRIBUTE_PURE;
extern lin translate_line_number (struct file_data const *, lin);
extern struct change *find_change (struct change *);
extern struct change *find_reverse_change (struct change *);

View File

@ -1045,7 +1045,7 @@ process_diff (char const *filea,
/* Skip tabs and spaces, and return the first character after them. */
static char *
static char * _GL_ATTRIBUTE_PURE
skipwhite (char *s)
{
while (*s == ' ' || *s == '\t')

View File

@ -308,7 +308,7 @@ diff_dirs (struct comparison const *cmp,
/* Return nonzero if CMP is looping recursively in argument I. */
static bool
static bool _GL_ATTRIBUTE_PURE
dir_loop (struct comparison const *cmp, int i)
{
struct comparison const *p = cmp;

View File

@ -477,13 +477,13 @@ lines_differ (char const *s1, char const *s2)
/* Find the consecutive changes at the start of the script START.
Return the last link before the first gap. */
struct change *
struct change * _GL_ATTRIBUTE_CONST
find_change (struct change *start)
{
return start;
}
struct change *
struct change * _GL_ATTRIBUTE_CONST
find_reverse_change (struct change *start)
{
return start;
@ -635,7 +635,7 @@ char const change_letter[] = { 0, 'd', 'a', 'c' };
Internal line numbers count from 0 starting after the prefix.
Actual line numbers count from 1 within the entire file. */
lin
lin _GL_ATTRIBUTE_PURE
translate_line_number (struct file_data const *file, lin i)
{
return i + file->prefix_lines + 1;

View File

@ -11,7 +11,7 @@ printf '\0'|diff - /dev/null > out 2> err
# diff must exit with status 2, stdout as above, and no stderr.
test $? = 2 || fail=1
compare out out-exp || fail=1
compare out-exp out || fail=1
compare /dev/null err || fail=1
Exit $fail