PR# 19305 Need new STRING creation procedure

Problem Report Summary
Submitter: prestoat2000
Category: EiffelBase
Priority: Medium
Date: 2016/12/07
Class: Feature Request
Severity: Serious
Number: 19305
Release: 16.05
Confidential: No
Status: Closed
Responsible: jfiat_es
Environment: linux
Synopsis: Need new STRING creation procedure

Description
I looked at the creation procedures for STRING_8 and IMMUTABLE_STRING_8 and could not
find one that provides what we need.  We need a creation procedure that takes a POINTER
and an INTEGER_32 length and creates a STRING_8 (or IMMUTABLE_STRING_8).  
The procedure should copy `length' bytes from the memory indicated by the pointer
into the `area', set count, etc.

The existing creation procedure `make_from_c' is very close, but it will not work because our strings 
may contain nulls (i.e., they are not null-terminated).

The creation procedure we want would look something like this (choose the name yourself):

   make_from_pointer_and_count (c_string: POINTER; a_length: INTEGER_32)
      require
         c_string_not_null: c_string /= default_pointer
         a_length_non_negative: a_length >= 0

Can this be added to class READABLE_STRING_8 and specified as a creation procedure
for STRING_8 and IMMUTABLE_STRING_8?

Note: There are other ways to get the effect we want, but they involve extra object creation
and copying of the bytes.
To Reproduce

										
Problem Report Interactions
From:jfiat_es    Date:2017/04/10    Status: Closed    Download   
Great, this will be available in the next release (this is already available in the subversion repository).

From:prestoat2000    Date:2017/04/03    Status: Analyzed    Download   
The procedure you proposed would work fine for me.

From:jfiat_es    Date:2017/04/03    Status: Analyzed    Download   
Hi,

To answer your need, we plan to add a new creation a little bit more general

	make_from_c_substring (c_string: POINTER; start_pos, end_pos: INTEGER)
			-- Initialize from substring of `c_string',
			-- between `start_index' and `end_index',
			-- `c_string' created by some C function.
		require
			c_string_exists: c_string /= default_pointer
			start_position_big_enough: start_pos >= 1
			end_position_big_enough: start_pos <= end_pos + 1

And your suggestion:    make_from_pointer_and_count (c_string: POINTER; a_length: INTEGER_32)
is just replaced by  make_from_c_substring (c_string, 1, a_length)

Any comment? It would be implemented in next 17.05 release.