Browse Source

cmText.h/c : Added cmTextLastWhiteChar().

master
kevin 10 years ago
parent
commit
a4020934ee
2 changed files with 25 additions and 0 deletions
  1. 20
    0
      cmText.c
  2. 5
    0
      cmText.h

+ 20
- 0
cmText.c View File

@@ -498,6 +498,26 @@ const cmChar_t* cmTextLastNonWhiteCharC( const cmChar_t* s )
498 498
 { return cmTextLastNonWhiteChar(s); }
499 499
 
500 500
 
501
+cmChar_t*       cmTextLastWhiteChar(  const cmChar_t* s )
502
+{
503
+  unsigned n;
504
+  if(s==NULL || (n = strlen(s)) == 0 )
505
+    return NULL;
506
+
507
+  cmChar_t* s0 = (cmChar_t*)s + n-1;
508
+
509
+  for(; s0>=s; --s0)
510
+    if( isspace(*s0) )
511
+      return s0;
512
+
513
+  return NULL;
514
+
515
+}
516
+
517
+const cmChar_t* cmTextLastWhiteCharC( const cmChar_t* s )
518
+{ return cmTextLastWhiteChar(s); }
519
+
520
+
501 521
 void cmTextShrinkS( cmChar_t* s, const cmChar_t* t, unsigned tn )
502 522
 { cmVOC_Shrink(s,strlen(s)+1,t,tn); }
503 523
 

+ 5
- 0
cmText.h View File

@@ -146,9 +146,14 @@ extern "C" {
146 146
   const cmChar_t* cmTextEndOfLineC( const cmChar_t* s );
147 147
 
148 148
   // Return a pointer to the last non-white character in the string
149
+  // or NULL if s is NULL or empty.
149 150
   cmChar_t*       cmTextLastNonWhiteChar(  const cmChar_t* s );
150 151
   const cmChar_t* cmTextLastNonWhiteCharC( const cmChar_t* s );
151 152
   
153
+  // Return a pointer to the last white character in the string
154
+  // or NULL if s is NULL or empty.
155
+  cmChar_t*       cmTextLastWhiteChar(  const cmChar_t* s );
156
+  const cmChar_t* cmTextLastWhiteCharC( const cmChar_t* s );
152 157
     
153 158
 
154 159
 

Loading…
Cancel
Save