cvsuser     02/01/10 15:23:03

  Modified:    .        string.c
               docs     strings.pod
  Log:
  Removed all the nul termination code, as this is in general a bad idea.
  Note added to docs/strings.pod to warn people away from assuming termination.
  
  Revision  Changes    Path
  1.39      +4 -9      parrot/string.c
  
  Index: string.c
  ===================================================================
  RCS file: /home/perlcvs/parrot/string.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -w -r1.38 -r1.39
  --- string.c  9 Jan 2002 22:35:14 -0000       1.38
  +++ string.c  10 Jan 2002 23:22:59 -0000      1.39
  @@ -1,7 +1,7 @@
   /* string.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: string.c,v 1.38 2002/01/09 22:35:14 dan Exp $
  + *     $Id: string.c,v 1.39 2002/01/10 23:22:59 ajgough Exp $
    *  Overview:
    *     This is the api definitions for the string subsystem
    *  Data Structure and Algorithms:
  @@ -45,7 +45,7 @@
       }
   
       s = mem_sys_allocate(sizeof(STRING));
  -    s->bufstart = mem_sys_allocate(buflen+1);
  +    s->bufstart = mem_sys_allocate(buflen);
       s->encoding = encoding;
       s->flags = flags;
       s->type = type;
  @@ -60,9 +60,6 @@
           s->strlen = s->bufused = 0;
       }
   
  -    /* Make it null terminate. This will simplify making a native string */
  -    memset((char *)s->bufstart+s->bufused,0,1);
  -
       return s;
   }
   
  @@ -194,7 +191,6 @@
   
       dest->bufused = destend - deststart;
       dest->strlen = src->strlen;
  -    memset((char *)dest->bufstart+dest->bufused,0,1);
   
       if (dest_ptr) {
           *dest_ptr = dest;
  @@ -235,7 +231,6 @@
                               b->bufstart, b->bufused);
               result->strlen = a->strlen + b->strlen;
               result->bufused = a->bufused + b->bufused;
  -            memset((char *)result->bufstart+result->bufused,0,1);
           }
           else {
               return string_copy(interpreter, a);
  @@ -301,6 +296,7 @@
   
       true_offset = (UINTVAL)offset;
   
  +    /* Allow regexes to return $' easily for "aaa" =~ /aaa/ */
       if (offset == string_length(src) || length < 1) {
           return NULL;
       }
  @@ -333,7 +329,6 @@
       mem_sys_memcopy(dest->bufstart, substart, (unsigned)(subend - substart));
       dest->bufused = subend - substart;
       dest->strlen = true_length;
  -    memset((char *)dest->bufstart+dest->bufused,0,1);
   
       if (d != NULL) {
           *d = dest;
  @@ -362,7 +357,7 @@
   
       s->bufused = bufend - bufstart;
       s->strlen = s->strlen - true_n;
  -    memset((char *)s->bufstart+s->bufused,0,1);
  +
       return s;
   }
   
  
  
  
  1.8       +11 -0     parrot/docs/strings.pod
  
  Index: strings.pod
  ===================================================================
  RCS file: /home/perlcvs/parrot/docs/strings.pod,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- strings.pod       28 Dec 2001 18:20:12 -0000      1.7
  +++ strings.pod       10 Jan 2002 23:23:03 -0000      1.8
  @@ -144,6 +144,17 @@
   be created. If C<len> is zero, the behaviour becomes more C<sprintf>ish
   than C<snprintf>-like.
   
  +=head1 Notes for Implementors
  +
  +=head2 Termination
  +
  +The character buffer pointed to by *bustart is not expected to be
  +terminated by a nul byte and functions which provide the string api
  +will not add one.  Any functions which access the buffer directly and
  +which require a terminating nul byte must place one there themselves
  +and also be very careful about nul bytes within the used portion of
  +the character buffer.  In particular, if bufused == buflen more space
  +must be allocated to hold a terminating byte.
   
   =head1 Elements of the C<STRING> structure
   
  
  
  


Reply via email to