summaryrefslogtreecommitdiff
path: root/common/stringx.c
blob: 159a7f491aacf28b63a05304c5212e00fb75cc0e (plain)
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

#include <string.h>
#include "stringx.h"

const char* trim_start(const char* data)
{
  while(*data && isspace(*data))
    ++data;
  return data;
}

char* trim_end(char* data)
{
  char* t = data + strlen(data);

  while(t > data && isspace(*(t - 1)))
  {
    t--;
    *t = 0;
  }

  return data;
}

char* trim_space(char* data)
{
  data = (char*)trim_start(data);
  return trim_end(data);
}