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

what: reduce code nesting #750

Merged
merged 1 commit into from
Oct 1, 2024
Merged

what: reduce code nesting #750

merged 1 commit into from
Oct 1, 2024

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Oct 1, 2024

  • Rewrite printWhat() function with fewer levels of nesting
  • Input loop is restructured to no longer require $done variable
  • Replace if-regex-matches loop with grep()
  • I verified that the output, with and without -s flag, matches the output of an older commit when running command across all of /usr/bin on my Linux system
  • I also ran a diff of output between -s and not-s to show that -s only lists one match per input file
%perl what /usr/bin/* > whatnew 
%perl ~/PerlPowerTools3/bin/what /usr/bin/* > whatold 
%cmp whatold whatnew 
%perl what -s /usr/bin/* > whatsnew 
%perl ~/PerlPowerTools3/bin/what -s /usr/bin/* > whatsold 
%cmp whatsnew whatsold  
%diff -U1 whatsnew whatnew 
--- whatsnew	2024-09-30 22:32:43.669989040 +0800
+++ whatnew	2024-09-30 22:31:50.659989071 +0800
@@ -282,2 +282,3 @@
 /usr/bin/crontab:
+         Copyright 1988,1989,1990,1993,1994 by Paul Vixie
          All rights reserved
@@ -300,2 +301,3 @@
 /usr/bin/cvs:
+        rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $
         rcsid_code: $MirOS: src/gnu/usr.bin/cvs/lib/getdate.c,v 1.19 2021/01/30 02:30:17 tg Exp $
@@ -433,2 +435,3 @@
          dvi2tty.c 6.0.0 20160305 M.J.E. Mol (c) 1989-2010, and contributors (c) -2016
+         dvistuff.c  6.0.0 20101027 M.J.E. Mol (c) 1989-2010
 /usr/bin/dviasm:
@@ -542,2 +545,3 @@
 /usr/bin/file:
+        $File: file.c,v 1.187 2020/06/07 17:38:30 christos Exp $
         $File: seccomp.c,v 1.15 2020/05/30 23:56:26 christos Exp $
@@ -1372,2 +1376,3 @@
 /usr/bin/pbyacc:
+        yaccpar 1.8 (Berkeley) 01/20/91 (JAKE-P5BP-0.6 04/26/98)
         yaccpar 1.8 (Berkeley) 01/20/91

* Rewrite printWhat() function with fewer levels of nesting
* Input loop is restructured to no longer require $done variable
* Replace if-regex-matches loop with grep()
* I verified that the output, with and without -s flag, matches the output of an older commit when running command across all of /usr/bin on my Linux system
* I also ran a diff of output between -s and not-s to show that -s only lists one match per input file
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: what The what program labels Oct 1, 2024
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:15 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 1, 2024 12:16 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Oct 1, 2024

Pull Request Test Coverage Report for Build 11125085784

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 11098690193: -0.7%
Covered Lines: 350
Relevant Lines: 479

💛 - Coveralls

@briandfoy briandfoy merged commit 97648b6 into briandfoy:master Oct 1, 2024
22 of 23 checks passed
@briandfoy briandfoy self-assigned this Oct 1, 2024
@briandfoy briandfoy removed the Priority: low get to this whenever label Oct 1, 2024
@briandfoy briandfoy added the Status: accepted The fix is accepted label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: what The what program Status: accepted The fix is accepted Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants