View Issue Details

IDProjectCategoryView StatusLast Update
0000624Perl for OS/2Feature Requestpublic2014-09-11 12:22
ReporterkomhAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Summary0000624: setmode() on stdin/stdout/stderr
DescriptionHi/2.

Currently, setmode() works on every file handle unconditionally. But if the handle is a console, it's better to set it to a text mode even if a binary mode is requested.

In practice, a windows port of perl behave like this. In fact, MinGW.

How about mimicing this ?
TagsNo tags attached.

Activities

komh

2014-09-11 12:22

reporter  

0001-Set-a-handle-to-a-text-mode-if-it-is-a-console.patch (633 bytes)
From fc4f98ac4e50adbaa94a4dcb4b4d1489f82d12ac Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Thu, 11 Sep 2014 11:42:47 +0900
Subject: [PATCH] Set a handle to a text mode if it is a console

---
 os2/os2ish.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/os2/os2ish.h b/os2/os2ish.h
index a0f984b..3429bfb 100644
--- a/os2/os2ish.h
+++ b/os2/os2ish.h
@@ -472,6 +472,9 @@ char *ctermid(char *s);
 
 #define OP_BINARY O_BINARY
 
+#define setmode(handle, mode) \
+    (setmode((handle), isatty((handle)) ? O_TEXT : (mode)))
+
 #define OS2_STAT_HACK 1
 #if OS2_STAT_HACK
 
-- 
1.7.3.2

Issue History

Date Modified Username Field Change
2014-09-11 12:22 komh New Issue
2014-09-11 12:22 komh File Added: 0001-Set-a-handle-to-a-text-mode-if-it-is-a-console.patch