File: util_str.c

package info (click to toggle)
s390-tools 2.40.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,288 kB
  • sloc: ansic: 187,079; sh: 12,157; cpp: 5,049; makefile: 2,812; perl: 2,541; asm: 1,097; python: 697; xml: 29
file content (33 lines) | stat: -rw-r--r-- 705 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * util - Utility function library
 *
 * Manipulate and work with strings
 *
 * Copyright IBM Corp. 2025
 *
 * s390-tools is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 */

#include <ctype.h>

#include "lib/util_str.h"

/**
 * Copy characters from \a src to \a dest, omitting all blank characters
 * (spaces and tabs). The resulting string in \a dest will be NUL terminated.
 *
 * @param[in]  src   Source string
 * @param[out] dest  Destination buffer
 */
void util_str_rm_whitespace(const char *src, char *dest)
{
	while (*src != '\0') {
		if (!isblank(*src)) {
			*dest = *src;
			dest++;
		}
		src++;
	}
	*dest = '\0';
}