diff src/org/tn5250j/framework/tn5250/tnvt.java @ 348:29076621bab0

merge tn5250j r1227; fix spelling
author Carl Byington <carl@five-ten-sg.com>
date Fri, 01 Aug 2014 10:25:44 -0700
parents 071eccdff8ea
children d26faad31533
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/tnvt.java	Thu Jul 31 18:57:57 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/tnvt.java	Fri Aug 01 10:25:44 2014 -0700
@@ -23,6 +23,8 @@
  */
 package org.tn5250j.framework.tn5250;
 
+import static java.lang.Math.max;
+import static java.lang.Math.min;
 import static org.tn5250j.TN5250jConstants.AID_HELP;
 import static org.tn5250j.TN5250jConstants.AID_PRINT;
 import static org.tn5250j.TN5250jConstants.CMD_CLEAR_FORMAT_TABLE;
@@ -1145,7 +1147,7 @@
             else {
                 if (planes.getCharAttr(y) != la) {
                     la = planes.getCharAttr(y);
-                    sac--;
+                    sac = max(sac--, 0);
                     sa[sac++] = (byte) la;
                 }
 
@@ -1160,7 +1162,7 @@
                 if (isDataUnicode(ch))
                     byteCh = codePage.uni2ebcdic(ch);
 
-                sa[sac++] = byteCh;
+                sa[min(sac++, len - 1)] = byteCh;
             }
         }
     }
@@ -1203,7 +1205,7 @@
                 else {
                     if (planes.getCharAttr(y) != la) {
                         la = planes.getCharAttr(y);
-                        sac--;
+                        sac = max(sac--, 0);
                         sa[sac++] = (byte) la;
                     }
 
@@ -1218,7 +1220,7 @@
                     if (isDataUnicode(ch))
                         byteCh = codePage.uni2ebcdic(ch);
 
-                    sa[sac++] = byteCh;
+                    sa[min(sac++, len - 1)] = byteCh;
                 }
             }
         }