Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
a1e7e4a7
Commit
a1e7e4a7
authored
Jan 20, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation with -fno-exceptions (#402, #405)
parent
3f24a388
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
include/fmt/posix.cc
include/fmt/posix.cc
+14
-13
include/fmt/posix.h
include/fmt/posix.h
+1
-1
No files found.
include/fmt/posix.cc
View file @
a1e7e4a7
...
...
@@ -70,7 +70,7 @@ fmt::BufferedFile::BufferedFile(
fmt
::
cstring_view
filename
,
fmt
::
cstring_view
mode
)
{
FMT_RETRY_VAL
(
file_
,
FMT_SYSTEM
(
fopen
(
filename
.
c_str
(),
mode
.
c_str
())),
0
);
if
(
!
file_
)
throw
system_error
(
errno
,
"cannot open file {}"
,
filename
.
c_str
(
));
FMT_THROW
(
system_error
(
errno
,
"cannot open file {}"
,
filename
.
c_str
()
));
}
void
fmt
::
BufferedFile
::
close
()
{
...
...
@@ -79,7 +79,7 @@ void fmt::BufferedFile::close() {
int
result
=
FMT_SYSTEM
(
fclose
(
file_
));
file_
=
0
;
if
(
result
!=
0
)
throw
system_error
(
errno
,
"cannot close file"
);
FMT_THROW
(
system_error
(
errno
,
"cannot close file"
)
);
}
// A macro used to prevent expansion of fileno on broken versions of MinGW.
...
...
@@ -88,7 +88,7 @@ void fmt::BufferedFile::close() {
int
fmt
::
BufferedFile
::
fileno
()
const
{
int
fd
=
FMT_POSIX_CALL
(
fileno
FMT_ARGS
(
file_
));
if
(
fd
==
-
1
)
throw
system_error
(
errno
,
"cannot get file descriptor"
);
FMT_THROW
(
system_error
(
errno
,
"cannot get file descriptor"
)
);
return
fd
;
}
...
...
@@ -101,7 +101,7 @@ fmt::File::File(fmt::cstring_view path, int oflag) {
FMT_RETRY
(
fd_
,
FMT_POSIX_CALL
(
open
(
path
.
c_str
(),
oflag
,
mode
)));
#endif
if
(
fd_
==
-
1
)
throw
system_error
(
errno
,
"cannot open file {}"
,
path
.
c_str
(
));
FMT_THROW
(
system_error
(
errno
,
"cannot open file {}"
,
path
.
c_str
()
));
}
fmt
::
File
::~
File
()
FMT_NOEXCEPT
{
...
...
@@ -119,7 +119,7 @@ void fmt::File::close() {
int
result
=
FMT_POSIX_CALL
(
close
(
fd_
));
fd_
=
-
1
;
if
(
result
!=
0
)
throw
system_error
(
errno
,
"cannot close file"
);
FMT_THROW
(
system_error
(
errno
,
"cannot close file"
)
);
}
long
long
fmt
::
File
::
size
()
const
{
...
...
@@ -133,7 +133,7 @@ long long fmt::File::size() const {
if
(
size_lower
==
INVALID_FILE_SIZE
)
{
DWORD
error
=
GetLastError
();
if
(
error
!=
NO_ERROR
)
throw
windows_error
(
GetLastError
(),
"cannot get file size"
);
FMT_THROW
(
windows_error
(
GetLastError
(),
"cannot get file size"
)
);
}
unsigned
long
long
long_size
=
size_upper
;
return
(
long_size
<<
sizeof
(
DWORD
)
*
CHAR_BIT
)
|
size_lower
;
...
...
@@ -141,7 +141,7 @@ long long fmt::File::size() const {
typedef
struct
stat
Stat
;
Stat
file_stat
=
Stat
();
if
(
FMT_POSIX_CALL
(
fstat
(
fd_
,
&
file_stat
))
==
-
1
)
throw
system_error
(
errno
,
"cannot get file attributes"
);
FMT_THROW
(
system_error
(
errno
,
"cannot get file attributes"
)
);
static_assert
(
sizeof
(
long
long
)
>=
sizeof
(
file_stat
.
st_size
),
"return type of File::size is not large enough"
);
return
file_stat
.
st_size
;
...
...
@@ -152,7 +152,7 @@ std::size_t fmt::File::read(void *buffer, std::size_t count) {
RWResult
result
=
0
;
FMT_RETRY
(
result
,
FMT_POSIX_CALL
(
read
(
fd_
,
buffer
,
convert_rwcount
(
count
))));
if
(
result
<
0
)
throw
system_error
(
errno
,
"cannot read from file"
);
FMT_THROW
(
system_error
(
errno
,
"cannot read from file"
)
);
return
internal
::
to_unsigned
(
result
);
}
...
...
@@ -160,7 +160,7 @@ std::size_t fmt::File::write(const void *buffer, std::size_t count) {
RWResult
result
=
0
;
FMT_RETRY
(
result
,
FMT_POSIX_CALL
(
write
(
fd_
,
buffer
,
convert_rwcount
(
count
))));
if
(
result
<
0
)
throw
system_error
(
errno
,
"cannot write to file"
);
FMT_THROW
(
system_error
(
errno
,
"cannot write to file"
)
);
return
internal
::
to_unsigned
(
result
);
}
...
...
@@ -169,7 +169,7 @@ fmt::File fmt::File::dup(int fd) {
// http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html
int
new_fd
=
FMT_POSIX_CALL
(
dup
(
fd
));
if
(
new_fd
==
-
1
)
throw
system_error
(
errno
,
"cannot duplicate file descriptor {}"
,
fd
);
FMT_THROW
(
system_error
(
errno
,
"cannot duplicate file descriptor {}"
,
fd
)
);
return
File
(
new_fd
);
}
...
...
@@ -205,7 +205,7 @@ void fmt::File::pipe(File &read_end, File &write_end) {
int
result
=
FMT_POSIX_CALL
(
pipe
(
fds
));
#endif
if
(
result
!=
0
)
throw
system_error
(
errno
,
"cannot create pipe"
);
FMT_THROW
(
system_error
(
errno
,
"cannot create pipe"
)
);
// The following assignments don't throw because read_fd and write_fd
// are closed.
read_end
=
File
(
fds
[
0
]);
...
...
@@ -216,7 +216,8 @@ fmt::BufferedFile fmt::File::fdopen(const char *mode) {
// Don't retry as fdopen doesn't return EINTR.
FILE
*
f
=
FMT_POSIX_CALL
(
fdopen
(
fd_
,
mode
));
if
(
!
f
)
throw
system_error
(
errno
,
"cannot associate stream with file descriptor"
);
FMT_THROW
(
system_error
(
errno
,
"cannot associate stream with file descriptor"
));
BufferedFile
file
(
f
);
fd_
=
-
1
;
return
file
;
...
...
@@ -230,7 +231,7 @@ long fmt::getpagesize() {
#else
long
size
=
FMT_POSIX_CALL
(
sysconf
(
_SC_PAGESIZE
));
if
(
size
<
0
)
throw
system_error
(
errno
,
"cannot get memory page size"
);
FMT_THROW
(
system_error
(
errno
,
"cannot get memory page size"
)
);
return
size
;
#endif
}
include/fmt/posix.h
View file @
a1e7e4a7
...
...
@@ -388,7 +388,7 @@ class Locale {
Locale
()
:
locale_
(
newlocale
(
LC_NUMERIC_MASK
,
"C"
,
NULL
))
{
if
(
!
locale_
)
throw
fmt
::
system_error
(
errno
,
"cannot create locale"
);
FMT_THROW
(
fmt
::
system_error
(
errno
,
"cannot create locale"
)
);
}
~
Locale
()
{
freelocale
(
locale_
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment