--- /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_LIBEDITTEXT_CURSORFIND
+#include"drd64_libedittext.h"
+
+#define LOCATION(n) DRD64_ERR_LOCATION( \
+ DRD64_ERROR_MODULE_LIBEDITTEXT, DRD64_ERROR_ARCH_NODEPEND, \
+ DRD64_SRC_LIBEDITTEXT_CURSORFIND_SRCID, (n))
+
+
+/*----------------------------------------------------------------------
+FindString
+FindNext
+BackFindString
+BackFindNext
+----------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+int
+ LibEditText_CursorFind_SetRegexString(
+ LibEditText_Cursor *p_cursor,
+ char *pstr_regex,
+ DWord dw_regexlen )
+{
+ char *pstr_now;
+ DWord dw_cnt;
+
+ assert( NULL != p_cursor );
+ assert( NULL != pstr_regex );
+
+ // Check regex length & NULL terminator ---
+ if( DRD64_LIBEDITTEXT_DEFAULT_REGSTR_SIZE <= dw_regexlen ) {
+ return -0x01;
+ }
+
+ pstr_now = (pstr_regex + dw_regexlen);
+ for( dw_cnt = dw_regexlen; dw_cnt > 0; dw_cnt-- ) {
+ if( *pstr_now == '\0' ) { break; }
+ pstr_now--;
+ }
+
+ if( 0 == dw_cnt ) {
+ return -0x02;
+ }
+
+ // Set regex string to CursorInfo ---
+ strncpy( p_cursor->str_regstr, pstr_regex, (dw_cnt + 1) );
+
+ return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+DWord
+ LibEditText_CursorFind_GetFindingPostion(
+ LibEditText_Cursor *p_cursor )
+{
+ DWord dw_pos;
+
+ dw_pos = p_cursor->dw_pos;
+
+ if( 0 < p_cursor->dw_find_prevpos_len ) {
+ if( p_cursor->dw_lineid != p_cursor->dw_find_prevlineid )
+ { goto goto_LibEditText_CursorFind_GetFindingPostion_post; }
+
+ if( p_cursor->dw_pos < p_cursor->dw_find_prevpos_start )
+ { goto goto_LibEditText_CursorFind_GetFindingPostion_post; }
+
+ if( p_cursor->dw_pos >=
+ (p_cursor->dw_find_prevpos_start + p_cursor->dw_find_prevpos_len ) )
+ { goto goto_LibEditText_CursorFind_GetFindingPostion_post; }
+
+ dw_pos = p_cursor->dw_find_prevpos_start + p_cursor->dw_find_prevpos_len;
+ }
+
+goto_LibEditText_CursorFind_GetFindingPostion_post:
+ return dw_pos;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBEDITTEXT_CURSORFIND_EXTERN
+int
+ LibEditText_CursorFind_FindString(
+ LibEditText_TextInfo *p_tinfo,
+ LibEditText_Cursor *p_cursor,
+ char *pstr_regex,
+ DWord dw_regexlen,
+ Byte b_flagfind )
+{
+ int i_result;
+ int i_flag;
+ int i_round;
+ Byte *pb_start;
+ DWord dw_pstart;
+ DWord dw_lnow;
+ DWord dw_len;
+ DWord dw_lidbase;
+ LibEditText_LineInfo *p_line;
+ regmatch_t t_match;
+
+ assert( NULL != p_tinfo );
+ assert( NULL != p_cursor );
+ assert( NULL != pstr_regex );
+
+ // Check & Set regex String ---
+ i_result = LibEditText_CursorFind_SetRegexString( p_cursor, pstr_regex, dw_regexlen );
+ if( 0x00 != i_result ) {
+ return i_result;
+ }
+
+ // Clear Before Find Data ---
+ if( NULL != p_cursor->pt_findreg ) {
+ regfree( p_cursor->pt_findreg );
+ p_cursor->pt_findreg = NULL;
+ }
+
+ // Compile regex string ---
+ i_flag = REG_EXTENDED;
+ if( LIBEDITTEXT_FLAGFIND_IGNOREICASE & b_flagfind ) { i_flag |= REG_ICASE; }
+
+ i_result = regcomp( p_cursor->pt_findreg, p_cursor->str_regstr, i_flag );
+ if( 0x00 != i_result ) {
+
+ return i_result;
+ }
+
+ // Exec Find ---
+ p_line = LINFO(p_tinfo, p_cursor->dw_lineid);
+ assert( NULL != p_line );
+
+ dw_lidbase = p_line->dw_id;
+ dw_lnow = p_cursor->dw_line;
+ dw_pstart = LibEditText_CursorFind_GetFindingPostion( p_cursor );
+ pb_start = p_tinfo->pb_text + p_line->dw_start + dw_pstart;
+ i_round = 0x00;
+
+ if( 0 < dw_pstart ) { i_flag = REG_NOTBOL; }
+ else { i_flag = 0x00; }
+
+ do {
+
+ i_result = regexec( p_cursor->pt_findreg, (const char *)pb_start,
+ 1, &t_match, i_flag );
+ if( 0x00 == i_result ) { break; }
+ else if( REG_NOMATCH != i_result ) {
+ return -0x10;
+ }
+
+ // Going to Next-Line ---
+ i_flag = 0x00;
+ p_line = LINFO(p_tinfo, p_line->dw_next);
+ dw_lnow++;
+ if( NULL == p_line ) {
+ p_line = LINFO(p_tinfo, p_tinfo->dw_line_start);
+ dw_lnow = 0;
+ i_round = 0x01;
+ }
+ assert( NULL != p_line );
+ dw_pstart = 0;
+ pb_start = p_tinfo->pb_text + p_line->dw_start;
+
+ }while( p_line->dw_id != dw_lidbase );
+
+ if( p_line->dw_id == dw_lidbase )
+ { return LIBEDITTEXT_RET_FINDNOMATCH; } // NO match string in Text.
+
+ dw_pstart += (DWord)t_match.rm_so; // Find String Pos.
+ dw_len = (DWord)(t_match.rm_eo - t_match.rm_so); // Find String Len.
+ // Find String Line is dw_lnow.
+
+ assert( dw_lnow < p_tinfo->dw_maxline );
+ assert( dw_pstart < p_line->dw_strlen );
+
+ i_result = LibEditText_CursorInfo_LocateCursor( p_tinfo, p_cursor, p_line, dw_lnow );
+ if( 0x00 != i_result ) {
+ return -0x20;
+ }
+
+ i_result = LibEditText_CursorMove_SetPosition( p_tinfo, p_cursor, dw_pstart );
+ if( 0x00 != i_result ) {
+ return -0x21;
+ }
+
+ p_cursor->dw_find_prevpos_start = dw_pstart;
+ p_cursor->dw_find_prevpos_len = dw_len;
+ p_cursor->dw_find_prevlineid = p_line->dw_id;
+
+ i_result = LIBEDITTEXT_RET_FINDMATCH;
+ if( 0x00 != i_round ) { i_result = LIBEDITTEXT_RET_FINDMATCH_ROUND; }
+
+ return i_result;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+/*LIBEDITTEXT_CURSORFIND_EXTERN
+int
+ LibEditText_CursorCtrl_AdjustCursorPosition_DeleteString(
+ LibEditText_TextInfo *p_tinfo,
+ LibEditText_LineInfo *p_line,
+ DWord dw_start,
+ DWord dw_len )
+{
+
+ return 0x00;
+}*/
+
+
+/* EOF of drd64_.c ----------------------------------- */
--- /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_.h
+Function: Header
+Comment:
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBEDITTEXT_CURSORFIND
+#define DRD64_HEADER_LIBEDITTEXT_CURSORFIND
+
+#ifdef DRD64_SRC_LIBEDITTEXT_CURSORFIND
+ #define LIBEDITTEXT_CURSORFIND_EXTERN
+#else
+ #define LIBEDITTEXT_CURSORFIND_EXTERN extern
+#endif
+
+#if defined DRD64_SRC_LIBEDITTEXT_CURSORFIND
+ #define LIBEDITTEXT_CURSORFIND_INTERNALFUNC
+#elif defined DRD64_SRC_TEST_LIBEDITTEXT_CURSORFIND
+ #define LIBEDITTEXT_CURSORFIND_INTERNALFUNC
+#endif
+
+
+
+#ifdef LIBEDITTEXT_CURSORFIND_INTERNALFUNC
+#endif
+
+#endif /* DRD64_HEADER_XXX */
+
+/* EOF of drd64_.h ----------------------------------- */