mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Fix indentation and formatting of str_clean_whitespaces
(cherry picked from commit b9c4086382
)
This commit is contained in:
parent
75d076b3bc
commit
8c4569991d
|
@ -2423,30 +2423,33 @@ void str_sanitize_filename(char *str_in)
|
|||
/* removes leading and trailing spaces and limits the use of multiple spaces */
|
||||
void str_clean_whitespaces(char *str_in)
|
||||
{
|
||||
char* r = str_in;
|
||||
int c = 0;
|
||||
|
||||
while(*r == ' ')
|
||||
++r;
|
||||
|
||||
while(*str_in)
|
||||
char *read = str_in;
|
||||
char *write = str_in;
|
||||
|
||||
/* skip initial whitespace */
|
||||
while(*read == ' ')
|
||||
read++;
|
||||
|
||||
/* end of read string is detected in the loop */
|
||||
while(1)
|
||||
{
|
||||
for(; *r == ' '; ++r)
|
||||
c = 1;
|
||||
|
||||
if(*r)
|
||||
/* skip whitespace */
|
||||
int found_whitespace = 0;
|
||||
for(; *read == ' '; read++)
|
||||
found_whitespace = 1;
|
||||
/* if not at the end of the string, put a found whitespace here */
|
||||
if(*read)
|
||||
{
|
||||
if(c)
|
||||
{
|
||||
*str_in++ = ' ';
|
||||
c = 0;
|
||||
}
|
||||
|
||||
*str_in++ = *r++;
|
||||
}
|
||||
if(found_whitespace)
|
||||
*write++ = ' ';
|
||||
*write++ = *read++;
|
||||
}
|
||||
else
|
||||
*str_in = 0;
|
||||
}
|
||||
{
|
||||
*write = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *str_skip_to_whitespace(char *str)
|
||||
|
|
Loading…
Reference in a new issue