mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 22:17:54 +00:00
parallel: --linebuffer treat \r as a full line, too.
This commit is contained in:
parent
ed76fe2979
commit
0724162ad4
20
src/parallel
20
src/parallel
|
@ -1208,7 +1208,7 @@ sub check_invalid_option_combinations {
|
||||||
|
|
||||||
sub init_globals {
|
sub init_globals {
|
||||||
# Defaults:
|
# Defaults:
|
||||||
$Global::version = 20160722;
|
$Global::version = 20160724;
|
||||||
$Global::progname = 'parallel';
|
$Global::progname = 'parallel';
|
||||||
$Global::infinity = 2**31;
|
$Global::infinity = 2**31;
|
||||||
$Global::debug = 0;
|
$Global::debug = 0;
|
||||||
|
@ -8050,22 +8050,22 @@ sub linebuffer_print {
|
||||||
my $outputlength = 0;
|
my $outputlength = 0;
|
||||||
while(read($in_fh,substr($$partial,length $$partial),3276800)) {
|
while(read($in_fh,substr($$partial,length $$partial),3276800)) {
|
||||||
# Append to $$partial
|
# Append to $$partial
|
||||||
# Find the last \n
|
# Find the last \n or \r
|
||||||
my $i = ::rindex64($partial,"\n");
|
my $i = (::rindex64($partial,"\n")+1) || (::rindex64($partial,"\r")+1);
|
||||||
if($i != -1) {
|
if($i) {
|
||||||
# One or more complete lines were found
|
# One or more complete lines were found
|
||||||
$outputlength += $i+1;
|
$outputlength += $i;
|
||||||
if($opt::tag or defined $opt::tagstring) {
|
if($opt::tag or defined $opt::tagstring) {
|
||||||
# Replace ^ with $tag within the full line
|
# Replace ^ with $tag within the full line
|
||||||
my $tag = $self->tag();
|
my $tag = $self->tag();
|
||||||
substr($$partial,0,$i+1) =~ s/^/$tag/gm;
|
substr($$partial,0,$i) =~ s/^/$tag/gm;
|
||||||
# Length of partial line has changed: Find the last \n again
|
# Length of partial line has changed: Find the last \n/\r again
|
||||||
$i = ::rindex64($partial,"\n");
|
$i = (::rindex64($partial,"\n")+1) || (::rindex64($partial,"\r")+1);
|
||||||
}
|
}
|
||||||
# Print up to and including the last \n
|
# Print up to and including the last \n
|
||||||
print $out_fd substr($$partial,0,$i+1);
|
print $out_fd substr($$partial,0,$i);
|
||||||
# Remove the printed part
|
# Remove the printed part
|
||||||
substr($$partial,0,$i+1) = "";
|
substr($$partial,0,$i) = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->add_returnsize($outputlength);
|
$self->add_returnsize($outputlength);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue