Sha256: fd0b3726885b2c23f6ff35e0cc6dcde08235c57b7f71f7e1121b098460b7a367

Contents?: true

Size: 332 Bytes

Versions: 22

Compression:

Stored size: 332 Bytes

Contents

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

char *
trim(char *str)
{
  char *end;

  // ltrim
  while (isspace(*str)) {
    str++;
  }

  if (*str == 0) // only spaces
    return str;

  // rtrim
  end = str + strlen(str) - 1;
  while (end > str && isspace(*end)) {
    end--;
  }

  // null terminator
  *(end+1) = 0;

  return str;
}

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
mathematical-1.6.20 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.18 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.14 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.13 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.12 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.11 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.10 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.9 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.8 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.7 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.6 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.5 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.4 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.3 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.2 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.1 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.6.0 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.5.12 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.5.0 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.4.2 ext/mathematical/mtex2MML/tests/deps/trim/trim.c