Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updating: adding string_copy.

  • Loading branch information...
commit 2e37f11e98678fd4599f53c2e0282e567ce4d43e 1 parent fffe998
authored March 11, 2013
16  prelude/CATS/string.cats
@@ -234,6 +234,20 @@ atspre_strbuf_initialize_substring (
234 234
 
235 235
 ATSinline()
236 236
 ats_ptr_type
  237
+atspre_string_copy
  238
+  (ats_ptr_type str) {
  239
+  int n ; char *des ;
  240
+  n = strlen((char*)str) ;
  241
+  des = (char*)ATS_MALLOC(n+1) ;
  242
+  des[n] = '\000' ;
  243
+  memcpy(des, str, n) ;
  244
+  return (des) ;
  245
+} // end of [atspre_string_copy]
  246
+
  247
+/* ****** ****** */
  248
+
  249
+ATSinline()
  250
+ats_ptr_type
237 251
 atspre_string_append
238 252
   (ats_ptr_type s1, ats_ptr_type s2) {
239 253
   int n1, n2 ; char *des ;
@@ -242,7 +256,7 @@ atspre_string_append
242 256
   des = (char*)ATS_MALLOC(n1+n2+1) ;
243 257
   des[n1+n2] = '\000' ;
244 258
   memcpy(des, s1, n1) ; memcpy (des+n1, s2, n2) ;
245  
-  return (ats_ptr_type)des ;
  259
+  return (des) ;
246 260
 } // end of [atspre_string_append]
247 261
 
248 262
 /* ****** ****** */
7  prelude/SATS/string.sats
@@ -503,6 +503,13 @@ fun string_make_substring__main {v:view}
503 503
 
504 504
 (* ****** ****** *)
505 505
 
  506
+fun string0_copy
  507
+  (str: string): string = "atspre_string_copy"
  508
+fun string1_copy {n:nat}
  509
+  (str: string (n)): strbufptr_gc (n) = "atspre_string_copy"
  510
+
  511
+(* ****** ****** *)
  512
+
506 513
 fun string0_append
507 514
   (s1: string, s2: string):<> string // persistent
508 515
   = "atspre_string_append" 

0 notes on commit 2e37f11

Please sign in to comment.
Something went wrong with that request. Please try again.