Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fold: remove assert in adj_col() #835

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions bin/fold
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ my %opt;
getopts('bsw:', \%opt) or usage();
my $Tabstop = 8; # sane tab stops
my $Width = defined $opt{'w'} ? $opt{'w'} : 80;
my $Byte_Only = $opt{'b'} || 0;
my $Space_Break = $opt{'s'} || 0;
my $Byte_Only = $opt{'b'};
my $Space_Break = $opt{'s'};

sub usage {
warn "$Program: @_\n" if @_;
warn qq[
usage: $Program [-bs] [-w width] [file ...]
-s split lines on whitespace where possible
Expand All @@ -59,10 +58,12 @@ usage: $Program [-bs] [-w width] [file ...]
}

unless ($Width && $Width =~ /^\d+$/) {
usage("illegal width value `$Width'");
warn "$Program: illegal width value `$Width'\n";
usage();
}
if ($Space_Break && $Width < $Tabstop) {
usage("width must be greater than $Tabstop with the -s option");
warn "$Program: width must be greater than $Tabstop with the -s option\n";
usage();
}
my $func = $Byte_Only ? \&fold_file_byte : \&fold_file;

Expand Down Expand Up @@ -101,8 +102,6 @@ exit $rc;
sub adj_col {
my($col, $char) = @_;

die "XXX: called while byte count set" if $Byte_Only;

# algorithm from BSD fold --tchrist
if ($char eq "\b") { $col-- if $col }
elsif ($char eq "\r") { $col = 0; }
Expand Down
Loading