VirtualBox

source: vbox/trunk/src/VBox/Runtime/strstrip.cpp@ 3261

Last change on this file since 3261 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/* $Id: strstrip.cpp 2981 2007-06-01 16:01:28Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - String Stripping and Trimming.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#include <iprt/string.h>
26#include <iprt/ctype.h>
27#include <iprt/string.h>
28
29
30/**
31 * Strips blankspaces from both ends of the string.
32 *
33 * @returns Pointer to first non-blank char in the string.
34 * @param psz The string to strip.
35 */
36RTDECL(char *) RTStrStrip(char *psz)
37{
38 /* left */
39 while (isspace(*psz))
40 psz++;
41
42 /* right */
43 char *pszEnd = strchr(psz, '\0');
44 while (--pszEnd > psz && isspace(*pszEnd))
45 *pszEnd = '\0';
46
47 return psz;
48}
49
50
51/**
52 * Strips blankspaces from the start of the string.
53 *
54 * @returns Pointer to first non-blank char in the string.
55 * @param psz The string to strip.
56 */
57RTDECL(char *) RTStrStripL(const char *psz)
58{
59 /* left */
60 while (isspace(*psz))
61 psz++;
62
63 return (char *)psz;
64}
65
66
67/**
68 * Strips blankspaces from the end of the string.
69 *
70 * @returns psz.
71 * @param psz The string to strip.
72 */
73RTDECL(char *) RTStrStripR(char *psz)
74{
75 /* right */
76 char *pszEnd = strchr(psz, '\0');
77 while (--pszEnd > psz && isspace(*pszEnd))
78 *pszEnd = '\0';
79
80 return psz;
81}
82
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette