Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Is this a bug? length(Buffer b, int len) not trucating fully
Topic Summary:
Created On: 7-Feb-2008 10:55
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Louie Landale, on Friday, February 8, 2008 9:07 AM

Answer:
Too lazy to look it up, but we did some work on this earlier in the formums. Perhaps look for 'length'.

IIRC, reducing the length of a buffer with the 'length' function is a disaster if you set it longer than the existing length.

IIRC, reducing the length works in some situation but fails in others.

IIRC, setting the null character as a mechanism for reducing the length works in some situation, but fails in others.

IIRC, setting the 'length' AND setting a null character worked.

Give the attached function a try, let us know if it works. But sure to set the length of a buffer to a value smaller than the original length, but larger than a previous set.

- Louie
 7-Feb-2008 10:55
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

Hi all,

I have observed a strange behaviour of the 'length' perm and would like to ask you if I get something wrong or whether this can be considered a bug:

When I truncate a Buffer b using length(b,len) and then use the truncated buffer by concatenating it to a second buffer, the full buffer content (before the truncation) is added.

The attached code illustrates this:

first, two buffers 'a' and 'b' are created and set to "hello world "
then, both are truncated to "hallo ", 'a' using the length perm, 'b' using the range

The contents of 'a' and 'b' are appended to a new Buffer 'c', which should then be "hello hello ", but instead shows "hello world hello".

As a workaround, a fourth Buffer d is created using the 'combine' perm and the explicit lengths of 'a' and 'b', which shows the expected result.


As we are still running DOORS 7.0, I would be curious to know if this is actually a bug, and whether it persists in later DOORS versions.


Regards,

Peter
Report this to a Moderator Report this to a Moderator
 7-Feb-2008 12:42
User is offline View Users Profile Print this message


Frank Jensen

Posts: 24
Joined: 18-Sep-2007

Hm, strange.

Same behaviour with 7.1 and 8.3.0.1

Cheers,
Frank

-------------------------
Frank Jensen
TRW Automotive
frank.jensenREMOVE_ME@trw.com
Report this to a Moderator Report this to a Moderator
 7-Feb-2008 12:43
User is offline View Users Profile Print this message


Frank Jensen

Posts: 24
Joined: 18-Sep-2007

- removed -

-------------------------
Frank Jensen
TRW Automotive
frank.jensenREMOVE_ME@trw.com

Edited: 7-Feb-2008 at 12:46 by Frank Jensen
Report this to a Moderator Report this to a Moderator
 7-Feb-2008 12:43
User is offline View Users Profile Print this message


Frank Jensen

Posts: 24
Joined: 18-Sep-2007

- removed -

-------------------------
Frank Jensen
TRW Automotive
frank.jensenREMOVE_ME@trw.com

Edited: 7-Feb-2008 at 12:46 by Frank Jensen
Report this to a Moderator Report this to a Moderator
 7-Feb-2008 12:45
User is offline View Users Profile Print this message


Frank Jensen

Posts: 24
Joined: 18-Sep-2007

Ups, sorry for tripple posting. I keep getting errors when pressing the 'Reply to Topic' button.

Cheers,
Frank

-------------------------
Frank Jensen
TRW Automotive
frank.jensenREMOVE_ME@trw.com
Report this to a Moderator Report this to a Moderator
 7-Feb-2008 20:53
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Answer Answer
Too lazy to look it up, but we did some work on this earlier in the formums. Perhaps look for 'length'.

IIRC, reducing the length of a buffer with the 'length' function is a disaster if you set it longer than the existing length.

IIRC, reducing the length works in some situation but fails in others.

IIRC, setting the null character as a mechanism for reducing the length works in some situation, but fails in others.

IIRC, setting the 'length' AND setting a null character worked.

Give the attached function a try, let us know if it works. But sure to set the length of a buffer to a value smaller than the original length, but larger than a previous set.

- Louie
Report this to a Moderator Report this to a Moderator
 8-Feb-2008 09:07
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

Hi Louie,

thanks for your reply, 'ShortenBuffer' does the trick; when I replace the 'length' call in my code snippet with a call to your routine, everything works as one expects.

Regards,

Peter
Report this to a Moderator Report this to a Moderator
 8-Feb-2008 17:24
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Bug fix, had to swap the last two statements in fShortenBuffer. Before that, tempStringOf retrieval was incorrect. That is, insert a null char and THEN reduce the length.

Attached is the new function and a simple test driver for it.

I was unable to cleverly extend the length of the buffer, neither for a buffer that had never been longer nor from a buffer that was long, then set short. the set 'length' command appears to be ignored with the desired length is longer than the actual. The set buffer character command likewise appears to be ignored when the desired location is beyond the length of the buffer.

I'd be interested to see if anyone can do more testing and break this fShortenBuffer.

- Louie

Edited: 8-Feb-2008 at 17:40 by Louie Landale
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 0 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 0 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.