Skip to content

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Nov 11, 2024

  • For some input files, fold would get stuck in a loop printing "\n when run with -b and -s options
  • In this case fold_file_byte() is called instead of fold_file()
  • The regular expressions $soft and $hard are expected to modify the length of $_ if they match
  • The while-loop controlled by $_ length never terminated if neither regex matched
  • Adding a condition to break out of the loop for no-match prevents the infinite loop
%perl fold -b -s ed  | head -n 2000 | less
...
00000c80: 676c 6520 6c65 7474 6572 2063 6f6d 6d61  gle letter comma
00000c90: 6e64 2065 6e74 6572 6564 2062 7920 7573  nd entered by us
00000ca0: 6572 0a6d 7920 2463 6f6d 6d61 6e64 7375  er.my $commandsu
00000cb0: 663b 2020 2020 2020 2020 2020 2020 2020  f;              
00000cc0: 2020 2023 2073 696e 676c 6520 6c65 7474     # single lett
00000cd0: 6572 206d 6f64 6966 6965 7220 6f66 2063  er modifier of c
00000ce0: 6f6d 6d61 6e64 0a0a 0a0a 0a0a 0a0a 0a0a  ommand..........
00000cf0: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d00: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d10: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d20: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d30: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d40: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d50: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d60: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d70: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d80: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000d90: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000da0: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000db0: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000dc0: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000dd0: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................
00000de0: 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a 0a0a  ................

* For some input files, fold would get stuck in a loop printing "\n when run with -b and -s options
* In this case fold_file_byte() is called instead of fold_file()
* The regular expressions $soft and $hard are expected to modify the length of $_ if they match
* The while-loop controlled by $_ length never terminated if neither regex matched
* Adding a condition to break out of the loop for no-match prevents the infinite loop
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: fold The fold program labels Nov 11, 2024
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:54 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 05:55 — with GitHub Actions Inactive
@mknos mknos changed the title fold: infinite loop for -bs WIP: fold: infinite loop for -bs Nov 11, 2024
@coveralls
Copy link

coveralls commented Nov 11, 2024

Pull Request Test Coverage Report for Build 11773015541

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 73.069%

Totals Coverage Status
Change from base Build 11772357361: -0.7%
Covered Lines: 350
Relevant Lines: 479

💛 - Coveralls

@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 11, 2024 06:00 — with GitHub Actions Inactive
@mknos mknos changed the title WIP: fold: infinite loop for -bs fold: infinite loop for -bs Nov 11, 2024
@briandfoy briandfoy merged commit 707ad88 into briandfoy:master Nov 11, 2024
21 of 22 checks passed
@briandfoy
Copy link
Owner

changes: fix possbile infinite loop in -bs

@briandfoy briandfoy self-assigned this Nov 11, 2024
@briandfoy briandfoy added Status: accepted The fix is accepted Type: bug an existing feature does not work and removed Priority: low get to this whenever Type: enhancement improve a feature that already exists labels Nov 11, 2024
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: fold The fold program Status: released there is a new release with this fix Type: bug an existing feature does not work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants