Commit graph

16 commits

Author SHA1 Message Date
Thomas Hindoe Paaboel Andersen 11c3a36649 basic: include only what we use
This is a cleaned up result of running iwyu but without forward
declarations on src/basic.
2015-11-30 21:51:03 +01:00
Lennart Poettering c89f52ac69 core: fix dependency parsing
3d793d2905 broke parsing of unit file
names that include backslashes, as extract_first_word() strips those.
Fix this, by introducing a new EXTRACT_RETAIN_ESCAPE flag which disables
looking at any flags, thus being compatible with the classic
FOREACH_WORD() behaviour.
2015-11-11 22:53:05 +01:00
Filipe Brandenburger 0247447e96 extract-word: Skip coalesced separators in place
Just skip them in place, instead of setting separator=true. We only do
that in a single place (while finding a separator outside of quote or
backslash states) so we don't really need a separate state for it.

Tested that no regressions were introduced in test-extract-word. Ran a
full `make check` and also installed the binaries on a test system and
did not see any issues related to parsing unit files or starting units
after a reboot.
2015-11-05 21:57:26 -08:00
Filipe Brandenburger 27fc921b65 extract-word: Do not re-evaluate the state on each parsed character
Use inner loops to keep processing the same state, except when there is
a state change, then break back to the outer loop so that the correct
branch can be selected again.

Tested that no regressions were introduced in test-extract-word.
2015-11-05 21:51:24 -08:00
Filipe Brandenburger 93de9eb76d extract-word: increment pointer p and keep c in sync in for loop
This will make it easier to use inner loops to keep looping in the same
state, by just updating p and c in the same way in the inner loops.

Tested that no regressions were created in test-extract-word.
2015-11-05 21:41:04 -08:00
Filipe Brandenburger 8372da448f extract-word: Check for early bail out before inspecting separators
It's a pretty small optimization but doesn't hurt...

Tested with test-extract-word.
2015-11-05 21:31:29 -08:00
Filipe Brandenburger 3ff13c298d extract-word: replace an use of goto with structured code
Using `goto` might be appropriate for the "finish" cases but it was
really not necessary at this point of the code... Just use if/else
blocks to accomplish the same.

Confirmed that the test cases in test-extract-word keep working as
expected.
2015-11-05 21:19:54 -08:00
Filipe Brandenburger b85e1c2534 extract-word: move start block outside the for loop
This block runs once before all the other handling, so move it outside
the main loop and put it in its own loop until it's finished doing its
job.

Tested by confirming `make check` (and particularly test-extract-word)
still passes and by booting a system with binaries including this
commit.
2015-11-05 21:19:54 -08:00
Lennart Poettering b11d6a7bed util-lib: move character class definitions to string-util.h 2015-11-03 17:45:11 +01:00
Lennart Poettering dcd1262673 Revert "utf8.[ch]: use char32_t and char16_t instead of int, int32_t, int16_t" 2015-11-02 11:21:25 +01:00
Shawn Landden 025b4c4105 utf8.[ch]: use char32_t and char16_t instead of int, int32_t, int16_t
rework C11 utf8.[ch] to use char32_t instead of uint32_t when referring
to unicode chars, to make things more expressive.
2015-10-31 21:00:57 -07:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 4f5dd3943b util: split out escaping code into escape.[ch]
This really deserves its own file, given how much code this is now.
2015-10-24 23:04:42 +02:00
Lennart Poettering dea7b6b043 util-lib: rework extract_first_word_and_warn() a bit
- Really warn in all error cases, not just some. We need to make sure
  that all errors are logged to not confuse the user.

- Explicitly check for EINVAL error code before claiming anything about
  invalid escapes, could be ENOMEM after all.
2015-10-24 23:03:49 +02:00
Lennart Poettering 84ac7bea36 util: split out extract_first_word() and related calls into extract-word.[ch]
This is quite a lot of code these days, hence move it to its own source
file.
2015-10-24 23:03:49 +02:00