summaryrefslogtreecommitdiff
path: root/src/basic/extract-word.h
Commit message (Collapse)AuthorAgeFilesLines
* basic/extract-word: add EXTRACT_RETAIN_SEPARATORS flagLuca Boccassi2021-06-241-0/+1
| | | | | Makes the helpers avoid skipping over the separator(s) in the input string
* extract-word: introduce EXTRACT_KEEP_QUOTE flagYu Watanabe2021-06-211-3/+4
|
* basic/extract-word: rename flagZbigniew Jędrzejewski-Szmek2021-03-111-1/+1
| | | | The flag enables "relaxed mode" for all kinds of unescaping, not just c-unescaping.
* basic/extract_word: try to explain what the various options doZbigniew Jędrzejewski-Szmek2021-03-111-7/+9
| | | | | | | | | | A test for stripping of escaped backslashes without any flags was explicitly added back in 4034a06ddb82ec9868cd52496fef2f5faa25575f. So it seems to be on purpose, though I would say that this is at least surprising and hence deserves a comment. In test-extract-word, add tests for standalone EXTRACT_UNESCAPE_SEPARATORS. Only behaviour combined with EXTRACT_CUNESCAPE was tested.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* basic/extract-word: add EXTRACT_UNESCAPE_SEPARATORS modeZbigniew Jędrzejewski-Szmek2020-08-051-3/+4
| | | | | This allows separators to be escaped, for example to allow "a\:b:c", to be treated as "a:b", "c" with ":" as the separator.
* Rename EXTRACT_QUOTES to EXTRACT_UNQUOTEZbigniew Jędrzejewski-Szmek2019-06-281-1/+1
| | | | | | Whenever I see EXTRACT_QUOTES, I'm always confused whether it means to leave the quotes in or to take them out. Let's say "unquote", like we say "cunescape".
* tree-wide: always declare bitflag enums the same wayLennart Poettering2019-01-071-6/+6
| | | | | let's always use the 1 << x syntax. No change of behaviour or even of the compiled binary.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-4/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* shared/extract-word: replace enum with unsigned int to avoid undefined behaviourZbigniew Jędrzejewski-Szmek2017-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ../src/basic/extract-word.c:255:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs] va_start(ap, flags); ^ ../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) { ^ ../src/basic/extract-word.c:286:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs] va_start(ap, flags); ^ ../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) { ^ 2 warnings generated. I think the relevant part of C99 is 6.7.2.2 Enumeration specifiers: Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration. and 7.16.1.4: The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ...). If the parameter parmN is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined. This might cause a real issue if the compiler chooses something that is not an integer for ExtractFlags. Rework the code to avoid the warning, but add an assert_cc in a large-valued ExtractFlags element is ever defined and the type is bumped to something wider than an int.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* core: fix dependency parsingLennart Poettering2015-11-111-4/+5
| | | | | | | | 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.
* util: split out extract_first_word() and related calls into extract-word.[ch]Lennart Poettering2015-10-241-0/+36
This is quite a lot of code these days, hence move it to its own source file.