@@ -91,13 +91,11 @@ asm(" .global __use_full_stdio\n");
91
91
92
92
using namespace mbed;
93
93
94
- #if defined(__MICROLIB)
95
- // Before version 5.03, we were using a patched version of microlib with proper names
96
- extern const char __stdin_name[] = " :tt" ;
97
- extern const char __stdout_name[] = " :tt" ;
98
- extern const char __stderr_name[] = " :tt" ;
99
-
100
- #else
94
+ // Microlib currently does not allow re-defining the pathnames for the
95
+ // standard I/O device handles (STDIN, STDOUT, and STDERR).
96
+ // It uses the default pathname ":tt" at library initialization to identify
97
+ // them all.
98
+ #if !defined(__MICROLIB)
101
99
extern const char __stdin_name[] = " /stdin" ;
102
100
extern const char __stdout_name[] = " /stdout" ;
103
101
extern const char __stderr_name[] = " /stderr" ;
@@ -555,11 +553,15 @@ std::FILE *fdopen(FileHandle *fh, const char *mode)
555
553
extern " C" FILEHANDLE PREFIX (_open)(const char *name, int openflags)
556
554
{
557
555
#if defined(__MICROLIB)
558
- // Before version 5.03, we were using a patched version of microlib with proper names
559
- // This is the workaround that the microlib author suggested us
560
- static int n = 0 ;
561
- if (std::strcmp (name, " :tt" ) == 0 && n < 3 ) {
562
- return n++;
556
+ // Use the mode requested to select the standard I/O device handle to return.
557
+ if (std::strcmp (name, " :tt" ) == 0 ) {
558
+ if (openflags & OPEN_W) {
559
+ return STDOUT_FILENO;
560
+ } else if (openflags & OPEN_A) {
561
+ return STDERR_FILENO;
562
+ } else {
563
+ return STDIN_FILENO;
564
+ }
563
565
}
564
566
#else
565
567
/* Use the posix convention that stdin,out,err are filehandles 0,1,2.
0 commit comments