Patch to make GNU indent work on 64-bit file systems
Eric Fischer <[email protected]> Mon, 25 Mar 2013 13:43:19 -0700
| Newsgroups | gmane.comp.gnu.indent.bugs |
|---|---|
| Message-ID | <CAMJYP_O2sw5wwztmHgPDyAbFtgVsu_My3-_N_9f71eyya6Cjpg@mail.gmail.com> |
Indent doesn't work on file systems with 64-bit inode numbers because calls to fstat() will overflow and fail. Here is a minimal patch to make it use fstat64() instead, also at https://github.com/ericfischer/indent/commit/b9e8ee5c9b0e6b36737fab5cc821dfc7f2f57237 Eric _______________________________________________ bug-indent mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-indent
indent.diff
(application/octet-stream, 4.6 KB)
commit b9e8ee5c9b0e6b36737fab5cc821dfc7f2f57237 Author: Eric Fischer <[email protected]> Date: Mon Mar 25 13:38:06 2013 -0700 Minimal modifications to make indent work on 64-bit filesystems. Without these changes, fstat() will fail on files with 64-bit inode numbers, keeping the program from doing anything useful. diff --git a/src/backup.c b/src/backup.c index 09e51be..434fc5d 100644 --- a/src/backup.c +++ b/src/backup.c @@ -83,6 +83,8 @@ * Written by jla, based on code from djm (see `patch') */ +#define _LARGEFILE64_SOURCE + #include "sys.h" #include <ctype.h> @@ -479,8 +481,8 @@ void initialize_backups(void) */ void make_backup( - file_buffer_ty * file, - const struct stat * file_stats) + file_buffer_ty * file, + const struct stat64 * file_stats) { FILE * bf; char * backup_filename; diff --git a/src/backup.h b/src/backup.h index 84b459f..3f34eda 100644 --- a/src/backup.h +++ b/src/backup.h @@ -85,6 +85,6 @@ extern void initialize_backups(void); extern void make_backup( file_buffer_ty * file, - const struct stat * file_stats); + const struct stat64 * file_stats); #endif /* INDENT_BACKUP_H */ diff --git a/src/code_io.c b/src/code_io.c index 29d373b..5fea39b 100644 --- a/src/code_io.c +++ b/src/code_io.c @@ -42,6 +42,8 @@ * - 2002-01-17 D.Ingamells Add a final newline if not present in file. */ +#define _LARGEFILE64_SOURCE + #include "sys.h" #include <ctype.h> @@ -241,8 +243,8 @@ int current_column (void) */ file_buffer_ty * read_file( - char * filename, - struct stat * file_stats) + char * filename, + struct stat64 * file_stats) { static file_buffer_ty fileptr; @@ -262,7 +264,7 @@ file_buffer_ty * read_file( fatal (_("Can't open input file %s"), filename); } - if (fstat(fd, file_stats) < 0) + if (fstat64(fd, file_stats) < 0) { fatal (_("Can't stat input file %s"), filename); } diff --git a/src/code_io.h b/src/code_io.h index 10fe8e6..b52937a 100644 --- a/src/code_io.h +++ b/src/code_io.h @@ -64,7 +64,7 @@ extern char * cur_line; extern char * skip_horiz_space(const char * p); -extern file_buffer_ty *read_file (char *filename, struct stat *); +extern file_buffer_ty *read_file (char *filename, struct stat64 *); extern file_buffer_ty *read_stdin (void); extern int current_column (void); extern void fill_buffer (void); diff --git a/src/comments.c b/src/comments.c index 01776e8..50fba7f 100644 --- a/src/comments.c +++ b/src/comments.c @@ -18,6 +18,8 @@ * GNU General Public License for more details. */ +#define _LARGEFILE64_SOURCE + #include <string.h> #include "sys.h" diff --git a/src/indent.c b/src/indent.c index 94154f9..9a4dba6 100644 --- a/src/indent.c +++ b/src/indent.c @@ -49,6 +49,8 @@ * - 2008-03-08 DI Re-baselined on the more acceptable (license-wise) OpenBSD release 3.4. */ +#define _LARGEFILE64_SOURCE + #include "sys.h" #if defined (HAVE_UNISTD_H) @@ -3159,7 +3161,7 @@ static exit_values_ty indent_multiple_files(void) for (i = 0; input_files; i++, input_files--) { exit_values_ty status; - struct stat file_stats; + struct stat64 file_stats; in_name = in_file_names[i]; out_name = in_file_names[i]; @@ -3202,7 +3204,7 @@ static exit_values_ty indent_multiple_files(void) static exit_values_ty indent_single_file(BOOLEAN using_stdin) { exit_values_ty exit_status = total_success; - struct stat file_stats; + struct stat64 file_stats; if ((input_files == 0) || using_stdin) { diff --git a/src/output.c b/src/output.c index f0a0648..9dc4fff 100644 --- a/src/output.c +++ b/src/output.c @@ -56,6 +56,8 @@ * Added --indent-label and --linux-style options. */ +#define _LARGEFILE64_SOURCE + #include <stdio.h> #include <stdlib.h> #include <sys/types.h> @@ -1341,7 +1343,7 @@ extern void reopen_output_trunc( */ extern void close_output( - struct stat * file_stats, + struct stat64 * file_stats, const char * filename) { if (output != stdout) diff --git a/src/output.h b/src/output.h index a4b8354..4b8542b 100644 --- a/src/output.h +++ b/src/output.h @@ -66,7 +66,7 @@ extern void reopen_output_trunc( const char * filename); extern void close_output( - struct stat * file_stats, + struct stat64 * file_stats, const char * filename); extern void inhibit_indenting( diff --git a/src/sys.h b/src/sys.h index fecdcbc..5e25628 100644 --- a/src/sys.h +++ b/src/sys.h @@ -42,6 +42,8 @@ #ifndef SYS_H #define SYS_H +#define _LARGEFILE64_SOURCE + #ifdef HAVE_CONFIG_H #include "config.h" #endif