Re: V-Series/VOS 16 porting tips for PL/I, collected

This is a discussion on Re: V-Series/VOS 16 porting tips for PL/I, collected within the pl1 forums in Programming Languages category; "Jay Levitt" <jay+news @ jay.fm> wrote in message news:13zmonjza1v9r$.dlg @ jay.fm... > Loop overflow (the wrong way - bin(15)): > > my_loop: procedure (buf); > declare buf char(*)var; > > declare n bin(15); > > do n = 1 to length (buf); > ... > > > Loop overflow (the right way - bin(31)): > > my_loop: procedure (buf); > declare buf char(*)var; > > declare n bin(31); > > do n = 1 to length (buf); > ... > > === > > Long strings (the right but currently buggy way): > > declare big1 char(32000)var; > declare big2 ...

Go Back   Application Development Forum > Programming Languages > pl1

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 01-13-2008, 06:29 PM
robin
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

"Jay Levitt" <jay+news@jay.fm> wrote in message news:13zmonjza1v9r$.dlg@jay.fm...

> Loop overflow (the wrong way - bin(15)):
>
> my_loop: procedure (buf);
> declare buf char(*)var;
>
> declare n bin(15);
>
> do n = 1 to length (buf);
> ...
>
>
> Loop overflow (the right way - bin(31)):
>
> my_loop: procedure (buf);
> declare buf char(*)var;
>
> declare n bin(31);
>
> do n = 1 to length (buf);
> ...
>
> ===
>
> Long strings (the right but currently buggy way):
>
> declare big1 char(32000)var;
> declare big2 char(32000)var;
> declare small char(4096)var;
>
> big1 = copy ('1234567890', 3100); /* 31000 bytes long */
> small = big[1]; /* should truncate at 4096 */
> big2 = small || big1; /* should concatenate and truncate at 32000, */
> /* but overflows the string instead even with */
> /* -check enabled */


Re these tips, it's important that STRINGSIZE and STRINGRANGE
be enabled, as well as FOFL and SIZE.

And not only when testing.


Reply With Quote
  #2  
Old 01-13-2008, 07:30 PM
Jay Levitt
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

On Sun, 13 Jan 2008 23:29:04 GMT, robin wrote:

> Re these tips, it's important that STRINGSIZE and STRINGRANGE
> be enabled, as well as FOFL and SIZE.
>
> And not only when testing.


Unfortunately, on Stratus, we only have FOFL (in the form of
-fixedoverflow) and STRINGRANGE (in the form of -check). We explicitly
don't have SIZE, and I don't know what STRINGSIZE is, but I don't think we
have it either...

--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer
Reply With Quote
  #3  
Old 01-13-2008, 09:18 PM
John W. Kennedy
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

Jay Levitt wrote:
....and I don't know what STRINGSIZE is....

DECLARE X CHAR(3);
X = 'ABCD'; /* STRINGSIZE */
--
John W. Kennedy
"Give up vows and dogmas, and fixed things, and you may grow like That.
....you may come to think a blow bad, because it hurts, and not because
it humiliates. You may come to think murder wrong, because it is
violent, and not because it is unjust."
-- G. K. Chesterton. "The Ball and the Cross"
Reply With Quote
  #4  
Old 01-14-2008, 10:02 AM
Jay Levitt
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

On Sun, 13 Jan 2008 21:18:36 -0500, John W. Kennedy wrote:

> Jay Levitt wrote:
> ...and I don't know what STRINGSIZE is....
>
> DECLARE X CHAR(3);
> X = 'ABCD'; /* STRINGSIZE */


Ah, ok, then Stratus PL/I doesn't have it. The manual explicitly states
that assigning a longer string to a shorter variable will truncate without
raising.

--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer
Reply With Quote
  #5  
Old 01-14-2008, 04:54 PM
robin
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

"Jay Levitt" <jay+news@jay.fm> wrote in message news:x0fwruufudzy.dlg@jay.fm...
> On Sun, 13 Jan 2008 23:29:04 GMT, robin wrote:
>
> > Re these tips, it's important that STRINGSIZE and STRINGRANGE
> > be enabled, as well as FOFL and SIZE.
> >
> > And not only when testing.

>
> Unfortunately, on Stratus, we only have FOFL (in the form of
> -fixedoverflow) and STRINGRANGE (in the form of -check). We explicitly
> don't have SIZE, and I don't know what STRINGSIZE is, but I don't think we
> have it either...


STRINGSIZE causes a check to be included that the destination (target)
of a character or bit operation does not exceed the length of that
target. And if the target is the shorter, the moved characters
are truncated. In this way, storage following the destination area is not
corrupted.

If you do not have this facility, you need to include code that
not only checks for this condition, but prevents it from
happening.


Reply With Quote
  #6  
Old 01-14-2008, 07:16 PM
Peter Flass
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

robin wrote:
> "Jay Levitt" <jay+news@jay.fm> wrote in message news:x0fwruufudzy.dlg@jay.fm...
>
>>On Sun, 13 Jan 2008 23:29:04 GMT, robin wrote:
>>
>>
>>>Re these tips, it's important that STRINGSIZE and STRINGRANGE
>>>be enabled, as well as FOFL and SIZE.
>>>
>>>And not only when testing.

>>
>>Unfortunately, on Stratus, we only have FOFL (in the form of
>>-fixedoverflow) and STRINGRANGE (in the form of -check). We explicitly
>>don't have SIZE, and I don't know what STRINGSIZE is, but I don't think we
>>have it either...

