|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Syntax highlighting of one line of text (text_hl.h): the rules of a bench text, JSON and CSV. More...
Data Structures | |
| struct | spans_t |
| Where the spans of a line are written. More... | |
Macros | |
| #define | CHECKSUM_DIGITS 8u |
| Digits of the checksum in a KST file's "checksum" line. | |
| #define | HEADING_MIN 3u |
| Characters a line has at least to be a heading. | |
| #define | CLASS_CSS(name, css, role) |
| Expands a row of TEXT_HL_CLASS_ROWS to its style sheet name. | |
Enumerations | |
| enum | letter_t { LETTER_NONE = 0 , LETTER_UPPER , LETTER_LOWER } |
| The case of a letter. More... | |
Functions | |
| static bool | is_word (unsigned char b) |
Whether b belongs to a word: an ASCII letter or digit, "_", or any byte of a UTF-8 sequence. | |
| static bool | is_digit (unsigned char b) |
Whether b is an ASCII digit. | |
| static bool | is_hex (unsigned char b) |
Whether b is a hexadecimal digit. | |
| static bool | is_blank (unsigned char b) |
Whether b is a space or a tab. | |
| static letter_t | letter (const unsigned char *s, size_t n, size_t *len) |
The case of the letter at s: ASCII and the 7 German letters. | |
| static void | emit (spans_t *sp, size_t start, size_t len, text_hl_class_t cls) |
Add bytes start to start + len as class cls, joined to the last span when it has that class. | |
| static void | trim (const char *s, size_t *a, size_t *b) |
Narrow [*a, *b) of s past the blanks at both ends. | |
| const char * | text_hl_word_core (const char *s, size_t *len) |
| The word a writer's string gives: spaces taken off both ends, a "Label:" and the spaces after it taken off the front, then one pair of parentheses around it and a full stop behind it. | |
| static bool | apart (unsigned char e, unsigned char nb) |
Whether the edge byte e of a word stands alone against its neighbour nb: a word byte against no word byte, a mark against anything but the same mark. | |
| static size_t | word_at (const unsigned char *line, size_t len, size_t i, const char *const *list, size_t n) |
The longest verdict word of list at byte i of the line. | |
| text_hl_class_t | text_hl_unit_class (const char *unit, size_t len) |
| The class of a unit of the table. | |
| const char * | text_hl_class_css (text_hl_class_t cls) |
| The style sheet's name of a class (TEXT_HL_CLASS_ROWS). | |
| static size_t | unit_end (const unsigned char *line, size_t len, size_t k) |
The end of a unit's bytes from byte k: a "%"; or a "/" and letters, or letters; the ohm sign counts as a letter. | |
| static text_hl_class_t | unit_class_at (const unsigned char *line, size_t len, size_t k, size_t u) |
The class of the unit from byte k to u, when it ends at no word byte. | |
| static size_t | number_at (const unsigned char *line, size_t len, size_t i, text_hl_class_t *cls) |
A number at byte i, with the unit behind it: joined to it, as in "6.00V", or after one space, as the older reports write it. | |
| static bool | hex_line (const unsigned char *s, size_t len) |
| Whether a line is a register line "NN: XX XX ...", a checksum line "checksum XXXXXXXX" or a journal line "key=hexdigits", trailing spaces allowed. | |
| static bool | heading (const unsigned char *s, size_t len) |
| Whether a line is a heading: its first character an upper-case letter, at least HEADING_MIN characters, and no lower-case letter before the first "(". | |
| static size_t | label_end (const unsigned char *s, size_t len) |
| Where a label ends: after the first ":" or "=" in the first TEXT_HL_LABEL_CELLS characters, when a blank or the line's end follows it and the line starts with no blank. | |
| static void | rest (spans_t *sp, const unsigned char *s, size_t len, size_t i, const text_hl_words_t *words) |
The spans of a bench text's line from byte i on: comments, verdict words and numbers with units. | |
| static void | text_line (spans_t *sp, const unsigned char *s, size_t len, size_t line_no, const text_hl_words_t *words) |
| The spans of a bench text's line. | |
| static size_t | json_number (const unsigned char *s, size_t len, size_t i) |
Bytes of a JSON number at i. | |
| static void | json_line (spans_t *sp, const unsigned char *s, size_t len) |
| The spans of a JSON line. | |
| static void | csv_line (spans_t *sp, const unsigned char *s, size_t len, size_t line_no) |
| The spans of a CSV line. | |
| size_t | text_hl_line (const char *line, size_t len, size_t line_no, text_hl_kind_t kind, const text_hl_words_t *words, text_hl_span_t *out, size_t cap) |
| The spans of one line. | |
| static bool | same_ext (const char *s, size_t n, const char *ext) |
Whether the n bytes at s are ext without regard to case. | |
| static size_t | ext_at (const char *name, size_t n) |
Where the extension of the first n bytes of name starts. | |
| text_hl_kind_t | text_hl_kind_of (const char *name) |
| How a file is classed, by its name: ".json" JSON, ".csv" CSV, ".txt" TEXT, in any case, a ".NEW" behind any of them taken off first; PLAIN for any other name. | |
Variables | |
| const text_hl_unit_t | text_hl_units [TEXT_HL_UNIT_COUNT] |
| The units a number may carry, case as written: V mV A mA W rpm Hz us ms s /s deg Grad % mOhm B kB MB mΩ Ω; mOhm for the reports of 0.22 and older. test_text_hl holds it to every unit the report formats of ui_text.def put behind a number. | |
| static const char *const | k_css [TEXT_HL_CLASSES] |
| The style sheet's name of each class, by class. | |
Syntax highlighting of one line of text (text_hl.h): the rules of a bench text, JSON and CSV.
SPDX-License-Identifier: MIT
| #define CLASS_CSS | ( | name, | |
| css, | |||
| role ) |
Expands a row of TEXT_HL_CLASS_ROWS to its style sheet name.
| enum letter_t |
|
static |
Whether the edge byte e of a word stands alone against its neighbour nb: a word byte against no word byte, a mark against anything but the same mark.
| e | The word's first or last byte. |
| nb | The byte beside it in the line. |
|
static |
The spans of a CSV line.
| sp | The spans. |
| s | The line. |
| len | Its bytes. |
| line_no | Its index in the file: 0 is the header. |
|
static |
Add bytes start to start + len as class cls, joined to the last span when it has that class.
| sp | The spans. |
| start | First byte; the end of the last span. |
| len | Bytes; 0 adds nothing. |
| cls | The class. |
|
static |
Where the extension of the first n bytes of name starts.
| name | The name. |
| n | Bytes to look at. |
n without one.
|
static |
Whether a line is a heading: its first character an upper-case letter, at least HEADING_MIN characters, and no lower-case letter before the first "(".
| s | The line. |
| len | Its bytes. |
|
static |
Whether a line is a register line "NN: XX XX ...", a checksum line "checksum XXXXXXXX" or a journal line "key=hexdigits", trailing spaces allowed.
| s | The line. |
| len | Its bytes. |
|
static |
Whether b is a space or a tab.
| b | The byte. |
|
static |
Whether b is an ASCII digit.
| b | The byte. |
|
static |
Whether b is a hexadecimal digit.
| b | The byte. |
|
static |
Whether b belongs to a word: an ASCII letter or digit, "_", or any byte of a UTF-8 sequence.
| b | The byte. |
|
static |
The spans of a JSON line.
| sp | The spans. |
| s | The line. |
| len | Its bytes. |
|
static |
Bytes of a JSON number at i.
| s | The line. |
| len | Its bytes. |
| i | Where it would start. |
|
static |
Where a label ends: after the first ":" or "=" in the first TEXT_HL_LABEL_CELLS characters, when a blank or the line's end follows it and the line starts with no blank.
| s | The line. |
| len | Its bytes. |
|
static |
The case of the letter at s: ASCII and the 7 German letters.
| s | The bytes. |
| n | Their count from s, at least 1. |
| len | Out: bytes of the character, 1 or 2. |
|
static |
A number at byte i, with the unit behind it: joined to it, as in "6.00V", or after one space, as the older reports write it.
A word joined to the number that is no unit of the table ("6.00Volt", "5x") makes the whole no number.
| line | The line. |
| len | Its bytes. |
| i | Where the number would start. |
| cls | Out: the unit's class; TEXT_HL_TEXT for a bare number. |
|
static |
The spans of a bench text's line from byte i on: comments, verdict words and numbers with units.
| sp | The spans. |
| s | The line. |
| len | Its bytes. |
| i | Where to start. |
| words | The verdict words; NULL for none. |
|
static |
Whether the n bytes at s are ext without regard to case.
| s | The bytes. |
| n | Their count. |
| ext | An extension in lower case, with its dot. |
| const char * text_hl_class_css | ( | text_hl_class_t | cls | ) |
The style sheet's name of a class (TEXT_HL_CLASS_ROWS).
| cls | The class. |
| text_hl_kind_t text_hl_kind_of | ( | const char * | name | ) |
How a file is classed, by its name: ".json" JSON, ".csv" CSV, ".txt" TEXT, in any case, a ".NEW" behind any of them taken off first; PLAIN for any other name.
| name | The file name; NULL is PLAIN. |
| size_t text_hl_line | ( | const char * | line, |
| size_t | len, | ||
| size_t | line_no, | ||
| text_hl_kind_t | kind, | ||
| const text_hl_words_t * | words, | ||
| text_hl_span_t * | out, | ||
| size_t | cap ) |
The spans of one line.
With room for fewer spans than the line has, the last span the room holds is TEXT and reaches to the line's end.
| line | The line's bytes, without its line end. |
| len | Their count. |
| line_no | The line's index in the file, from 0. |
| kind | How the file is classed. |
| words | The verdict words; NULL for none. |
| out | Out: the spans. |
| cap | Room in out. |
cap 0. | text_hl_class_t text_hl_unit_class | ( | const char * | unit, |
| size_t | len ) |
The class of a unit of the table.
| unit | The unit's bytes. |
| len | Their count. |
| const char * text_hl_word_core | ( | const char * | s, |
| size_t * | len ) |
The word a writer's string gives: spaces taken off both ends, a "Label:" and the spaces after it taken off the front, then one pair of parentheses around it and a full stop behind it.
"Brown-out: not run" gives "not run", " (cut short)" "cut short", "Not run." "Not run".
| s | The string; NULL gives an empty word. |
| len | Out: bytes of the word. |
s.
|
static |
The spans of a bench text's line.
| sp | The spans. |
| s | The line. |
| len | Its bytes. |
| line_no | Its index in the file. |
| words | The verdict words; NULL for none. |
|
static |
Narrow [*a, *b) of s past the blanks at both ends.
| s | The string. |
| a | In and out: the first byte. |
| b | In and out: the byte after the last. |
|
static |
The class of the unit from byte k to u, when it ends at no word byte.
| line | The line. |
| len | Its bytes. |
| k | The unit's first byte. |
| u | The byte after its last (unit_end()). |
|
static |
The end of a unit's bytes from byte k: a "%"; or a "/" and letters, or letters; the ohm sign counts as a letter.
| line | The line. |
| len | Its bytes. |
| k | Where the unit would start. |
k for none.
|
static |
The longest verdict word of list at byte i of the line.
| line | The line. |
| len | Its bytes. |
| i | Where the word would start. |
| list | The words. |
| n | Their count. |
|
static |
The style sheet's name of each class, by class.
| const text_hl_unit_t text_hl_units[TEXT_HL_UNIT_COUNT] |
The units a number may carry, case as written: V mV A mA W rpm Hz us ms s /s deg Grad % mOhm B kB MB mΩ Ω; mOhm for the reports of 0.22 and older. test_text_hl holds it to every unit the report formats of ui_text.def put behind a number.