瀏覽代碼

cmText.h/c : Added cmTextSysIsStored() and cmTsIsStored().

master
kpl 11 年之前
父節點
當前提交
f9f9873eaf
共有 2 個檔案被更改,包括 29 行新增0 行删除
  1. 22
    0
      cmText.c
  2. 7
    0
      cmText.h

+ 22
- 0
cmText.c 查看文件

148
   cmLhFree(p->lhH,(cmChar_t*)s);
148
   cmLhFree(p->lhH,(cmChar_t*)s);
149
 }
149
 }
150
 
150
 
151
+bool  cmTextSysIsStored(cmTextSysH_t h, const cmChar_t* s )
152
+{ 
153
+  cmTextSys_t* p = _cmTextSysHandleToPtr(h);  
154
+  return cmLHeapIsPtrInHeap(p->lhH,s);
155
+}
156
+
151
 
157
 
152
   //
158
   //
153
   // Global interface
159
   // Global interface
203
 void                cmTsFreeStr( const cmChar_t* s )
209
 void                cmTsFreeStr( const cmChar_t* s )
204
 { cmTextSysFreeStr(_cmTextSysGlobalH,s); }
210
 { cmTextSysFreeStr(_cmTextSysGlobalH,s); }
205
 
211
 
212
+bool           cmTsIsStored( const cmChar_t* s )
213
+{ return cmTextSysIsStored(_cmTextSysGlobalH,s); }
206
 
214
 
207
 cmChar_t* cmTsVPrintfP( cmChar_t* s, const cmChar_t* fmt, va_list vl )
215
 cmChar_t* cmTsVPrintfP( cmChar_t* s, const cmChar_t* fmt, va_list vl )
208
 {
216
 {
615
 bool cmTextIsNotEmpty( const cmChar_t* s )
623
 bool cmTextIsNotEmpty( const cmChar_t* s )
616
 { return !cmTextIsEmpty(s); }
624
 { return !cmTextIsEmpty(s); }
617
 
625
 
626
+int cmTextCmp( const cmChar_t* s0, const cmChar_t* s1 )
627
+{
628
+  if( s0 == NULL && s1 == NULL )
629
+    return 0;
630
+
631
+  if( s0 == NULL || s1 == NULL )
632
+  {
633
+    if( s0 == NULL )
634
+      return -1;
635
+    return 1;
636
+  }
637
+
638
+  return strcmp(s0,s1);
639
+}
618
 
640
 
619
 cmChar_t* cmTextLine( cmChar_t* s, unsigned line )
641
 cmChar_t* cmTextLine( cmChar_t* s, unsigned line )
620
 {
642
 {

+ 7
- 0
cmText.h 查看文件

52
   cmChar_t*     cmTextSysVPrintf( cmTextSysH_t h, const cmChar_t* fmt, va_list vl );
52
   cmChar_t*     cmTextSysVPrintf( cmTextSysH_t h, const cmChar_t* fmt, va_list vl );
53
   cmChar_t*     cmTextSysPrintf(  cmTextSysH_t h, const cmChar_t* fmt, ... );
53
   cmChar_t*     cmTextSysPrintf(  cmTextSysH_t h, const cmChar_t* fmt, ... );
54
   void          cmTextSysFreeStr( cmTextSysH_t h, const cmChar_t* s );
54
   void          cmTextSysFreeStr( cmTextSysH_t h, const cmChar_t* s );
55
+  // Return true if 's' is stored in the text systems internal heap,
56
+  bool          cmTextSysIsStored(cmTextSysH_t h, const cmChar_t* s );
55
 
57
 
56
   //
58
   //
57
   // Global interface:
59
   // Global interface:
71
   cmChar_t*     cmTsVPrintf( const cmChar_t* fmt, va_list vl );
73
   cmChar_t*     cmTsVPrintf( const cmChar_t* fmt, va_list vl );
72
   cmChar_t*     cmTsPrintf(  const cmChar_t* fmt, ... );
74
   cmChar_t*     cmTsPrintf(  const cmChar_t* fmt, ... );
73
   void          cmTsFreeStr( const cmChar_t* s );
75
   void          cmTsFreeStr( const cmChar_t* s );
76
+  bool          cmTsIsStored(const cmChar_t* s );
74
 
77
 
75
   // Print a formatted string into s[].  s[] is reallocated as necessary to
78
   // Print a formatted string into s[].  s[] is reallocated as necessary to
76
   // hold the string.  s must be freed by the caller via cmMemFree().
79
   // hold the string.  s must be freed by the caller via cmMemFree().
196
   bool cmTextIsEmpty( const cmChar_t* s );
199
   bool cmTextIsEmpty( const cmChar_t* s );
197
   bool cmTextIsNotEmpty( const cmChar_t* s );
200
   bool cmTextIsNotEmpty( const cmChar_t* s );
198
 
201
 
202
+  // Same as strcmp() but handles NULL.  Note that if both s0 and s1 are NULL
203
+  // then return is 0.
204
+  int cmTextCmp( const cmChar_t* s0, const cmChar_t* s1 );
205
+
199
   // Returns NULL if string contains fewer than lineIdx lines.
206
   // Returns NULL if string contains fewer than lineIdx lines.
200
   // Note: first line == 1.
207
   // Note: first line == 1.
201
   cmChar_t* cmTextLine( cmChar_t* s, unsigned line );
208
   cmChar_t* cmTextLine( cmChar_t* s, unsigned line );

Loading…
取消
儲存