Ignore:
Timestamp:
01/28/11 23:29:40 (13 years ago)
Author:
Maciej Komosinski
Message:

a lot of minor fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/gdk/sstringutils.cpp

    r5 r64  
    1 // This file is a part of Framsticks GDK library.
    2 // Copyright (C) 2002-2006  Szymon Ulatowski.  See LICENSE.txt for details.
    3 // Refer to http://www.frams.alife.pl/ for further information.
     1// This file is a part of the Framsticks GDK library.
     2// Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
     3// Refer to http://www.framsticks.com/ for further information.
    44
    55#include "sstringutils.h"
     
    233233}
    234234
     235SString trim(SString& s)
     236{
     237const unsigned char*b=(const unsigned char*)(const char*)s;
     238const unsigned char*e=b+s.len();
     239while((b<e)&&(*b<=' ')) b++;
     240while((b<e)&&(e[-1]<=' ')) e--;
     241if ((e-b)==s.len()) return s;
     242SString newstring;
     243char* t=newstring.directWrite();
     244memmove(t,b,e-b);
     245newstring.endWrite(e-b);
     246return newstring;
     247}
Note: See TracChangeset for help on using the changeset viewer.