summaryrefslogtreecommitdiff
path: root/src/basic/locale-util.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* locale: honour new env var $SYSTEMD_UTF8=Lennart Poettering2022-11-101-1/+9
| | | | | | | | | This is useful to force off fancy unicode glyph use (i.e. use "->" instead of "→"), which is useful in tests where locales might be missing, and thus control via $LC_CTYPE is not reliable. Use this in TEST-58, to ensure the output checks we do aren't confused by missing these glyphs being unicode or not.
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* locale-setup: merge locale handling in PID1 and localedYu Watanabe2022-06-141-0/+11
|
* locale-util: align locale entriesYu Watanabe2022-06-141-13/+13
|
* locale-util: check if enumerated locales are validYu Watanabe2022-06-141-0/+9
|
* locale-util: fix memleak on failureYu Watanabe2022-06-141-2/+5
|
* core: check size before mmapTobias Stoeckmann2022-03-031-0/+4
| | | | | | | | | | | | | | | The data type off_t can be 64 on 32 bit systems if they have large file support. Since mmap expects a size_t with 32 bits as second argument truncation could occur. At worst these huge files could lead to mmaps smaller than the previous check for small files. This in turn shouldn't have a lot of impact because mmap allocates at page size boundaries. This also made the PAGE_ALIGN call in open_mmap unneeded. In fact it was neither in sync with other mmap calls nor with its own munmap counterpart in error path. If such large files are encountered, which is very unlikely in these code paths, treat them with the same error as if they are too small.
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-4/+3
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* tree-wide: remove a few unnecessary inclusions of ftw.hLennart Poettering2021-10-071-1/+0
|
* basic: split out glyph/emoji related calls from locale-util.[ch] into ↵Lennart Poettering2021-10-051-123/+0
| | | | | | | | glyph-util.[ch] These functions are used pretty much independently of locale, i.e. the only info relevant is whether th locale is UTF-8 or not. Hence let's give this its own pair of .c/.h files.
* glyph-util: add three more emojis to emoji listLennart Poettering2021-07-301-1/+9
|
* dirent-util: use readdir_ensure_type() in readdir_no_dot() and FOREACH_DIRENT()Yu Watanabe2021-06-241-2/+0
|
* locale-util: make SpecialGlyph more like our usual enumsLennart Poettering2021-04-081-1/+3
| | | | | | | | Let's define both an enum and a typedef named SpecialGlyph, the way we usually do it. Also, introduce an "invalid" special glyph, assigned to -EINVAL, also like we always do it. (And handle it somewhat sanely in special_glyph()
* basic/locale-util: reduce variable scopeZbigniew Jędrzejewski-Szmek2021-02-111-5/+2
|
* feature: display status with a different shape depending on the status (#17728)Jiehong2021-01-221-0/+6
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* locale-util: add support for touch emojiLennart Poettering2020-07-011-1/+5
| | | | | We can use this to highlight when users are supposed to touch their security tokens.
* locale-util: add glyph for external linksLennart Poettering2020-05-291-0/+4
|
* locale-util: add new helper locale_is_installed()Lennart Poettering2020-05-071-0/+15
| | | | | | | | | | This new helper checks whether the specified locale is installed. It's distinct from locale_is_valid() which just superficially checks if a string looks like something that could be a valid locale. Heavily inspired by @jsynacek's #13964. Replaces: #13964
* locale-util: export emoji_enable() for other code to useLennart Poettering2020-04-151-1/+1
|
* locale-util: add support for lock+key emojiLennart Poettering2020-04-151-1/+5
| | | | | It looks pretty nice on gnome-terminal at least, let's make use of it when asking for passwords.
* locale-util: add special glyph ΣLennart Poettering2020-01-201-0/+2
|
* locale-util: add block drawing special glyphsLennart Poettering2020-01-201-0/+4
|
* locale-util: extend comments on unicode glyph use, and drop mdash (that ↵Lennart Poettering2020-01-071-15/+22
| | | | | | | | | | | | | actually was an ndash) Let's add the actual unicode names of the glyphs we use. Let's also add in comments what the width expectations of these glyphs are on the console. Also, remove the "mdash" definition. First of all it wasn't used, but what's worse the glyph encoded was actually an "ndash"... Fixes: #14075
* locale-util: drop weird invisible unicode codepoints accidentally inserted ↵Lennart Poettering2019-12-111-1/+1
| | | | in comment
* tree-wide: drop locale.h when locale-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop dirent.h when dirent-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* Remove unprintable non-ASCII char from special glyph ASCII fallback tableMarko Myllynen2019-10-221-1/+1
|
* locale-util: suppress non-UTF-8 locales when enumerating themLennart Poettering2019-07-141-0/+19
| | | | | | | | | | | | | | Let's hide non-UTF-8 locales by default. It's 2019 after all. Let's add an undocumented env var to reenable listing them though. This should substantially shorten the list of choices we offer users, and only show realistic choices. note that only firstboot and localectl make use of this information, and both allow configuration of values outside of these lists, hence all this change does is hide legacy options, but they are still available if you know what you do, and that's how it should be.
* locale-util: normalize UTF-8 locale namesLennart Poettering2019-07-141-2/+36
| | | | Let's generate out lists in the format people expect.
* codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|
* util: split out kbd related stuffLennart Poettering2019-03-141-93/+0
| | | | | This stuff is neither generic enough to be in def.h, nor really has much to do with locale, hence give it its own .c/.h file pair.
* locale-util: prefix special glyph enum values with SPECIAL_GLYPH_Lennart Poettering2018-12-141-40/+40
| | | | | | | This has been irritating me for quite a while: let's prefix these enum values with a common prefix, like we do for almost all other enums. No change in behaviour, just some renaming.
* tree-wide: add whitespace between type and variable nameYu Watanabe2018-12-041-1/+1
|
* locale-util: add logic to output smiley emojis at various happiness levelsLennart Poettering2018-11-301-27/+62
|
* locale-util: add unicode bullet to special glyphsLennart Poettering2018-11-281-0/+2
|
* locale-util: add special glyph support for check marks/cross marksLennart Poettering2018-11-161-0/+4
|
* locale-util: introduce common helper locale_variables_free() for freeing ↵Lennart Poettering2018-11-141-0/+10
| | | | locale variable arrays
* analyze: Add "timespan" command to dump time span in usecChris Down2018-10-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | This is useful for a couple of cases, I'm mostly interested in case #1: 1. Verifying "reasonable" values in a trivially scriptable way 2. Debugging unexpected time span parsing directly Test Plan: ``` % build/systemd-analyze timespan 20 Original: 20 μs: 20 Human: 20us % build/systemd-analyze timespan 20ms Original: 20ms μs: 20000 Human: 20ms % build/systemd-analyze timespan 20z Failed to parse time span '20z': Invalid argument ```
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+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.
* locale-util: on overlayfs FTW_MOUNT causes nftw(3) to not list *any* filesFranck Bui2018-06-141-1/+1
| | | | | | | | | | | | | | On overlayfs, FTW_MOUNT causes nftw to not list *any* files because the condition used by glibc to verify that it's on the same mountpoint doesn't work on overlayfs, see https://bugzilla.suse.com/show_bug.cgi?id=1096807 for the details. However using FTW_MOUNT doesn't seem to be really needed when walking through the keymap directorie tree. So until the glibc or the kernel is fixed (which might take some time), let's make localectl works with overlayfs. There's a small side effect here, by which regular (non-directory) files with bind mounts will be parsed while they were skipped by the previous logic.
* locale-util: add comment with link to unicode chars supported by eurlatgr ↵Lennart Poettering2018-05-031-0/+7
| | | | | (#8894) See: #6443
* tree-wide: be more careful with the type of array sizesLennart Poettering2018-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were a bit sloppy with the index and size types of arrays, we'd regularly use unsigned. While I don't think this ever resulted in real issues I think we should be more careful there and follow a stricter regime: unless there's a strong reason not to use size_t for array sizes and indexes, size_t it should be. Any allocations we do ultimately will use size_t anyway, and converting forth and back between unsigned and size_t will always be a source of problems. Note that on 32bit machines "unsigned" and "size_t" are equivalent, and on 64bit machines our arrays shouldn't grow that large anyway, and if they do we have a problem, however that kind of overly large allocation we have protections for usually, but for overflows we do not have that so much, hence let's add it. So yeah, it's a story of the current code being already "good enough", but I think some extra type hygiene is better. This patch tries to be comprehensive, but it probably isn't and I missed a few cases. But I guess we can cover that later as we notice it. Among smaller fixes, this changes: 1. strv_length()' return type becomes size_t 2. the unit file changes array size becomes size_t 3. DNS answer and query array sizes become size_t Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=76745
* locale: add ellipsis as special glyphLennart Poettering2018-04-181-1/+3
|
* 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.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)