summaryrefslogtreecommitdiffstats
path: root/lib/strutils.c
Commit message (Collapse)AuthorAgeFilesLines
* textual: fix some typosSami Kerola2014-07-131-1/+1
| | | | | | | Found with misspell-check version 2.0d. Reference: https://github.com/lyda/misspell-check Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libsmartcols: rewrite test code to tree(1)-like utilKarel Zak2014-04-081-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: fix parse_size() return codeKarel Zak2014-03-111-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: support dec.points in parse_size()Karel Zak2014-03-111-2/+43
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: use proper return codes in parse_size()Karel Zak2014-03-111-9/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: optimalize {starts,ends}with()Karel Zak2013-09-101-66/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: move *swith() functions to private librarySami Kerola2013-08-291-0/+67
| | | | | | | | Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/strutils: add strtotimeval_or_err()Karel Zak2013-03-131-0/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: simplify strtosize(), return info about suffixKarel Zak2013-03-111-37/+28Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add callback for ask-numbers APIKarel Zak2013-03-111-0/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Implement mempcpy() in terms of memcpy() if mempcpy() is unavailableDaniel Trebbien2013-01-311-0/+7
|
* lib/strutils: add string_add_to_idarray() - parse and add to id listMilan Broz2012-07-261-0/+27
| | | | | Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: circumvent missing localeconv()maximilian attems2012-06-051-1/+1
| | | | | | | Add stub too nls.h, include it instead of locale.h. Code in strutils handles already returned NULL. Signed-off-by: maximilian attems <max@stro.at>
* lib/strutils: create type specific strtoxx_or_err()Karel Zak2012-05-151-21/+74
| | | | | | | We need [un]signed int ([u]int32_t) on many places. It's also more readable and robust to use uintXX_t types than for example "long long". Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: add string_to_bitmask()Karel Zak2012-05-031-0/+43
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix typos found by misspellingsBernhard Voelker2012-04-231-1/+1
| | | | | | | | | | | | | | | The tool misspellings (https://github.com/lyda/misspell-check) detected several typos. Command used: $ git ls-files | grep -v ^po/ | misspellings -f - * isosize: Fix typo in usage string. * configure.ac: Fix typo in help string of --enable-most-builds option. * fdisk: Fix typo in man page. * libblkid, blkid, mount: Likewise. * Fix various typos in docs and in source code comments. Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* strutils: return success on test programDavidlohr Bueso2012-04-101-1/+1
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* lib/strutils: add strtosize_or_err, clean upKarel Zak2012-03-301-37/+45
| | | | | | | | | | | | * add strtosize_or_err(), we use strtosize() + err() on many places * add STRTOXX_EXIT_CODE to overwrite the default EXIT_FAILURE * remove else-after-noreturn (e.g. if (foo) err(...); else err(...)) * clean up indent... Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: move array bounds check in string_to_idarray() to appropriate ↵Chandan B Rajenda2012-02-231-2/+2
| | | | | | | | | | | place. string_to_idarray() will incorrectly exit with an error when the last element of the passed in array gets filled. However it should only exit with an error if there is more input. To fix this move the array bounds check. Signed-off-by: Chandan B Rajenda <chandan@linux.vnet.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* libmount: ignore tailing slash in netfs source pathsPetr Uzel2011-11-081-0/+32
| | | | | | Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480 Signed-off-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib,strutils: add default value to parse_range()Davidlohr Bueso2011-10-171-3/+4
| | | | | | | | This function currently sets the low or high values to 0 when the string doesn't contain a value, like '123:' or ':123'. In order to make it more flexible, we allow it to be passed an arbitrary value. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* lib,strutils: share parse_range()Davidlohr Bueso2011-10-121-1/+44
| | | | | | | This function is currently only being used by partx(8), but it's handy and generic enough that we can use it elsewhere as well. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* lib: [strutils] add strtod_or_err() functionSami Kerola2011-09-291-0/+24
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: [strutils.c] fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [strutils.c] add list parsersKarel Zak2011-07-271-0/+95
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add strtoul_or_err() functionSami Kerola2011-06-011-0/+24
| | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* This adds a second parameter to size_to_human_string() to return aFrancesco Cosoleto2011-05-261-8/+25
| | | | | | | | | | | | | | | string with a different format based on the following flags: SIZE_SUFFIX_1LETTER = "1K" SIZE_SUFFIX_3LETTER = "1KiB", SIZE_SUFFIX_SPACE = "1 KiB" or "1 K" [kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format, - fix suffix[] buffer size - add 3 letter version to the test] Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [strutils.c] more robust strtol checksKarel Zak2011-02-211-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* strutils: new wrapper function strtoll_or_errSami Kerola2011-02-211-0/+24
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: [strutils] avoid integer overflow on large valuesDave Reisner2011-02-151-4/+14
| | | | | | | | | | | | | | This is visible on a 2TB disk via lsblk, where a large partition incorrectly displays as 1.171798692T instead of 1.8T. This is corrected by using a uint64_t type instead of a simple int -- consistant with the type used in lsblk.c to represent the raw size in bytes. [kzak@redhat.com: - add EiB support - add size_to_human_string() to regression tests] Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* remove duplicate includesKarel Zak2011-01-041-4/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: fix strtosize() testKarel Zak2011-01-031-0/+24
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: complete rewriteDavidlohr Bueso2010-12-091-0/+49
| | | | | | Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [strutils] move strmode() from namei.c to strutils.cKarel Zak2010-11-241-0/+40
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [strutils] general purpose string handling functionsDavidlohr Bueso2010-11-231-0/+186
This patch replaces a few functions used throughout the source: * Renames getnum (from schedutils) to strtol_or_err * Moves strtosize (from lib/strtosize.c) * Moves xstrncpy (from include/xstrncpy.h) * Adds strnlen, strnchr and strndup if not available (remove it from libmount utils) A few Makefile.am files were modified to compile accordingly along with trivial renaming in schedutils source code. Signed-off-by: Davidlohr Bueso <dave@gnu.org>