"Fossies" - the Fresh Open Source Software Archive

Member "poppler-0.82.0/goo/glibc_strtok_r.cc" (25 Oct 2019, 3498 Bytes) of package /linux/misc/poppler-0.82.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "glibc_strtok_r.cc" see the Fossies "Dox" file reference documentation.

    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 // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
   53 // Copyright (C) 2017 Pekka Vuorela <pekka.vuorela@jollamobile.com>
   54 //
   55 // To see a description of the changes please see the Changelog file that
   56 // came with your tarball or type make ChangeLog if you are building from git
   57 //
   58 //========================================================================
   59 
   60 #include "glibc.h"
   61 
   62 #ifndef HAVE_STRTOK_R
   63 
   64 #include <string.h>
   65 
   66 #define __rawmemchr strchr
   67 
   68 char * strtok_r (char *s, const char *delim, char **save_ptr)
   69 {
   70   char *token;
   71 
   72   if (s == NULL)
   73     s = *save_ptr;
   74 
   75   /* Scan leading delimiters.  */
   76   s += strspn (s, delim);
   77   if (*s == '\0')
   78     {
   79       *save_ptr = s;
   80       return NULL;
   81     }
   82 
   83   /* Find the end of the token.  */
   84   token = s;
   85   s = strpbrk (token, delim);
   86   if (s == NULL)
   87     /* This token finishes the string.  */
   88     *save_ptr = __rawmemchr (token, '\0');
   89   else
   90     {
   91       /* Terminate the token and make *SAVE_PTR point past it.  */
   92       *s = '\0';
   93       *save_ptr = s + 1;
   94     }
   95   return token;
   96 }
   97 
   98 #endif