wrapPythonProgram: fix magical sed expression

* Treat #! as all other comments;
* Treat comma at the end as a multi-line marker;
* Skip lines with a space at start (they are continuing previous lines);
* Don't allow spaces in front of quotes or the first real statement.
This commit is contained in:
Nikolay Amiantov 2016-08-17 04:31:35 +03:00
parent 4ad459e3e0
commit adafdb88f5

View File

@ -53,7 +53,7 @@ in modules // {
isSingle = elem quote [ "\"" "'\"'\"'" ];
endQuote = if isSingle then "[^\\\\]${quote}" else quote;
in ''
/^ *[a-z]?${quote}/ {
/^[a-z]?${quote}/ {
/${quote}${quote}|${quote}.*${endQuote}/{n;br}
:${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label}
}
@ -73,11 +73,11 @@ in modules // {
in ''
1 {
/^#!/!b; :r
/\\$/{N;br}
/__future__|^ *(#.*)?$/{n;br}
:r
/\\$|,$/{N;br}
/__future__|^ |^ *(#.*)?$/{n;br}
${concatImapStrings mkStringSkipper quoteVariants}
/^ *[^# ]/i ${replaceStrings ["\n"] [";"] preamble}
/^[^# ]/i ${replaceStrings ["\n"] [";"] preamble}
}
'';
}