summaryrefslogtreecommitdiff
path: root/contrib/expat/xmlwf/readfilemap.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2019-11-25 07:48:16 +0000
committerXin LI <delphij@FreeBSD.org>2019-11-25 07:48:16 +0000
commit6b2c1e49da284f28ec7b52f7c031474087e37104 (patch)
tree1c6eabb549a0be6167f4f25f3e388afa0f730197 /contrib/expat/xmlwf/readfilemap.c
parent6a14746c01a91a9f33f67d79565d01d96a879a3a (diff)
parent987ba809b8add6260181a8c036ec3c017948ff56 (diff)
downloadsrc-test2-6b2c1e49da284f28ec7b52f7c031474087e37104.tar.gz
src-test2-6b2c1e49da284f28ec7b52f7c031474087e37104.zip
Notes
Diffstat (limited to 'contrib/expat/xmlwf/readfilemap.c')
-rw-r--r--contrib/expat/xmlwf/readfilemap.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/contrib/expat/xmlwf/readfilemap.c b/contrib/expat/xmlwf/readfilemap.c
index 4c4780bde0e3..d5b84f995ad4 100644
--- a/contrib/expat/xmlwf/readfilemap.c
+++ b/contrib/expat/xmlwf/readfilemap.c
@@ -37,40 +37,40 @@
#include <stdio.h>
/* Functions close(2) and read(2) */
-#if !defined(_WIN32) && !defined(_WIN64)
-# include <unistd.h>
+#if ! defined(_WIN32) && ! defined(_WIN64)
+# include <unistd.h>
#endif
/* Function "read": */
#if defined(_MSC_VER)
-# include <io.h>
- /* https://msdn.microsoft.com/en-us/library/wyssk1bs(v=vs.100).aspx */
-# define _EXPAT_read _read
-# define _EXPAT_read_count_t int
-# define _EXPAT_read_req_t unsigned int
-#else /* POSIX */
- /* http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html */
-# define _EXPAT_read read
-# define _EXPAT_read_count_t ssize_t
-# define _EXPAT_read_req_t size_t
+# include <io.h>
+/* https://msdn.microsoft.com/en-us/library/wyssk1bs(v=vs.100).aspx */
+# define _EXPAT_read _read
+# define _EXPAT_read_count_t int
+# define _EXPAT_read_req_t unsigned int
+#else /* POSIX */
+/* http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html */
+# define _EXPAT_read read
+# define _EXPAT_read_count_t ssize_t
+# define _EXPAT_read_req_t size_t
#endif
#ifndef S_ISREG
-# ifndef S_IFREG
-# define S_IFREG _S_IFREG
-# endif
-# ifndef S_IFMT
-# define S_IFMT _S_IFMT
-# endif
-# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# ifndef S_IFREG
+# define S_IFREG _S_IFREG
+# endif
+# ifndef S_IFMT
+# define S_IFMT _S_IFMT
+# endif
+# define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
#endif /* not S_ISREG */
#ifndef O_BINARY
-# ifdef _O_BINARY
-# define O_BINARY _O_BINARY
-# else
-# define O_BINARY 0
-# endif
+# ifdef _O_BINARY
+# define O_BINARY _O_BINARY
+# else
+# define O_BINARY 0
+# endif
#endif
#include "xmltchar.h"
@@ -79,15 +79,14 @@
int
filemap(const tchar *name,
void (*processor)(const void *, size_t, const tchar *, void *arg),
- void *arg)
-{
+ void *arg) {
size_t nbytes;
int fd;
_EXPAT_read_count_t n;
struct stat sb;
void *p;
- fd = topen(name, O_RDONLY|O_BINARY);
+ fd = topen(name, O_RDONLY | O_BINARY);
if (fd < 0) {
tperror(name);
return 0;
@@ -97,14 +96,14 @@ filemap(const tchar *name,
close(fd);
return 0;
}
- if (!S_ISREG(sb.st_mode)) {
+ if (! S_ISREG(sb.st_mode)) {
ftprintf(stderr, T("%s: not a regular file\n"), name);
close(fd);
return 0;
}
if (sb.st_size > XML_MAX_CHUNK_LEN) {
close(fd);
- return 2; /* Cannot be passed to XML_Parse in one go */
+ return 2; /* Cannot be passed to XML_Parse in one go */
}
nbytes = sb.st_size;
@@ -116,7 +115,7 @@ filemap(const tchar *name,
return 1;
}
p = malloc(nbytes);
- if (!p) {
+ if (! p) {
ftprintf(stderr, T("%s: out of memory\n"), name);
close(fd);
return 0;