Lines Matching +full:num +full:- +full:strings
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Helpers for formatting and printing strings
23 * string_get_size - get the size in the specified units
114 remainder -= 1000; in string_get_size()
135 * parse_int_array_user - Split string into a sequence of integers
159 ret = -ENOENT; in parse_int_array_user()
165 ret = -ENOMEM; in parse_int_array_user()
209 u8 num; in unescape_octal() local
214 num = (*q++) & 7; in unescape_octal()
215 while (num < 32 && isodigit(*q) && (q - *src < 3)) { in unescape_octal()
216 num <<= 3; in unescape_octal()
217 num += (*q++) & 7; in unescape_octal()
219 *p = num; in unescape_octal()
229 u8 num; in unescape_hex() local
234 num = digit = hex_to_bin(*q++); in unescape_hex()
241 num = (num << 4) | digit; in unescape_hex()
243 *p = num; in unescape_hex()
275 * string_unescape - unquote characters in the given string
288 * destination buffer will always be NULL-terminated. Source string must be
289 * NULL-terminated as well. The supported flags are::
292 * '\f' - form feed
293 * '\n' - new line
294 * '\r' - carriage return
295 * '\t' - horizontal tab
296 * '\v' - vertical tab
298 * '\NNN' - byte with octal value NNN (1 to 3 digits)
300 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits)
302 * '\"' - double quote
303 * '\\' - backslash
304 * '\a' - alert (BEL)
305 * '\e' - escape
317 while (*src && --size) { in string_unescape()
320 size--; in string_unescape()
344 return out - dst; in string_unescape()
488 * string_escape_mem - quote characters in the given memory buffer
494 * @only: NULL-terminated string containing characters used to limit
504 * must go as-is to the output.
515 * destination buffer will not be NULL-terminated, thus caller have to append
519 * '\f' - form feed
520 * '\n' - new line
521 * '\r' - carriage return
522 * '\t' - horizontal tab
523 * '\v' - vertical tab
525 * '\"' - double quote
526 * '\\' - backslash
527 * '\a' - alert (BEL)
528 * '\e' - escape
530 * '\0' - null
532 * '\NNN' - byte with octal value NNN (3 digits)
536 * escape only non-printable characters, checked by isprint()
540 * '\xHH' - byte with hexadecimal value HH (2 digits)
542 * escape only non-ascii characters, checked by isascii()
544 * escape only non-printable or non-ascii characters
572 while (isz--) { in string_escape_mem()
578 * - the @only string is supplied and does not contain a in string_escape_mem()
580 * - the character is printable and ASCII, when @flags has in string_escape_mem()
582 * - the character is printable, when @flags has in string_escape_mem()
584 * - the character is ASCII, when @flags has in string_escape_mem()
586 * - the character doesn't fall into a class of symbols in string_escape_mem()
630 return p - dst; in string_escape_mem()
662 * Returns allocated NULL-terminated string containing process
663 * command line, with inter-argument NULLs replaced with spaces,
675 res = get_cmdline(task, buffer, PAGE_SIZE - 1); in kstrdup_quotable_cmdline()
678 /* Collapse trailing NULLs, leave res pointing to last non-NULL. */ in kstrdup_quotable_cmdline()
679 while (--res >= 0 && buffer[res] == '\0') in kstrdup_quotable_cmdline()
682 /* Replace inter-argument NULLs. */ in kstrdup_quotable_cmdline()
695 * Returns allocated NULL-terminated string containing pathname,
738 * kasprintf_strarray - allocate and fill array of sequential strings
743 * Allocates and fills @n strings using pattern "%s-%zu", where prefix
747 * Returns array of strings or NULL when memory can't be allocated.
759 names[i] = kasprintf(gfp, "%s-%zu", prefix, i); in kasprintf_strarray()
771 * kfree_strarray - free a number of dynamically allocated strings contained
774 * @array: Dynamically allocated array of strings to free.
775 * @n: Number of strings (starting from the beginning of the array) to free.
777 * Passing a non-NULL @array and @n == 0 as well as NULL @array are valid
778 * use-cases. If @array is NULL, the function does nothing.
802 kfree_strarray(array->array, array->n); in devm_kfree_strarray()
811 return ERR_PTR(-ENOMEM); in devm_kasprintf_strarray()
813 ptr->array = kasprintf_strarray(GFP_KERNEL, prefix, n); in devm_kasprintf_strarray()
814 if (!ptr->array) { in devm_kasprintf_strarray()
816 return ERR_PTR(-ENOMEM); in devm_kasprintf_strarray()
819 ptr->n = n; in devm_kasprintf_strarray()
822 return ptr->array; in devm_kasprintf_strarray()
827 * strscpy_pad() - Copy a C-string into a sized buffer
834 * buffer is always %NUL terminated, unless it's zero-sized.
844 * * -E2BIG if count is 0 or @src was truncated.
851 if (written < 0 || written == count - 1) in strscpy_pad()
854 memset(dest + written + 1, 0, count - written - 1); in strscpy_pad()
861 * skip_spaces - Removes leading whitespace from @str.
864 * Returns a pointer to the first non-whitespace character in @str.
875 * strim - Removes leading and trailing whitespace from @s.
878 * Note that the first trailing whitespace is replaced with a %NUL-terminator
879 * in the given string @s. Returns a pointer to the first non-whitespace
891 end = s + size - 1; in strim()
893 end--; in strim()
901 * sysfs_streq - return true if strings are equal, modulo trailing newline
905 * This routine returns true iff two strings are equal, treating both
906 * NUL and newline-then-NUL as equivalent string terminations. It's
907 * geared for use with sysfs input strings, which generally terminate
928 * match_string - matches given string in an array
929 * @array: array of strings
930 * @n: number of strings in the array or -1 for NULL terminated arrays
933 * This routine will look for a string in an array of strings up to the
934 * n-th element in the array or until the first NULL element.
936 * Historically the value of -1 for @n, was used to search in arrays that
942 * index of a @string in the @array if matches, or %-EINVAL otherwise.
957 return -EINVAL; in match_string()
962 * __sysfs_match_string - matches given string in an array
963 * @array: array of strings
964 * @n: number of strings in the array or -1 for NULL terminated arrays
967 * Returns index of @str in the @array or -EINVAL, just like match_string().
970 * This routine will look for a string in an array of strings up to the
971 * n-th element in the array or until the first NULL element.
973 * Historically the value of -1 for @n, was used to search in arrays that
991 return -EINVAL; in __sysfs_match_string()
996 * strreplace - Replace all occurrences of character in string.
1017 * memcpy_and_pad - Copy one buffer to another with padding
1029 memset(dest + count, pad, dest_len - count); in memcpy_and_pad()
1037 /* These are placeholders for fortify compile-time warnings. */