From: Paul Eggert Date: Tue, 12 Dec 2006 23:56:24 +0000 (+0000) Subject: Port to Forte Developer 7 C 5.4 and C99. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=8e3f3adf9888cca4acedfe005d277867c999fcb3;p=chaz%2Ftar Port to Forte Developer 7 C 5.4 and C99. * src/common.h (add_exclude_tag): Add decl; C99 requires this and Forte warns about it. * src/incremen.c: Include for mkdtemp prototype, for same reason. * src/misc.c (get_max_open_files): Rewrite to avoid code that Forte C complains about as being unreachable. * src/xheader.c (mtime_code): Rewrite to avoid Forte error reported by Trond Hasle Amundsen. * src/incremen.c (compare_dirnames): Rewrite to avoid casts. * src/utf8.c (string_ascii_p): Likewise. * src/xheader.c (mtime_coder, volume_size_coder, volume_offset_coder): Likewise. SCALAR(0x8283218) --- diff --git a/ChangeLog b/ChangeLog index 4f852e5..531eaac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-12-12 Paul Eggert + + Port to Forte Developer 7 C 5.4 and C99. + * src/common.h (add_exclude_tag): Add decl; C99 requires this + and Forte warns about it. + * src/incremen.c: Include for mkdtemp prototype, + for same reason. + * src/misc.c (get_max_open_files): Rewrite to avoid code that + Forte C complains about as being unreachable. + * src/xheader.c (mtime_code): Rewrite to avoid Forte error + reported by Trond Hasle Amundsen. + + * src/incremen.c (compare_dirnames): Rewrite to avoid casts. + * src/utf8.c (string_ascii_p): Likewise. + * src/xheader.c (mtime_coder, volume_size_coder, volume_offset_coder): + Likewise. + 2006-12-08 Sergey Poznyakoff * bootstrap: Add paxutils files to dot_ignore. @@ -19,7 +36,7 @@ Patch proposed by Jan-Benedict Glaw * tests/truncate.at: Use genfile instead of dd, because on some systems /dev/zero is not available. - + 2006-12-04 Paul Eggert * NEWS: Fix some race conditions with tar -x --same-owner. diff --git a/src/common.h b/src/common.h index e7f4c68..b8c124e 100644 --- a/src/common.h +++ b/src/common.h @@ -417,6 +417,7 @@ enum dump_status dump_status_not_implemented }; +void add_exclude_tag (const char *name); bool file_dumpable_p (struct tar_stat_info *st); void create_archive (void); void pad_archive (off_t size_left); diff --git a/src/incremen.c b/src/incremen.c index 6cd8efb..c68a88b 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "common.h" @@ -378,7 +379,9 @@ dumpdir_size (const char *p) static int compare_dirnames (const void *first, const void *second) { - return strcmp (*(const char**)first, *(const char**)second); + char const *const *name1 = first; + char const *const *name2 = second; + return strcmp (*name1, *name2); } /* Compare dumpdir array from DIRECTORY with directory listing DIR and diff --git a/src/misc.c b/src/misc.c index 328591c..1d7e9e1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1,7 +1,7 @@ /* Miscellaneous functions, not really specific to GNU tar. Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001, - 2003, 2004, 2005 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -588,10 +588,12 @@ get_max_open_files () if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) return rlim.rlim_max; + return -1; #elif defined HAVE_GETDTABLESIZE return getdtablesize (); -#endif +#else return -1; +#endif } /* Close all descriptors, except the first three */ @@ -603,7 +605,7 @@ closeopen () for (i = get_max_open_files () - 1; i > 2; i--) close (i); } - + /* Change to directory I. If I is 0, change to the initial working directory; otherwise, I must be a value returned by chdir_arg. */ void @@ -611,7 +613,7 @@ chdir_do (int i) { static int previous; static int saved_count; - + if (previous != i) { struct wd *prev = &wd[previous]; diff --git a/src/utf8.c b/src/utf8.c index 3352cd1..75b7c1d 100644 --- a/src/utf8.c +++ b/src/utf8.c @@ -1,6 +1,6 @@ /* Charset handling for GNU tar. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -28,7 +28,7 @@ # define ICONV_CONST #endif -#ifndef HAVE_ICONV +#ifndef HAVE_ICONV # undef iconv_open # define iconv_open(tocode, fromcode) ((iconv_t) -1) @@ -39,7 +39,7 @@ # undef iconv_close # define iconv_close(cd) 0 -#endif +#endif @@ -88,11 +88,10 @@ utf8_convert (bool to_utf, char const *input, char **output) bool -string_ascii_p (const char *str) +string_ascii_p (char const *p) { - const unsigned char *p = (const unsigned char *)str; for (; *p; p++) - if (*p > 127) + if (! (0 <= *p && *p <= 127)) return false; return true; } diff --git a/src/xheader.c b/src/xheader.c index 70d287c..11b725e 100644 --- a/src/xheader.c +++ b/src/xheader.c @@ -225,7 +225,7 @@ xheader_set_option (char *string) to the result of the basename utility on the translated file name. %p The process ID of the pax process. - %n The value of the 3rd argument. + %n The value of the 3rd argument. %% A '%' character. */ char * @@ -331,7 +331,7 @@ xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n) } free (dirp); - + /* Do not allow it to end in a slash */ while (q > buf && ISSLASH (q[-1])) q--; @@ -508,7 +508,7 @@ decode_record (char **ptr, ERROR ((0, 0, _("Extended header length is out of allowed range"))); return false; } - + if (len_max < len) { int len_len = len_lim - p; @@ -954,7 +954,7 @@ decode_time (struct timespec *ts, char const *arg, char const *keyword) return true; } - + static void code_num (uintmax_t value, char const *keyword, struct xheader *xhdr) @@ -1094,8 +1094,8 @@ static void mtime_coder (struct tar_stat_info const *st, char const *keyword, struct xheader *xhdr, void const *data) { - const struct timespec mtime = data ? *(struct timespec *) data : st->mtime; - code_time (mtime, keyword, xhdr); + struct timespec const *mtime = data; + code_time (mtime ? *mtime : st->mtime, keyword, xhdr); } static void @@ -1379,8 +1379,8 @@ static void volume_size_coder (struct tar_stat_info const *st, char const *keyword, struct xheader *xhdr, void const *data) { - off_t v = *(off_t*)data; - code_num (v, keyword, xhdr); + off_t const *v = data; + code_num (*v, keyword, xhdr); } static void @@ -1398,8 +1398,8 @@ static void volume_offset_coder (struct tar_stat_info const *st, char const *keyword, struct xheader *xhdr, void const *data) { - off_t v = *(off_t*)data; - code_num (v, keyword, xhdr); + off_t const *v = data; + code_num (*v, keyword, xhdr); } static void @@ -1438,12 +1438,12 @@ sparse_major_decoder (struct tar_stat_info *st, if (decode_num (&u, arg, TYPE_MAXIMUM (unsigned), keyword)) st->sparse_major = u; } - + static void sparse_minor_coder (struct tar_stat_info const *st, char const *keyword, struct xheader *xhdr, void const *data) { - code_num (st->sparse_minor, keyword, xhdr); + code_num (st->sparse_minor, keyword, xhdr); } static void @@ -1456,7 +1456,7 @@ sparse_minor_decoder (struct tar_stat_info *st, if (decode_num (&u, arg, TYPE_MAXIMUM (unsigned), keyword)) st->sparse_minor = u; } - + struct xhdr_tab const xhdr_tab[] = { { "atime", atime_coder, atime_decoder, false }, { "comment", dummy_coder, dummy_decoder, false },