Skip to contentSkip to conversation

kbuild: Fix cleanpatch to always replace leading space with tab

PATCH New Andi Kleen 1 participant 1 message Oct 10, 2014 Kbuild

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 kbuild: Fix cleanpatch to always replace leading space with tab

From: Andi Kleen <[email protected]>

If you have something like

<sp><sp><sp><sp><sp><sp><sp><sp>blabla

in a patch cleanpatch does not replace the spaces with tabs. That is because it only handles space in front of tab.

But it's more convenient if it also replaces space with tabs, even if there is no tab at all, as that is what checkpatch and other pedants expect.

---
 scripts/cleanpatch | 4 ++++
 1 file changed, 4 insertions(+)
scripts/cleanpatch +4 -0
index 9680d03..d14aac9 100755
@@ -39,6 +39,10 @@ sub clean_space_tabs($)
 	} elsif ($c eq " ") {
 	    $nsp++;
 	} else {
+	    while ($nsp >= 8) {
+	        $lo .= "\t";
+		$nsp -= 8;
+	    }
 	    $lo .= " " x $nsp;
 	    $pos += $nsp;
 	    $nsp = 0;
Signature · 1 line
1.9.3