summaryrefslogtreecommitdiff
path: root/src/test/test-utf8.c
Commit message (Collapse)AuthorAgeFilesLines
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* strv: declare iterator of FOREACH_STRING() in the loopZbigniew Jędrzejewski-Szmek2022-03-231-3/+0
| | | | | | | | | | | Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
* test: allow to set NULL to intro or outroYu Watanabe2022-02-021-1/+1
| | | | Addresses https://github.com/systemd/systemd/pull/22338#discussion_r796741033.
* tests: rework test macros to not take code as parametersLennart Poettering2022-02-021-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | C macros are nasty. We use them, but we try to be conservative with them. In particular passing literal, complex code blocks as argument is icky, because of "," handling of C, and also because it's quite a challange for most code highlighters and similar. Hence, let's avoid that. Using macros for genreating functions is OK but if so, the parameters should be simple words, not full code blocks. hence, rework DEFINE_CUSTOM_TEST_MAIN() to take a function name instead of code block as argument. As side-effect this also fixes a bunch of cases where we might end up returning a negative value from main(). Some uses of DEFINE_CUSTOM_TEST_MAIN() inserted local variables into the main() functions, these are replaced by static variables, and their destructors by the static destructor logic. This doesn't fix any bugs or so, it's just supposed to make the code easier to work with and improve it easthetically. Or in other words: let's use macros where it really makes sense, but let's not go overboard with it. (And yes, FOREACH_DIRENT() is another one of those macros that take code, and I dislike that too and regret I ever added that.)
* test: Use TEST macroJan Janssen2021-11-251-63/+15
| | | | | | | | | This converts to TEST macro where it is trivial. Some additional notable changes: - simplify HAVE_LIBIDN #ifdef in test-dns-domain.c - use saved_argc/saved_argv in test-copy.c, test-path-util.c, test-tmpfiles.c and test-unit-file.c
* basic/utf8: add function to convert to ASCIIZbigniew Jędrzejewski-Szmek2021-11-161-0/+28
| | | | The conversion must be lossy because ASCII doesn't have enough chars.
* test-utf8: hide most output by defaultZbigniew Jędrzejewski-Szmek2021-05-051-9/+13
| | | | | Unless one is working on the code, there is little reason to write most of the output. So let's hide it unless requested with SYSTEMD_LOG_LEVEL=debug.
* basic/escape: allow truncation mode where "…" is always appendedZbigniew Jędrzejewski-Szmek2021-05-051-26/+23
| | | | | | | | | | | So far we would append "…" or "..." when the string was wider than the specified output width. But let's add a mode where the caller knows that the string being passed is already truncated. The condition for jumping back in utf8_escape_non_printable_full() was off-by-one. But we only jumped to that label after doing a check with a stronger condition, so I think it didn't matter. Now it matters because we'd output the forced ellipsis one column too early.
* tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-051-3/+3
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* shared/utf8: add utf8_is_valid_n()Zbigniew Jędrzejewski-Szmek2020-09-011-0/+20
| | | | | Sometimes we need to check strings without the terminating NUL. Add a variant that does that.
* shared/logs-show: strip trailing carriage returns at EOL/EOFZbigniew Jędrzejewski-Szmek2019-10-291-0/+3
| | | | | | | | | | | | | When showing logs from a container, we would fail to show various lines: Oct 29 09:50:51 krowka systemd-nspawn[61376]: Detected architecture x86-64. Oct 29 09:50:51 krowka systemd-nspawn[61376]: [1B blob data] Oct 29 09:50:51 krowka systemd-nspawn[61376]: Welcome to Fedora 32 (Rawhide)! Oct 29 09:50:51 krowka systemd-nspawn[61376]: [1B blob data] Those are only harmless \r characters that trail the line. We already replace tabs and strip various ansi characters that we deem inconsequential, so let's also strip trailing carriage returns. Non-trailing ones are different, because they change what would be displayed.
* util-lib: add truncation based on printable width to utf8_escape_non_printable()Zbigniew Jędrzejewski-Szmek2019-05-221-0/+32
|
* test-utf8: add function headers and rename tests after functions they testZbigniew Jędrzejewski-Szmek2019-05-211-4/+26
|
* basic/utf8: do not read past end of string when looking for a multi-byte ↵Zbigniew Jędrzejewski-Szmek2019-02-261-5/+15
| | | | | | character Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9341.
* utf8: add utf8_to_utf16() helperLennart Poettering2018-09-251-5/+39
|
* tree-wide: drop copyright lines for more authorsZbigniew Jędrzejewski-Szmek2018-06-221-3/+0
| | | | Acks in https://github.com/systemd/systemd/issues/9320.
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* 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.
* basic/utf8: add ascii_is_valid_n()Zbigniew Jędrzejewski-Szmek2018-06-091-1/+12
|
* test-utf8: add a smoke test for utf8_console_width()Zbigniew Jędrzejewski-Szmek2018-04-181-0/+10
|
* 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.
* tests: add a simple test for utf8_n_codepoints()Zbigniew Jędrzejewski-Szmek2018-02-191-0/+10
|
* 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.
* 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.
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-1/+1
| | | | Sort the includes accoding to the new coding style.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-0/+1
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* test: utf8 - fix utf16 tests on BE machinesTom Gundersen2015-02-181-1/+1
|
* shared: utf8 - support decoding the full utf16Tom Gundersen2014-12-221-0/+13
| | | | We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2).
* utf8: when escaping unprintable unichars, escape the whole unichar, not just ↵Lennart Poettering2014-12-041-2/+5
| | | | the first byte of it
* utf8: intruduce utf8_escape_non_printableWaLyong Cho2014-12-041-0/+25
|
* core: do not print invalid utf-8 in error messagesZbigniew Jędrzejewski-Szmek2014-02-081-0/+17
|
* utf8: ascii_filter() is unused, let's remove itLennart Poettering2013-11-071-17/+0
|
* utf8: fix utf8_is_printableZbigniew Jędrzejewski-Szmek2013-10-051-0/+1
|
* test-utf8: add more tests for public functionsDave Reisner2013-09-191-0/+34
|
* device-nodes: move device node specific code to own fileDave Reisner2013-09-191-27/+1
| | | | | | | | In the process, rename udev_encode_string which is poorly named for what it does. It deals specifically with encoding names that udev creates and has its own rules: utf8 is valid but some ascii is not (e.g. path separators), and everything else is simply escaped. Rename it to encode_devnode_name.
* shared/utf8: merge implementations, remove cruftDave Reisner2013-09-191-0/+9
| | | | | This unifies the utf8 handling code which was previously duplicated in udev and systemd.
* move utf8 functions from libudev-private.h to utf8.hDave Reisner2013-09-171-0/+59
There's now some more obvious overlap amongst the two utf8 validation functions, but no more than there already was previously. This also adds some menial tests for anyone who wants to do more merging of these two in the future.