perform in chunks, don’t read the entire file into memory ahead

This commit is contained in:
tg 2017-08-08 20:38:08 +00:00
parent ce64148abb
commit 252c4b181b
1 changed files with 24 additions and 22 deletions

View File

@ -1,5 +1,5 @@
# $Id$
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.115 2017/08/08 20:22:16 tg Exp $
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.116 2017/08/08 20:38:08 tg Exp $
#-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
@ -109,7 +109,8 @@ function hd_mksh {
\\builtin typeset dasc line i
\\builtin set +U
\\builtin cat "$@" | if \\builtin read -arN -1 line; then
\\builtin cat "$@" | {
while \\builtin read -arn 512 line; do
\\builtin typeset -i1 'line[*]'
i=0
while (( i < ${#line[*]} )); do
@ -130,13 +131,14 @@ function hd_mksh {
(( (pos++ & 15) == 7 )) && \
\\builtin print -nr -- '- '
done
done
while (( pos & 15 )); do
\\builtin print -nr ' '
(( (pos++ & 15) == 7 )) && \
\\builtin print -nr -- '- '
done
(( hv == 2147483647 )) || \\builtin print -r -- "$dasc|"
fi
}
}
# Berkeley C shell compatible dirs, popd, and pushd functions