summaryrefslogtreecommitdiff
path: root/src/basic/extract-word.c
AgeCommit message (Collapse)Author
2016-02-22tree-wide: make ++/-- usage consistent WRT spacingVito Caputo
Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-01-27utf8.[ch] et al: use char32_t and char16_t instead of int, int32_t, int16_tShawn Landden
rework C11 utf8.[ch] to use char32_t instead of uint32_t when referring to unicode chars, to make things more expressive. [ @zonque: * rebased to current master * use AC_CHECK_DECLS to detect availibility of char{16,32}_t * make utf8_encoded_to_unichar() return int ]
2016-01-18basic/escape: merge utf8 and non-utf8 paths in cunescape_oneZbigniew Jędrzejewski-Szmek
Not every byte sequence is valid utf8. We allow escaping of non-utf8 sequences in strings by using octal and hexadecimal escape sequences (\123 and \0xAB) for bytes at or above 128. Users of cunescape_one could infer whether such use occured when they received an answer between 128 and 256 in *ret (a non-ascii one byte character). But this is subtle and misleading: the comments were wrong, because ascii is a subset of unicode, so c != 0 did not mean non-unicode, but rather ascii-subset-of-unicode-or-raw-byte. This was all rather confusing, so make the "single byte" condition explicit. I'm not convinced that allowing non-utf8 sequences to be produced is useful in all cases where we allow it (e.g. in config files), but that behaviour is unchanged, just made more explicit. This also fixes an (invalid) gcc warning about unitialized variable (*ret_unicode) in callers of cunescape_one.
2015-11-30basic: include only what we useThomas Hindoe Paaboel Andersen
This is a cleaned up result of running iwyu but without forward declarations on src/basic.
2015-11-11core: fix dependency parsingLennart Poettering
3d793d29059a7ddf5282efa6b32b953c183d7a4d 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-05extract-word: Skip coalesced separators in placeFilipe Brandenburger
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-05extract-word: Do not re-evaluate the state on each parsed characterFilipe Brandenburger
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-05extract-word: increment pointer p and keep c in sync in for loopFilipe Brandenburger
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-05extract-word: Check for early bail out before inspecting separatorsFilipe Brandenburger
It's a pretty small optimization but doesn't hurt... Tested with test-extract-word.
2015-11-05extract-word: replace an use of `goto` with structured codeFilipe Brandenburger
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-05extract-word: move start block outside the for loopFilipe Brandenburger
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-03util-lib: move character class definitions to string-util.hLennart Poettering
2015-11-02Revert "utf8.[ch]: use char32_t and char16_t instead of int, int32_t, int16_t"Lennart Poettering
2015-10-31utf8.[ch]: use char32_t and char16_t instead of int, int32_t, int16_tShawn Landden
rework C11 utf8.[ch] to use char32_t instead of uint32_t when referring to unicode chars, to make things more expressive.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util: split out escaping code into escape.[ch]Lennart Poettering
This really deserves its own file, given how much code this is now.
2015-10-24util-lib: rework extract_first_word_and_warn() a bitLennart Poettering
- 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-24util: split out extract_first_word() and related calls into extract-word.[ch]Lennart Poettering
This is quite a lot of code these days, hence move it to its own source file.