/* Interface to 'ar' archives for GNU Make.
-Copyright (C) 1988-2020 Free Software Foundation, Inc.
+Copyright (C) 1988-2022 Free Software Foundation, Inc.
This file is part of GNU Make.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program. If not, see <http://www.gnu.org/licenses/>. */
+this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
#include "filedef.h"
#include "dep.h"
#include <fnmatch.h>
+#include <intprops.h>
/* Return nonzero if NAME is an archive-member reference, zero if not. An
archive-member reference is a name like 'lib(member)' where member is a
const char *p = strchr (name, '(');
const char *end;
- if (p == 0 || p == name)
+ if (p == NULL || p == name)
return 0;
end = p + strlen (p) - 1;
*arname_p = xstrdup (name);
p = strchr (*arname_p, '(');
+ /* This is never called unless ar_name() is true so p cannot be NULL. */
+ if (!p)
+ OS (fatal, NILF, "Internal: ar_parse_name: bad name '%s'", *arname_p);
*(p++) = '\0';
p[strlen (p) - 1] = '\0';
*memname_p = p;
/* This function is called by 'ar_scan' to find which member to look at. */
/* ARGSUSED */
-static long int
+static intmax_t
ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
long int hdrpos UNUSED, long int datapos UNUSED,
- long int size UNUSED, long int date,
+ long int size UNUSED, intmax_t date,
int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED,
const void *name)
{
{
char *arname;
char *memname;
- long int val;
+ intmax_t val;
ar_parse_name (name, &arname, &memname);
free (arname);
- return (val <= 0 ? (time_t) -1 : (time_t) val);
+ return 0 < val && val <= TYPE_MAXIMUM (time_t) ? val : -1;
}
\f
/* Set the archive-member NAME's modtime to now. */
/* This function is called by 'ar_scan' to match one archive
element against the pattern in STATE. */
-static long int
+static intmax_t
ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
long int hdrpos UNUSED, long int datapos UNUSED,
- long int size UNUSED, long int date UNUSED, int uid UNUSED,
+ long int size UNUSED, intmax_t date UNUSED, int uid UNUSED,
int gid UNUSED, unsigned int mode UNUSED, const void *arg)
{
struct ar_glob_state *state = (struct ar_glob_state *)arg;
++state->n;
}
- return 0L;
+ return 0;
}
/* Return nonzero if PATTERN contains any metacharacters.