Hi,

How can I unpack two or more consecutive C-strings with the
String#unpack method? Like this:

  "abc\000def\000".unpack("??") # => ["abc", "def"]

Currently, this seems not to be possible. Any chance to get the
following patch applied, which implements exactly this?


Regards,

  Michael


Index: pack.c
===================================================================
RCS file: /src/ruby/pack.c,v
retrieving revision 1.69
diff -r1.69 pack.c
1287a1288,1290
>  *       T    | String  | read zero-terminated string 
>  *            |         | (with null char removed)
>  *     -------+---------+-----------------------------------------
1389a1393,1408
> 	    break;
> 
> 	  case 'T':
>             /* read until end of string or until a null character occurs */
>             {
>                 char *start = s;
> 
>                 while (s < send) {     /* don't read more than the whole string */
>                   if (*s == '\000') break;
>                   s++;
>                 }
> 
>                 rb_ary_push(ary, infected_str_new(start, s-start, str));
> 
>                 if (s < send && *s == '\000') s++; /* skip null character */
>             }