JDEdwards / Oracle EnterpriseOne - jdeStrncat

First of all, this function was brought into play due to Unicode. It should be a safer alternative for jdeStrcat as it has its third parameter. This parameter might be expected to define the size of the target string, however this assumption is wrong because it actually defines the maximum number of JCHARs to be appended.

Especially when building a large text, a good developer rather uses jdeStrncat just in case it overflows the size of the target string. The following code is however wrong:

JCHAR szTest[1000];
jdeStrncat(szTest, _J("ABCD"), DIM(szTest)-1);

We might rather use a code like this:

jdeStrncat(szTest, _J("ABCD"), DIM(szTest)-jdeStrlen(szTest)-1);

Although this looks like a relatively simple solution, it is still not 100% perfect. The problem occurs when the third parameter gets negative for some reason although normally it should not happen. In such a case the function simply ignores it and appends the whole string.

BTW, be careful about the usage of DIM.

Resolution: You may use a similar code to the last example but make sure the third parameter never gets negative.

Back to Content

In case of any questions or suggestions please contact David Macek.