~naesten/tex-live/trunk

« back to all changes in this revision

Viewing changes to libs/poppler/poppler-src/poppler/strtok_r.cpp

  • Committer: karl
  • Date: 2018-01-09 18:53:05 UTC
  • Revision ID: svn-v4:c570f23f-e606-0410-a88d-b1316a301751:trunk/Build/source:46257
poppler 0.62.0, requiring C++11; luatex not updated yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Reentrant string tokenizer.  Generic version.
2
 
   Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc.
3
 
   This file is part of the GNU C Library.
4
 
 
5
 
   The GNU C Library is free software; you can redistribute it and/or
6
 
   modify it under the terms of the GNU Lesser General Public
7
 
   License as published by the Free Software Foundation; either
8
 
   version 2.1 of the License, or (at your option) any later version.
9
 
 
10
 
   The GNU C Library is distributed in the hope that it will be useful,
11
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
   Lesser General Public License for more details.
14
 
 
15
 
   You should have received a copy of the GNU Lesser General Public
16
 
   License along with the GNU C Library; if not, write to the Free
17
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
 
   02111-1307 USA.  */
19
 
 
20
 
/* Copyright (C) 1991,93,96,97,99,2000,2002 Free Software Foundation, Inc.
21
 
   This file is part of the GNU C Library.
22
 
   Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
23
 
   with help from Dan Sahlin (dan@sics.se) and
24
 
   commentary by Jim Blandy (jimb@ai.mit.edu);
25
 
   adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
26
 
   and implemented by Roland McGrath (roland@ai.mit.edu).
27
 
 
28
 
   The GNU C Library is free software; you can redistribute it and/or
29
 
   modify it under the terms of the GNU Lesser General Public
30
 
   License as published by the Free Software Foundation; either
31
 
   version 2.1 of the License, or (at your option) any later version.
32
 
 
33
 
   The GNU C Library is distributed in the hope that it will be useful,
34
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
35
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36
 
   Lesser General Public License for more details.
37
 
 
38
 
   You should have received a copy of the GNU Lesser General Public
39
 
   License along with the GNU C Library; if not, write to the Free
40
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
41
 
   02111-1307 USA.  */
42
 
 
43
 
//========================================================================
44
 
//
45
 
// Modified under the Poppler project - http://poppler.freedesktop.org
46
 
//
47
 
// All changes made under the Poppler project to this file are licensed
48
 
// under GPL version 2 or later
49
 
//
50
 
// Copyright (C) 2012 Alexey Pavlov <alexpux@gmail.com>
51
 
// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
52
 
//
53
 
// To see a description of the changes please see the Changelog file that
54
 
// came with your tarball or type make ChangeLog if you are building from git
55
 
//
56
 
//========================================================================
57
 
 
58
 
#if defined(__MINGW32__) && !defined(__WINPTHREADS_VERSION)
59
 
#include <string.h>
60
 
 
61
 
#define __rawmemchr strchr
62
 
 
63
 
char * strtok_r (char *s, const char *delim, char **save_ptr)
64
 
{
65
 
  char *token;
66
 
 
67
 
  if (s == NULL)
68
 
    s = *save_ptr;
69
 
 
70
 
  /* Scan leading delimiters.  */
71
 
  s += strspn (s, delim);
72
 
  if (*s == '\0')
73
 
    {
74
 
      *save_ptr = s;
75
 
      return NULL;
76
 
    }
77
 
 
78
 
  /* Find the end of the token.  */
79
 
  token = s;
80
 
  s = strpbrk (token, delim);
81
 
  if (s == NULL)
82
 
    /* This token finishes the string.  */
83
 
    *save_ptr = __rawmemchr (token, '\0');
84
 
  else
85
 
    {
86
 
      /* Terminate the token and make *SAVE_PTR point past it.  */
87
 
      *s = '\0';
88
 
      *save_ptr = s + 1;
89
 
    }
90
 
  return token;
91
 
}
92
 
#endif