PR/33123: Murray Armfield: standards compliance & glob.h

Certain fields in glob.h need to be size_t; fix this and version glob(3).
    http://www.opengroup.org/onlinepubs/000095399/basedefs/glob.h.html
This commit is contained in:
christos 2006-03-26 18:11:22 +00:00
parent 229fa64dde
commit 3b6811d33b
8 changed files with 56 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: glob.h,v 1.20 2005/09/13 01:44:32 christos Exp $ */
/* $NetBSD: glob.h,v 1.21 2006/03/26 18:11:22 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -42,14 +42,17 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef __gl_size_t
#define __gl_size_t size_t
#endif
#ifndef __gl_stat_t
#define __gl_stat_t struct stat
#endif
typedef struct {
int gl_pathc; /* Count of total paths so far. */
int gl_matchc; /* Count of paths matching pattern. */
int gl_offs; /* Reserved at beginning of gl_pathv. */
__gl_size_t gl_pathc; /* Count of total paths so far. */
__gl_size_t gl_matchc; /* Count of paths matching pattern. */
__gl_size_t gl_offs; /* Reserved at beginning of gl_pathv. */
int gl_flags; /* Copy of flags parameter to glob. */
char **gl_pathv; /* List of paths matching pattern. */
/* Copy of errfunc parameter to glob. */
@ -95,8 +98,8 @@ typedef struct {
__BEGIN_DECLS
#ifndef __LIBC12_SOURCE__
int glob(const char * __restrict, int,
int (*)(const char *, int), glob_t * __restrict) __RENAME(__glob13);
void globfree(glob_t *) __RENAME(__globfree13);
int (*)(const char *, int), glob_t * __restrict) __RENAME(__glob30);
void globfree(glob_t *) __RENAME(__globfree30);
#endif
__END_DECLS

View File

@ -1,8 +1,8 @@
# $NetBSD: Makefile.inc,v 1.2 2006/03/11 21:07:18 christos Exp $
# $NetBSD: Makefile.inc,v 1.3 2006/03/26 18:11:22 christos Exp $
.PATH: ${COMPATDIR}/gen
SRCS+=compat_errlist.c compat_fts.c compat___fts13.c compat_getmntinfo.c \
compat_glob.c compat_opendir.c compat_readdir.c compat_scandir.c \
compat_siglist.c compat_signame.c compat_sigsetops.c compat_times.c \
compat_timezone.c compat_unvis.c compat_utmpx.c compat__sys_errlist.c \
compat__sys_nerr.c compat__sys_siglist.c
compat__sys_nerr.c compat__sys_siglist.c compat___glob13.c

View File

@ -0,0 +1,26 @@
/* $NetBSD: compat___glob13.c,v 1.1 2006/03/26 18:11:22 christos Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@NetBSD.org>, October 21, 1997.
* Public domain.
*/
#include "namespace.h"
#include <sys/stat.h>
#include <dirent.h>
#define __gl_size_t int
#define __LIBC12_SOURCE__
__warn_references(__glob13,
"warning: reference to compatibility __glob13(); include <glob.h> for correct reference")
__warn_references(__globfree13,
"warning: reference to compatibility __globfree13(); include <glob.h> for correct reference")
#undef glob
#undef globfree
#define glob __glob13
#define globfree __globfree13
#include <glob.h>
#include <compat/include/glob.h>
#include "gen/glob.c"

View File

@ -1,4 +1,4 @@
.\" $NetBSD: glob.3,v 1.29 2003/12/08 00:55:57 grant Exp $
.\" $NetBSD: glob.3,v 1.30 2006/03/26 18:11:22 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@ -31,7 +31,7 @@
.\"
.\" @(#)glob.3 8.3 (Berkeley) 4/16/94
.\"
.Dd October 27, 2001
.Dd March 22, 2006
.Dt GLOB 3
.Os
.Sh NAME
@ -60,9 +60,9 @@ defines the structure type
which contains at least the following fields:
.Bd -literal
typedef struct {
int gl_pathc; /* count of total paths so far */
int gl_matchc; /* count of paths matching pattern */
int gl_offs; /* reserved at beginning of gl_pathv */
size_t gl_pathc; /* count of total paths so far */
size_t gl_matchc; /* count of paths matching pattern */
size_t gl_offs; /* reserved at beginning of gl_pathv */
int gl_flags; /* returned flags */
char **gl_pathv; /* list of paths matching pattern */
} glob_t;

View File

@ -1,4 +1,4 @@
/* $NetBSD: glob.c,v 1.15 2006/01/24 17:24:09 christos Exp $ */
/* $NetBSD: glob.c,v 1.16 2006/03/26 18:11:22 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
#else
__RCSID("$NetBSD: glob.c,v 1.15 2006/01/24 17:24:09 christos Exp $");
__RCSID("$NetBSD: glob.c,v 1.16 2006/03/26 18:11:22 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -460,7 +460,8 @@ glob0(pattern, pglob)
glob_t *pglob;
{
const Char *qpatnext;
int c, error, oldpathc;
int c, error;
__gl_size_t oldpathc;
Char *bufnext, patbuf[MAXPATHLEN+1];
size_t limit = 0;
@ -791,8 +792,7 @@ globextend(path, pglob, limit)
size_t *limit;
{
char **pathv;
int i;
size_t newsize, len;
size_t i, newsize, len;
char *copy;
const Char *p;
@ -808,7 +808,7 @@ globextend(path, pglob, limit)
if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
/* first time around -- clear initial gl_offs items */
pathv += pglob->gl_offs;
for (i = pglob->gl_offs; --i >= 0; )
for (i = pglob->gl_offs + 1; --i > 0; )
*--pathv = NULL;
}
pglob->gl_pathv = pathv;
@ -895,7 +895,7 @@ void
globfree(pglob)
glob_t *pglob;
{
int i;
size_t i;
char **pp;
_DIAGASSERT(pglob != NULL);

View File

@ -34,7 +34,7 @@
#else
#if MSDOS_COMPILER==DJGPPC
#define DECL_GLOB_LIST(list) glob_t list; int i;
#define DECL_GLOB_LIST(list) glob_t list; size_t i;
#define GLOB_LIST(filename,list) glob(filename,GLOB_NOCHECK,0,&list)
#define GLOB_LIST_FAILED(list) 0
#define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++

View File

@ -1,4 +1,4 @@
/* $NetBSD: catman.c,v 1.24 2004/10/29 20:35:16 dsl Exp $ */
/* $NetBSD: catman.c,v 1.25 2006/03/26 18:11:22 christos Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -264,7 +264,8 @@ uniquepath(void)
struct stat st1;
struct stat st2;
struct stat st3;
int i, j, len, lnk, gflags;
int len, lnk, gflags;
size_t i, j;
char path[PATH_MAX], *p;
gflags = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: file.c,v 1.76 2005/12/06 01:07:30 ben Exp $ */
/* $NetBSD: file.c,v 1.77 2006/03/26 18:11:22 christos Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -17,7 +17,7 @@
#if 0
static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
#else
__RCSID("$NetBSD: file.c,v 1.76 2005/12/06 01:07:30 ben Exp $");
__RCSID("$NetBSD: file.c,v 1.77 2006/03/26 18:11:22 christos Exp $");
#endif
#endif
@ -553,7 +553,7 @@ move_files(const char *dir, const char *pattern, const char *to)
{
char fpath[MaxPathSize];
glob_t globbed;
int i;
size_t i;
(void) snprintf(fpath, sizeof(fpath), "%s/%s", dir, pattern);
if ((i=glob(fpath, GLOB_NOSORT, NULL, &globbed)) != 0) {