|
@@ -519,6 +519,49 @@ void cmTextClip( cmChar_t* s, unsigned n )
|
519
|
519
|
|
520
|
520
|
}
|
521
|
521
|
|
|
522
|
+cmChar_t* cmTextTrimBegin( cmChar_t* s )
|
|
523
|
+{
|
|
524
|
+ if( s==NULL || strlen(s) == 0 )
|
|
525
|
+ return s;
|
|
526
|
+
|
|
527
|
+ cmChar_t* s0 = cmTextNextNonWhite(s);
|
|
528
|
+
|
|
529
|
+ // no non-white char's exist
|
|
530
|
+ if( s0 == NULL )
|
|
531
|
+ {
|
|
532
|
+ s[0] = 0;
|
|
533
|
+ return s;
|
|
534
|
+ }
|
|
535
|
+
|
|
536
|
+ if( s0 != s )
|
|
537
|
+ cmTextShrinkS(s,s,s0-s);
|
|
538
|
+
|
|
539
|
+ return s;
|
|
540
|
+}
|
|
541
|
+
|
|
542
|
+cmChar_t* cmTextTrimEnd( cmChar_t* s )
|
|
543
|
+{
|
|
544
|
+ unsigned sn;
|
|
545
|
+
|
|
546
|
+ if( s==NULL || (sn = strlen(s))==0)
|
|
547
|
+ return s;
|
|
548
|
+
|
|
549
|
+ cmChar_t* s0 = cmTextLastNonWhiteChar(s);
|
|
550
|
+
|
|
551
|
+ if(s0-s+1 < sn )
|
|
552
|
+ s[s0-s+1] = 0;
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+ return s;
|
|
556
|
+}
|
|
557
|
+
|
|
558
|
+cmChar_t* cmTextTrim( cmChar_t* s)
|
|
559
|
+{
|
|
560
|
+ cmTextTrimBegin(s);
|
|
561
|
+ cmTextTrimEnd(s);
|
|
562
|
+ return s;
|
|
563
|
+}
|
|
564
|
+
|
522
|
565
|
|
523
|
566
|
cmChar_t* cmTextExpandS( cmChar_t* s, const cmChar_t* t, unsigned tn )
|
524
|
567
|
{ return cmVOC_Expand(s,strlen(s)+1,t,tn); }
|