#define LIBEDITTEXT_API_LINECTRL extern
#endif
LIBEDITTEXT_API_LINECTRL
- int LibEditText_AppendLine( int i_tinfoid, Byte *pstr_text, DWord dw_length );
+ int LibEditText_AppendLine( int i_tinfoid, char *pstr_text, DWord dw_length );
#ifdef DRD64_SRC_LIBEDITTEXT_LINEEDIT
#define LIBEDITTEXT_API_LINEEDIT extern
#endif
LIBEDITTEXT_API_LINEEDIT
- int LibEditText_InsertChar( int i_tinfoid, DWord dw_line, DWord dw_pos, Byte b_char );
-
-
+ int LibEditText_InsertChar_toLine(
+ int i_tinfoid, DWord dw_line, DWord dw_pos, Byte b_char );
+LIBEDITTEXT_API_LINEEDIT
+ int LibEditText_InsertString_toLine(
+ int i_tinfoid, DWord dw_line, DWord dw_pos, char *pstr_string );
#endif /* DRD64_HEADER_DRCC_INCLUDE */
test_libedittext_file.o \
test_libedittext_lineinfo.o \
test_libedittext_linectrl.o \
+ test_libedittext_lineedit.o \
test_libedittext_system.o
TEST_HEADER = \
test_libedittext.h
$(CC) -c -o test_libedittext_linectrl.o \
$(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
test_libedittext_linectrl.c
+test_libedittext_lineedit.o: test_libedittext_lineedit.c $(HEADER) $(TEST_HEADER)
+ $(CC) -c -o test_libedittext_lineedit.o \
+ $(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
+ test_libedittext_lineedit.c
$(TEST_TARGET): $(TEST_OBJS) $(OBJS) $(TARGET)
$(CC) -o $(TEST_TARGET) $(FLAGS_DEBUG) $(OBJS) $(TEST_OBJS) $(TARGET) \
#ifndef DRD64_HEADER_LIBEDITTEXT_CONFIG
#define DRD64_HEADER_LIBEDITTEXT_CONFIG
-#define DEBUG_TEXTINFO_OUTPUT 0x01
+#define DEBUG_TEXTINFO_OUTPUT 0x02
/* Output TextData for Console if this value isn't 0x00 when run test_drcc program.*/
int
LibEditText_AppendLine(
int i_tinfoid,
- Byte *pstr_text,
+ char *pstr_text,
DWord dw_length )
{
int i_result;
if( NULL == pstr_text ) { return -0x03; }
- i_result = LibEditText_LineCtrl_AppendLine( p_tinfo, pstr_text, dw_length, 0x00 );
+ i_result = LibEditText_LineCtrl_AppendLine( p_tinfo, (Byte *)pstr_text, dw_length, 0x00 );
return i_result;
}
assert( NULL != p_line );
/* Check Line Remain-Length & Swap line-buffer ---*/
- if( p_line->dw_strlen + dw_srclen > p_line->dw_linelen ) {
+ if( p_line->dw_strlen + dw_srclen + 1 > p_line->dw_linelen ) {
i_result = LibEditText_LineInfo_ExpandLineBuffer(
p_tinfo, p_line,
dw_srclen + DRD64_LIBEDITTEXT_DEFAULT_RESERVEBUF_INLINE);
assert( NULL != pb_pos );
if( p_line->dw_strlen > dw_pos ) {
- dw_length = p_line->dw_strlen - dw_pos;
+ dw_length = p_line->dw_strlen - dw_pos + 1;
memmove( pb_pos + dw_srclen, pb_pos, dw_length );
}
----------------------------------------------------------------------*/
LIBEDITTEXT_API_LINEEDIT
int
- LibEditText_InsertChar(
+ LibEditText_InsertChar_toLine(
int i_tinfoid,
DWord dw_line,
DWord dw_pos,
}
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBEDITTEXT_API_LINEEDIT
+int
+ LibEditText_InsertString_toLine(
+ int i_tinfoid,
+ DWord dw_line,
+ DWord dw_pos,
+ char *pstr_string )
+{
+ int i_result;
+ int i_len;
+ LibEditText_TextInfo *p_tinfo;
+ LibEditText_LineInfo *p_line;
+
+ if( 0 > i_tinfoid ) { return -0x01; }
+ p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
+ if( NULL == p_tinfo ) { return -0x02; }
+
+ /* Check Line in TextBuffer range ---*/
+ if( p_tinfo->dw_maxline <= dw_line )
+ { return -0x03; }
+
+ p_line = LINFO(p_tinfo, dw_line);
+ if( NULL == p_line ) { return -0x03; }
+
+ i_len = strnlen( pstr_string , 1024+1 );
+ if( 1025 == i_len ) { return -0x04; }
+
+ i_result = LibEditText_LineEdit_InsertString(
+ p_tinfo, p_line, dw_pos, (Byte *)pstr_string, (DWord)i_len );
+
+ return i_result;
+}
+
+
/* EOF of drd64_.c ----------------------------------- */
assert( NULL != p_dest );
assert( NULL != p_src );
+ if( p_dest->dw_linelen < p_src->dw_linelen ) { return; }
+
pb_tmpbuf = p_tinfo->pb_text
+ (p_tinfo->dw_bufsize - DRD64_LIBEDITTEXT_DEFAULT_COPYBUFFER);
dw_tmp_linelen = p_src->dw_linelen;
- /* Copy Src to Tmp ---*/
- dw_tmp_start = p_src->dw_start;
- dw_tmp_strlen = p_src->dw_strlen;
-
- /* memcpy */
+ /* Copy Dest to Tmp ---*/
if( DRD64_LIBEDITTEXT_DEFAULT_COPYBUFFER < dw_tmp_linelen ) {
LibEditText_LineInfo_MemCopy(pb_tmpbuf,
- (p_tinfo->pb_text + p_src->dw_start), dw_tmp_linelen );
+ (p_tinfo->pb_text + p_dest->dw_start), dw_tmp_linelen );
}
else
- { memcpy( pb_tmpbuf, (p_tinfo->pb_text + p_src->dw_start), dw_tmp_linelen ); }
+ { memcpy( pb_tmpbuf, (p_tinfo->pb_text + p_dest->dw_start), dw_tmp_linelen ); }
- /* Copy Dest to Src ---*/
- p_src->dw_start = p_dest->dw_start;
- p_src->dw_strlen = p_dest->dw_strlen;
+ dw_tmp_start = p_dest->dw_start;
+ dw_tmp_strlen = p_dest->dw_strlen;
- /* memcpy */
- memcpy( (p_tinfo->pb_text + p_src->dw_start),
- (p_tinfo->pb_text + p_dest->dw_start), dw_tmp_linelen );
+ /* Copy Src to Dest ---*/
+ memcpy( (p_tinfo->pb_text + p_dest->dw_start),
+ (p_tinfo->pb_text + p_src->dw_start), p_src->dw_linelen );
+ memset( (p_tinfo->pb_text + p_dest->dw_start + p_src->dw_linelen),
+ 0x00, (p_dest->dw_linelen - p_src->dw_linelen) );
- /* Copy Tmp to Dest ---*/
- p_dest->dw_start = dw_tmp_start;
- p_dest->dw_strlen = dw_tmp_strlen;
+ p_dest->dw_start = p_src->dw_start;
+ p_dest->dw_strlen = p_src->dw_strlen;
- /* memcpy */
+ /* Copy Tmp to Dest ---*/
if( DRD64_LIBEDITTEXT_DEFAULT_COPYBUFFER < dw_tmp_linelen ) {
LibEditText_LineInfo_MemCopy(
- (p_tinfo->pb_text + p_dest->dw_start), pb_tmpbuf, dw_tmp_linelen );
+ (p_tinfo->pb_text + dw_tmp_start), pb_tmpbuf, dw_tmp_linelen );
}
else
- { memcpy( (p_tinfo->pb_text + p_dest->dw_start), pb_tmpbuf, dw_tmp_linelen ); }
+ { memcpy( (p_tinfo->pb_text + dw_tmp_start), pb_tmpbuf, dw_tmp_linelen ); }
+
+ p_src->dw_start = dw_tmp_start;
+ p_src->dw_strlen = dw_tmp_strlen;
return;
}
assert( NULL != p_src );
/* Copy Src to Dest ---*/
- p_dest->dw_start = p_src->dw_start;
p_dest->dw_strlen = p_src->dw_strlen;
/* memcpy */
memcpy( (p_tinfo->pb_text + p_dest->dw_start),
(p_tinfo->pb_text + p_src->dw_start), p_src->dw_linelen );
+ memset( (p_tinfo->pb_text + p_src->dw_start), 0x00, p_src->dw_linelen );
/* Clear Src ---*/
- p_src->dw_start = 0;
p_src->dw_strlen = 0;
return;
}
p_tinfo->pb_text = pb_text;
- pb_attr = (Byte *)realloc( p_tinfo->pb_attr,
+ pb_text += p_tinfo->dw_bufsize;
+ memset( pb_text, 0x00, dw_expandsize );
+
+ if( NULL != p_tinfo->pb_attr ) {
+ pb_attr = (Byte *)realloc( p_tinfo->pb_attr,
(p_tinfo->dw_bufsize + dw_expandsize ) );
- if( NULL == pb_attr ) {
- return -0x03;
+ if( NULL == pb_attr ) {
+ return -0x03;
+ }
+ p_tinfo->pb_attr = pb_attr;
+
+ pb_attr += p_tinfo->dw_bufsize;
+ memset( pb_attr, 0x00, dw_expandsize );
}
- p_tinfo->pb_attr = pb_attr;
p_tinfo->dw_bufsize += dw_expandsize;
return 0x00;
Test_LibEditText_File();
Test_LibEditText_LineInfo();
Test_LibEditText_LineCtrl();
+ Test_LibEditText_LineEdit();
CU_basic_run_tests();
CU_cleanup_registry();
/*---------------------------------------------------------------------*/
+#ifdef DRD64_SRC_TEST_LIBEDITTEXT_LINEEDIT
+ #define DRD64_TEST_LIBEDITTEXT_LINEEDIT_EXTERN
+#else
+ #define DRD64_TEST_LIBEDITTEXT_LINEEDIT_EXTERN extern
+#endif
+DRD64_TEST_LIBEDITTEXT_LINEEDIT_EXTERN int Test_LibEditText_LineEdit( void );
+
+/*---------------------------------------------------------------------*/
#ifdef DRD64_SRC_TEST_LIBEDITTEXT_LINECTRL
#define DRD64_TEST_LIBEDITTEXT_LINECTRL_EXTERN
#else
for( i_cnt = 1; i_cnt < 65537; i_cnt++ ) {
i_len = snprintf( str_testdata, 255, "%6d Dr.deamon64 libeditext testdata---\n", i_cnt);
- i_result = LibEditText_AppendLine( i_tinfoid, (Byte *)str_testdata, i_len);
+ i_result = LibEditText_AppendLine( i_tinfoid, str_testdata, i_len);
CU_ASSERT( 0x00 == i_result );
}
--- /dev/null
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+ D r . D e a m o n 6 4
+ for INTEL64(R), AMD64(R)
+
+ Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function:
+Comment:
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_TEST_LIBEDITTEXT_LINEEDIT
+#include"test_libedittext.h"
+#include"drd64_libedittext.h"
+
+
+/* LibEditText_InsertChar_toLine (API) ********************************/
+/*--------------------------------------------------------------------*/
+void Test_LibEditText_API_InsertStringChar_toLine_test00_001(void)
+{
+ int i_result;
+ int i_tinfoid;
+ int i_cnt;
+ char c_tmp;
+
+ i_result = LibEditText_Init();
+ CU_ASSERT( 0x00 == i_result );
+
+ i_tinfoid = LibEditText_CreateTextFile( "./testdata", NULL );
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_InsertString_toLine( i_tinfoid, 0, 0, "Line 1: \n" );
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_AppendLine( i_tinfoid, "Line 2: \n", 9);
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_AppendLine( i_tinfoid, "Line 3: \n", 5);
+ CU_ASSERT( 0x00 == i_result );
+
+ for( i_cnt = 0; i_cnt < 100; i_cnt++ ) {
+ c_tmp = 0x30 + (i_cnt % 10);
+ //i_result = LibEditText_InsertChar_toLine( i_tinfoid, 1, 7, c_tmp );
+ CU_ASSERT( 0x00 == i_result );
+ }
+
+ i_result = LibEditText_Debug_DebugTextInfo( i_tinfoid, DEBUG_TEXTINFO_OUTPUT );
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_Term();
+ CU_ASSERT( 0x00 == i_result );
+
+ return;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+DRD64_TEST_LIBEDITTEXT_LINEEDIT_EXTERN
+int
+ Test_LibEditText_LineEdit(
+ void )
+{
+ CU_pSuite pt_edittext;
+
+ pt_edittext = CU_add_suite( "LibEditText_LineEdit", NULL, NULL );
+
+ CU_add_test( pt_edittext, "EditText_API_InsertStringChar_toLine_test00_001",
+ Test_LibEditText_API_InsertStringChar_toLine_test00_001 );
+
+ return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */