skipCommentsAndSpace removes leading whitespace, line comments (--) and block comments (/* */, nested) from s. Returns ok=false on an unterminated block comment.
(s string)
| 173 | // block comments (/* */, nested) from s. Returns ok=false on an unterminated |
| 174 | // block comment. |
| 175 | func skipCommentsAndSpace(s string) (string, bool) { |
| 176 | for { |
| 177 | s = strings.TrimLeft(s, " \t\r\n") |
| 178 | switch { |
| 179 | case strings.HasPrefix(s, "--"): |
| 180 | idx := strings.IndexByte(s, '\n') |
| 181 | if idx < 0 { |
| 182 | return "", true |
| 183 | } |
| 184 | s = s[idx+1:] |
| 185 | case strings.HasPrefix(s, "/*"): |
| 186 | depth := 1 |
| 187 | i := 2 |
| 188 | for i < len(s) && depth > 0 { |
| 189 | switch { |
| 190 | case strings.HasPrefix(s[i:], "/*"): |
| 191 | depth++ |
| 192 | i += 2 |
| 193 | case strings.HasPrefix(s[i:], "*/"): |
| 194 | depth-- |
| 195 | i += 2 |
| 196 | default: |
| 197 | i++ |
| 198 | } |
| 199 | } |
| 200 | if depth > 0 { |
| 201 | return "", false |
| 202 | } |
| 203 | s = s[i:] |
| 204 | default: |
| 205 | return s, true |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | // hasTrailingStatement reports whether query contains a top-level semicolon |
| 211 | // (outside string literals, quoted identifiers, and comments) followed by |
no outgoing calls
no test coverage detected