summaryrefslogtreecommitdiff
path: root/core/src/xmake/io/stdfile.c
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-09 22:34:50 +0800
committerruki <[email protected]>2025-11-09 22:34:50 +0800
commitbf2da8a3d7f04bf5ffcdce8fd4c334d5421d3494 (patch)
tree054a98d5d2b875f9bb552c6848a31877e5afde4c /core/src/xmake/io/stdfile.c
parentf2f3821a0248b24941566c90e7aabcc0e7d95e77 (diff)
format core
Diffstat (limited to 'core/src/xmake/io/stdfile.c')
-rw-r--r--core/src/xmake/io/stdfile.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/core/src/xmake/io/stdfile.c b/core/src/xmake/io/stdfile.c
index 0dcb43501..ac77b272d 100644
--- a/core/src/xmake/io/stdfile.c
+++ b/core/src/xmake/io/stdfile.c
@@ -71,8 +71,9 @@ static tb_size_t xm_io_stdfile_isatty(tb_size_t type) {
/* we cannot call is_cygpty for stdin, because it will cause io.readable is always true
* https://github.com/xmake-io/xmake/issues/2504#issuecomment-1170130756
*/
- if (!answer && type != XM_IO_FILE_TYPE_STDIN)
+ if (!answer && type != XM_IO_FILE_TYPE_STDIN) {
answer = is_cygpty(console_handle);
+ }
#else
switch (type) {
case XM_IO_FILE_TYPE_STDIN:
@@ -87,8 +88,9 @@ static tb_size_t xm_io_stdfile_isatty(tb_size_t type) {
}
#endif
- if (answer)
+ if (answer) {
type |= XM_IO_FILE_FLAG_TTY;
+ }
return type;
}
@@ -97,8 +99,9 @@ static tb_void_t xm_io_stdfile_init_buffer(tb_size_t type) {
#if !defined(TB_CONFIG_OS_WINDOWS)
struct stat stats;
tb_int_t size = BUFSIZ;
- if (fstat(fileno(stdout), &stats) != -1)
+ if (fstat(fileno(stdout), &stats) != -1) {
size = stats.st_blksize;
+ }
setvbuf(stdout, tb_null, _IOLBF, size);
#endif
}
@@ -154,8 +157,9 @@ tb_int_t xm_io_stdfile(lua_State *lua) {
* @note we need to ensure that it is a singleton in the external lua script, and will only be created once, e.g. io.stdin, io.stdout, io.stderr
*/
xm_io_file_t *file = xm_io_stdfile_new(lua, type);
- if (file)
+ if (file) {
return 1;
- else
+ } else {
xm_io_return_error(lua, "invalid stdfile type!");
+ }
}