>
>
> STRINGSIZE causes a check to be included that the destination (target)
> of a character or bit operation does not exceed the length of that
> target. And if the target is the shorter, the moved characters
> are truncated. In this way, storage following the destination area is not
> corrupted.
>


Unlike C, storage will never be corrupted:
"Result After the condition action, the truncated string is assigned to
its target string. The right-hand characters, bits, widechars or
graphics of the source string are truncated so that the target string
can accommodate the source string."
(Enterprise PL/I language reference, others similar.)

In most cases I find STRINGSIZE to be a nuisance, since it is frequently
normal programming practice to assign a longer string to a shorter one,
and most programmers expect truncation, just like assigning a shorter
string to a longer causes padding on the right. Occasionally STRINGSIZE
indicates a data error, and should be enabled when necessary.

> If you do not have this facility, you need to include code that
> not only checks for this condition, but prevents it from
> happening.
>


Result After the condition action, the truncated string is assigned to
its target string. The right-hand characters, bits, widechars or
graphics of the source string are truncated so that the target string
can accommodate the source string.

>


Reply With Quote
  #7  
Old 01-14-2008, 09:05 PM
John W. Kennedy
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

Jay Levitt wrote:
> On Sun, 13 Jan 2008 21:18:36 -0500, John W. Kennedy wrote:
>
>> Jay Levitt wrote:
>> ...and I don't know what STRINGSIZE is....
>>
>> DECLARE X CHAR(3);
>> X = 'ABCD'; /* STRINGSIZE */

>
> Ah, ok, then Stratus PL/I doesn't have it. The manual explicitly states
> that assigning a longer string to a shorter variable will truncate without
> raising.


STRINGSIZE was, I believe, a post-1970 IBM addition to the language.

--
John W. Kennedy
"...when you're trying to build a house of cards, the last thing you
should do is blow hard and wave your hands like a madman."
-- Rupert Goodwins
Reply With Quote
  #8  
Old 01-15-2008, 05:17 PM
Peter Flass
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

John W. Kennedy wrote:
> Jay Levitt wrote:
>
>> On Sun, 13 Jan 2008 21:18:36 -0500, John W. Kennedy wrote:
>>
>>> Jay Levitt wrote:
>>> ...and I don't know what STRINGSIZE is....
>>>
>>> DECLARE X CHAR(3);
>>> X = 'ABCD'; /* STRINGSIZE */

>>
>>
>> Ah, ok, then Stratus PL/I doesn't have it. The manual explicitly states
>> that assigning a longer string to a shorter variable will truncate
>> without
>> raising.

>
>
> STRINGSIZE was, I believe, a post-1970 IBM addition to the language.
>


It's in ANSI 1976, FWIW.

Reply With Quote
  #9  
Old 01-15-2008, 08:58 PM
Jay Levitt
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

On Mon, 14 Jan 2008 21:54:20 GMT, robin wrote:

>> Unfortunately, on Stratus, we only have FOFL (in the form of
>> -fixedoverflow) and STRINGRANGE (in the form of -check). We explicitly
>> don't have SIZE, and I don't know what STRINGSIZE is, but I don't think we
>> have it either...

>
> If you do not have this facility, you need to include code that
> not only checks for this condition, but prevents it from
> happening.


Totally untrue; I have never included such code. I just make sure that all
the really important data is stored at the beginning of the string.

--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer
Reply With Quote
  #10  
Old 01-16-2008, 04:31 PM
robin
Guest
 
Default Re: V-Series/VOS 16 porting tips for PL/I, collected

"Peter Flass" <Peter_Flass@Yahoo.com> wrote in message
news:478bfbde$0$31802$4c368faf@roadrunner.com...
> robin wrote:
> > "Jay Levitt" <jay+news@jay.fm> wrote in message news:x0fwruufudzy.dlg@jay.fm...
> >
> >>On Sun, 13 Jan 2008 23:29:04 GMT, robin wrote:
> >>
> >>
> >>>Re these tips, it's important that STRINGSIZE and STRINGRANGE
> >>>be enabled, as well as FOFL and SIZE.
> >>>
> >>>And not only when testing.
> >>
> >>Unfortunately, on Stratus, we only have FOFL (in the form of
> >>-fixedoverflow) and STRINGRANGE (in the form of -check). We explicitly
> >>don't have SIZE, and I don't know what STRINGSIZE is, but I don't think we
> >>have it either...

> >
> >
> > STRINGSIZE causes a check to be included that the destination (target)
> > of a character or bit operation does not exceed the length of that
> > target. And if the target is the shorter, the moved characters
> > are truncated. In this way, storage following the destination area is not
> > corrupted.
> >

>
> Unlike C, storage will never be corrupted:
> "Result After the condition action, the truncated string is assigned to
> its target string. The right-hand characters, bits, widechars or
> graphics of the source string are truncated so that the target string
> can accommodate the source string."
> (Enterprise PL/I language reference, others similar.)


But if STRINGSIZE is not enabled, storage can be
corrupted. There is another section of the manual
that is explicit about the conditions under which this occurs
(but I don't have the manual at hand to quote).

> In most cases I find STRINGSIZE to be a nuisance, since it is frequently
> normal programming practice to assign a longer string to a shorter one,
> and most programmers expect truncation, just like assigning a shorter
> string to a longer causes padding on the right. Occasionally STRINGSIZE
> indicates a data error, and should be enabled when necessary.
>
> > If you do not have this facility, you need to include code that
> > not only checks for this condition, but prevents it from
> > happening.
> >

>
> Result After the condition action, the truncated string is assigned to
> its target string. The right-hand characters, bits, widechars or
> graphics of the source string are truncated so that the target string
> can accommodate the source string.



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:12 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.