| 43 | } |
| 44 | |
| 45 | ADFile::ADFile(std::vector<char> &buf) { |
| 46 | auto buffer_size = buf.size(); |
| 47 | |
| 48 | char *saved_locale; |
| 49 | saved_locale = setlocale(LC_NUMERIC, "C"); // Use '.' as delimiter for strtod |
| 50 | |
| 51 | ENSURE_OR_FAIL(buffer_size > 4, error_msg, return); |
| 52 | size_t file_buf_size = 3 * (1 + buffer_size); |
| 53 | file_buf = (char *)calloc(1, file_buf_size); |
| 54 | ENSURE_OR_FAIL(file_buf != nullptr, error_msg, return); |
| 55 | |
| 56 | arena = &file_buf[buffer_size + 1]; |
| 57 | arena_end = file_buf + file_buf_size - 1; |
| 58 | |
| 59 | std::copy(buf.begin(), buf.end(), file_buf); |
| 60 | file_buf[buffer_size] = 0; |
| 61 | *arena_end = 0; |
| 62 | |
| 63 | int current_block = 0; |
| 64 | int net_count = 0; |
| 65 | |
| 66 | std::vector<char *> lines; |
| 67 | stringfile(file_buf, lines); |
| 68 | |
| 69 | std::vector<char *>::iterator line_it = lines.begin(); |
| 70 | while (line_it != lines.end()) { |
| 71 | char *line = *line_it; |
| 72 | char *p; |
| 73 | ++line_it; |
| 74 | |
| 75 | while (isspace((uint8_t)*line)) line++; |
| 76 | if (!line[0]) continue; |
| 77 | |
| 78 | if (strstr(line, "RECORD=Track")) { |
| 79 | current_block = ADFILE_BLOCK_TRACKS; |
| 80 | } |
| 81 | |
| 82 | if (strstr(line, "RECORD=Net")) { |
| 83 | current_block = ADFILE_BLOCK_NETS; |
| 84 | } |
| 85 | |
| 86 | if (strstr(line, "RECORD=Component")) { |
| 87 | current_block = ADFILE_BLOCK_COMPONENTS; |
| 88 | } |
| 89 | |
| 90 | if (strstr(line, "RECORD=Pad")) { |
| 91 | current_block = ADFILE_BLOCK_PADS; |
| 92 | } |
| 93 | |
| 94 | if (strstr(line, "RECORD=Arc")) { |
| 95 | current_block = ADFILE_BLOCK_ARC; |
| 96 | } |
| 97 | |
| 98 | p = line; |
| 99 | |
| 100 | switch (current_block) { |
| 101 | case ADFILE_BLOCK_ARC: { |
| 102 | char *layer = NULL; |
nothing calls this directly
no test coverage detected