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
116 remainder -= 1000; in string_get_size()
137 * parse_int_array_user - Split string into a sequence of integers
161 ret = -ENOENT; in parse_int_array_user()
167 ret = -ENOMEM; in parse_int_array_user()
211 u8 num; in unescape_octal() local
216 num = (*q++) & 7; in unescape_octal()
217 while (num < 32 && isodigit(*q) && (q - *src < 3)) { in unescape_octal()
218 num <<= 3; in unescape_octal()
219 num += (*q++) & 7; in unescape_octal()
221 *p = num; in unescape_octal()
231 u8 num; in unescape_hex() local
236 num = digit = hex_to_bin(*q++); in unescape_hex()
243 num = (num << 4) | digit; in unescape_hex()
245 *p = num; in unescape_hex()
277 * string_unescape - unquote characters in the given string
290 * destination buffer will always be NULL-terminated. Source string must be
291 * NULL-terminated as well. The supported flags are::
294 * '\f' - form feed
295 * '\n' - new line
296 * '\r' - carriage return
297 * '\t' - horizontal tab
298 * '\v' - vertical tab
300 * '\NNN' - byte with octal value NNN (1 to 3 digits)
302 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits)
304 * '\"' - double quote
305 * '\\' - backslash
306 * '\a' - alert (BEL)
307 * '\e' - escape
319 while (*src && --size) { in string_unescape()
322 size--; in string_unescape()
346 return out - dst; in string_unescape()
490 * string_escape_mem - quote characters in the given memory buffer
496 * @only: NULL-terminated string containing characters used to limit
506 * must go as-is to the output.
517 * destination buffer will not be NULL-terminated, thus caller have to append
521 * '\f' - form feed
522 * '\n' - new line
523 * '\r' - carriage return
524 * '\t' - horizontal tab
525 * '\v' - vertical tab
527 * '\"' - double quote
528 * '\\' - backslash
529 * '\a' - alert (BEL)
530 * '\e' - escape
532 * '\0' - null
534 * '\NNN' - byte with octal value NNN (3 digits)
538 * escape only non-printable characters, checked by isprint()
542 * '\xHH' - byte with hexadecimal value HH (2 digits)
544 * escape only non-ascii characters, checked by isascii()
546 * escape only non-printable or non-ascii characters
574 while (isz--) { in string_escape_mem()
580 * - the @only string is supplied and does not contain a in string_escape_mem()
582 * - the character is printable and ASCII, when @flags has in string_escape_mem()
584 * - the character is printable, when @flags has in string_escape_mem()
586 * - the character is ASCII, when @flags has in string_escape_mem()
588 * - the character doesn't fall into a class of symbols in string_escape_mem()
632 return p - dst; in string_escape_mem()
664 * Returns allocated NULL-terminated string containing process
665 * command line, with inter-argument NULLs replaced with spaces,
677 res = get_cmdline(task, buffer, PAGE_SIZE - 1); in kstrdup_quotable_cmdline()
680 /* Collapse trailing NULLs, leave res pointing to last non-NULL. */ in kstrdup_quotable_cmdline()
681 while (--res >= 0 && buffer[res] == '\0') in kstrdup_quotable_cmdline()
684 /* Replace inter-argument NULLs. */ in kstrdup_quotable_cmdline()
697 * Returns allocated NULL-terminated string containing pathname,
740 * kasprintf_strarray - allocate and fill array of sequential strings
745 * Allocates and fills @n strings using pattern "%s-%zu", where prefix
749 * Returns array of strings or NULL when memory can't be allocated.
761 names[i] = kasprintf(gfp, "%s-%zu", prefix, i); in kasprintf_strarray()
773 * kfree_strarray - free a number of dynamically allocated strings contained
776 * @array: Dynamically allocated array of strings to free.
777 * @n: Number of strings (starting from the beginning of the array) to free.
779 * Passing a non-NULL @array and @n == 0 as well as NULL @array are valid
780 * use-cases. If @array is NULL, the function does nothing.
804 kfree_strarray(array->array, array->n); in devm_kfree_strarray()
813 return ERR_PTR(-ENOMEM); in devm_kasprintf_strarray()
815 ptr->array = kasprintf_strarray(GFP_KERNEL, prefix, n); in devm_kasprintf_strarray()
816 if (!ptr->array) { in devm_kasprintf_strarray()
818 return ERR_PTR(-ENOMEM); in devm_kasprintf_strarray()
821 ptr->n = n; in devm_kasprintf_strarray()
824 return ptr->array; in devm_kasprintf_strarray()
829 * strscpy_pad() - Copy a C-string into a sized buffer
836 * buffer is always %NUL terminated, unless it's zero-sized.
846 * * -E2BIG if count is 0 or @src was truncated.
853 if (written < 0 || written == count - 1) in strscpy_pad()
856 memset(dest + written + 1, 0, count - written - 1); in strscpy_pad()
863 * skip_spaces - Removes leading whitespace from @str.
866 * Returns a pointer to the first non-whitespace character in @str.
877 * strim - Removes leading and trailing whitespace from @s.
880 * Note that the first trailing whitespace is replaced with a %NUL-terminator
881 * in the given string @s. Returns a pointer to the first non-whitespace
893 end = s + size - 1; in strim()
895 end--; in strim()
903 * sysfs_streq - return true if strings are equal, modulo trailing newline
907 * This routine returns true iff two strings are equal, treating both
908 * NUL and newline-then-NUL as equivalent string terminations. It's
909 * geared for use with sysfs input strings, which generally terminate
930 * match_string - matches given string in an array
931 * @array: array of strings
932 * @n: number of strings in the array or -1 for NULL terminated arrays
935 * This routine will look for a string in an array of strings up to the
936 * n-th element in the array or until the first NULL element.
938 * Historically the value of -1 for @n, was used to search in arrays that
944 * index of a @string in the @array if matches, or %-EINVAL otherwise.
959 return -EINVAL; in match_string()
964 * __sysfs_match_string - matches given string in an array
965 * @array: array of strings
966 * @n: number of strings in the array or -1 for NULL terminated arrays
969 * Returns index of @str in the @array or -EINVAL, just like match_string().
972 * This routine will look for a string in an array of strings up to the
973 * n-th element in the array or until the first NULL element.
975 * Historically the value of -1 for @n, was used to search in arrays that
993 return -EINVAL; in __sysfs_match_string()
998 * strreplace - Replace all occurrences of character in string.
1019 * memcpy_and_pad - Copy one buffer to another with padding
1031 memset(dest + count, pad, dest_len - count); in memcpy_and_pad()
1039 /* These are placeholders for fortify compile-time warnings. */