string.c (bbf215553c7233fbab8a0afdf1fac74c44781867) string.c (29219719c034367724cbf77434175b3c4e681e43)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 12 unchanged lines hidden (view full) ---

21/*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2014 Joyent, Inc. All rights reserved.
25 */
26
27/*
28 * Copyright (c) 2016 by Delphix. All rights reserved.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 12 unchanged lines hidden (view full) ---

21/*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2014 Joyent, Inc. All rights reserved.
25 */
26
27/*
28 * Copyright (c) 2016 by Delphix. All rights reserved.
29 * Copyright 2018 Nexenta Systems, Inc.
29 * Copyright 2022 Tintri by DDN, Inc. All rights reserved.
30 */
31
32/*
33 * Implementations of the functions described in vsnprintf(3C) and string(3C),
34 * for use by the kernel, the standalone, and kmdb. Unless otherwise specified,
35 * these functions match the section 3C manpages.
36 */
37

--- 666 unchanged lines hidden (view full) ---

704 return (tok);
705 }
706 } while (sc != 0);
707 }
708 /* NOTREACHED */
709}
710
711/*
30 */
31
32/*
33 * Implementations of the functions described in vsnprintf(3C) and string(3C),
34 * for use by the kernel, the standalone, and kmdb. Unless otherwise specified,
35 * these functions match the section 3C manpages.
36 */
37

--- 666 unchanged lines hidden (view full) ---

704 return (tok);
705 }
706 } while (sc != 0);
707 }
708 /* NOTREACHED */
709}
710
711/*
712 * strtok_r
713 *
714 * uses strpbrk and strspn to break string into tokens on
715 * sequentially subsequent calls. returns NULL when no
716 * non-separator characters remain.
717 * `subsequent' calls are calls with first argument NULL.
718 */
719char *
720strtok_r(char *string, const char *sepset, char **lasts)
721{
722 char *q, *r;
723
724 /* first or subsequent call */
725 if (string == NULL)
726 string = *lasts;
727
728 if (string == NULL) /* return if no tokens remaining */
729 return (NULL);
730
731 q = string + strspn(string, sepset); /* skip leading separators */
732
733 if (*q == '\0') /* return if no tokens remaining */
734 return (NULL);
735
736 if ((r = strpbrk(q, sepset)) == NULL) { /* move past token */
737 *lasts = NULL; /* indicate this is last token */
738 } else {
739 *r = '\0';
740 *lasts = r + 1;
741 }
742 return (q);
743}
744
745/*
712 * Unless mentioned otherwise, all of the routines below should be added to
713 * the Solaris DDI as necessary. For now, only provide them to standalone.
714 */
715#if defined(_BOOT) || defined(_KMDB)
716char *
717strtok(char *string, const char *sepset)
718{
719 char *p, *q, *r;

--- 117 unchanged lines hidden ---
746 * Unless mentioned otherwise, all of the routines below should be added to
747 * the Solaris DDI as necessary. For now, only provide them to standalone.
748 */
749#if defined(_BOOT) || defined(_KMDB)
750char *
751strtok(char *string, const char *sepset)
752{
753 char *p, *q, *r;

--- 117 unchanged lines hidden ---