Lines Matching +full:num +full:- +full:strings
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Helpers for formatting and printing strings
22 #include <kunit/test-bug.h>
25 * string_get_size - get the size in the specified units
119 remainder -= 1000; in string_get_size()
142 * parse_int_array_user - Split string into a sequence of integers
166 ret = -ENOENT; in parse_int_array_user()
172 ret = -ENOMEM; in parse_int_array_user()
216 u8 num; in unescape_octal() local
221 num = (*q++) & 7; in unescape_octal()
222 while (num < 32 && isodigit(*q) && (q - *src < 3)) { in unescape_octal()
223 num <<= 3; in unescape_octal()
224 num += (*q++) & 7; in unescape_octal()
226 *p = num; in unescape_octal()
236 u8 num; in unescape_hex() local
241 num = digit = hex_to_bin(*q++); in unescape_hex()
248 num = (num << 4) | digit; in unescape_hex()
250 *p = num; in unescape_hex()
282 * string_unescape - unquote characters in the given string
295 * destination buffer will always be NULL-terminated. Source string must be
296 * NULL-terminated as well. The supported flags are::
299 * '\f' - form feed
300 * '\n' - new line
301 * '\r' - carriage return
302 * '\t' - horizontal tab
303 * '\v' - vertical tab
305 * '\NNN' - byte with octal value NNN (1 to 3 digits)
307 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits)
309 * '\"' - double quote
310 * '\\' - backslash
311 * '\a' - alert (BEL)
312 * '\e' - escape
327 while (*src && --size) { in string_unescape()
330 size--; in string_unescape()
354 return out - dst; in string_unescape()
498 * string_escape_mem - quote characters in the given memory buffer
504 * @only: NULL-terminated string containing characters used to limit
514 * must go as-is to the output.
525 * destination buffer will not be NULL-terminated, thus caller have to append
529 * '\f' - form feed
530 * '\n' - new line
531 * '\r' - carriage return
532 * '\t' - horizontal tab
533 * '\v' - vertical tab
535 * '\"' - double quote
536 * '\\' - backslash
537 * '\a' - alert (BEL)
538 * '\e' - escape
540 * '\0' - null
542 * '\NNN' - byte with octal value NNN (3 digits)
546 * escape only non-printable characters, checked by isprint()
550 * '\xHH' - byte with hexadecimal value HH (2 digits)
552 * escape only non-ascii characters, checked by isascii()
554 * escape only non-printable or non-ascii characters
582 while (isz--) { in string_escape_mem()
588 * - the @only string is supplied and does not contain a in string_escape_mem()
590 * - the character is printable and ASCII, when @flags has in string_escape_mem()
592 * - the character is printable, when @flags has in string_escape_mem()
594 * - the character is ASCII, when @flags has in string_escape_mem()
596 * - the character doesn't fall into a class of symbols in string_escape_mem()
640 return p - dst; in string_escape_mem()
672 * Returns allocated NULL-terminated string containing process
673 * command line, with inter-argument NULLs replaced with spaces,
685 res = get_cmdline(task, buffer, PAGE_SIZE - 1); in kstrdup_quotable_cmdline()
688 /* Collapse trailing NULLs, leave res pointing to last non-NULL. */ in kstrdup_quotable_cmdline()
689 while (--res >= 0 && buffer[res] == '\0') in kstrdup_quotable_cmdline()
692 /* Replace inter-argument NULLs. */ in kstrdup_quotable_cmdline()
705 * Returns allocated NULL-terminated string containing pathname,
748 * kasprintf_strarray - allocate and fill array of sequential strings
753 * Allocates and fills @n strings using pattern "%s-%zu", where prefix
757 * Returns array of strings or NULL when memory can't be allocated.
769 names[i] = kasprintf(gfp, "%s-%zu", prefix, i); in kasprintf_strarray()
781 * kfree_strarray - free a number of dynamically allocated strings contained
784 * @array: Dynamically allocated array of strings to free.
785 * @n: Number of strings (starting from the beginning of the array) to free.
787 * Passing a non-NULL @array and @n == 0 as well as NULL @array are valid
788 * use-cases. If @array is NULL, the function does nothing.
812 kfree_strarray(array->array, array->n); in devm_kfree_strarray()
821 return ERR_PTR(-ENOMEM); in devm_kasprintf_strarray()
823 ptr->array = kasprintf_strarray(GFP_KERNEL, prefix, n); in devm_kasprintf_strarray()
824 if (!ptr->array) { in devm_kasprintf_strarray()
826 return ERR_PTR(-ENOMEM); in devm_kasprintf_strarray()
829 ptr->n = n; in devm_kasprintf_strarray()
832 return ptr->array; in devm_kasprintf_strarray()
837 * skip_spaces - Removes leading whitespace from @str.
840 * Returns a pointer to the first non-whitespace character in @str.
851 * strim - Removes leading and trailing whitespace from @s.
854 * Note that the first trailing whitespace is replaced with a %NUL-terminator
855 * in the given string @s. Returns a pointer to the first non-whitespace
867 end = s + size - 1; in strim()
869 end--; in strim()
877 * sysfs_streq - return true if strings are equal, modulo trailing newline
881 * This routine returns true iff two strings are equal, treating both
882 * NUL and newline-then-NUL as equivalent string terminations. It's
883 * geared for use with sysfs input strings, which generally terminate
904 * match_string - matches given string in an array
905 * @array: array of strings
906 * @n: number of strings in the array or -1 for NULL terminated arrays
909 * This routine will look for a string in an array of strings up to the
910 * n-th element in the array or until the first NULL element.
912 * Historically the value of -1 for @n, was used to search in arrays that
918 * index of a @string in the @array if matches, or %-EINVAL otherwise.
933 return -EINVAL; in match_string()
938 * __sysfs_match_string - matches given string in an array
939 * @array: array of strings
940 * @n: number of strings in the array or -1 for NULL terminated arrays
943 * Returns index of @str in the @array or -EINVAL, just like match_string().
946 * This routine will look for a string in an array of strings up to the
947 * n-th element in the array or until the first NULL element.
949 * Historically the value of -1 for @n, was used to search in arrays that
967 return -EINVAL; in __sysfs_match_string()
972 * strreplace - Replace all occurrences of character in string.
993 * memcpy_and_pad - Copy one buffer to another with padding
1005 memset(dest + count, pad, dest_len - count); in memcpy_and_pad()
1013 /* These are placeholders for fortify compile-time warnings. */