Sha256: 698fccb2329179b1dcf953c9f883cc78f7a6726917868245f5862d7296ff3df6

Contents?: true

Size: 291 Bytes

Versions: 3

Compression:

Stored size: 291 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
mathematical-1.3.0 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.2.2 ext/mathematical/mtex2MML/tests/deps/trim/trim.c
mathematical-1.2.1 ext/mathematical/mtex2MML/tests/deps/trim/trim.c