Created
November 22, 2016 14:20
-
-
Save yatsuta/14eb9c5c5cdee1aacbf02491418779bd to your computer and use it in GitHub Desktop.
indent C headers for readability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$reserved = 0; | |
$indent = 0; | |
while (<>) { | |
if ($reserved) { | |
$indent++; | |
$reserved = 0; | |
} | |
if (/^#if/) { | |
$reserved = 1; | |
} | |
if (/^#else/) { | |
$indent--; | |
$reserved = 1; | |
} | |
if (/^#endif/) { | |
$indent--; | |
} | |
$space = ""; | |
for ($i = 0; $i < $indent; $i++) {$space .= "__";} | |
print ($space . $_); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment