Commit Graph

33 Commits

Author SHA1 Message Date
Karel Zak 6c6750db34 lib/strutils: support dec.points in parse_size()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 3643958f48 lib/strutils: use proper return codes in parse_size()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 646e159aa9 lib/strutils: optimalize {starts,ends}with()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10 12:18:20 +02:00
Sami Kerola 199e939d88 lib/strutils: move *swith() functions to private library
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>
2013-08-29 18:14:08 +01:00
Karel Zak 477254da93 lib/strutils: add strtotimeval_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 11:51:15 +01:00
Karel Zak 23106a29b0 lib/strutils: simplify strtosize(), return info about suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Karel Zak 416c43a9a5 fdisk: add callback for ask-numbers API
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Daniel Trebbien 02887b73eb Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable 2013-01-30 18:53:00 -05:00
Milan Broz f5077b5180 lib/strutils: add string_add_to_idarray() - parse and add to id list
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 16:26:27 +02:00
maximilian attems ab65d635c8 lib/strutils: circumvent missing localeconv()
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>
2012-06-05 14:54:12 +02:00
Karel Zak 551dae405a lib/strutils: create type specific strtoxx_or_err()
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>
2012-05-15 17:40:03 +02:00
Karel Zak 5ef167714e lib/strutils: add string_to_bitmask()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 17:28:44 +02:00
Bernhard Voelker 455fe9a075 Fix typos found by misspellings
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>
2012-04-23 13:16:35 +02:00
Davidlohr Bueso 958d2b712a strutils: return success on test program
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-10 12:21:30 +02:00
Karel Zak a99c913091 lib/strutils: add strtosize_or_err, clean up
* 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>
2012-03-30 16:11:31 +02:00
Chandan B Rajenda 179b923a19 lib/strutils: move array bounds check in string_to_idarray() to appropriate 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>
2012-02-23 10:54:25 +01:00
Petr Uzel b106d05238 libmount: ignore tailing slash in netfs source paths
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>
2011-11-08 16:25:01 +01:00
Davidlohr Bueso af7df9ee67 lib,strutils: add default value to parse_range()
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>
2011-10-17 11:06:48 +02:00
Davidlohr Bueso a883c6349c lib,strutils: share parse_range()
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>
2011-10-12 10:01:26 +02:00
Sami Kerola a9f97001c3 lib: [strutils] add strtod_or_err() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:45:27 +02:00
Karel Zak b28f22673d lib: [strutils.c] fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 12:01:29 +02:00
Karel Zak c87638ad30 include: [strutils.c] add list parsers
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:41:21 +02:00
Sami Kerola e53bc9604c lib: add strtoul_or_err() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-01 09:57:43 +02:00
Francesco Cosoleto 5d2a98490e This adds a second parameter to size_to_human_string() to return a
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>
2011-05-26 15:32:33 +02:00
Karel Zak 69e433d8d9 lib: [strutils.c] more robust strtol checks
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-21 15:35:04 +01:00
Sami Kerola 94d32126bf strutils: new wrapper function strtoll_or_err
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-02-21 15:32:50 +01:00
Dave Reisner f9e05dafd0 lib: [strutils] avoid integer overflow on large values
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>
2011-02-15 10:13:31 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
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>
2011-02-14 17:45:24 +01:00
Karel Zak 218f9d3d66 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-04 22:36:09 +01:00
Karel Zak 013bff51a6 tests: fix strtosize() test
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:48 +01:00
Davidlohr Bueso c4ecaf21d5 partx: complete rewrite
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-09 21:54:17 +01:00
Karel Zak ce877f2d16 lib: [strutils] move strmode() from namei.c to strutils.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:32 +01:00
Davidlohr Bueso 8abcf29002 lib: [strutils] general purpose string handling functions
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>
2010-11-23 21:06:49 +01:00