summaryrefslogtreecommitdiffstats
path: root/src/basic/locale-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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-231-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-031-1/+0
|
* tree-wide: drop dirent.h when dirent-util.h is includedYu Watanabe2019-11-031-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-031-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)
* 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.
* systemd-firstboot: add vconsole keymap support (#7035)tblume2017-11-101-0/+95
| | | | | | | Enable systemd-firstboot to set the keymap. RFE: https://github.com/systemd/systemd/issues/6346
* locale-util: mark special_glyph() as _const_Zbigniew Jędrzejewski-Szmek2016-05-091-1/+1
| | | | | | | | _const_ means that the caller can assume that the function will return the same result every time (and will not modify global memory). special_glyph() meets this: even though it depends on global memory, that part of global memory is not expected to change. This allows the calls to special_glyph() to be optimized, even if -flto is not used.
* tree-wide: rename draw_special_char to special_glyphZbigniew Jędrzejewski-Szmek2016-05-091-24/+25
| | | | | | | | | That function doesn't draw anything on it's own, just returns a string, which sometimes is more than one character. Also remove "DRAW_" prefix from character names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't draw anything, and are always used as an argument to special_glyph(). Rename "DASH" to "MDASH", as there's more than one type of dash.
* basic: fallback to fstatat if entry->d_type is DT_UNKNOWNEvgeny Vereshchagin2016-04-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * tests-functions: improve FSTYPE-support make clean setup FSTYPE=reiserfs is working fine now :) * basic: fallback to fstatat if entry->d_type is DT_UNKNOWN Fixes localectl on reiserfs: -bash-4.3# mkdir -p /usr/lib/locale -bash-4.3# stat -f /usr/lib/locale/ File: "/usr/lib/locale/" ID: bdb0322715b5366e Namelen: 255 Type: reiserfs Block size: 4096 Blocks: Total: 99835 Free: 60262 Available: 60262 Inodes: Total: 0 Free: 0 -bash-4.3# mkdir /usr/lib/locale/HeyHo -bash-4.3# localectl list-locales --no-pager -bash-4.3# mount -t tmpfs tmpfs /usr/lib/locale -bash-4.3# mkdir /usr/lib/locale/HeyHo -bash-4.3# localectl list-locales --no-pager HeyHo
* 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.
* basic: re-sort includesThomas Hindoe Paaboel Andersen2015-12-011-1/+1
| | | | | My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.