Skip to content

Commit 1686352

Browse files
committed
Addresses review comments.
1 parent 26065dd commit 1686352

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

libcxx/include/fstream

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,10 @@ private:
287287
_LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&);
288288

289289
// There are multiple (__)open function, they use different C-API open
290-
// function. After that call these functions behave the same. This function
290+
// function. After that call these functions behave the same. This function
291291
// does that part and determines the final return value.
292-
_LIBCPP_HIDE_FROM_ABI basic_filebuf* __open_common_part(ios_base::openmode __mode) {
292+
_LIBCPP_HIDE_FROM_ABI basic_filebuf* __do_open(FILE* __file, ios_base::openmode __mode) {
293+
__file_ = __file;
293294
if (!__file_)
294295
return nullptr;
295296

@@ -599,8 +600,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char*
599600
if (!__mdstr)
600601
return nullptr;
601602

602-
__file_ = fopen(__s, __mdstr);
603-
return __open_common_part(__mode);
603+
return __do_open(fopen(__s, __mdstr), __mode);
604604
}
605605

606606
template <class _CharT, class _Traits>
@@ -611,8 +611,7 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in
611611
if (!__mdstr)
612612
return nullptr;
613613

614-
__file_ = fdopen(__fd, __mdstr);
615-
return __open_common_part(__mode);
614+
return __do_open(fdopen(__fd, __mdstr), __mode);
616615
}
617616

618617
# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
@@ -626,8 +625,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar
626625
if (!__mdstr)
627626
return nullptr;
628627

629-
__file_ = _wfopen(__s, __mdstr);
630-
return __open_common_part(__mode);
628+
return __do_open(_wfopen(__s, __mdstr), __mode);
631629
}
632630
# endif
633631

0 commit comments

Comments
 (0)