/* str/lstrip.c - Strip whitespace from the left of a string
 * Copyright (C) 2001  Bruce Guenter <bruceg@em.ca>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#include <ctype.h>
#include "str.h"

void str_lstrip(str* s)
{
  unsigned off;
  for (off = 0; off < s->len && isspace(s->s[off]); ++off) ;
  if (off) {
    memcpy(s->s, s->s+off, s->len-off+1);
    s->len -= off;
  }
}

/* str/lstrip.c - Strip whitespace from the left of a string
 * Copyright (C) 2001  Bruce Guenter <bruceg@em.ca>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#include <ctype.h>
#include <string.h>
#include "str.h"

void str_lstrip(str* s)
{
  unsigned off;
  for (off = 0; off < s->len && isspace(s->s[off]); ++off) ;
  if (off) {
    memmove(s->s, s->s+off, s->len-off+1);
    s->len -= off;
  }
}

Use memmove instead of memcpy due to the fact that the strings will be overlapping.
Use memmove instead of memcpy due to the fact that the strings will be
overlapping.

