-
Notifications
You must be signed in to change notification settings - Fork 0
Add table iteration API and improve parsing robustness #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
cf2f7bf
add TableIterator (#79)
defname f1d2cd5
Merge main for TableIterator
defname 7cb1997
WIP: implement definition loader
defname 9c175a0
add Table_GetUsage()
defname bec5990
allow ':' in INI file key names
defname acba4b4
fix location of tests
defname 5eee148
fix typo in Doxygen comment
defname 7f8bd73
add NULL guard to String_Take()
defname 6314f66
Add early-exit guards to table lookup functions (#80)
defname 66b8eec
Merge branch 'main' for Table fixes
defname 90c1acd
add functiond to create SyntaxDefinition_FromTable() with tests. More…
defname 32b8f9a
additional tests (still not enough)
defname bda89eb
fix: free correct regex in regex_end branch in SyntaxBlockDef_FromTab…
defname eb6f0b7
fix: wrong numbe of arguments in String_Format() call in SymtaxBlockD…
defname 4f24ddd
add explanation
defname 12b8a98
fix correct recognition of root block
defname 3dcbaa2
fix memory lealk
defname 5af64c2
add NULL guard for strdup in init_definition()
defname e43de22
fix last fix
defname File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "tableiterator.h" | ||
|
|
||
| TableIterator TableIterator_Begin(const Table *table) { | ||
| return (TableIterator){ | ||
| .table = table, | ||
| .index = -1, | ||
| .current = NULL | ||
| }; | ||
| } | ||
|
|
||
| bool TableIterator_Next(TableIterator *it) { | ||
| if (!it || !it->table) { | ||
| return false; | ||
| } | ||
| for (size_t i = (size_t)(it->index + 1); i < it->table->capacity; i++) { | ||
| TableSlot *slot = &it->table->slots[i]; | ||
| if (slot->state == TABLE_SLOT_USED) { | ||
| it->index = i; | ||
| it->current = slot; | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #ifndef TABLEITERATOR_H | ||
| #define TABLEITERATOR_H | ||
|
|
||
| #include <sys/types.h> | ||
| #include <stdbool.h> | ||
| #include "table.h" | ||
|
|
||
| typedef struct _TableIterator { | ||
| const Table *table; | ||
| ssize_t index; | ||
| const TableSlot *current; | ||
| } TableIterator; | ||
|
|
||
| TableIterator TableIterator_Begin(const Table *table); | ||
| bool TableIterator_Next(TableIterator *it); | ||
|
|
||
| #endif | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.