Enable 64-bit stat

epel9
Petr Písař 12 years ago
parent 8091e8f2af
commit 01526ea0b7

@ -0,0 +1,102 @@
From 7ef312f8a721b99469ea85e33e973475006c6a7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 19 Feb 2013 13:17:12 +0100
Subject: [PATCH 2/2] Allow 64-bit stat
---
src/code_io.c | 38 ++++++++++++++++++++++++++++++++------
src/indent.h | 2 +-
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/src/code_io.c b/src/code_io.c
index 8c8fd41..8b93188 100644
--- a/src/code_io.c
+++ b/src/code_io.c
@@ -50,6 +50,8 @@
#include <unistd.h>
#endif
#include <string.h>
+#include <errno.h>
+#include <limits.h>
#ifdef VMS
#include <file.h>
@@ -246,13 +248,18 @@ extern file_buffer_ty * read_file(
{
static file_buffer_ty fileptr = {NULL};
+#if defined(__MSDOS__) || defined(VMS)
/*
* size is required to be unsigned for MSDOS,
* in order to read files larger than 32767
* bytes in a 16-bit world...
*/
- unsigned int size;
+ unsigned int size, size_to_read;
+#else
+ ssize_t size;
+ size_t size_to_read;
+#endif
int namelen = strlen(filename);
int fd = open(filename, O_RDONLY, 0777);
@@ -289,6 +296,10 @@ extern file_buffer_ty * read_file(
}
}
+ if (file_stats->st_size > SSIZE_MAX)
+ {
+ fatal(_("File %s is too big to read"), filename);
+ }
fileptr.size = file_stats->st_size;
if (fileptr.data != 0)
@@ -305,11 +316,26 @@ extern file_buffer_ty * read_file(
* newline. */
}
- size = INDENT_SYS_READ (fd, fileptr.data, fileptr.size);
-
- if (size == (unsigned int) -1)
- {
- fatal (_("Error reading input file %s"), filename);
+ size_to_read = fileptr.size;
+ while (size_to_read > 0) {
+ size = INDENT_SYS_READ (fd, fileptr.data + fileptr.size - size_to_read,
+ size_to_read);
+
+ if (size ==
+#if defined(__MSDOS__) || defined(VMS)
+ (unsigned int)
+#endif
+ -1)
+ {
+#if !defined(__MSDOS__) && !defined(VMS)
+ if (errno == EINTR)
+ {
+ continue;
+ }
+#endif
+ fatal (_("Error reading input file %s"), filename);
+ }
+ size_to_read -= size;
}
if (close (fd) < 0)
diff --git a/src/indent.h b/src/indent.h
index 60ccb5a..bcb6b64 100644
--- a/src/indent.h
+++ b/src/indent.h
@@ -106,7 +106,7 @@ typedef unsigned char BOOLEAN;
typedef struct file_buffer
{
char *name;
- unsigned long size;
+ size_t size;
char *data;
} file_buffer_ty;
--
1.8.1.2

@ -17,6 +17,8 @@ Patch8: indent-2.2.11-Do-not-split-decimal-float-suffix-from-constant.patch
Patch9: indent-2.2.11-Return-non-zero-exit-code-on-tests-failure.patch Patch9: indent-2.2.11-Return-non-zero-exit-code-on-tests-failure.patch
# Submitted to upstream # Submitted to upstream
Patch10: indent-2.2.11-Fix-compiler-warnings.patch Patch10: indent-2.2.11-Fix-compiler-warnings.patch
# Submitted to upstream
Patch11: indent-2.2.11-Allow-64-bit-stat.patch
# gperf to update pre-generated code to fix compiler warnings # gperf to update pre-generated code to fix compiler warnings
BuildRequires: gperf BuildRequires: gperf
BuildRequires: texinfo texi2html BuildRequires: texinfo texi2html
@ -39,11 +41,13 @@ you want a program to format your code.
%patch8 -p1 -b .float_suffix %patch8 -p1 -b .float_suffix
%patch9 -p1 -b .exit_code %patch9 -p1 -b .exit_code
%patch10 -p1 -b .warnings %patch10 -p1 -b .warnings
%patch11 -p1 -b .warnings
# Regenerate sources # Regenerate sources
rm src/gperf.c src/gperf-cc.c rm src/gperf.c src/gperf-cc.c
%build %build
%configure # Enable 64-bit stat(2)
%configure CFLAGS='%optflags -D_FILE_OFFSET_BITS=64'
make %{?_smp_mflags} make %{?_smp_mflags}
%install %install
@ -74,6 +78,7 @@ fi
%changelog %changelog
* Tue Feb 19 2013 Petr Pisar <ppisar@redhat.com> - 2.2.11-9 * Tue Feb 19 2013 Petr Pisar <ppisar@redhat.com> - 2.2.11-9
- Fix compiler warnings - Fix compiler warnings
- Enable 64-bit stat
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.11-8 * Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.11-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

Loading…
Cancel
Save