The content of an import path literal; NULL when it is none this scan can * record (not a plain string, empty, too long, or with bytes no path has). */
| 1699 | /* The content of an import path literal; NULL when it is none this scan can |
| 1700 | * record (not a plain string, empty, too long, or with bytes no path has). */ |
| 1701 | static const char *go_import_path(const go_scan_t *s, TSNode lit, size_t *len) { |
| 1702 | const char *t = go_node_span(s, lit, len); |
| 1703 | if (*len < PAIR_LEN || (t[0] != '"' && t[0] != '`') || t[*len - SKIP_ONE] != t[0]) { |
| 1704 | return NULL; |
| 1705 | } |
| 1706 | t++; |
| 1707 | *len -= PAIR_LEN; |
| 1708 | if (*len == 0 || *len > GO_PATH_MAX) { |
| 1709 | return NULL; |
| 1710 | } |
| 1711 | for (size_t i = 0; i < *len; i++) { |
| 1712 | unsigned char c = (unsigned char)t[i]; |
| 1713 | if (c <= ' ' || c == '\\' || c == '"' || c == '`' || c == GO_ASCII_DEL) { |
| 1714 | return NULL; |
| 1715 | } |
| 1716 | } |
| 1717 | return t; |
| 1718 | } |
| 1719 | |
| 1720 | static void go_scan_import_spec(go_scan_t *s, TSNode spec) { |
| 1721 | size_t path_len = 0; |
no test coverage detected