summaryrefslogtreecommitdiff
path: root/src/dir.c
Commit message (Collapse)AuthorAgeFilesLines
* Clean up some preprocessor operationsPaul Smith2023-01-161-1/+1
|
* Use MK_OS_OS2 macro instead of __EMX__Paul Smith2023-01-161-1/+1
| | | | | * src/makeint.h: Set MK_OS_OS2 to 1 if __EMX__ is set. * src/*: Convert #if refs to __EMX__, to use MK_OS_OS2.
* Use MK_OS_DOS macro instead of __MSDOS__Paul Smith2023-01-161-4/+4
| | | | | | * src/configh.dos: Set MK_OS_DOS to 1 * src/*: Convert #if refs to __MSDOS__, to use MK_OS_DOS. * gl/lib/*: Ditto.
* Rename WINDOWS32 macro to MK_OS_W32Paul Smith2023-01-151-28/+28
| | | | | | | | | | * configure.ac: Set MK_OS_W32 to 1 if we're on Windows32. * src/config.h.W32: Ditto. * mk/Windows32.mk: Ditto. * src/makeint.h: Convert #if refs to WINDOWS32, to use MK_OS_W32. * src/*: Ditto. * src/w32/*: Ditto. * gl/lib/*: Ditto.
* Rename VMS macro to MK_OS_VMSPaul Smith2023-01-151-27/+27
| | | | | | * src/makeint.h: Set MK_OS_VMS to 1 if we're on VMS. * src/*: Convert all #if references to VMS, to use MK_OS_VMS. * gl/lib/*: Ditto.
* Remove support for AmigaOSPaul Smith2023-01-151-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a lot of specialized code for supporting AmigaOS and it has not been maintained for a number of years. It's highly unlikely that the latest versions even compile properly on AmigaOS anymore. After requesting that someone step forward to own the maintenance of the port in the GNU Make 4.4 release and getting no takers, I removed it. * NEWS: Announce the removal. * README.in: Remove README.Amiga reference. * README.Amiga: Remove unused file. * SCOPTIONS: Ditto. * src/amiga.c: Ditto. * src/amiga.h: Ditto. * src/config.ami: Ditto. * mk/Amiga.mk: Ditto. * Makefile.am: Remove references to deleted files. * Basic.mk.template: Ditto. * maintMakefile: Ditto. * src/commands.c: Remove ifdef'd Amiga code. * src/default.c: Ditto. * src/dir.c: Ditto. * src/file.c: Ditto. * src/function.c: Ditto. * src/job.c: Ditto. * src/job.h: Ditto. * src/main.c: Ditto. * src/os.h: Ditto. * src/read.c: Ditto. * src/remake.c: Ditto.
* Update support for OS/2Paul Smith2023-01-081-1/+7
| | | | | | | | | | | | | | | | | | Patches provided by KO Myung-Hun <komh78@gmail.com> * NEWS: Add a note. * AUTHORS: Add a new author. * README.OS2: Updates to build instructions. * src/dir.c (dir_contents_file_exists_p): Use a stack copy when modifying a const string. * src/job.c (construct_command_argv_internal): Ditto. Reuse variables rather than re-defining them. (exec_command): Cast a const string (we don't change it anyway). * src/getopt.c (_getopt_initialize): Reference unused variables. (_getopt_internal): Add block braces to quiet the compiler. * src/main.c (main): Cast argument to child_execute_job(). * src/posixos.c (set_blocking): Reference unused variables. * src/remake.c (f_mtime): Delete useless code.
* Update ancient glob/fnmatch implementationsPaul Smith2023-01-021-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | I looked again at trying to use the latest gnulib implemenentations of GNU glob and fnmatch, and the effort required to extract them from gnulib and make them portable to systems which don't support configure is simply far too daunting for me. However it's clear that the previous implementations are growing too long on the tooth to continue to be used without some maintenance, so perform some upkeep on them. - Remove support for pre-ANSI function definitions. - Remove the obsolete "register" keyword. - Assume standard ISO C90/C99 header file support. - Assume standard ISO C "void" and "const" support. - Avoid symbols prefixed with "__" as they're reserved. * maintMakefile: Add a rule to verify lib has the latest content. * src/dir.c: Use void* not __ptr_t which was removed. * gl/lib/glob.c: See above. * gl/lib/fnmatch.in.h: See above. * gl/lib/glob.in.h: See above. * gl/lib/fnmatch.c: See above. Remove __strchrnul(): it is not checked anywhere and is only used in one place anyway.
* Don't free uninitialized hash_tablePaul Smith2023-01-011-42/+40
| | | | | | * src/dir.c (clear_directory_contents): We use ht_vec to mark when we have initialized the hash_table: don't free if it's NULL. (everywhere): Use NULL instead of 0 when working with pointers.
* Update the copyright year on all filesPaul Smith2023-01-011-1/+1
|
* * src/dir.c (dir_contents_file_exists_p): Show dir name in error.Paul Smith2022-11-131-29/+26
| | | | | | | | If we fail to read a directory show the directory name in the error message. Pass struct directory instead of directory_contents to allow that. (dir_file_exists_p): Change dir_contents_file_exists_p caller. (open_dirstrem): Ditto.
* Fix issues found by ASAN and CoverityPaul Smith2022-10-311-1/+1
| | | | | | | | | | | | | | | * tests/test_driver.pl: Preserve the LSAN_OPTIONS variable. * tests/scripts/targets/ONESHELL: Don't set a local variable. * tests/scripts/functions/let: Test empty let variable. * src/posixos.c (osync_parse_mutex): Free existing osync_tmpfile. * src/misc.c (get_tmpfd): Set umask() before invoking mkstemp(). * src/ar.c (ar_parse_name): Check invalid name (shouldn't happen). * src/function.c (define_new_function): Free previous function entry when replacing it with a new one. * src/job.c (child_execute_job): Initialize pid for safety. (construct_command_argv_internal): In oneshell mode ensure that the returned argv has the right format (0th element is a pointer to the entire buffer).
* Set PATH_MAX on systems without a default valuePaul Smith2022-10-221-4/+4
| | | | | | | | | | | | | | | | Some systems (HURD) use fully-dynamic pathnames, with no limit. We can't support this without significant effort so for now set PATH_MAX to a large value. * src/makeint.h: Set PATH_MAX to 4096 if not set and MAXPATHLEN is also not set. Remove MAXPATHLEN setting: we won't use it. * src/misc.c (get_path_max): If we can't get the path max via pathconf() use the default PATH_MAX. * src/dir.c (find_directory) [W32]: Use MAX_PATH not MAXPATHLEN. (local_stat) [W32]: Ditto. * src/job.c (create_batch_file) [W32]: Ditto. * src/remake.c (name_mtime) [W32]: Ditto. * src/w32/w32os.c (os_anontmp) [W32]: Ditto.
* Update URLs to use https rather than httpPaul Smith2022-10-181-1/+1
| | | | | * (all): Change http:// to https:// * README.W32: Remove invalid link to mingw.org.
* Add ISDIRSEP() helper macro and use itPaul Smith2022-10-181-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | Create a ISDIRSEP() macro to check for directory separator chars using the stopchar_map, and replace inline checks and explicit STOP_SET calls with this macro. * src/makeint.h (ISDIRSEP): Create the macro using MAP_DIRSEP. * src/dir.c (find_directory): Replace inline checks with ISDIRSEP. (file_exists_p): Ditto. (file_impossible): Ditto. (file_impossible_p): Ditto. (local_stat): Ditto. * src/file.c (lookup_file): Ditto. * src/function.c (abspath): Ditto. * src/job.c (_is_unixy_shell): Ditto. (is_bourne_compatible_shell): Ditto. (construct_command_argv): Ditto. * src/main.c (find_and_set_default_shell): Ditto. (main): Ditto. * src/read.c (eval): Ditto. (parse_file_seq): Ditto. * src/remake.c (name_mtime): Ditto. * src/vpath.c (construct_vpath_list): Ditto.
* Provide new functions to convert long long to stringPaul Smith2022-09-251-22/+17
| | | | | | | | | | | | | | | | | | | | The previous attempt to use PRI* macros to avoid compiler-specific printf format specifiers didn't work because we are using raw long long type, not the uintX_t types. On systems where long and long long are the same size, uint64_t might be type "long" and PRId64 is just "ld". Instead write new functions that convert [unsigned] long long to a string and call those instead. * src/makeint.h: Declare make_lltoa() and make_ulltoa(). * src/misc.c (make_lltoa): New function that writes a long long value into a provided buffer. Return the buffer for ease-of-use. (make_ulltoa): Ditto, for unsigned long long. * src/function.c (func_wordlist): Call these new methods. Also rework the error strings so we share the translated string. * src/dir.c (print_dir_data_base): Call the new methods instead of using MSVC macros.
* * <all>: Update copyright notices.Paul Smith2022-02-101-1/+1
|
* Fix build and test issues on WindowsPaul Smith2021-03-281-2/+3
| | | | | | | | | * src/dep.h (DEP): Remove extraneous semicolon. * src/dir.c (find_directory) [W32]: Replace removed variable. * tests/scripts/features/include: Allow the extra default makefile searched for on Windows. * tests/scripts/functions/file: Use $(info ...) to avoid "command too long" errors on Windows.
* [SV 41273] Allow the directory cache to be invalidatedPaul Smith2020-11-291-113/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | Each time we invoke a command it's possible that it will change the filesystem in ways that were not described by the target. If that happens but we have cached previous directory contents then we may make decisions or report results based on obsolete information. Keep a count of how many commands we've invoked, and remember the current command count every time we load the contents of a directory. If we request the directory and the current command count has changed we know the cache is outdated so reload from scratch. * NEWS: Announce the change. * src/makeint.h (command_count): Create a global counter. * src/main.c (command_count): Ditto. * src/job.c (reap_children): Increment the counter on job completion. * src/function.c (func_file): Increment if we write a file. * src/dir.c (clear_directory_contents): Clear the current contents of a cached directory. (struct directory_contents): Remember the counter value. (struct directory): Remember the counter value for non-existing dirs. (find_directory): If we have a cached directory and the count hasn't changed then return it. Else, clear the previous contents and re-read from scratch. * tests/scripts/features/dircache: Add tests of the directory cache.
* [SV 57930] Cast char to unsigned char to call ctype functionsPaul Smith2020-05-031-1/+1
| | | | | | | | | | | | | This cast was already done almost everywhere: fix some stragglers. * src/load.c (load_file): Cast char to unsigned char. * src/misc.c (strcasecmp, strncasecmp): [!POSIX] Ditto. * src/dir.c (vms_hash): [VMS] Ditto. * src/vms_progname.c (set_program_name): [VMS] Ditto. * src/vms_jobs.c (posix_parse_dq): [VMS] Ditto. (posix_parse_dollar): [VMS] Ditto. (build_vms_cmd): [VMS] Ditto. (child_execute_job): [VMS] Ditto.
* * src/dir.c (local_stat): [WINDOWS32] Fix buffer-overflow warning.Jens Rehsack2020-03-311-4/+4
| | | | | | | [SV 57888] Provide space for the path to use MAXPATHLEN plus nul. Signed-off-by: Jens Rehsack <sno@netbsd.org> Copyright-paperwork-exempt: yes
* Update copyright statements for 2020Paul Smith2020-01-031-1/+1
|
* * configure.ac: Check whether struct dirent has a d_type fieldPaul Smith2019-09-071-2/+2
| | | | | | | * src/dir.c (dir_contents_file_exists_p): Use the autoconf macro HAVE_STRUCT_DIRENT_D_TYPE rather than relying on the GNU libc- specific _DIRENT_HAVE_D_TYPE. * lib/glob.c: Set HAVE_D_TYPE if HAVE_STRUCT_DIRENT_D_TYPE.
* * src/dir.c (dir_setup_glob): Initialize unused gl_offs.Paul Smith2019-09-071-0/+1
| | | | | * tests/scripts/functions/wildcard: Add trailing slash tests. Initial changes by Dmitry Goncharov <dgoncharov@users.sf.net>
* Update copyright statements for 2019Paul Smith2019-05-191-1/+1
|
* * src/dir.c: Preserve glob d_type fieldspagoveanu@gmail.com2018-08-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | When using GNU make on a system with glibc glob a pattern ending in a slash is also matching regular files, but only in subdirectories: $ mkdir -p dir/subdir $ cd dir $ touch file1 subdir/file2 $ echo 'test:; @echo $(wildcard */ */*/)' | make -f - subdir/ subdir/file2 $ echo 'test: */ */*/; @echo "$?" != */ */*/' | make -f - subdir/ subdir/file2 != subdir/ */*/ It happens because in the gl->gl_readdir callback supplied to glob(), dirent->d_type is set to DT_UNKNOWN, and the glob() implementation in glibc assumes that such a directory entry *cannot* possibly be a regular file. Pass the actual d_type down to glob(); this is the right thing to do even if glibc is fixed, because it saves an extra stat() syscall for each dirent. Copyright-paperwork-exempt: yes
* Resolve most of the Windows Visual Studio warnings.Paul Smith2018-07-021-5/+5
| | | | | * Convert integer types to size_t where necessary. * Align other integral types to avoid casts and type warnings.
* * all: Update Copyright statements for 2018Paul Smith2018-07-011-1/+1
|
* Rework directory structure to use GNU-recommended "src" directory.Paul Smith2017-11-191-0/+1346
Move the source code (other than glob) into the "src" subdirectory. Update all scripting and recommendations to support this change. * *.c, *.h, w32/*: Move to src/ * configure.ac, Makefile.am, maintMakefile: Locate new source files. * Basic.mk.template, mk/*: Update for new source file locations. * NEWS, README.DOS.template: Update for new locations. * build.template, build_w32.bat, builddos.bat: Ditto. * po/POTFILES.in: Ditto * tests/run_make_tests.pl, tests/scripts/features/load*: Ditto. * make.1: Move to doc. * mk/VMS.mk: Add support for building on VMS (hopefully). * makefile.vms, prepare_w32.bat: Remove. * SCOPTIONS: Update to define HAVE_CONFIG_H