What the table named `key` is. `array`: it is written `[[key]]`. */
| 3827 | |
| 3828 | /* What the table named `key` is. `array`: it is written `[[key]]`. */ |
| 3829 | static rs_table_t rs_table_class(const rs_toml_key_t *key, bool array) { |
| 3830 | rs_table_t t = {.kind = RS_TABLE_OTHER}; |
| 3831 | if (!key->ok || key->n == 0) { |
| 3832 | return t; |
| 3833 | } |
| 3834 | const char *first = key->seg[0]; |
| 3835 | const char *last = key->seg[key->n - SKIP_ONE]; |
| 3836 | t.is_workspace = strcmp(first, "workspace") == 0; |
| 3837 | static const char *const targets[] = {"bin", "example", "test", "bench"}; |
| 3838 | for (size_t i = 0; array && key->n == SKIP_ONE && i < sizeof(targets) / sizeof(targets[0]); |
| 3839 | i++) { |
| 3840 | if (strcmp(first, targets[i]) == 0) { |
| 3841 | t.kind = RS_TABLE_TARGET; |
| 3842 | t.name = targets[i]; |
| 3843 | return t; |
| 3844 | } |
| 3845 | } |
| 3846 | if (array) { |
| 3847 | return t; |
| 3848 | } |
| 3849 | if (key->n == SKIP_ONE && strcmp(first, "package") == 0) { |
| 3850 | t.kind = RS_TABLE_PACKAGE; |
| 3851 | t.name = "package"; |
| 3852 | } else if (key->n == SKIP_ONE && strcmp(first, "lib") == 0) { |
| 3853 | t.kind = RS_TABLE_LIB; |
| 3854 | t.name = "lib"; |
| 3855 | } else if (key->n == PAIR_LEN && t.is_workspace && strcmp(last, "package") == 0) { |
| 3856 | t.kind = RS_TABLE_WORKSPACE_PACKAGE; |
| 3857 | t.name = "workspace.package"; |
| 3858 | } else if (rs_dep_kind(last)) { |
| 3859 | t.kind = RS_TABLE_DEPS; |
| 3860 | t.dep = t.is_workspace ? 'w' : rs_dep_kind(last); |
| 3861 | } else if (key->n >= PAIR_LEN && rs_dep_kind(key->seg[key->n - PAIR_LEN])) { |
| 3862 | t.kind = RS_TABLE_DEP; |
| 3863 | t.dep = t.is_workspace ? 'w' : rs_dep_kind(key->seg[key->n - PAIR_LEN]); |
| 3864 | t.name = last; |
| 3865 | } |
| 3866 | return t; |
| 3867 | } |
| 3868 | |
| 3869 | static void rs_rec_dep(rs_scan_t *s, char kind, const char *name, const char *attr, |
| 3870 | const char *value) { |
no test coverage detected