From: Rene S. <sa...@us...> - 2005-12-16 21:17:18
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4272/src/jake2/qcommon Modified Files: Com.java Log Message: lots of bugfixes in redirection Index: Com.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Com.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Com.java 13 Nov 2005 13:36:00 -0000 1.13 --- Com.java 16 Dec 2005 21:17:08 -0000 1.14 *************** *** 52,64 **** public abstract static class RD_Flusher { ! public abstract void rd_flush(int target, byte[] buffer); } static int rd_target; ! static byte[] rd_buffer; static int rd_buffersize; static RD_Flusher rd_flusher; ! public static void BeginRedirect(int target, byte[] buffer, int buffersize, RD_Flusher flush) { if (0 == target || null == buffer || 0 == buffersize || null == flush) --- 52,64 ---- public abstract static class RD_Flusher { ! public abstract void rd_flush(int target, StringBuffer buffer); } static int rd_target; ! static StringBuffer rd_buffer; static int rd_buffersize; static RD_Flusher rd_flusher; ! public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush) { if (0 == target || null == buffer || 0 == buffersize || null == flush) *************** *** 70,74 **** rd_flusher= flush; ! rd_buffer= null; } --- 70,74 ---- rd_flusher= flush; ! rd_buffer.setLength(0); } *************** *** 124,138 **** } return 0; - // // faster than if - // try - // { - // return data[index]; - // } - // catch (Exception e) - // { - // data= null; - // // last char - // return 0; - // } } --- 124,127 ---- *************** *** 145,161 **** } return 0; - // try - // { - // index++; - // return data[index]; - // } - // catch (Exception e) - // { - // data= null; - // // avoid int wraps; - // index--; - // // last char - // return 0; - // } } --- 134,137 ---- *************** *** 367,385 **** } public static void Printf(String fmt, Vargs vargs) { - // Com.Printf is for testing only. String msg= sprintf(_debugContext + fmt, vargs); - if (rd_target != 0) { ! if ((msg.length() + Lib.strlen(rd_buffer)) > (rd_buffersize - 1)) { rd_flusher.rd_flush(rd_target, rd_buffer); ! // *rd_buffer = 0; ! rd_buffer[rd_buffersize]= '\0'; } ! // TODO handle rd_buffer ! // strcat(rd_buffer, msg); return; } --- 343,358 ---- } + /** Prints out messages, which can also be redirected to a remote client. */ public static void Printf(String fmt, Vargs vargs) { String msg= sprintf(_debugContext + fmt, vargs); if (rd_target != 0) { ! if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1)) { rd_flusher.rd_flush(rd_target, rd_buffer); ! rd_buffer.setLength(0); } ! rd_buffer.append(msg); return; } |