Advances |text| to the start of the next line and writes the new position to |position|.
| 38 | // Advances |text| to the start of the next line and writes the new position to |
| 39 | // |position|. |
| 40 | spv_result_t advanceLine(spv_text text, spv_position position) { |
| 41 | while (true) { |
| 42 | if (position->index >= text->length) return SPV_END_OF_STREAM; |
| 43 | switch (text->str[position->index]) { |
| 44 | case '\0': |
| 45 | return SPV_END_OF_STREAM; |
| 46 | case '\n': |
| 47 | position->column = 0; |
| 48 | position->line++; |
| 49 | position->index++; |
| 50 | return SPV_SUCCESS; |
| 51 | default: |
| 52 | position->column++; |
| 53 | position->index++; |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // Advances |text| to first non white space character and writes the new |
| 60 | // position to |position|. |