-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_functions.c
More file actions
37 lines (30 loc) · 778 Bytes
/
Copy pathstring_functions.c
File metadata and controls
37 lines (30 loc) · 778 Bytes
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
34
35
36
37
#include "string_functions.h"
//Removes leading white spaces from left and proceeding white spaces from right of a string, and returns the new string.
char *white_space_left_right(char *str)
{
char *end;
// Trim leading space
while (isspace((unsigned char)*str))
str++;
if (*str == 0) // All spaces?
return str;
// Trim trailing space
end = str + strlen(str) - 1;
while (end > str && isspace((unsigned char)*end))
end--;
// Write new null terminator character
end[1] = '\0';
return str;
}
//Remove double quotes from string:
char *update_string_echo(char *cmd)
{
for (int i = 0; i < strlen(cmd); i++)
{
if (cmd[i] == '"')
{
cmd[i] = ' ';
}
}
return cmd;
}