1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRC_LIBEDITTEXT_DEBUG
38 #include"drd64_libedittext.h"
41 /*----------------------------------------------------------------------
42 ----------------------------------------------------------------------*/
43 LIBEDITTEXT_DEBUG_EXTERN
45 LibEditText_Debug_RedoInfo(
46 LibEditText_TextInfo *p_tinfo,
59 LibEditText_UndoInfo t_udinfo;
61 assert( NULL != p_tinfo );
63 if( 0x00 != b_putflag ) {
64 puts("[7] Redo Info +----2----+----3----+----4----+----5----+----6----+----7----+----8");
67 if( 0x03 > b_putflag ) {
68 puts(" Not print-out Redo-Info Setting. (Only Check UndoInfo Data Integrity.)");
71 if( p_tinfo->dw_undo_lastsize == p_tinfo->dw_undo_last ) {
72 if( 0x03 == b_putflag ) { puts(" No Redo Info."); }
76 pb_undo = p_tinfo->pb_undo + p_tinfo->dw_undo_last;
78 dw_line = p_tinfo->dw_undo_line;
79 dw_pos = p_tinfo->dw_undo_pos;
80 dw_nowsize = p_tinfo->dw_undo_last;
87 i_result = LibEditText_UndoInfo_ReadUndoInfo(
88 p_tinfo, &t_udinfo, dw_line, dw_pos, pb_now, 0x01 );
90 switch( t_udinfo.b_cmd ) {
91 case LIBEDITTEXT_UNDOCMD_INSERTLINE:
92 snprintf( str_cmd, 127, " [%05u] InsertLine ", dw_cnt); break;
93 case LIBEDITTEXT_UNDOCMD_DELETELINE:
94 snprintf( str_cmd, 127, " [%05u] DeleteLine ", dw_cnt); break;
95 case LIBEDITTEXT_UNDOCMD_INSERTSTRING:
96 snprintf( str_cmd, 127, " [%05u] InsertString ", dw_cnt); break;
97 case LIBEDITTEXT_UNDOCMD_DELETESTRING:
98 snprintf( str_cmd, 127, " [%05u] DeleteString ", dw_cnt); break;
99 case LIBEDITTEXT_UNDOCMD_INSERTCHAR:
100 snprintf( str_cmd, 127, " [%05u] InsertChar ", dw_cnt); break;
101 case LIBEDITTEXT_UNDOCMD_DELETECHAR:
102 snprintf( str_cmd, 127, " [%05u] DeleteChar ", dw_cnt); break;
104 snprintf( str_cmd, 127, " [%05u] *** Command Error!! [%2x] *** \n",
105 dw_cnt, t_udinfo.b_cmd);
110 dw_line = t_udinfo.dw_line;
111 dw_pos = t_udinfo.dw_pos;
113 if( 0x03 <= b_putflag ) {
114 fputs( str_cmd, stdout );
116 if( 0x00 == i_cmdflag ) {
117 printf("[%4u:%3u] ", dw_line, dw_pos );
119 if( 0x00 != t_udinfo.t_udflag.bf_linksz )
120 { printf(" Link:%4u", t_udinfo.dw_prevlength ); }
122 { fputs(" No Link. ", stdout ); }
124 fputs(" Flag[", stdout);
125 if( 0x00 != t_udinfo.t_udflag.bf_redone ) { putchar('R'); }
126 else { putchar(' '); }
128 if( 0x00 != t_udinfo.t_udflag.bf_chain ) { putchar('C'); }
129 else { putchar(' '); }
131 if( 0x00 != t_udinfo.t_udflag.bf_line )
132 { printf("%d", t_udinfo.t_udflag.bf_line ); }
133 else { putchar(' '); }
135 if( 0x00 != t_udinfo.t_udflag.bf_pos )
136 { printf("%d", t_udinfo.t_udflag.bf_pos ); }
137 else { putchar(' '); }
140 if( LIBEDITTEXT_UNDOCMD_INSERTSTRING == t_udinfo.b_cmd )
141 { printf(" String(%u): %s", t_udinfo.dw_data, t_udinfo.pb_str ); }
142 else if( LIBEDITTEXT_UNDOCMD_INSERTCHAR == t_udinfo.b_cmd ) {
143 printf(" Data: '%c'", t_udinfo.b_data );
144 if( '\n' == t_udinfo.b_data ) { printf(" <ERROR!!> "); }
146 else if( LIBEDITTEXT_UNDOCMD_DELETESTRING == t_udinfo.b_cmd )
147 { printf(" String(%u): %s", t_udinfo.dw_data, t_udinfo.pb_str ); }
148 else if( LIBEDITTEXT_UNDOCMD_DELETECHAR == t_udinfo.b_cmd )
149 { printf(" Data: '%c'", t_udinfo.b_data ); }
155 dw_line += t_udinfo.dw_plusline;
156 dw_pos += t_udinfo.dw_pluspos;
157 dw_nowsize += t_udinfo.dw_uinfosize;
158 pb_undo += t_udinfo.dw_uinfosize;
159 }while( dw_nowsize < p_tinfo->dw_undo_lastsize );
165 /*----------------------------------------------------------------------
166 ----------------------------------------------------------------------*/
167 LIBEDITTEXT_DEBUG_EXTERN
169 LibEditText_Debug_UndoInfo(
170 LibEditText_TextInfo *p_tinfo,
174 int i_cmdflag = 0x00;
181 LibEditText_UndoInfo t_udinfo;
183 assert( NULL != p_tinfo );
185 if( 0x00 != b_putflag ) {
186 puts("[6] Undo Info +----2----+----3----+----4----+----5----+----6----+----7----+----8");
189 if( 0x03 > b_putflag ) {
190 puts(" Not print-out Undo-Info Setting. (Only Check UndoInfo Data Integrity.)");
193 if( 0 == p_tinfo->dw_undo_last ) {
194 if( 0x00 != b_putflag ) {
195 puts(" No Undo Info.");
200 pb_undo = p_tinfo->pb_undo + p_tinfo->dw_undo_end;
202 dw_line = p_tinfo->dw_undo_line;
203 dw_pos = p_tinfo->dw_undo_pos;
210 i_result = LibEditText_UndoInfo_ReadUndoInfo(
211 p_tinfo, &t_udinfo, dw_line, dw_pos, pb_now, 0x00 );
213 switch( t_udinfo.b_cmd ) {
214 case LIBEDITTEXT_UNDOCMD_INSERTLINE:
215 snprintf( str_cmd, 127, " [%05u] InsertLine ", dw_cnt); break;
216 case LIBEDITTEXT_UNDOCMD_DELETELINE:
217 snprintf( str_cmd, 127, " [%05u] DeleteLine ", dw_cnt); break;
218 case LIBEDITTEXT_UNDOCMD_INSERTSTRING:
219 snprintf( str_cmd, 127, " [%05u] InsertString ", dw_cnt); break;
220 case LIBEDITTEXT_UNDOCMD_DELETESTRING:
221 snprintf( str_cmd, 127, " [%05u] DeleteString ", dw_cnt); break;
222 case LIBEDITTEXT_UNDOCMD_INSERTCHAR:
223 snprintf( str_cmd, 127, " [%05u] InsertChar ", dw_cnt); break;
224 case LIBEDITTEXT_UNDOCMD_DELETECHAR:
225 snprintf( str_cmd, 127, " [%05u] DeleteChar ", dw_cnt); break;
227 snprintf( str_cmd, 127, " [%05u] *** Command Error!! [%2x] *** \n",
228 dw_cnt, t_udinfo.b_cmd);
233 if( 0x03 <= b_putflag ) {
234 fputs( str_cmd, stdout );
236 if( 0x00 == i_cmdflag ) {
237 dw_line -= t_udinfo.dw_plusline;
238 dw_pos -= t_udinfo.dw_pluspos;
239 printf("[%4u:%3u] ", dw_line, dw_pos );
241 if( 0x00 != t_udinfo.t_udflag.bf_linksz )
242 { printf(" Link:%4u", t_udinfo.dw_prevlength ); }
244 { fputs(" No Link. ", stdout ); }
246 fputs(" Flag[", stdout);
247 if( 0x00 != t_udinfo.t_udflag.bf_redone ) { putchar('R'); }
248 else { putchar(' '); }
250 if( 0x00 != t_udinfo.t_udflag.bf_chain ) { putchar('C'); }
251 else { putchar(' '); }
254 if( 0x00 != t_udinfo.t_udflag.bf_line )
255 { printf(" Line:%u", t_udinfo.dw_line ); }
256 if( 0x00 != t_udinfo.t_udflag.bf_pos )
257 { printf(" Pos:%u", t_udinfo.dw_pos ); }
259 if( LIBEDITTEXT_UNDOCMD_INSERTSTRING == t_udinfo.b_cmd )
260 { printf(" String(%u): %s", t_udinfo.dw_data, t_udinfo.pb_str ); }
261 else if( LIBEDITTEXT_UNDOCMD_INSERTCHAR == t_udinfo.b_cmd ) {
262 printf(" Data: '%c'", t_udinfo.b_data );
263 if( '\n' == t_udinfo.b_data ) { printf(" <ERROR!!> "); }
265 else if( LIBEDITTEXT_UNDOCMD_DELETESTRING == t_udinfo.b_cmd )
266 { printf(" String(%u): %s", t_udinfo.dw_data, t_udinfo.pb_str ); }
267 else if( LIBEDITTEXT_UNDOCMD_DELETECHAR == t_udinfo.b_cmd )
268 { printf(" Data: '%c'", t_udinfo.b_data ); }
273 dw_line = t_udinfo.dw_line;
274 dw_pos = t_udinfo.dw_pos;
277 pb_undo -= t_udinfo.dw_prevlength;
278 }while((0 < t_udinfo.dw_prevlength) && ( 0x00 == i_cmdflag ) );
280 if( 0x00 == i_cmdflag ) {
282 printf(" Error!: Last Line in Undo-Info is not Line 0. (%u)\n", dw_line );
286 printf(" Error!: Last Pos. in Undo-Info is not Position 0. (%u)\n", dw_pos );
295 /*----------------------------------------------------------------------
296 ----------------------------------------------------------------------*/
297 LIBEDITTEXT_DEBUG_EXTERN
299 LibEditText_Debug_Cursor(
300 LibEditText_TextInfo *p_tinfo,
304 LibEditText_Cursor *p_cursor;
306 if( 0x00 != b_putflag ) {
307 puts("[5] Cursor Info ---2----+----3----+----4----+----5----+----6----+----7----+----8");
310 for( dw_cnt = 0; dw_cnt < DRD64_LIBEDITTEXT_DEFAULT_MAX_CURSORS; dw_cnt++ ) {
311 p_cursor = &(p_tinfo->t_cursor[ dw_cnt ]);
313 if( 0 == p_cursor->dw_rangelines ) {
314 if( 0x00 != b_putflag )
315 { printf( " Cursor %u: Not Alloced.\n", dw_cnt ); }
319 if( 0x00 != b_putflag ) {
320 printf( " Cursor %u: (RangeLines: %u, Updates: %s) \n",
321 dw_cnt, p_cursor->dw_rangelines,
322 ((0x00 != p_cursor->b_update) ? "YES" : "NO") );
324 if( 1 < p_cursor->dw_rangelines ) {
325 printf(" Start : [%5u] (ID:%u)\n",
326 p_cursor->dw_start_line, p_cursor->dw_start_lineid );
329 printf(" Center: [%5u:%3u] (ID:%u)\n",
330 p_cursor->dw_line, p_cursor->dw_pos, p_cursor->dw_lineid );
332 if( 1 < p_cursor->dw_rangelines ) {
333 printf(" End : [%5u] (ID:%u)\n",
334 p_cursor->dw_end_line, p_cursor->dw_end_lineid );
343 /*----------------------------------------------------------------------
344 ----------------------------------------------------------------------*/
346 LibEditText_Debug_EmptyChain(
347 LibEditText_TextInfo *p_tinfo,
352 DWord dw_lencount = 1;
353 LibEditText_LineInfo *p_line;
355 if( 0x00 != b_putflag ) {
356 puts("[3] Empty LineInfo Chain ----3----+----4----+----5----+----6----+----7----+----8");
359 for( i_cnt = 0; i_cnt < DRD64_LIBEDITTEXT_DEFAULT_LINESORT_ARRAYS; i_cnt++ ) {
360 p_line = LINFO(p_tinfo, p_tinfo->dw_empty[i_cnt]);
361 if( NULL == p_line ) { continue; }
363 dw_nowlen = p_line->dw_linelen;
366 while( NULL != p_line ) {
367 if( dw_nowlen < p_line->dw_linelen ) {
368 if( 0x00 != b_putflag )
369 { printf(" Empty Line Length=%u : Chains: %u\n", dw_nowlen, dw_lencount ); }
371 dw_nowlen = p_line->dw_linelen;
372 if( 0 == dw_nowlen ) { return -0x02; }
374 else if( dw_nowlen > p_line->dw_linelen )
378 p_line = LINFO(p_tinfo, p_line->dw_sortnext);
381 if( 0x00 != b_putflag )
382 { printf(" Empty Line Length=%u : Chains: %u\n", dw_nowlen, dw_lencount ); }
389 /*----------------------------------------------------------------------
390 ----------------------------------------------------------------------*/
392 LibEditText_Debug_SortChain(
393 LibEditText_TextInfo *p_tinfo,
399 LibEditText_LineInfo *p_line;
401 assert( NULL != p_tinfo );
403 if( 0x00 != b_putflag ) {
404 puts("[2] LineInfo SortChain -+----3----+----4----+----5----+----6----+----7----+----8");
407 for( i_cnt = 0; i_cnt < DRD64_LIBEDITTEXT_DEFAULT_LINESORT_ARRAYS; i_cnt++ ) {
408 p_line = LINFO(p_tinfo, p_tinfo->dw_linesort[i_cnt]);
409 if( NULL == p_line ) { continue; }
411 dw_nowlen = p_line->dw_linelen;
412 if( 0 == dw_nowlen ) { return -0x01; }
415 while( NULL != p_line ) {
416 if( dw_nowlen < p_line->dw_linelen ) {
417 if( 0x00 != b_putflag )
418 { printf(" Line Length=%u : Chains: %u\n", dw_nowlen, dw_lencount ); }
420 dw_nowlen = p_line->dw_linelen;
421 if( 0 == dw_nowlen ) { return -0x02; }
423 else if( dw_nowlen > p_line->dw_linelen )
427 p_line = LINFO(p_tinfo, p_line->dw_sortnext);
430 if( 0x00 != b_putflag )
431 { printf(" Line Length=%u : Chains: %u\n", dw_nowlen, dw_lencount ); }
438 /*----------------------------------------------------------------------
439 ----------------------------------------------------------------------*/
441 LibEditText_Debug_DebugSection(
442 LibEditText_TextInfo *p_tinfo,
446 LibEditText_LineSection *p_section;
448 if( 0x00 != b_putlevel ) {
449 puts("[4] LineSection Info ---+----3----+----4----+----5----+----6----+----7----+----8");
452 for( dw_section = 0; dw_section < p_tinfo->dw_sections; dw_section++ ) {
453 p_section = (p_tinfo->p_section + dw_section);
454 if( NULL == p_section ) { return -0x01; }
456 if( 0x00 != b_putlevel ) {
457 printf(" Section %04u: [%4u] LineID: %u\n",
458 dw_section, p_section->dw_line, p_section->dw_linfoid );
466 /*----------------------------------------------------------------------
467 ----------------------------------------------------------------------*/
468 LIBEDITTEXT_DEBUG_EXTERN
470 LibEditText_Debug_DumpTextData(
471 LibEditText_TextInfo *p_tinfo,
476 LibEditText_LineInfo *p_before;
477 LibEditText_LineInfo *p_line;
478 LibEditText_LineInfo *p_tmp;
480 if( 0x02 > b_putlevel ) { return 0x00; }
482 puts("[8] Text Data *********** ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8");
485 p_line = LINFO(p_tinfo, p_tinfo->dw_line_start);
487 puts( " ROW [strz:bufz (INFID)] <Text Data>");
488 for( dw_nowrow = 0; dw_nowrow < p_tinfo->dw_maxline; dw_nowrow++ ) {
489 printf("%05u [%4u:%4u (%05u)] ",
490 dw_nowrow, p_line->dw_strlen, p_line->dw_linelen, p_line->dw_id );
492 pb_now = p_tinfo->pb_text + p_line->dw_start;
494 fputs( (char *)pb_now, stdout );
496 p_tmp = LINFO(p_tinfo, p_line->dw_before);
497 if( p_before != p_tmp ) { return -0x05; }
499 p_line = LINFO(p_tinfo, p_line->dw_next);
502 if( NULL != p_line ) { return -0x06; }
505 puts("************************* ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8");
511 /*----------------------------------------------------------------------
512 ----------------------------------------------------------------------*/
513 LIBEDITTEXT_DEBUG_EXTERN
515 LibEditText_Debug_DebugTextInfo(
521 LibEditText_TextInfo *p_tinfo;
523 if( 0 > i_tinfoid ) { return -0x01; }
524 p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
525 if( NULL == p_tinfo ) { return -0x02; }
527 /* 1st: Check TextInfo Strcut Data --- */
528 if( 0x00 != b_putflag ) {
530 puts( "********************************************************************************");
531 if( NULL != pstr_title ) {
533 puts( "********************************************************************************");
536 puts("[1] TextInfo Struct Data ----3----+----4----+----5----+----6----+----7----+----8");
537 printf(" TextInfo Struct ID: %d\n", p_tinfo->i_fd);
538 printf(" Path: %s\n", p_tinfo->str_pathname );
539 printf(" File: %s\n", p_tinfo->str_filename );
540 printf(" Lines: %u, Buffer Lines: %u\n", p_tinfo->dw_maxline, p_tinfo->dw_bufline );
541 printf(" (Start LineID:%u, End LineID:%u\n", p_tinfo->dw_line_start, p_tinfo->dw_line_end );
542 printf(" Buffer size: %u, Used Last-Byte:%u\n", p_tinfo->dw_bufsize, p_tinfo->dw_lastsize );
543 printf(" FileDescriptor: %d, File SubType: %04x\n", p_tinfo->i_fd, p_tinfo->w_subtype );
544 puts( " LineSection Info. ---");
545 printf(" Alloc LineSections: %u, Sections: %u, Section Steps: %u\n"
546 ,p_tinfo->dw_bufsections, p_tinfo->dw_sections, p_tinfo->dw_sect_steps );
549 i_result = LibEditText_Debug_SortChain( p_tinfo, b_putflag );
550 if( 0x00 != i_result ) { return -0x3000 + i_result; }
552 i_result = LibEditText_Debug_EmptyChain( p_tinfo, b_putflag );
553 if( 0x00 != i_result ) { return -0x4000 + i_result; }
555 i_result = LibEditText_Debug_DebugSection( p_tinfo, b_putflag );
556 if( 0x00 != i_result ) { return -0x5000 + i_result; }
558 i_result = LibEditText_Debug_Cursor( p_tinfo, b_putflag );
559 if( 0x00 != i_result ) { return -0x6000 + i_result; }
561 i_result = LibEditText_Debug_UndoInfo( p_tinfo, b_putflag );
562 if( 0x00 != i_result ) { return -0x7000 + i_result; }
564 i_result = LibEditText_Debug_RedoInfo( p_tinfo, b_putflag );
565 if( 0x00 != i_result ) { return -0x8000 + i_result; }
567 i_result = LibEditText_Debug_DumpTextData( p_tinfo, b_putflag );
568 if( 0x00 != i_result ) { return -0x9000 + i_result; }
575 /* EOF of drd64_.c ---------------------------------- */