~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/strsep.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: strsep.c,v 1.1 2006/07/02 19:27:17 serassio Exp $
 
3
 */
 
4
 
 
5
/* Copyright (C) 2004 Free Software Foundation, Inc.
 
6
 * Written by Yoann Vandoorselaere <yoann@prelude-ids.org>
 
7
 *
 
8
 * The file is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2.1 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This file is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this file; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
21
 * USA.
 
22
 */
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#include <config.h>
 
26
#endif
 
27
 
 
28
/* Specification.  */
 
29
#include "strsep.h"
 
30
 
 
31
#include <string.h>
 
32
 
 
33
char *
 
34
strsep (char **stringp, const char *delim)
 
35
{
 
36
  char *start = *stringp;
 
37
  char *ptr;
 
38
 
 
39
  if (!start)
 
40
    return NULL;
 
41
 
 
42
  if (!*delim)
 
43
    ptr = start + strlen (start);
 
44
  else
 
45
    {
 
46
      ptr = strpbrk (start, delim);
 
47
      if (!ptr)
 
48
        {
 
49
          *stringp = NULL;
 
50
          return start;
 
51
        }
 
52
    }
 
53
 
 
54
  *ptr = '\0';
 
55
  *stringp = ptr + 1;
 
56
 
 
57
  return start;
 
58
}