| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| "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. |
|
#2
| |||
| |||
| 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 |
|
#3
| |||
| |||
| 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" |
|
#4
| |||
| |||
| 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 |
|
#5
| |||
| |||
| "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. |
|
#6
| |||
| |||
| 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. > |
|
#7
| |||
| |||
| 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 |
|
#8
| |||
| |||
| 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. |
|
#9
| |||
| |||
| 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 |
|
#10
| |||
| |||
| "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. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.