File: xstring.h

package info (click to toggle)
sjaakii 1.4.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,628 kB
  • sloc: ansic: 16,287; cpp: 4,543; makefile: 15
file content (31 lines) | stat: -rw-r--r-- 476 bytes parent folder | download | duplicates (5)
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
#ifndef XSTRING_H
#define XSTRING_H

#include <string.h>
#include <ctype.h>

static inline char *trim(char *s)
{
   char *p = s;
   while (*p && isspace(*p)) p++;
   if (p!= s) {
      for (size_t n = 0; n<=strlen(p); n++)
         s[n] = p[n];
   }
   return s;
}

static inline char *chomp(char *s)
{
   char *p;
   p = strstr(s, "\n");
   if (p) *p = '\0';
   return s;
}

static inline bool streq(const char *s1, const char *s2)
{
   return strcmp(s1, s2) == 0;
}

#endif