(0000238)
|
sigonnea
|
2011-08-03 16:23
(bearbeitet am: 2011-08-03 16:51) |
|
The following patch fixes this bug. I can't find how to properly attach it to the bug report, so here it is inlined:
[Allow punctuation after closing a block
Benjamin Sigonneau <benjamin@xxxxxxxxxxxx.info>**20110803140159
Ignore-this: 8e62908a2f3ed1ae99a0b2bb80e014a
Closing parens have to be followed by whitespace *unless* they are
followed by some punctuation, eg. like in
(f x), (g y)
or in
[(f x); y]
] hunk ./src/checks/typo_spacesAroundBlocks.ml 48
| Camlp4.Sig.SYMBOL "{"
| Camlp4.Sig.LIDENT "begin" -> true
| _ -> false
-
+
let closing = function
| Camlp4.Sig.SYMBOL ")"
| Camlp4.Sig.SYMBOL "]"
hunk ./src/checks/typo_spacesAroundBlocks.ml 63
| (_, _, hd) :: _ -> closing hd
| [] -> true
+let punctuation = fun t ->
+ match t with
+ | Camlp4.Sig.SYMBOL ","
+ | Camlp4.Sig.SYMBOL "."
+ | Camlp4.Sig.SYMBOL ";"
+ | Camlp4.Sig.SYMBOL ":"
+ | Camlp4.Sig.SYMBOL "::"
+ | Camlp4.Sig.LABEL _
+ | Camlp4.Sig.OPTLABEL _ -> true
+ | _ -> false
+
+let first_punctuation = function
+ | (_, _, hd) :: _ -> punctuation hd
+ | [] -> true
+
let run _ _ (_, tokens) _ report =
let rec iter = function
| (_, _, prev) :: (line, column, (Camlp4.Sig.SYMBOL s)) :: tl ->
hunk ./src/checks/typo_spacesAroundBlocks.ml 84
let err = report.Check.error line (Some column) in
(match s with
| "(" | "[" | "[|" ->
- if not (opening prev) then
+ if not ((opening prev) || (punctuation prev)) then
Camlp4Utils.check_white "sign" s err prev;
Camlp4Utils.check_first_not_white "sign" s err tl
| ")" | "]" | "|]" ->
hunk ./src/checks/typo_spacesAroundBlocks.ml 90
if not ((closing prev) || (opening prev)) then
Camlp4Utils.check_not_white "sign" s err prev;
- if not (first_closing tl) then
+ if not ((first_closing tl) || (first_punctuation tl)) then
Camlp4Utils.check_first_white "sign" s err tl
| "{" | "}" ->
Camlp4Utils.check_white "sign" s err prev;
Context:
[TAG 1.0-beta
mascot@x9c.fr**20110715041203
Ignore-this: 5d3c45d2c84c26077cf3af5135d116a3
]
|
|
(0000240)
|
xclerc
|
2011-08-07 08:17
|
|
Thanks for reporting.
I have committed a slightly different patch, to underline the various kinds of symbol:
until now only "opening" and "closing" were explicitly handled; following your report we
now handle "opening", "closing", "punctuation", and "other".
note: the ability to upload/attach a file was disabled after a server attack... |
|