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

log2changes.pl: wrap long lines at 80 columns #9897

Closed
wants to merge 2 commits into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Nov 11, 2022

Also, only use author names in the output.

Fixes #9896
Reported-by: John Sherrill

Also, only use author names in the output.

Fixes #9896
Reported-by: John Sherrill
@bagder bagder added the script label Nov 11, 2022
my ($p, $msg)=@_;
while(length($msg) > 77) {
print $p.substr($msg, 0, 77, "")."\n";
$p=" ";
Copy link
Member

@vszakats vszakats Nov 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid outputting lines with spaces-only (untested):

$o=substr($msg, 0, 77, "");
if $o ne "" {
    $o=$p.$o;
}
print $o."\n";

Fixed earlier in fde1cb9.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see them actually occurring? I tried this:

diff --git a/scripts/log2changes.pl b/scripts/log2changes.pl
index f4c06b750..fbaf177a9 100755
--- a/scripts/log2changes.pl
+++ b/scripts/log2changes.pl
@@ -41,11 +41,12 @@ sub printmsg {
     my ($p, $msg)=@_;
     while(length($msg) > 77) {
         print $p.substr($msg, 0, 77, "")."\n";
         $p="  ";
     }
-    print "$p$msg\n";
+    print "$p$msg\n" if($msg !~ /^\s+\z/);
+    print "HERE\n" if($msg =~ /^\s+\z/);
 }
 

... but I don't see any HERE output when I try this?

Copy link
Member

@vszakats vszakats Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why the test doesn't trigger, but the spaces are definitely there in the output:
Screen Shot 2022-11-14 at 11 31 24

Also, my patch was incomplete, here's one that fixes the above (and multiple issues with my untested patch):

--- log2changes-a.pl
+++ log2changes-b.pl
@@ -40,9 +40,16 @@
 sub printmsg {
     my ($p, $msg)=@_;
     while(length($msg) > 77) {
-        print $p.substr($msg, 0, 77, "")."\n";
+        $o=substr($msg, 0, 77, "");
+        if($o eq "") {
+            $p="";
+        }
+        print "$p$o\n";
         $p="  ";
     }
+    if($msg eq "") {
+        $p="";
+    }
     print "$p$msg\n";
 }

Copy link
Member Author

@bagder bagder Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now I get it. I think it can be simplified to:

index f4c06b750..ee8a753eb 100755
--- a/scripts/log2changes.pl
+++ b/scripts/log2changes.pl
@@ -41,10 +41,13 @@ sub printmsg {
     my ($p, $msg)=@_;
     while(length($msg) > 77) {
         print $p.substr($msg, 0, 77, "")."\n";
         $p="  ";
     }
+    if($msg eq "") {
+        $p = "";
+    }
     print "$p$msg\n";
 }
 
 print

... since it it isn't likely that lines longer than 77 columns would return a "" (or even spaces-only) for those initial 77 columns.

@bagder bagder closed this in 9805109 Nov 15, 2022
@bagder bagder deleted the bagder/log2changes-80col branch November 15, 2022 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

OS400 sh makefile.sh > makelog 2>&1 fails.
2 participants