Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 37 additions & 32 deletions src/dir.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Directory hashing 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.

GNU Make is free software; you can redistribute it and/or modify it under the
Expand All @@ -12,12 +12,13 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
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 "hash.h"
#include "filedef.h"
#include "dep.h"
#include "debug.h"

#ifdef HAVE_DIRENT_H
# include <dirent.h>
Expand Down Expand Up @@ -164,7 +165,7 @@ vms_hash (const char *name)

while (*name)
{
unsigned char uc = *name;
unsigned char uc = (unsigned char) *name;
int g;
#ifdef HAVE_CASE_INSENSITIVE_FS
h = (h << 4) + (isupper (uc) ? tolower (uc) : uc);
Expand Down Expand Up @@ -221,6 +222,12 @@ vmsstat_dir (const char *name, struct stat *st)
#endif /* _USE_STD_STAT */
#endif /* VMS */

/* Never have more than this many directories open at once. */

#define MAX_OPEN_DIRECTORIES 10

static unsigned int open_directories = 0;

/* Hash table of directories. */

#ifndef DIRECTORY_BUCKETS
Expand Down Expand Up @@ -251,9 +258,25 @@ struct directory_contents
# endif
#endif /* WINDOWS32 */
struct hash_table dirfiles; /* Files in this directory. */
unsigned long counter; /* command_count value when last read. */
DIR *dirstream; /* Stream reading this directory. */
};

static struct directory_contents *
clear_directory_contents (struct directory_contents *dc)
{
dc->counter = 0;
if (dc->dirstream)
{
--open_directories;
closedir (dc->dirstream);
dc->dirstream = 0;
}
hash_free (&dc->dirfiles, 1);

return NULL;
}

static unsigned long
directory_contents_hash_1 (const void *key_0)
{
Expand Down Expand Up @@ -331,7 +354,9 @@ static struct hash_table directory_contents;

struct directory
{
const char *name; /* Name of the directory. */
const char *name; /* Name of the directory. */
unsigned long counter; /* command_count value when last read.
Used for non-existent directories. */

/* The directory's contents. This data may be shared by several
entries in the hash table, which refer to the same directory
Expand Down Expand Up @@ -361,12 +386,6 @@ directory_hash_cmp (const void *x, const void *y)
/* Table of directories hashed by name. */
static struct hash_table directories;

/* Never have more than this many directories open at once. */

#define MAX_OPEN_DIRECTORIES 10

static unsigned int open_directories = 0;


/* Hash table of files in each directory. */

Expand Down Expand Up @@ -501,6 +520,10 @@ dir_contents_file_exists_p (struct directory_contents *dir,
{
struct dirfile *df;
struct dirent *d;
#ifdef WINDOWS32
struct stat st;
int rehash = 0;
#endif

if (dir == 0 || dir->dirfiles.ht_vec == 0)
/* The directory could not be stat'd or opened. */
Expand Down Expand Up @@ -609,10 +632,8 @@ file_exists_p (const char *name)
const char *slash;

#ifndef NO_ARCHIVES
{
if (ar_name (name))
return ar_member_date (name) != (time_t) -1;
}
if (ar_name (name))
return ar_member_date (name) != (time_t) -1;
#endif

dirend = strrchr (name, '/');
Expand Down Expand Up @@ -831,8 +852,6 @@ print_dir_data_base (void)

/* Hooks for globbing. */

#include <glob.h>

/* Structure describing state of iterating through a directory hash table. */

struct dirstream
Expand Down Expand Up @@ -923,17 +942,10 @@ read_dirstream (__ptr_t stream)
* On MS-Windows, stat() "succeeds" for foo/bar/. where foo/bar is a
* regular file; fix that here.
*/
#if !defined(stat) && !defined(WINDOWS32) || defined(VMS)
# ifndef VMS
#if !defined(stat) && !defined(WINDOWS32)
# ifndef HAVE_SYS_STAT_H
int stat (const char *path, struct stat *sbuf);
# endif
# else
/* We are done with the fake stat. Go back to the real stat */
# ifdef stat
# undef stat
# endif
# endif
# define local_stat stat
#else
static int
Expand All @@ -946,17 +958,10 @@ local_stat (const char *path, struct stat *buf)
#endif

/* Similarly for lstat. */
#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
# ifndef VMS
#if !defined(lstat) && !defined(WINDOWS32)
# ifndef HAVE_SYS_STAT_H
int lstat (const char *path, struct stat *sbuf);
# endif
# else
/* We are done with the fake lstat. Go back to the real lstat */
# ifdef lstat
# undef lstat
# endif
# endif
# define local_lstat lstat
#elif defined(WINDOWS32)
/* Windows doesn't support lstat(). */
Expand Down
60 changes: 24 additions & 36 deletions src/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!

Copyright (C) 1987-2020 Free Software Foundation, Inc.
Copyright (C) 1987-2022 Free Software Foundation, Inc.

NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
Expand All @@ -18,7 +18,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
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/>. */

/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
Expand All @@ -40,12 +40,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */

#include <stdio.h>

#ifdef _GNU_SOURCE
# define ATTRIBUTE_UNUSED __attribute__((unused))
#else
# define ATTRIBUTE_UNUSED
#endif

/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
Expand Down Expand Up @@ -383,9 +377,7 @@ exchange (char **argv)
static const char *_getopt_initialize (int, char *const *, const char *);
#endif
static const char *
_getopt_initialize (int argc ATTRIBUTE_UNUSED,
char *const *argv ATTRIBUTE_UNUSED,
const char *optstring)
_getopt_initialize (int argc, char *const *argv, const char *optstring)
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
Expand Down Expand Up @@ -434,7 +426,7 @@ _getopt_initialize (int argc ATTRIBUTE_UNUSED,
if (__getopt_nonoption_flags == NULL)
nonoption_flags_max_len = -1;
else
memset (mempcpy (__getopt_nonoption_flags, orig_str, len),
memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
'\0', nonoption_flags_max_len - len);
}
}
Expand Down Expand Up @@ -505,8 +497,7 @@ _getopt_initialize (int argc ATTRIBUTE_UNUSED,

int
_getopt_internal (int argc, char *const *argv, const char *optstring,
const struct option *longopts,
int *longind, int long_only)
const struct option *longopts, int *longind, int long_only)
{
optarg = NULL;

Expand Down Expand Up @@ -665,7 +656,7 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
Expand All @@ -686,23 +677,21 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
else
{
if (opterr)
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
_("%s: option `--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);

nextchar += strlen (nextchar);

optopt = pfound->val;
return '?';
}
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
_("%s: option '--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
_("%s: option '%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);

nextchar += strlen (nextchar);

optopt = pfound->val;
return '?';
}
}
else if (pfound->has_arg == 1)
Expand All @@ -713,7 +702,7 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
{
if (opterr)
fprintf (stderr,
_("%s: option `%s' requires an argument\n"),
_("%s: option '%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
optopt = pfound->val;
Expand Down Expand Up @@ -742,11 +731,11 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
Expand All @@ -756,7 +745,6 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
}
}


/* Look at and handle the next short option-character. */

{
Expand Down
4 changes: 2 additions & 2 deletions src/getopt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Declarations for getopt.
Copyright (C) 1989-2020 Free Software Foundation, Inc.
Copyright (C) 1989-2022 Free Software Foundation, Inc.

NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
Expand All @@ -14,7 +14,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
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/>. */

#ifndef _GETOPT_H
#define _GETOPT_H 1
Expand Down
4 changes: 2 additions & 2 deletions src/getopt1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987-1994, 1996-2020 Free Software Foundation, Inc.
Copyright (C) 1987-1994, 1996-2022 Free Software Foundation, Inc.

NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
Expand All @@ -14,7 +14,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
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/>. */

#ifdef HAVE_CONFIG_H
#include <config.h>
Expand Down
4 changes: 2 additions & 2 deletions src/gettext.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-2020 Free Software Foundation, Inc.
Copyright (C) 1995-2022 Free Software Foundation, Inc.
This file is part of GNU Make.

GNU Make is free software; you can redistribute it and/or modify it under the
Expand All @@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
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/>. */

#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
Expand Down
6 changes: 3 additions & 3 deletions src/git2cl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Copyright (C) 2007, 2008 Simon Josefsson <simon@josefsson.org>
# Copyright (C) 2007 Luis Mondesi <lemsx1@gmail.com>
# * calls git directly. To use it just:
# * calls git directly. To use it just:
# cd ~/Project/my_git_repo; git2cl > ChangeLog
# * implements strptime()
# * fixes bugs in $comment parsing
Expand Down Expand Up @@ -59,7 +59,7 @@ Thus, typically you would use it as follows:
=head1 SEE ALSO

Output format specification:
<http://www.gnu.org/prep/standards/html_node/Change-Logs.html>
<https://www.gnu.org/prep/standards/html_node/Change-Logs.html>

=head1 AUTHORS

Expand Down Expand Up @@ -350,7 +350,7 @@ while (my $_l = <$fh>) {
$state = 1 if ($_l =~ m,^$, and $author and (@date+0>0));
} elsif ($state == 1) {
# * modifying our input text is a bad choice
# let's make a copy of it first, then we remove spaces
# let's make a copy of it first, then we remove spaces
# * if we meet a "merge branch" statement, we need to start
# over and find a real entry
# Luis Mondesi <lemsx1@gmail.com>
Expand Down