summaryrefslogtreecommitdiff
path: root/src/parse.h
Commit message (Collapse)AuthorAgeFilesLines
* refdb_fs: convert reflog parsing to use parserPatrick Steinhardt2019-10-181-0/+1
| | | | | The refdb_fs code to parse the reflog currently uses a hand-rolled parser. Convert it to use our `git_parse_ctx` structure instead.
* parse: remove use of variadic macros which are not C89 compliantPatrick Steinhardt2019-08-011-3/+0
| | | | | | | | | | | | | The macro `git_parse_error` is implemented in a variadic way so that it's possible to pass printf-style parameters. Unfortunately, variadic macros are not defined by C89 and thus we cannot use that functionality. But as we have implemented `git_error_vset` in the previous commit, we can now just use that instead. Convert `git_parse_error` to a variadic function and use `git_error_vset` to fix the compliance violation. While at it, move the function to "patch_parse.c".
* config_parse: provide parser init and dispose functionsPatrick Steinhardt2019-07-111-0/+2
| | | | | | | | | | | | | | Right now, all configuration file backends are expected to directly mess with the configuration parser's internals in order to set it up. Let's avoid doing that by implementing both a `git_config_parser_init` and `git_config_parser_dispose` function to clearly define the interface between configuration backends and the parser. Ideally, we would make the `git_config_parser` structure definition private to its implementation. But as that would require an additional memory allocation that was not required before we just live with it being visible to others.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-1/+1
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* consistent header guardsethomson/header_guardsEdward Thomson2018-02-011-0/+5
| | | | use consistent names for the #include / #define header guard pattern.
* parse: implement `git_parse_peek`Patrick Steinhardt2017-11-111-0/+6
| | | | | | | Some code parts need to inspect the next few bytes without actually consuming it yet, for example to examine what content it has to expect next. Create a new function `git_parse_peek` which returns the next byte without modifying the parsing context and use it at multiple call sites.
* parse: implement and use `git_parse_advance_digit`Patrick Steinhardt2017-11-111-0/+1
| | | | | | The patch parsing code has multiple recurring patterns where we want to parse an actual number. Create a new function `git_parse_advance_digit` and use it to avoid code duplication.
* parse: extract parse modulePatrick Steinhardt2017-11-111-0/+49
The `git_patch_parse_ctx` encapsulates both parser state as well as options specific to patch parsing. To advance this state and keep it consistent, we provide a few functions which handle advancing the current position and accessing bytes of the patch contents. In fact, these functions are quite generic and not related to patch-parsing by themselves. Seeing that we have similar logic inside of other modules, it becomes quite enticing to extract this functionality into its own parser module. To do so, we create a new module `parse` with a central struct called `git_parse_ctx`. It encapsulates both the content that is to be parsed as well as its lengths and the current position. `git_patch_parse_ctx` now only contains this `parse_ctx` only, which is then accessed whenever we need to touch the current parser. This is the first step towards re-using this functionality across other modules which require parsing functionality and remove code-duplication.