You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
(17) |
May
(11) |
Jun
(5) |
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(19) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(12) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <spa...@us...> - 2017-06-29 18:27:23
|
Revision: 204
http://sourceforge.net/p/bviplus/code/204
Author: spacegctc
Date: 2017-06-29 18:27:21 +0000 (Thu, 29 Jun 2017)
Log Message:
-----------
Based on SVN rev #203
Revision Links:
--------------
http://sourceforge.net/p/bviplus/code/203
Added Paths:
-----------
tags/1.0/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2017-06-29 18:20:42
|
Revision: 203
http://sourceforge.net/p/bviplus/code/203
Author: spacegctc
Date: 2017-06-29 18:20:41 +0000 (Thu, 29 Jun 2017)
Log Message:
-----------
Add script to help make file releases
Added Paths:
-----------
trunk/make_release.sh
Added: trunk/make_release.sh
===================================================================
--- trunk/make_release.sh (rev 0)
+++ trunk/make_release.sh 2017-06-29 18:20:41 UTC (rev 203)
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+function usage {
+ echo " Usage:"
+ echo " $0 <rel_version> [svn_version]"
+ echo " eg. $0 1.0 202"
+ echo " If no svn_version is supplied the current checked out version will be used."
+}
+
+if [ -z $1 ]; then
+ usage
+ return &> /dev/null || exit
+else
+ rev=$1
+fi
+
+if [ ! -z $2 ]; then
+ rev_exists=`svn info -r $2 | grep "Revision:"`
+ if [ -z "$rev_exists" ]; then
+ echo "Revision $2 does not exists."
+ usage
+ return &> /dev/null || exit
+ fi
+ svnrev=$2
+else
+ svnrev=HEAD
+fi
+
+svn export -r $svnrev ./ ../bviplus-${rev}
+cd ../
+tar -czvf bviplus-${rev}.tgz bviplus-${rev}
+rm -rf bviplus-${rev}
+cd -
+
+echo "Based on SVN rev #${svnrev}" > ../${rev}-relnotes.txt
+
Property changes on: trunk/make_release.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-08-24 23:23:48
|
Revision: 202
http://bviplus.svn.sourceforge.net/bviplus/?rev=202&view=rev
Author: spacegctc
Date: 2010-08-24 23:23:42 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
Speed up matches by reducing defaul max match size. Fix some crash.
Modified Paths:
--------------
trunk/user_prefs.c
trunk/virt_file.c
Modified: trunk/user_prefs.c
===================================================================
--- trunk/user_prefs.c 2010-08-09 19:19:33 UTC (rev 201)
+++ trunk/user_prefs.c 2010-08-24 23:23:42 UTC (rev 202)
@@ -41,7 +41,7 @@
{ "search_hl", "hl", 1, 1, 0, 0, P_BOOL },
{ "search_immediate", "si", 1, 1, 0, 0, P_BOOL },
{ "ignorecase", "ic", 0, 0, 0, 0, P_BOOL },
- { "max_match", "mm", 256, 256, 0, 0, P_INT },
+ { "max_match", "mm", 64, 64, 0, 0, P_INT },
{ "", "", 0, 0, 0, 0, P_NONE },
};
Modified: trunk/virt_file.c
===================================================================
--- trunk/virt_file.c 2010-08-09 19:19:33 UTC (rev 201)
+++ trunk/virt_file.c 2010-08-24 23:23:42 UTC (rev 202)
@@ -262,6 +262,10 @@
snprintf(f->fname, MAX_PATH_LEN - 1, "%s", file_name);
f->fname[MAX_PATH_LEN] = 0;
+ f->fm.fp = fopen(f->fname, "a");
+ if(NULL != f->fm.fp)
+ fclose(f->fm.fp);
+
if (stat(f->fname, &stat_buf))
{
vf_term(f);
@@ -274,9 +278,6 @@
f->fm.size = stat_buf.st_size;
}
- f->fm.fp = fopen(f->fname, "a");
- if(NULL != f->fm.fp)
- fclose(f->fm.fp);
f->fm.fp = fopen(f->fname, "r");
if(NULL == f->fm.fp)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-08-09 19:19:39
|
Revision: 201
http://bviplus.svn.sourceforge.net/bviplus/?rev=201&view=rev
Author: spacegctc
Date: 2010-08-09 19:19:33 +0000 (Mon, 09 Aug 2010)
Log Message:
-----------
Apply some of the msg_box display fixes to msg_prompt which uses similar code.
Modified Paths:
--------------
trunk/display.c
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2010-08-09 19:17:46 UTC (rev 200)
+++ trunk/display.c 2010-08-09 19:19:33 UTC (rev 201)
@@ -84,13 +84,13 @@
if (strlen(msgbox_line))
{
- x = ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
+ x = 1 + ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
mvwaddstr(msgbox, y, x, msgbox_line);
memset(msgbox_line, 0, MAX_MSG_BOX_LEN);
}
strncat(msgbox_line, "Y / N", MAX_MSG_BOX_LEN);
- x = ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
+ x = 1 + ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
mvwaddstr(msgbox, MSG_BOX_H - 2, x, msgbox_line);
curs_set(0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-08-09 19:17:52
|
Revision: 200
http://bviplus.svn.sourceforge.net/bviplus/?rev=200&view=rev
Author: spacegctc
Date: 2010-08-09 19:17:46 +0000 (Mon, 09 Aug 2010)
Log Message:
-----------
Fix a crash when trying to save to a file which you do not have write permissions. Fix minor display bugs in msg_box.
Modified Paths:
--------------
trunk/actions.c
trunk/display.c
trunk/virt_file.c
Modified: trunk/actions.c
===================================================================
--- trunk/actions.c 2010-01-15 23:39:37 UTC (rev 199)
+++ trunk/actions.c 2010-08-09 19:17:46 UTC (rev 200)
@@ -1346,16 +1346,18 @@
size = vf_save(current_file, &complete);
if (size != display_info.file_size)
{
- msg_box("Only saved %d bytes, should have saved %d bytes!!",
+ complete = 100;
+ msg_box("Only saved %jd bytes, should have saved %jd bytes!!",
size, display_info.file_size);
+ error = E_INVALID;
update_status("[failed save]");
- curs_set(1);
- return E_INVALID;
}
pthread_join(save_status_thread, &pthread_status);
- update_status("[saved]");
+ if (error == E_SUCCESS)
+ update_status("[saved]");
+
curs_set(1);
print_screen(display_info.page_start);
}
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2010-01-15 23:39:37 UTC (rev 199)
+++ trunk/display.c 2010-08-09 19:17:46 UTC (rev 200)
@@ -198,7 +198,7 @@
if (strlen(msgbox_line))
{
- x = ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
+ x = 1 + ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
mvwaddstr(msgbox, y, x, msgbox_line);
y++;
if (y > (MSG_BOX_H - 2))
@@ -207,7 +207,7 @@
}
strncat(msgbox_line, "[PRESS ANY KEY]", MAX_MSG_BOX_LEN);
- x = ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
+ x = 1 + ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
mvwaddstr(msgbox, MSG_BOX_H - 2, x, msgbox_line);
curs_set(0);
Modified: trunk/virt_file.c
===================================================================
--- trunk/virt_file.c 2010-01-15 23:39:37 UTC (rev 199)
+++ trunk/virt_file.c 2010-08-09 19:17:46 UTC (rev 200)
@@ -470,6 +470,12 @@
fclose(f->fm.fp);
f->fm.fp = fopen(f->fname, "r+");
+ if (f->fm.fp == NULL) /* can't open for writing, permissions? */
+ {
+ f->fm.fp = fopen(f->fname, "r");
+ return 0;
+ }
+
while(NULL != tmp)
{
if(FALSE == tmp->active || 0 == tmp->size)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-15 23:39:43
|
Revision: 199
http://bviplus.svn.sourceforge.net/bviplus/?rev=199&view=rev
Author: spacegctc
Date: 2010-01-15 23:39:37 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
Just testing, but actually this is buggy
Modified Paths:
--------------
branches/simplified/display.c
branches/simplified/display.h
Modified: branches/simplified/display.c
===================================================================
--- branches/simplified/display.c 2010-01-13 21:47:24 UTC (rev 198)
+++ branches/simplified/display.c 2010-01-15 23:39:37 UTC (rev 199)
@@ -244,7 +244,6 @@
display_info.cursor_addr = display_info.page_start;
if (display_info.cursor_addr > display_info.page_end)
display_info.cursor_addr = display_info.page_end;
- display_info.cursor_addr -= (display_info.cursor_addr % user_prefs[GROUPING].value);
update_percent();
update_status(NULL);
}
@@ -343,9 +342,9 @@
int visual_span(void)
{
if (display_info.cursor_addr < display_info.visual_select_addr)
- return (display_info.visual_select_addr - display_info.cursor_addr) + user_prefs[GROUPING].value;
+ return (display_info.visual_select_addr - display_info.cursor_addr) + 1;
else
- return (display_info.cursor_addr - display_info.visual_select_addr) + user_prefs[GROUPING].value;
+ return (display_info.cursor_addr - display_info.visual_select_addr) + 1;
}
off_t visual_addr(void)
{
@@ -386,124 +385,121 @@
for (i=0,j=0; i<HEX_COLS; i++)
{
/* print hex and ascii */
- for (j=0; j<user_prefs[GROUPING].value; j++)
+ if (user_prefs[LIL_ENDIAN].value)
+ byte_addr = line_addr - 1 + i - j;
+ else
+ byte_addr = line_addr + i + j;
+
+ if (screen_buf == NULL)
{
- if (user_prefs[LIL_ENDIAN].value)
- byte_addr = line_addr - 1 + (i*user_prefs[GROUPING].value) + (user_prefs[GROUPING].value - j);
+ if (address_invalid(line_addr))
+ {
+ search_hl(FALSE);
+ visual_select_hl(FALSE);
+ break;
+ }
else
- byte_addr = line_addr + (i*user_prefs[GROUPING].value) + j;
-
- if (screen_buf == NULL)
+ c = vf_get_char(current_file, &result, byte_addr);
+ }
+ else
+ {
+ if (byte_addr < page_addr || byte_addr >= page_addr + screen_buf_size)
{
- if (address_invalid(line_addr))
- {
- search_hl(FALSE);
- visual_select_hl(FALSE);
- break;
- }
- else
- c = vf_get_char(current_file, &result, byte_addr);
+ search_hl(FALSE);
+ visual_select_hl(FALSE);
+ break;
}
else
+ c = screen_buf[byte_addr - page_addr];
+
+/* cck for search highlighting */
+ if (search_item[current_search].highlight &&
+ search_aid != NULL)
{
- if (byte_addr < page_addr || byte_addr >= page_addr + screen_buf_size)
+ if (search_aid->hl_start != -1)
{
- search_hl(FALSE);
- visual_select_hl(FALSE);
- break;
- }
- else
- c = screen_buf[byte_addr - page_addr];
-
-/* check for search highlighting */
- if (search_item[current_search].highlight &&
- search_aid != NULL)
- {
- if (search_aid->hl_start != -1)
+ if(search_aid->hl_start <= byte_addr)
{
- if(search_aid->hl_start <= byte_addr)
+ if (search_aid->hl_end > byte_addr)
{
- if (search_aid->hl_end > byte_addr)
- {
+ search_hl(TRUE);
+ }
+ else
+ {
+ search_hl(FALSE);
+ buf_search(search_aid);
+ if(search_aid->hl_start <= byte_addr &&
+ search_aid->hl_end > byte_addr)
search_hl(TRUE);
- }
- else
- {
- search_hl(FALSE);
- buf_search(search_aid);
- if(search_aid->hl_start <= byte_addr &&
- search_aid->hl_end > byte_addr)
- search_hl(TRUE);
- }
}
}
}
-/**/
}
+/**/
+ }
- if (is_visual_on())
+ if (is_visual_on())
+ {
+ if ((display_info.visual_select_addr <= byte_addr &&
+ display_info.cursor_addr >= byte_addr) ||
+ (display_info.cursor_addr <= byte_addr &&
+ display_info.visual_select_addr >= byte_addr))
{
- if ((display_info.visual_select_addr <= byte_addr &&
- display_info.cursor_addr + user_prefs[GROUPING].value - 1 >= byte_addr) ||
- (display_info.cursor_addr <= byte_addr &&
- display_info.visual_select_addr + user_prefs[GROUPING].value - 1 >= byte_addr))
- {
- visual_select_hl(TRUE);
- }
- else
- {
- visual_select_hl(FALSE);
- }
+ visual_select_hl(TRUE);
}
-
- if (user_prefs[BLOB_GROUPING_OFFSET].value > byte_addr)
- {
- blob_standout(TRUE);
- }
else
{
- if (user_prefs[BLOB_GROUPING].value &&
- (((byte_addr - user_prefs[BLOB_GROUPING_OFFSET].value) / user_prefs[BLOB_GROUPING].value) & 1))
- {
- blob_standout(TRUE);
- }
+ visual_select_hl(FALSE);
}
+ }
- if (user_prefs[DISPLAY_BINARY].value)
+ if (user_prefs[BLOB_GROUPING_OFFSET].value > byte_addr)
+ {
+ blob_standout(TRUE);
+ }
+ else
+ {
+ if (user_prefs[BLOB_GROUPING].value &&
+ (((byte_addr - user_prefs[BLOB_GROUPING_OFFSET].value) / user_prefs[BLOB_GROUPING].value) & 1))
{
- snprintf(bin_text, 8, "%c", c);
- for (k=0; k<8; k++)
- {
- if ((c >> (7 - k)) & 1)
- mvwaddch(window_list[WINDOW_HEX], y, x, '1');
- else
- mvwaddch(window_list[WINDOW_HEX], y, x, '0');
- x++;
- }
+ blob_standout(TRUE);
}
- else
+ }
+
+ if (user_prefs[DISPLAY_BINARY].value)
+ {
+ snprintf(bin_text, 8, "%c", c);
+ for (k=0; k<8; k++)
{
- mvwaddch(window_list[WINDOW_HEX], y, x, HEX(c>>4&0xF));
+ if ((c >> (7 - k)) & 1)
+ mvwaddch(window_list[WINDOW_HEX], y, x, '1');
+ else
+ mvwaddch(window_list[WINDOW_HEX], y, x, '0');
x++;
- mvwaddch(window_list[WINDOW_HEX], y, x, HEX(c>>0&0xF));
- x++;
}
+ }
+ else
+ {
+ mvwaddch(window_list[WINDOW_HEX], y, x, HEX(c>>4&0xF));
+ x++;
+ mvwaddch(window_list[WINDOW_HEX], y, x, HEX(c>>0&0xF));
+ x++;
+ }
- if (!isprint(c))
- c = '.';
+ if (!isprint(c))
+ c = '.';
- if (user_prefs[LIL_ENDIAN].value)
- mvwaddch(window_list[WINDOW_ASCII], y, (1+i)*user_prefs[GROUPING].value-j, c);
- else
- mvwaddch(window_list[WINDOW_ASCII], y, 1+i*user_prefs[GROUPING].value+j, c);
+ if (user_prefs[LIL_ENDIAN].value)
+ mvwaddch(window_list[WINDOW_ASCII], y, (1+i)-j, c);
+ else
+ mvwaddch(window_list[WINDOW_ASCII], y, 1+i+j, c);
- blob_standout(FALSE);
+ blob_standout(FALSE);
- }
mvwaddch(window_list[WINDOW_HEX], y, x++, ' ');
}
- return ((i-1) * user_prefs[GROUPING].value) + j;
+ return (i-1) + j;
}
void update_file_tabs_window(void)
@@ -746,7 +742,7 @@
if (offset > PAGE_SIZE)
return -1;
- z = (HEX_COLS * user_prefs[GROUPING].value);
+ z = HEX_COLS;
y += offset / z;
return y;
@@ -762,10 +758,10 @@
y--;
- offset -= y * HEX_COLS * user_prefs[GROUPING].value;
+ offset -= y * HEX_COLS;
if (display_info.cursor_window == WINDOW_HEX)
- x = 1 + (offset / user_prefs[GROUPING].value) * BYTES_PER_GROUP;
+ x = 1 + offset * BYTES_PER_GROUP;
else
x = 1 + offset;
@@ -786,7 +782,7 @@
if (offset > page_size)
return -1;
- z = (HEX_COLS * user_prefs[GROUPING].value);
+ z = HEX_COLS;
y += offset / z;
return y;
@@ -804,10 +800,10 @@
y--;
offset = addr - display_info.page_start;
- offset -= y * HEX_COLS * user_prefs[GROUPING].value;
+ offset -= y * HEX_COLS;
if (display_info.cursor_window == WINDOW_HEX)
- x = 1 + (offset / user_prefs[GROUPING].value) * BYTES_PER_GROUP;
+ x = 1 + offset * BYTES_PER_GROUP;
else
x = 1 + offset;
@@ -831,8 +827,8 @@
if (x > (BYTES_PER_GROUP * HEX_COLS) - BYTES_PER_GROUP)
return -1;
- addr += y * HEX_COLS * user_prefs[GROUPING].value;
- addr += (x / BYTES_PER_GROUP) * user_prefs[GROUPING].value;
+ addr += y * HEX_COLS;
+ addr += x / BYTES_PER_GROUP;
if (addr > display_info.page_end || address_invalid(addr))
return -1;
Modified: branches/simplified/display.h
===================================================================
--- branches/simplified/display.h 2010-01-13 21:47:24 UTC (rev 198)
+++ branches/simplified/display.h 2010-01-15 23:39:37 UTC (rev 199)
@@ -55,14 +55,13 @@
#define WINDOW_STATUS_Y MENU_BOX_H + ADDR_BOX_H
#define WINDOW_STATUS_X 0
-#define HEX_BYTE_DIGITS (user_prefs[DISPLAY_BINARY].value ? 8 : 2)
+#define HEX_BYTE_DIGITS 2
#define ASCII_BYTE_DIGITS 1
#define BYTE_DIGITS (display_info.cursor_window == WINDOW_HEX ? HEX_BYTE_DIGITS : ASCII_BYTE_DIGITS )
#define SPACE_DIGITS 1
-/* each hex byte is represented in hex by 2(hex)/8(binary) digits, plus each grouping has one trailing space */
-#define HEX_BYTES_PER_GROUP ((user_prefs[GROUPING].value * HEX_BYTE_DIGITS) + SPACE_DIGITS)
-#define ASCII_BYTES_PER_GROUP (user_prefs[GROUPING].value * ASCII_BYTE_DIGITS)
+#define HEX_BYTES_PER_GROUP (HEX_BYTE_DIGITS + SPACE_DIGITS)
+#define ASCII_BYTES_PER_GROUP ASCII_BYTE_DIGITS
#define BYTES_PER_GROUP (display_info.cursor_window == WINDOW_HEX ? HEX_BYTES_PER_GROUP : ASCII_BYTES_PER_GROUP)
/* width of hex box + ascii box */
@@ -70,7 +69,7 @@
#define MAX_HEX_COLS ((SHARED_WIDTH-4)/((3*ASCII_BYTES_PER_GROUP) + 1))
#define HEX_COLS (user_prefs[MAX_COLS].value == 0 ? MAX_HEX_COLS : MAX_HEX_COLS > user_prefs[MAX_COLS].value ? user_prefs[MAX_COLS].value : MAX_HEX_COLS)
-#define BYTES_PER_LINE (HEX_COLS * user_prefs[GROUPING].value)
+#define BYTES_PER_LINE (HEX_COLS)
#define HEX_LINES (HEX_BOX_H - 2)
@@ -85,7 +84,7 @@
#define ASCII_BOX_X (HEX_BOX_X + HEX_BOX_W)
#define ASCII_BOX_Y MENU_BOX_H
#define ASCII_BOX_W_ (SHARED_WIDTH - HEX_BOX_W)
-#define ASCII_BOX_W (ASCII_BOX_W_ > (user_prefs[GROUPING].value + 2) ? ASCII_BOX_W_ : (user_prefs[GROUPING].value + 2))
+#define ASCII_BOX_W (ASCII_BOX_W_ > 2 ? ASCII_BOX_W_ : 2)
#define ASCII_BOX_H ADDR_BOX_H
#define PAGE_SIZE (HEX_LINES * BYTES_PER_LINE)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-13 21:47:42
|
Revision: 198
http://bviplus.svn.sourceforge.net/bviplus/?rev=198&view=rev
Author: spacegctc
Date: 2010-01-13 21:47:24 +0000 (Wed, 13 Jan 2010)
Log Message:
-----------
Experiment with removing support for binary display mode and grouping mode. These features are very untested and I think there should be a significan performance bennifit from removing them.
Added Paths:
-----------
branches/simplified/
Property changes on: branches/simplified
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-184
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-13 21:34:12
|
Revision: 197
http://bviplus.svn.sourceforge.net/bviplus/?rev=197&view=rev
Author: spacegctc
Date: 2010-01-13 21:34:06 +0000 (Wed, 13 Jan 2010)
Log Message:
-----------
Based on SVN rev #196
- Update vf_get_buf to return partial buffers, instead of 0, when not enough
data can be read from the file
- Add movement keys w (next word), W (next word, whitespace delimeters only), e
(end of word), E (end of word, whitespace only delimeters)
- Add stubs for movement keys b, B (like e, E but go to the back to the
beginning of a word instead of forward to the end)
- Add change keys 'c' and 's'. The effect of these keys is to delete the range
and enter insert mode
- 'c' takes either a visual span or a movement key (e.g. 'cw' changes from the
cursor to the end of the word)
- 's' takes either a visual span or the one character under the cursor
- Impliment backward word move keys 'b' and 'B' (Similar to 'e' and 'E' but
backwards)
- Resolve a bug where search would not match if the match term included the
last byte in the file
Revision Links:
--------------
http://bviplus.svn.sourceforge.net/bviplus/?rev=196&view=rev
Added Paths:
-----------
tags/0.9.4/
Property changes on: tags/0.9.4
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-184
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-13 20:20:34
|
Revision: 196
http://bviplus.svn.sourceforge.net/bviplus/?rev=196&view=rev
Author: spacegctc
Date: 2010-01-13 20:20:21 +0000 (Wed, 13 Jan 2010)
Log Message:
-----------
Resolve a bug where search would not match if the match term included the last byte in the file
Modified Paths:
--------------
trunk/search.c
Modified: trunk/search.c
===================================================================
--- trunk/search.c 2010-01-13 00:08:28 UTC (rev 195)
+++ trunk/search.c 2010-01-13 20:20:21 UTC (rev 196)
@@ -600,7 +600,7 @@
a = addr + display_size + user_prefs[MAX_MATCH].value;
if (address_invalid(a))
- a = display_info.file_size - 1;
+ a = display_info.file_size;
search_aid->buf_size = a - search_aid->buf_start_addr;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-13 00:08:35
|
Revision: 195
http://bviplus.svn.sourceforge.net/bviplus/?rev=195&view=rev
Author: spacegctc
Date: 2010-01-13 00:08:28 +0000 (Wed, 13 Jan 2010)
Log Message:
-----------
Impliment backward word move keys 'b' and 'B' (Similar to 'e' and 'E' but backwards)
Modified Paths:
--------------
trunk/key_handler.c
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2010-01-12 07:13:40 UTC (rev 194)
+++ trunk/key_handler.c 2010-01-13 00:08:28 UTC (rev 195)
@@ -551,7 +551,7 @@
}
next_addr += size;
- size = vf_get_buf(current_file, buf, cur_addr, 256);
+ size = vf_get_buf(current_file, buf, next_addr, 256);
}
break;
@@ -628,14 +628,124 @@
}
next_addr += size;
- size = vf_get_buf(current_file, buf, cur_addr, 256);
+ size = vf_get_buf(current_file, buf, next_addr, 256);
}
+ break;
+ default:
+ break;
+ }
+ flash();
+ return E_NO_ACTION;
+}
+
+action_code_t word_move_back(int c, cursor_t cursor)
+{
+ int i, size = 0;
+ off_t cur_addr, next_addr = 0;
+ char buf[256], current_char;
+ int require_whitespace = 0;
+
+ size = 256;
+ cur_addr = display_info.cursor_addr - (size-1);
+ if (address_invalid(cur_addr))
+ {
+ cur_addr = 0;
+ size = display_info.cursor_addr;
+ }
+
+ size = vf_get_buf(current_file, buf, cur_addr, size);
+
+ current_char = buf[size-1];
+
+ next_addr = cur_addr;
+
+ switch(c)
+ {
+ case 'B': /* end of word, same delimit rules as W */
+ require_whitespace = 1;
+ /* no break */
+ case 'b': /* end of word, same delimit rules as w */
+ while (size > 1)
+ {
+ for (i=size-1; i>=0; i--)
+ {
+ if (ALPHANUMERIC(current_char))
+ {
+ if (WHITESPACE(buf[i]))
+ {
+ if (i == size-2 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i + 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ else if (!ALPHANUMERIC(buf[i]) && require_whitespace == 0)
+ {
+ if (i == size-2 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i + 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ else if (WHITESPACE(current_char))
+ {
+ if (!WHITESPACE(buf[i]))
+ {
+ current_char = buf[i];
+ continue;
+ }
+ }
+ else
+ {
+ if (WHITESPACE(buf[i]))
+ {
+ if (i == size-2 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i + 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ else if (ALPHANUMERIC(buf[i]) && require_whitespace == 0)
+ {
+ if (i == size-2 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i + 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ }
+
+ next_addr -= size;
+ if (address_invalid(next_addr))
+ {
+ size = size + next_addr;
+ next_addr = 0;
+ }
+
+ size = vf_get_buf(current_file, buf, next_addr, size);
+ }
break;
- case 'b': /* previous word, same delimit rules as w */
+ default:
break;
- case 'B': /* previous word, same delimit rules as W */
- break;
}
flash();
@@ -746,9 +856,11 @@
case 'W':
case 'e':
case 'E':
+ word_move(c, CURSOR_VIRTUAL);
+ return display_info.virtual_cursor_addr;
case 'b':
case 'B':
- word_move(c, CURSOR_VIRTUAL);
+ word_move_back(c, CURSOR_VIRTUAL);
return display_info.virtual_cursor_addr;
case '?':
case '/':
@@ -1654,9 +1766,11 @@
case 'W':
case 'e':
case 'E':
+ word_move(c, CURSOR_REAL);
+ break;
case 'b':
case 'B':
- word_move(c, CURSOR_REAL);
+ word_move_back(c, CURSOR_REAL);
break;
case INS:
case 'i':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-12 07:13:46
|
Revision: 194
http://bviplus.svn.sourceforge.net/bviplus/?rev=194&view=rev
Author: spacegctc
Date: 2010-01-12 07:13:40 +0000 (Tue, 12 Jan 2010)
Log Message:
-----------
Update vf_get_buf to return partial buffers, instead of 0, when not enough data can be read from the file
Add movement keys w (next word), W (next word, whitespace delimeters only), e (end of word), E (end of word, whitespace only delimeters)
Add stubs for movement keys b, B (like e, E but go to the back to the beginning of a word instead of forward to the end)
Add change keys 'c' and 's'. The effect of these keys is to delete the range and enter insert mode
'c' takes either a visual span or a movement key (e.g. 'cw' changes from the cursor to the end of the word)
's' takes either a visual span or the one character under the cursor
Modified Paths:
--------------
trunk/key_handler.c
trunk/vf_backend.c
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2010-01-11 01:12:24 UTC (rev 193)
+++ trunk/key_handler.c 2010-01-12 07:13:40 UTC (rev 194)
@@ -36,6 +36,9 @@
#include "app_state.h"
#include "help.h"
+#define ALPHANUMERIC(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || (x >= '0' && x <= '9'))
+#define WHITESPACE(x) (x == ' ' || x == '\t' || !isprint(x)) /* includes all non-print chars */
+
macro_record_t macro_record[26];
int macro_key = -1;
int last_macro_key = -1;
@@ -475,6 +478,170 @@
return E_SUCCESS;
}
+action_code_t word_move(int c, cursor_t cursor)
+{
+ int i, size = 0;
+ off_t cur_addr, next_addr;
+ char buf[256], current_char;
+ int require_whitespace = 0;
+
+ cur_addr = display_info.cursor_addr;
+ next_addr = cur_addr;
+
+ size = vf_get_buf(current_file, buf, cur_addr, 256);
+
+ current_char = buf[0];
+
+ /* This seems like an ugly hack to me, but when a user presses 'w' they expect to go
+ to the next word, but when they type 'cw' they expect to change the current word,
+ and not the trailing whitespace or the first character of the next word */
+ if (cursor == CURSOR_VIRTUAL)
+ {
+ if (c == 'w')
+ c = 'e';
+ if (c == 'W')
+ c = 'E';
+ }
+
+ switch(c)
+ {
+ case 'W': /* next word, only whilespace are delimeters */
+ require_whitespace = 1;
+ /* no break */
+ case 'w': /* next word, any non-alphanumeric is delimiter,
+ and whitespace delimits groups of delimeters */
+ while (size > 1)
+ {
+ for (i=0; i<size; i++)
+ {
+ if (ALPHANUMERIC(current_char))
+ {
+ if (WHITESPACE(buf[i]))
+ {
+ current_char = buf[i];
+ continue;
+ }
+ else if (!ALPHANUMERIC(buf[i]) && require_whitespace == 0)
+ {
+ place_cursor(next_addr + i, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ else if (WHITESPACE(current_char))
+ {
+ if (!WHITESPACE(buf[i]))
+ {
+ place_cursor(next_addr + i, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ else
+ {
+ if (WHITESPACE(buf[i]))
+ {
+ current_char = buf[i];
+ continue;
+ }
+ else if (ALPHANUMERIC(buf[i]) && require_whitespace == 0)
+ {
+ place_cursor(next_addr + i, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ }
+
+ next_addr += size;
+ size = vf_get_buf(current_file, buf, cur_addr, 256);
+ }
+
+ break;
+ case 'E': /* end of word, same delimit rules as W */
+ require_whitespace = 1;
+ /* no break */
+ case 'e': /* end of word, same delimit rules as w */
+ while (size > 1)
+ {
+ for (i=0; i<size; i++)
+ {
+ if (ALPHANUMERIC(current_char))
+ {
+ if (WHITESPACE(buf[i]))
+ {
+ if (i == 1 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i - 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ else if (!ALPHANUMERIC(buf[i]) && require_whitespace == 0)
+ {
+ if (i == 1 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i - 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ else if (WHITESPACE(current_char))
+ {
+ if (!WHITESPACE(buf[i]))
+ {
+ current_char = buf[i];
+ continue;
+ }
+ }
+ else
+ {
+ if (WHITESPACE(buf[i]))
+ {
+ if (i == 1 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i - 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ else if (ALPHANUMERIC(buf[i]) && require_whitespace == 0)
+ {
+ if (i == 1 && next_addr == cur_addr)
+ {
+ /* if we were on the last character in a word we need
+ to move on to the next word */
+ current_char = buf[i];
+ continue;
+ }
+ place_cursor(next_addr + i - 1, CALIGN_NONE, cursor);
+ return E_SUCCESS;
+ }
+ }
+ }
+
+ next_addr += size;
+ size = vf_get_buf(current_file, buf, cur_addr, 256);
+ }
+
+ break;
+ case 'b': /* previous word, same delimit rules as w */
+ break;
+ case 'B': /* previous word, same delimit rules as W */
+ break;
+ }
+
+ flash();
+ return E_NO_ACTION;
+}
+
action_code_t do_cmd_line(cursor_t cursor)
{
char *cmd;
@@ -575,6 +742,14 @@
case ':':
do_cmd_line(CURSOR_VIRTUAL);
return display_info.virtual_cursor_addr;
+ case 'w':
+ case 'W':
+ case 'e':
+ case 'E':
+ case 'b':
+ case 'B':
+ word_move(c, CURSOR_VIRTUAL);
+ return display_info.virtual_cursor_addr;
case '?':
case '/':
case '\\':
@@ -892,6 +1067,7 @@
action_yank(count, end_addr, TRUE);
}
+
void do_replace(int count)
{
int hx, hy, ax, ay, c, i, char_count = 0, chars_per_byte = 0;
@@ -1013,6 +1189,38 @@
}
+void do_change(int multiplier, int c)
+{
+ off_t end_addr = 0;
+ /* later we may want to create a real change operation on the file backend,
+ but for now we have to do a delete/insert, so just do it as two operations,
+ which will make this implimentation easy */
+
+ if (is_visual_on())
+ {
+ action_delete(1, INVALID_ADDR);
+ }
+ else
+ {
+ switch(c)
+ {
+ case 'c':
+ case 'C':
+ end_addr = get_next_motion_addr();
+ break;
+ case 's':
+ case 'S':
+ end_addr = display_info.cursor_addr;
+ break;
+ }
+
+ action_delete(multiplier, end_addr);
+ }
+
+ action_visual_select_off();
+ do_insert(1, 'i');
+}
+
void do_overwrite(int count)
{
char *screen_buf, *rep_buf, *tmp_rep_buf;
@@ -1436,12 +1644,20 @@
case 'v':
action_visual_select_toggle();
break;
-/* These are not handled yet */
case 'c':
case 'C':
case 's':
case 'S':
-/*****************************/
+ do_change(multiplier, c);
+ break;
+ case 'w':
+ case 'W':
+ case 'e':
+ case 'E':
+ case 'b':
+ case 'B':
+ word_move(c, CURSOR_REAL);
+ break;
case INS:
case 'i':
case 'I':
Modified: trunk/vf_backend.c
===================================================================
--- trunk/vf_backend.c 2010-01-11 01:12:24 UTC (rev 193)
+++ trunk/vf_backend.c 2010-01-12 07:13:40 UTC (rev 194)
@@ -789,6 +789,8 @@
/* make sure we're still in the buf */
if(offset + len > vb->start + vb->size)
+ len = vb->start + vb->size - offset;
+ if (len < 1)
return 0;
tmp = vb->first_child;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-11 01:12:31
|
Revision: 193
http://bviplus.svn.sourceforge.net/bviplus/?rev=193&view=rev
Author: spacegctc
Date: 2010-01-11 01:12:24 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
Wrong tag for this release
Added Paths:
-----------
tags/0.9.3/
Removed Paths:
-------------
tags/0.9.2/
Property changes on: tags/0.9.3
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-184
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-11 01:03:18
|
Revision: 192
http://bviplus.svn.sourceforge.net/bviplus/?rev=192&view=rev
Author: spacegctc
Date: 2010-01-11 01:03:13 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
Based on svn rev #191
- Add GPL to code
- Add support for .bviplusrc file
- Add makefile support for gprof
- Add macro support
- Update status message functionality
- Update documentation
Revision Links:
--------------
http://bviplus.svn.sourceforge.net/bviplus/?rev=191&view=rev
Added Paths:
-----------
tags/0.9.2/
Property changes on: tags/0.9.2
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-184
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-11 00:53:27
|
Revision: 191
http://bviplus.svn.sourceforge.net/bviplus/?rev=191&view=rev
Author: spacegctc
Date: 2010-01-11 00:53:21 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
Imliment overwrite mode
Modified Paths:
--------------
trunk/actions.c
trunk/actions.h
trunk/key_handler.c
Modified: trunk/actions.c
===================================================================
--- trunk/actions.c 2010-01-07 19:19:53 UTC (rev 190)
+++ trunk/actions.c 2010-01-11 00:53:21 UTC (rev 191)
@@ -715,9 +715,18 @@
return E_INVALID;
return error;
}
-action_code_t action_replace(int count)
+action_code_t action_replace(int count, char *buf, int buf_size)
{
action_code_t error = E_SUCCESS;
+ off_t addr = display_info.cursor_addr;
+ int i;
+
+ for (i=0; i<count; i++)
+ {
+ vf_replace(current_file, buf, addr, buf_size);
+ addr += buf_size;
+ }
+
return error;
}
Modified: trunk/actions.h
===================================================================
--- trunk/actions.h 2010-01-07 19:19:53 UTC (rev 190)
+++ trunk/actions.h 2010-01-11 00:53:21 UTC (rev 191)
@@ -65,7 +65,7 @@
action_code_t action_clean_yank(void);
action_code_t action_yank(int count, off_t end_addr, BOOL move_cursor); /* yank from cursor to end_addr (end_addr can be INVALID_ADDR) */
action_code_t action_append(void);
-action_code_t action_replace(int count);
+action_code_t action_replace(int count, char *buf, int buf_size);
action_code_t action_discard_changes(void);
action_code_t action_close_file(void);
action_code_t action_open_file(void);
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2010-01-07 19:19:53 UTC (rev 190)
+++ trunk/key_handler.c 2010-01-11 00:53:21 UTC (rev 191)
@@ -1012,14 +1012,229 @@
print_screen(display_info.page_start);
}
+
void do_overwrite(int count)
{
- char *tmp_buf;
- int tmp_buf_size = 4;
+ char *screen_buf, *rep_buf, *tmp_rep_buf;
+ char tmp[9], tmp2[MAX_GRP], tmpc;
+ int c2 = 0, i;
+ int hy, hx, ay, ax;
+ int rep_buf_size;
+ int chars_per_byte, char_count = 0, tmp_char_count = 0, low_tmp_char_count = 0;
+ int offset = 0, len1, rep_buf_offset, len2, len3;
+ off_t ins_addr, page_start;
- tmp_buf = malloc(tmp_buf_size);
+ if (is_visual_on())
+ {
+ /* What should we do if user tries to OVERWRITE in visual select mode? */
+ flash();
+ return;
+ }
- free(tmp_buf);
+ screen_buf = (char *)malloc(2 * PAGE_SIZE); /* fix this later, but make it big for now */
+ rep_buf_size = user_prefs[GROUPING].value;
+ rep_buf = (char *)malloc(rep_buf_size);
+
+ ins_addr = display_info.cursor_addr;
+
+ page_start = display_info.page_start;
+
+ while (c2 != ESC)
+ {
+ if ((offset + char_count) > PAGE_SIZE)
+ page_start += BYTES_PER_LINE;
+ offset = ins_addr - page_start;
+ if (offset < 0)
+ {
+ len1 = 0;
+ rep_buf_offset = page_start - ins_addr;
+ len2 = char_count - rep_buf_offset;
+ }
+ else
+ {
+ len1 = offset;
+ len2 = char_count;
+ rep_buf_offset = 0;
+ }
+ if ((len1 + len2) > PAGE_SIZE)
+ len3 = 0;
+ else
+ len3 = PAGE_SIZE - (len1 + len2);
+
+ if (len1 != 0)
+ vf_get_buf(current_file, screen_buf, page_start, len1);
+ if (len2 != 0)
+ memcpy(screen_buf + len1, rep_buf + rep_buf_offset, len2);
+ if (len3 > 0)
+ vf_get_buf(current_file, screen_buf + len1 + len2, ins_addr + len2, len3);
+ else
+ len3 = 0;
+
+ print_screen_buf(page_start, screen_buf, len1+len2+len3, NULL);
+
+ if (display_info.cursor_window == WINDOW_HEX)
+ {
+ hy = get_y_from_page_offset(len1+len2);
+ hx = get_x_from_page_offset(len1+len2);
+ display_info.cursor_window = WINDOW_ASCII;
+ ay = get_y_from_page_offset(len1+len2);
+ ax = get_x_from_page_offset(len1+len2);
+ display_info.cursor_window = WINDOW_HEX;
+ chars_per_byte = 2;
+ }
+ else
+ {
+ display_info.cursor_window = WINDOW_HEX;
+ hy = get_y_from_page_offset(len1+len2);
+ hx = get_x_from_page_offset(len1+len2);
+ display_info.cursor_window = WINDOW_ASCII;
+ ay = get_y_from_page_offset(len1+len2);
+ ax = get_x_from_page_offset(len1+len2);
+ chars_per_byte = 1;
+ }
+
+ if (tmp_char_count > 0 || low_tmp_char_count)
+ {
+ for (i=0; i<user_prefs[GROUPING].value; i++) /* print from temp buf here to clear or print partial insert */
+ {
+ if (i>=tmp_char_count)
+ {
+ if (low_tmp_char_count && i == tmp_char_count)
+ mvwaddch(window_list[WINDOW_HEX], hy, hx+(2*i), tmp[0]);
+ else
+ mvwaddch(window_list[WINDOW_HEX], hy, hx+(2*i), ' ');
+ mvwaddch(window_list[WINDOW_HEX], hy, hx+(2*i)+1, ' ');
+ mvwaddch(window_list[WINDOW_ASCII], ay, ax+i, ' ');
+ }
+ else
+ {
+ mvwaddch(window_list[WINDOW_HEX], hy, hx+(2*i), HEX(tmp2[i]>>4&0xF));
+ mvwaddch(window_list[WINDOW_HEX], hy, hx+(2*i)+1, HEX(tmp2[i]>>0&0xF));
+ if (isprint(tmp2[i]))
+ mvwaddch(window_list[WINDOW_ASCII], ay, ax+i, tmp2[i]);
+ else
+ mvwaddch(window_list[WINDOW_ASCII], ay, ax+i, '.');
+ }
+ }
+ }
+
+ update_panels();
+ doupdate();
+ if (display_info.cursor_window == WINDOW_HEX)
+ wmove(window_list[WINDOW_HEX], hy, hx);
+ else
+ wmove(window_list[WINDOW_ASCII], ay, ax);
+ c2 = mgetch();
+ switch (c2)
+ {
+ case KEY_BACKSPACE:
+ low_tmp_char_count--;
+ if (low_tmp_char_count < 0)
+ {
+ low_tmp_char_count = chars_per_byte - 1;
+ tmp_char_count--;
+ if (tmp_char_count < 0)
+ {
+ tmp_char_count = user_prefs[GROUPING].value - 1;
+ char_count--;
+ if (char_count < 0)
+ {
+ low_tmp_char_count = 0;
+ tmp_char_count = 0;
+ char_count = 0;
+ flash();
+ }
+ else
+ {
+ memcpy(tmp2, rep_buf + char_count, user_prefs[GROUPING].value);
+ tmp[1] = HEX((tmp2[tmp_char_count] & 0xF0) >> 4);
+ tmp[0] = HEX((tmp2[tmp_char_count] & 0x0F));
+ }
+ }
+ else
+ {
+ tmp[1] = HEX((tmp2[tmp_char_count] & 0xF0) >> 4);
+ tmp[0] = HEX((tmp2[tmp_char_count] & 0x0F));
+ }
+ }
+ break;
+ case KEY_RESIZE:
+ break;
+ case ESC:
+ break;
+ default:
+ if (display_info.cursor_window == WINDOW_HEX)
+ {
+ if (is_hex(c2) == 0)
+ {
+ flash();
+ continue;
+ }
+ tmp[low_tmp_char_count] = (char)c2;
+ low_tmp_char_count++;
+ if ((low_tmp_char_count % chars_per_byte) == 0)
+ {
+ low_tmp_char_count = 0;
+ tmp[chars_per_byte] = 0;
+ tmpc = (char)strtol(tmp, NULL, 16);
+ tmp2[tmp_char_count % user_prefs[GROUPING].value] = tmpc;
+ tmp_char_count++;
+
+ if ((tmp_char_count % user_prefs[GROUPING].value) == 0)
+ {
+ while (char_count + tmp_char_count >= rep_buf_size)
+ {
+ tmp_rep_buf = calloc(1, rep_buf_size * 2);
+ memcpy(tmp_rep_buf, rep_buf, rep_buf_size);
+ rep_buf_size *= 2;
+ free(rep_buf);
+ rep_buf = tmp_rep_buf;
+ }
+
+ memcpy(rep_buf + char_count, tmp2, tmp_char_count);
+ char_count += tmp_char_count;
+ tmp_char_count = 0;
+ }
+ }
+ }
+ else /* cursor in ascii window */
+ {
+ tmp2[tmp_char_count % user_prefs[GROUPING].value] = (char)c2;
+ tmp_char_count++;
+
+ if ((tmp_char_count % user_prefs[GROUPING].value) == 0)
+ {
+ while (char_count + tmp_char_count >= rep_buf_size)
+ {
+ tmp_rep_buf = calloc(1, rep_buf_size * 2);
+ memcpy(tmp_rep_buf, rep_buf, rep_buf_size);
+ rep_buf_size *= 2;
+ free(rep_buf);
+ rep_buf = tmp_rep_buf;
+ }
+
+ memcpy(rep_buf + char_count, tmp2, tmp_char_count);
+ char_count += tmp_char_count;
+ tmp_char_count = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ if (char_count)
+ {
+ if (count == 0)
+ count = 1;
+
+ action_replace(count,rep_buf,char_count);
+ }
+
+ free(rep_buf);
+ free(screen_buf);
+
+ place_cursor(ins_addr+char_count, CALIGN_NONE, CURSOR_REAL);
+ print_screen(page_start);
}
void do_delete(int count, int c)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-07 19:20:15
|
Revision: 190
http://bviplus.svn.sourceforge.net/bviplus/?rev=190&view=rev
Author: spacegctc
Date: 2010-01-07 19:19:53 +0000 (Thu, 07 Jan 2010)
Log Message:
-----------
Update documentation for new macro support and .bviplusrc file support
Modified Paths:
--------------
trunk/help.c
web/documentation.html
Modified: trunk/help.c
===================================================================
--- trunk/help.c 2010-01-07 19:02:00 UTC (rev 189)
+++ trunk/help.c 2010-01-07 19:19:53 UTC (rev 190)
@@ -147,6 +147,15 @@
" ",
"ESC ESC temporarily turns off search highlighting (until next search)",
" ",
+ "Configuration file:",
+ " bviplus will look for your configuration file in $HOME/.bviplusrc",
+ " The configuration file may be used to set the defaul for any parameters which can be changed using the ':set' command",
+ " The format for the configuration file is line separated <option> [= value], just as you would do with :set <option> [= value]",
+ " e.g.",
+ " # Comments begin with a '#' mark",
+ " cols=40",
+ " nohl",
+ " ",
"Running external programs on data sets:",
" (First select 1 or more bytes using visual select)",
" :ex <external program> Run the external program on the visual select data.",
@@ -165,6 +174,15 @@
" :last",
" ",
" alt+<n> Switch to <n>th open file",
+ " ",
+ "Macros:",
+ " Record macros with:",
+ " q<storage key><macro contents>q",
+ " Play macros with:",
+ " @<storage key>",
+ " Valid storage keys are a-z",
+ " If '@' is specified as the storage key when playing back a macro, the last macro played back is played again",
+ " ",
0,
};
Modified: web/documentation.html
===================================================================
--- web/documentation.html 2010-01-07 19:02:00 UTC (rev 189)
+++ web/documentation.html 2010-01-07 19:19:53 UTC (rev 190)
@@ -131,6 +131,15 @@
ESC ESC temporarily turns off search highlighting (until next search)
+ Configuration file:
+ bviplus will look for your configuration file in $HOME/.bviplusrc
+ The configuration file may be used to set the defaul for any parameters which can be changed using the ':set' command
+ The format for the configuration file is line separated <option> [= value], just as you would do with :set <option> [= value]
+ e.g.
+ # Comments begin with a '#' mark
+ cols=40
+ nohl
+
Running external programs on data sets:
(First select 1 or more bytes using visual select)
:ex <external program> Run the external program on the visual select data.
@@ -149,6 +158,15 @@
:last
alt+<n> Switch to <n>th open file",
+
+ Macros:
+ Record macros with:
+ q<storage key><macro contents>q
+ Play macros with:
+ @<storage key>
+ Valid storage keys are a-z
+ If '@' is specified as the storage key when playing back a macro, the last macro played back is played again
+
</pre>
<hr>
<p>Email: <a href="mailto:spa...@us...">spa...@us...</a></p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-07 19:02:07
|
Revision: 189
http://bviplus.svn.sourceforge.net/bviplus/?rev=189&view=rev
Author: spacegctc
Date: 2010-01-07 19:02:00 +0000 (Thu, 07 Jan 2010)
Log Message:
-----------
Add macro support like in vim (record qith q<key>.....q, play with @<key> and @@ to repeat last macro play)
Change the way status messages work. They now display until a new key is pressed. A macro recording message is not sticky in the status bar while the macro is being recorded.
Modified Paths:
--------------
trunk/actions.c
trunk/creadline.c
trunk/display.c
trunk/display.h
trunk/help.c
trunk/key_handler.c
trunk/key_handler.h
trunk/main.c
Modified: trunk/actions.c
===================================================================
--- trunk/actions.c 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/actions.c 2010-01-07 19:02:00 UTC (rev 189)
@@ -854,7 +854,7 @@
mvwprintw(search_window, 1, i, " ");
wattroff(search_window, A_STANDOUT);
mvwprintw(search_window, 2, 1, "Press ESC to cancel search... %3d%%", complete);
- while ((c = wgetch(search_window)) != ERR)
+ while ((c = mwgetch(search_window)) != ERR)
if (c == ESC)
break;
wrefresh(search_window);
Modified: trunk/creadline.c
===================================================================
--- trunk/creadline.c 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/creadline.c 2010-01-07 19:02:00 UTC (rev 189)
@@ -78,7 +78,7 @@
do
{
wrefresh(w);
- c = getch();
+ c = mgetch();
switch(c)
{
case KEY_UP:
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/display.c 2010-01-07 19:02:00 UTC (rev 189)
@@ -31,6 +31,7 @@
#include "user_prefs.h"
#include "app_state.h"
#include "virt_file.h"
+#include "key_handler.h"
#include "search.h"
display_info_t display_info;
@@ -94,9 +95,9 @@
curs_set(0);
wrefresh(msgbox);
- c = wgetch(msgbox);
+ c = mwgetch(msgbox);
while (c != 'y' && c != 'Y' && c != 'n' && c != 'N')
- c = wgetch(msgbox);
+ c = mwgetch(msgbox);
curs_set(1);
delwin(msgbox);
@@ -145,7 +146,7 @@
curs_set(0);
wrefresh(msgbox);
- wgetch(msgbox);
+ mwgetch(msgbox);
curs_set(1);
delwin(msgbox);
print_screen(display_info.page_start);
@@ -211,7 +212,7 @@
curs_set(0);
wrefresh(msgbox);
- wgetch(msgbox);
+ mwgetch(msgbox);
curs_set(1);
delwin(msgbox);
print_screen(display_info.page_start);
@@ -262,12 +263,15 @@
void update_status(const char *msg)
{
if (vf_need_save(current_file) > 0)
- snprintf(display_info.status, MAX_STATUS, "[+]");
- else if (msg != NULL)
- strncpy(display_info.status, msg, MAX_STATUS);
+ snprintf(display_info.status, MAX_STATUS, "[+] ");
else
display_info.status[0] = 0;
+ if (msg != NULL)
+ snprintf(display_info.status_msg, MAX_STATUS, "%s ", msg);
+ else
+ display_info.status_msg[0] = 0;
+
display_info.status[MAX_STATUS-1] = 0;
}
@@ -546,6 +550,9 @@
if (len)
len += snprintf(line+len, MAX_FILE_NAME-len, " ");
len += snprintf(line+len, MAX_FILE_NAME-len, "%s", display_info.status);
+ len += snprintf(line+len, MAX_FILE_NAME-len, "%s", display_info.status_msg);
+ if (macro_key != -1)
+ len += snprintf(line+len, MAX_FILE_NAME-len, "[recording '%c']", macro_key + 'a');
line[MAX_FILE_NAME-1] = 0;
mvwaddstr(window_list[WINDOW_STATUS], 0, 0, line);
Modified: trunk/display.h
===================================================================
--- trunk/display.h 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/display.h 2010-01-07 19:02:00 UTC (rev 189)
@@ -147,6 +147,7 @@
BOOL has_color;
char percent[4];
char status[MAX_STATUS];
+ char status_msg[MAX_STATUS];
} display_info_t;
typedef enum cursor_alignment
Modified: trunk/help.c
===================================================================
--- trunk/help.c 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/help.c 2010-01-07 19:02:00 UTC (rev 189)
@@ -250,7 +250,7 @@
mvwprintw(scrollbox, SCROLL_BOX_H - 2, 1, " [j|DOWN] Down [k|UP] Up [q|ESC] Quit |");
wrefresh(scrollbox);
}
- c = wgetch(scrollbox);
+ c = mwgetch(scrollbox);
} while(c != 'q' && c != ESC);
delwin(scrollbox);
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/key_handler.c 2010-01-07 19:02:00 UTC (rev 189)
@@ -36,6 +36,39 @@
#include "app_state.h"
#include "help.h"
+macro_record_t macro_record[26];
+int macro_key = -1;
+int last_macro_key = -1;
+
+int mwgetch(WINDOW *w)
+{
+ int i, k;
+
+ if (macro_key == -1)
+ return wgetch(w);
+ else
+ {
+ k = wgetch(w);
+ i = macro_record[macro_key].key_index++;
+ macro_record[macro_key].key[i] = k;
+ return k;
+ }
+}
+int mgetch(void)
+{
+ int i, k;
+
+ if (macro_key == -1)
+ return getch();
+ else
+ {
+ k = getch();
+ i = macro_record[macro_key].key_index++;
+ macro_record[macro_key].key[i] = k;
+ return k;
+ }
+}
+
action_code_t show_set(void)
{
action_code_t error = E_SUCCESS;
@@ -214,7 +247,7 @@
mvwprintw(fb, SCROLL_BOX_H - 2, 1, " [j|DOWN] Down [k|UP] Up [ENTER|g] Select [q|ESC] Cancel |");
wrefresh(fb);
}
- c = getch();
+ c = mgetch();
} while(c != ESC && c != 'q' && c != 'Q');
delwin(fb);
@@ -409,11 +442,11 @@
werase(window_list[WINDOW_STATUS]);
mvwprintw(window_list[WINDOW_STATUS], 0, 0, prompt);
wrefresh(window_list[WINDOW_STATUS]);
- c = getch();
+ c = mgetch();
while (c != '/' && c != '\\' && c != ESC)
{
flash();
- c = getch();
+ c = mgetch();
}
prompt[1] = c;
prompt[2] = 0;
@@ -466,7 +499,7 @@
display_info.virtual_cursor_addr = -1;
- c = getch();
+ c = mgetch();
while (c != ESC)
{
if (c >= '0' && c <= '9')
@@ -492,7 +525,7 @@
switch (c)
{
case '`':
- mark = getch();
+ mark = mgetch();
jump_addr = action_get_mark(mark);
action_jump_to(jump_addr, CURSOR_VIRTUAL);
return display_info.virtual_cursor_addr;
@@ -560,7 +593,7 @@
}
flash();
- c = getch();
+ c = mgetch();
}
return display_info.virtual_cursor_addr;
}
@@ -712,7 +745,7 @@
wmove(window_list[WINDOW_HEX], hy, hx);
else
wmove(window_list[WINDOW_ASCII], ay, ax);
- c2 = getch();
+ c2 = mgetch();
switch (c2)
{
case KEY_BACKSPACE:
@@ -905,7 +938,7 @@
{
update_panels();
doupdate();
- c = getch();
+ c = mgetch();
if (c == ESC)
break;
@@ -1052,7 +1085,7 @@
switch (c)
{
case '`':
- mark = getch();
+ mark = mgetch();
jump_addr = action_get_mark(mark);
action_jump_to(jump_addr, CURSOR_REAL);
break;
@@ -1062,12 +1095,58 @@
case '>':
action_blob_shift_right(multiplier);
break;
+ case '@': /* macro playback */
+ {
+ int i, k = getch(); /* do not use mgetch here since we don't want this key if recording a macro */
+
+ if (k == '@')
+ k = last_macro_key;
+
+ if (k < 'a' || k > 'z')
+ break;
+
+ last_macro_key = k;
+
+ k -= 'a';
+
+ if (macro_key != -1)
+ /* Playing one macro inside another --
+ Remove the @ from the key list and allow all the keys from one macro to go into the new one
+ In the future we could use mungetch() which would increment an 'ignore' count, causing mgetch or mwgetch to ignore the keys pushed on to the stack by this macro. Then we could record the @<key> directly into this macro */
+ macro_record[k].key_index--;
+
+ for (i=macro_record[k].key_index-1; i>=0; i--)
+ ungetch(macro_record[k].key[i]);
+
+ break;
+ }
+ case 'q': /* macro record */
+ if (macro_key == -1)
+ {
+ macro_key = getch(); /* don't save the macro-key specifying key */
+ if (macro_key < 'a' || macro_key > 'z')
+ {
+ macro_key = -1;
+ msg_box("Record a macro on keys 'a' through 'z'");
+ }
+ else
+ {
+ macro_key -= 'a';
+ macro_record[macro_key].key_index = 0;
+ }
+ }
+ else
+ {
+ macro_record[macro_key].key_index--; /* don't save the macro-closing 'q' key */
+ macro_key = -1;
+ }
+ break;
case 'm':
- mark = getch();
+ mark = mgetch();
action_set_mark(mark);
break;
case 'g':
- c = getch();
+ c = mgetch();
if (c > '0' && c <= '9')
{
flash();
@@ -1179,7 +1258,7 @@
action_paste_before(multiplier);
break;
case '"':
- mark = getch();
+ mark = mgetch();
action_set_yank_register(mark);
case 'u':
action_undo(multiplier);
Modified: trunk/key_handler.h
===================================================================
--- trunk/key_handler.h 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/key_handler.h 2010-01-07 19:02:00 UTC (rev 189)
@@ -34,7 +34,17 @@
#define TAB 9
#define BVICTRL(n) (n&0x1f)
+typedef struct macro_record_s
+{
+ int key[256];
+ int key_index;
+} macro_record_t;
+extern macro_record_t macro_record[];
+extern int macro_key;
+
+int mwgetch(WINDOW *w);
+int mgetch(void);
void handle_key(int c);
int is_hex(int c);
Modified: trunk/main.c
===================================================================
--- trunk/main.c 2010-01-07 00:03:48 UTC (rev 188)
+++ trunk/main.c 2010-01-07 19:02:00 UTC (rev 189)
@@ -30,6 +30,7 @@
#include <unistd.h> /* usleep */
#include <stdlib.h> /* calloc */
#include <ctype.h> /* isprint */
+#include <string.h> /* memset */
#include "virt_file.h"
#include "key_handler.h"
#include "display.h"
@@ -70,7 +71,8 @@
fprintf(stderr, "Empty file failed?\n");
}
- /* Initialize yank, search, and comand line history support */
+ /* Initialize macros, yank, search, and comand line history support */
+ memset(macro_record, 0, sizeof(macro_record_t) * 26);
action_init_yank();
search_init();
ascii_search_hist = new_history();
@@ -126,7 +128,8 @@
/* Replace the cursor after updating the screen */
place_cursor(display_info.cursor_addr, CALIGN_NONE, CURSOR_REAL);
/* Get and handle the users next key press */
- c = wgetch(window_list[display_info.cursor_window]);
+ c = mwgetch(window_list[display_info.cursor_window]);
+ update_status(NULL);
handle_key(c);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2010-01-07 00:03:59
|
Revision: 188
http://bviplus.svn.sourceforge.net/bviplus/?rev=188&view=rev
Author: spacegctc
Date: 2010-01-07 00:03:48 +0000 (Thu, 07 Jan 2010)
Log Message:
-----------
Add PROFILE option to Makefile for building for gprof
Add support for rc file ($HOME/.bviplusrc)
Modified Paths:
--------------
trunk/Makefile
trunk/key_handler.c
trunk/main.c
trunk/user_prefs.c
trunk/user_prefs.h
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2009-11-07 20:34:48 UTC (rev 187)
+++ trunk/Makefile 2010-01-07 00:03:48 UTC (rev 188)
@@ -42,12 +42,18 @@
EXTRA_CFLAGS :=
+PROFILE ?= 0
+ifneq "$(PROFILE)" "0"
+EXTRA_CFLAGS += -pg
+endif
+
DEBUG ?= 0
ifeq "$(DEBUG)" "0"
EXTRA_CFLAGS += -O2
else
EXTRA_CFLAGS += -O0 -g
endif
+
EXTRA_CFLAGS += $(CFLAGS)
EXTRA_CFLAGS += -Wall -D_FILE_OFFSET_BITS=64
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2009-11-07 20:34:48 UTC (rev 187)
+++ trunk/key_handler.c 2010-01-07 00:03:48 UTC (rev 188)
@@ -90,102 +90,23 @@
action_code_t do_set(void)
{
action_code_t error = E_SUCCESS;
- char *tok, tmp[MAX_CMD_BUF], *ptr;
const char delimiters[] = " =";
- int option, set = 1;
- long value;
+ char *option, *value;
/* process same string as last strtok() call from cmd_parse()*/
- tok = strtok(NULL, delimiters);
+ option = strtok(NULL, delimiters);
+ value = strtok(NULL, delimiters);
- if (tok == NULL)
+ if (option == NULL)
{
error = show_set();
return error;
}
- if (strncmp(tok, "no", 2) == 0)
- {
- tok += 2;
- set = 0;
- }
+ error = set_pref(option, value);
- option = 0;
- while (strncmp(user_prefs[option].name, "", MAX_CMD_BUF))
- {
- if (strncmp(user_prefs[option].name, tok, MAX_CMD_BUF) == 0 ||
- strncmp(user_prefs[option].short_name, tok, MAX_CMD_BUF) == 0)
- {
+ action_do_resize(); /* just in case a display pref was set */
- if (user_prefs[option].flags == P_BOOL)
- {
- tok = strtok(NULL, delimiters);
-
- if (tok == NULL)
- {
- user_prefs[option].value = set;
- }
- else
- {
- strncpy(tmp, tok, MAX_CMD_BUF-1);
- for(ptr=tmp;*ptr;ptr++)
- *ptr=toupper(*ptr);
- if (strncmp("FALSE", tmp, MAX_CMD_BUF) == 0 ||
- strncmp("OFF", tmp, MAX_CMD_BUF) == 0 ||
- strncmp("NO", tmp, MAX_CMD_BUF) == 0)
- set = set == 0 ? 1 : 0;
-
- user_prefs[option].value = set;
- }
-
- break;
- }
-
- if (user_prefs[option].flags == P_INT)
- {
- tok = strtok(NULL, delimiters);
-
- if (tok == NULL)
- {
- msg_box("Not enough parameters to 'set %s', using default value: %d",
- user_prefs[option].name, user_prefs[option].def);
- user_prefs[option].value = user_prefs[option].def;
- break;
- }
-
- value = atol(tok);
-
- if ((value < user_prefs[option].min && user_prefs[option].min) ||
- (value > user_prefs[option].max && user_prefs[option].max))
- {
- msg_box("Value out of range for 'set %s' (min = %d, max = %d)",
- user_prefs[option].name,
- user_prefs[option].min,
- user_prefs[option].max);
- return E_INVALID;
- }
-
- user_prefs[option].value = value;
- break;
- }
-
- }
-
- option++;
-
- }
-
-/******* Print some warnings since this stuff is not tested ******/
- if (strncmp(user_prefs[option].short_name, "grp", MAX_CMD_BUF) == 0)
- msg_box("Warning, grouping other than 1 is experimental!!");
- if (strncmp(user_prefs[option].short_name, "bin", MAX_CMD_BUF) == 0)
- msg_box("Warning, binary display mode is experimental!!");
- if (strncmp(user_prefs[option].short_name, "le", MAX_CMD_BUF) == 0)
- msg_box("Warning, little endian display mode is experimental!!");
-/*****************************************************************/
-
- action_do_resize();
-
return error;
}
Modified: trunk/main.c
===================================================================
--- trunk/main.c 2009-11-07 20:34:48 UTC (rev 187)
+++ trunk/main.c 2010-01-07 00:03:48 UTC (rev 188)
@@ -36,6 +36,7 @@
#include "app_state.h"
#include "actions.h"
#include "creadline.h"
+#include "user_prefs.h"
#define MILISECONDS(x) ((x) * 1000)
#define SECONDS(x) (MILISECONDS(x) * 1000)
@@ -90,6 +91,9 @@
use_default_colors();
init_pair(1, COLOR_YELLOW, -1); /* for blob_grouping */
+ /* Read user rc file and set preferences */
+ read_rc_file();
+
reset_display_info();
app_state.quit = FALSE;
Modified: trunk/user_prefs.c
===================================================================
--- trunk/user_prefs.c 2009-11-07 20:34:48 UTC (rev 187)
+++ trunk/user_prefs.c 2010-01-07 00:03:48 UTC (rev 188)
@@ -23,7 +23,11 @@
*
*************************************************************/
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#include "user_prefs.h"
+#include "creadline.h"
/*------------------------------------------------*/
/* [name] [short_name] [value] [default] [min] [max] [flags]*/
@@ -41,3 +45,138 @@
{ "", "", 0, 0, 0, 0, P_NONE },
};
+action_code_t set_pref(const char *option, const char *value)
+{
+ char tmp[MAX_CMD_BUF], *ptr = NULL;
+ int opt, set = 1;
+ long val = 0;
+
+ if (option == NULL)
+ return E_INVALID;
+
+ if (strncmp(option, "no", 2) == 0)
+ {
+ option += 2;
+ set = 0;
+ }
+
+ opt = 0;
+ while (strncmp(user_prefs[opt].name, "", MAX_CMD_BUF))
+ {
+ if (strncmp(user_prefs[opt].name, option, MAX_CMD_BUF) == 0 ||
+ strncmp(user_prefs[opt].short_name, option, MAX_CMD_BUF) == 0)
+ {
+
+ if (user_prefs[opt].flags == P_BOOL)
+ {
+ if (value == NULL)
+ {
+ user_prefs[opt].value = set;
+ }
+ else
+ {
+ strncpy(tmp, value, MAX_CMD_BUF-1);
+ for(ptr=tmp;*ptr;ptr++)
+ *ptr=toupper(*ptr);
+ if (strncmp("FALSE", tmp, MAX_CMD_BUF) == 0 ||
+ strncmp("OFF", tmp, MAX_CMD_BUF) == 0 ||
+ strncmp("NO", tmp, MAX_CMD_BUF) == 0)
+ set = set == 0 ? 1 : 0;
+
+ user_prefs[opt].value = set;
+ }
+
+ break;
+ }
+
+ if (user_prefs[opt].flags == P_INT)
+ {
+ if (value == NULL)
+ {
+ msg_box("Not enough parameters to 'set %s', using default value: %d",
+ user_prefs[opt].name, user_prefs[opt].def);
+ user_prefs[opt].value = user_prefs[opt].def;
+ break;
+ }
+
+ val = atol(value);
+
+ if ((val < user_prefs[opt].min && user_prefs[opt].min) ||
+ (val > user_prefs[opt].max && user_prefs[opt].max))
+ {
+ msg_box("Value out of range for 'set %s' (min = %d, max = %d)",
+ user_prefs[opt].name,
+ user_prefs[opt].min,
+ user_prefs[opt].max);
+ return E_INVALID;
+ }
+
+ user_prefs[opt].value = val;
+ break;
+ }
+
+ }
+
+ opt++;
+
+ }
+
+/******* Print some warnings since this stuff is not tested ******/
+ if (strncmp(user_prefs[opt].short_name, "grp", MAX_CMD_BUF) == 0)
+ msg_box("Warning, grouping other than 1 is experimental!!");
+ if (strncmp(user_prefs[opt].short_name, "bin", MAX_CMD_BUF) == 0)
+ msg_box("Warning, binary display mode is experimental!!");
+ if (strncmp(user_prefs[opt].short_name, "le", MAX_CMD_BUF) == 0)
+ msg_box("Warning, little endian display mode is experimental!!");
+/*****************************************************************/
+
+ action_do_resize();
+
+ return E_SUCCESS;
+}
+
+void read_rc_file(void)
+{
+ FILE *fp;
+ const char *home;
+ char rcfile[FILENAME_MAX+1];
+ char *line, *option, *value;
+ size_t line_len = 256;
+ int ret = 0;
+ action_code_t error = E_SUCCESS;
+
+ home = getenv("HOME");
+
+ snprintf(rcfile, FILENAME_MAX, "%s/.bviplusrc", home);
+
+ fp = fopen(rcfile, "r");
+ if (fp == NULL)
+ {
+ printf("No rc file found at %s\n", rcfile);
+ return;
+ }
+
+ line = malloc(line_len);
+
+ while (!feof(fp))
+ {
+ ret = getline(&line, &line_len, fp);
+ if (ret > 0)
+ {
+ option = strtok(line, " \t\n=");
+ value = strtok(NULL, " \t\n=");
+ if (option != NULL && option[0] != '#')
+ {
+ error = set_pref(option, value);
+ if (error != E_SUCCESS)
+ printf("Error parsing commands near character %ld in file %s\n",
+ ftell(fp), rcfile);
+ }
+ }
+ }
+
+ free(line);
+ fclose(fp);
+
+}
+
Modified: trunk/user_prefs.h
===================================================================
--- trunk/user_prefs.h 2009-11-07 20:34:48 UTC (rev 187)
+++ trunk/user_prefs.h 2010-01-07 00:03:48 UTC (rev 188)
@@ -25,6 +25,7 @@
*************************************************************/
#include "virt_file.h"
+#include "actions.h"
#ifndef __USER_PREFS_H__
#define __USER_PREFS_H__
@@ -65,5 +66,8 @@
extern user_pref_t user_prefs[];
+action_code_t set_pref(const char *option, const char *value);
+void read_rc_file(void);
+
#endif /* __USER_PREFS_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-07 20:34:58
|
Revision: 187
http://bviplus.svn.sourceforge.net/bviplus/?rev=187&view=rev
Author: spacegctc
Date: 2009-11-07 20:34:48 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
Add GPL to requirements to code
Modified Paths:
--------------
trunk/Makefile
trunk/actions.c
trunk/actions.h
trunk/app_state.c
trunk/app_state.h
trunk/creadline.c
trunk/creadline.h
trunk/display.c
trunk/display.h
trunk/help.c
trunk/help.h
trunk/key_handler.c
trunk/key_handler.h
trunk/main.c
trunk/search.c
trunk/search.h
trunk/user_prefs.c
trunk/user_prefs.h
trunk/vf_backend.c
trunk/vf_backend.h
trunk/virt_file.c
trunk/virt_file.h
Added Paths:
-----------
trunk/COPYING
Added: trunk/COPYING
===================================================================
--- trunk/COPYING (rev 0)
+++ trunk/COPYING 2009-11-07 20:34:48 UTC (rev 187)
@@ -0,0 +1,676 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+
+
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/Makefile 2009-11-07 20:34:48 UTC (rev 187)
@@ -1,3 +1,22 @@
+#
+# Copyright (C) 2009 David Kelley
+#
+# This file is part of bviplus.
+#
+# Bviplus is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Bviplus is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+#
+
TARGET := bviplus
PREFIX ?= /usr/local
Modified: trunk/actions.c
===================================================================
--- trunk/actions.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/actions.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -1,11 +1,28 @@
-/*************************************************************
+/*************************************************************************
*
* File: actions.c
* Author: David Kelley
* Description: Implimentation for most of the actions that
* occur as a result of user input
*
- *************************************************************/
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
+ ************************************************************************/
#include <stdlib.h>
#include <unistd.h>
Modified: trunk/actions.h
===================================================================
--- trunk/actions.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/actions.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines, structures, and function prototypes
* related to program actions
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include "virt_file.h"
Modified: trunk/app_state.c
===================================================================
--- trunk/app_state.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/app_state.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Description: Aplication state variables
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include "virt_file.h"
Modified: trunk/app_state.h
===================================================================
--- trunk/app_state.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/app_state.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Description: Make available aplication state variables
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include "virt_file.h"
Modified: trunk/creadline.c
===================================================================
--- trunk/creadline.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/creadline.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -6,6 +6,23 @@
* similar to gnu realine library but specific
* for ncurses
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <string.h>
Modified: trunk/creadline.h
===================================================================
--- trunk/creadline.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/creadline.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines, structures, and function prototypes
* relates to reading command line input
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <ncurses.h>
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/display.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Functions related to rendering the data on
* the screen
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <string.h>
Modified: trunk/display.h
===================================================================
--- trunk/display.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/display.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines, structures, and functions prototypes
* related to rendering the data on the screen
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <ncurses.h>
Modified: trunk/help.c
===================================================================
--- trunk/help.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/help.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Description: In program help
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <string.h>
Modified: trunk/help.h
===================================================================
--- trunk/help.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/help.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines, structures, and function prototypes
* related to in program help
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#ifndef __HELP_H__
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/key_handler.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Description: Handle key presses and other user input
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <ncurses.h>
Modified: trunk/key_handler.h
===================================================================
--- trunk/key_handler.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/key_handler.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines and function prototypes related to
* user input
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#ifndef __KEY_HANDLER_H__
Modified: trunk/main.c
===================================================================
--- trunk/main.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/main.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Program entry point. Contains initialization,
* main program loop, and termination code.
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <stdio.h>
Modified: trunk/search.c
===================================================================
--- trunk/search.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/search.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Description: Search implimentation
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include <regex.h>
Modified: trunk/search.h
===================================================================
--- trunk/search.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/search.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines, structures, and function prototypes
* related to searching
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include "virt_file.h"
Modified: trunk/user_prefs.c
===================================================================
--- trunk/user_prefs.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/user_prefs.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Description: User preferences and related functions
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include "user_prefs.h"
Modified: trunk/user_prefs.h
===================================================================
--- trunk/user_prefs.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/user_prefs.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -5,6 +5,23 @@
* Description: Defines, structures, and function prototypes
* related to user preferences
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*************************************************************/
#include "virt_file.h"
Modified: trunk/vf_backend.c
===================================================================
--- trunk/vf_backend.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/vf_backend.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Date: 29 Sept, 2008
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
*****************************************************/
/****************
Modified: trunk/vf_backend.h
===================================================================
--- trunk/vf_backend.h 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/vf_backend.h 2009-11-07 20:34:48 UTC (rev 187)
@@ -1,12 +1,41 @@
-#include "virt_file.h"
+/*************************************************************************
+ *
+ * File: vf_backend.h
+ * Author: David Kelley
+ * Description: Defines, structures, and function prototypes
+ * related to the virtual file backend
+ *
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bviplus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with bviplus. If not, see <http://www.gnu.org/licenses/>.
+ *
+ ************************************************************************/
#ifndef __VIRT_FILE_H__
#define __VIRT_FILE_H__
-#define MAP_SIZE_IN_PAGES 1000
-#define MAP_OVERLAP_IN_PAGES 10
+/****************
+ INCLUDES
+ ***************/
+#include "virt_file.h"
+/****************
+ PROTOTYPES
+ ***************/
void cleanup(file_manager_t * f);
inline void compute_percent_complete(off_t offset, off_t size, int *complete);
void mod_start_offset(vbuf_t * vb, off_t shift, BOOL increase);
Modified: trunk/virt_file.c
===================================================================
--- trunk/virt_file.c 2009-11-05 10:18:50 UTC (rev 186)
+++ trunk/virt_file.c 2009-11-07 20:34:48 UTC (rev 187)
@@ -4,6 +4,23 @@
* Author: David Kelley
* Date: 29 Sept, 2008
*
+ * Copyright (C) 2009 David Kelley
+ *
+ * This file is part of bviplus.
+ *
+ * Bviplus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Fr...
[truncated message content] |
|
From: <spa...@us...> - 2009-11-05 10:19:03
|
Revision: 186
http://bviplus.svn.sourceforge.net/bviplus/?rev=186&view=rev
Author: spacegctc
Date: 2009-11-05 10:18:50 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
Based on svn rev #185
A few important changes were supposed to make it into the 0.9 release but were made on the wrong svn branch. This update adds those changes.
- Fix a bug with files > 2GiB that was introduced with the more efficient vf_get_buf()
- Reduce virtual file access when no search term is set
- Fix a compile warning
Revision Links:
--------------
http://bviplus.svn.sourceforge.net/bviplus/?rev=185&view=rev
Added Paths:
-----------
tags/0.9.1/
Property changes on: tags/0.9.1
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-184
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-05 10:07:07
|
Revision: 185
http://bviplus.svn.sourceforge.net/bviplus/?rev=185&view=rev
Author: spacegctc
Date: 2009-11-05 10:07:00 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
These changes were supposed to be on trunk and in the 0.9 release, but were accidentally made on branches/new_search. Merging them in now and will release 0.9.1.
Modified Paths:
--------------
trunk/display.c
trunk/search.c
trunk/vf_backend.c
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/new_search:168-180
+ /branches/new_search:168-184
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2009-11-04 19:13:47 UTC (rev 184)
+++ trunk/display.c 2009-11-05 10:07:00 UTC (rev 185)
@@ -676,7 +676,7 @@
{
int screen_buf_size;
char *screen_buf;
- search_aid_t search_aid;
+ search_aid_t search_aid, *sa_p = NULL;
display_info.page_start = addr;
display_info.page_end = PAGE_END;
@@ -685,11 +685,16 @@
screen_buf = (char *)malloc(screen_buf_size);
vf_get_buf(current_file, screen_buf, addr, screen_buf_size);
- fill_search_buf(addr, screen_buf_size, &search_aid, SEARCH_FORWARD);
+ if (search_item[current_search].used == TRUE)
+ {
+ fill_search_buf(addr, screen_buf_size, &search_aid, SEARCH_FORWARD);
+ sa_p = &search_aid;
+ }
- print_screen_buf(addr, screen_buf, screen_buf_size, &search_aid);
+ print_screen_buf(addr, screen_buf, screen_buf_size, sa_p);
- free_search_buf(&search_aid);
+ if (search_item[current_search].used == TRUE)
+ free_search_buf(&search_aid);
free(screen_buf);
update_file_tabs_window();
Modified: trunk/search.c
===================================================================
--- trunk/search.c 2009-11-04 19:13:47 UTC (rev 184)
+++ trunk/search.c 2009-11-05 10:07:00 UTC (rev 185)
@@ -272,7 +272,6 @@
free_compiled_pattern(cpat);
- search_item[current_search].used = TRUE;
strncpy(search_item[current_search].pattern, pattern, MAX_SEARCH_PAT_LEN);
len = strnlen(pattern, MAX_SEARCH_PAT_LEN);
@@ -482,17 +481,17 @@
if (!is_hex(pattern[i+1]))
{
pat_err("Invalid hex digit",
- pattern, i, MAX_SEARCH_PAT_LEN);
+ pattern, i+1, MAX_SEARCH_PAT_LEN);
search_item[current_search].used = FALSE;
return;
}
str2hex[1] = 0;
str2hex[0] = pattern[i++];
- value = (char)(strtol(str2hex, NULL, 16) & 0xF);
+ value = (char)(strtol((char *)str2hex, NULL, 16) & 0xF);
value = value << 4;
str2hex[0] = pattern[i];
- value |= (char)(strtol(str2hex, NULL, 16) & 0xF);
+ value |= (char)(strtol((char *)str2hex, NULL, 16) & 0xF);
}
if (buildrange)
@@ -538,6 +537,8 @@
cpat->criteria_count++;
}
}
+
+ search_item[current_search].used = TRUE;
}
void search_init(void)
Modified: trunk/vf_backend.c
===================================================================
--- trunk/vf_backend.c 2009-11-04 19:13:47 UTC (rev 184)
+++ trunk/vf_backend.c 2009-11-05 10:07:00 UTC (rev 185)
@@ -797,7 +797,7 @@
switch(vb->buf_type)
{
case TYPE_FILE:
- fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ fseeko(vb->fp, tmp_offset + shift, SEEK_SET);
result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
break;
case TYPE_INSERT: /* no break */
@@ -866,7 +866,7 @@
switch(vb->buf_type)
{
case TYPE_FILE:
- fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ fseeko(vb->fp, tmp_offset + shift, SEEK_SET);
result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
break;
case TYPE_INSERT: /* no break */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-04 19:13:53
|
Revision: 184
http://bviplus.svn.sourceforge.net/bviplus/?rev=184&view=rev
Author: spacegctc
Date: 2009-11-04 19:13:47 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
Based on svn rev #183
- Optimized vf_get_buf to be smart about reading data from virtual file interface, rather than itterating over the range calling vf_get_char
- Reduced access to virtual file by not filling the search buffer when no search term is set
- All new search implimentation.
- Updated documentation to match new search capabilities.
- Search is more robust now and gives meaningful error messages when the search term cannot be compiled
- Doing a standard text search in a 2.2GiB file shows about an order of magnitude speed improvement over old search (thanks in large part to optimized vf_get_buf())
Revision Links:
--------------
http://bviplus.svn.sourceforge.net/bviplus/?rev=183&view=rev
Added Paths:
-----------
tags/0.9/
Property changes on: tags/0.9
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-180
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-04 17:20:24
|
Revision: 183
http://bviplus.svn.sourceforge.net/bviplus/?rev=183&view=rev
Author: spacegctc
Date: 2009-11-04 17:20:10 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
Merge new search features and improved vf_get_buf() implementation from branches/new_search branch
Modified Paths:
--------------
trunk/actions.c
trunk/actions.h
trunk/display.c
trunk/display.h
trunk/help.c
trunk/key_handler.c
trunk/key_handler.h
trunk/search.c
trunk/search.h
trunk/user_prefs.c
trunk/user_prefs.h
trunk/vf_backend.c
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/new_search:168-180
Modified: trunk/actions.c
===================================================================
--- trunk/actions.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/actions.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -857,16 +857,13 @@
{
action_code_t error = E_SUCCESS;
search_aid_t search_aid;
- off_t addr, tmp;
+ off_t addr;
+ int read_size;
pthread_t search_status_thread;
pthread_attr_t attr;
void *pthread_status;
search_thread_data_t search_data;
- addr = display_info.cursor_addr - PAGE_SIZE;
- if (address_invalid(addr))
- addr = 0;
-
search_data.start = display_info.cursor_addr;
search_data.current = display_info.cursor_addr;
search_data.end = 0;
@@ -877,30 +874,39 @@
(void *)&search_data);
pthread_attr_destroy(&attr);
-/* now search past pages */
- while(!address_invalid(addr) && search_data.abort == 0)
+/* now search backwards */
+ addr = display_info.cursor_addr;
+ read_size = LONG_SEARCH_BUF_SIZE;
+ while(!address_invalid(addr) && search_data.abort == 0 && read_size > 0)
{
search_data.current = addr;
- fill_search_buf(addr, PAGE_SIZE, &search_aid);
- do
+ if (address_invalid(addr - read_size))
{
- tmp = search_aid.hl_start;
- buf_search(&search_aid);
- } while (search_aid.hl_start != -1 && search_aid.hl_start < display_info.cursor_addr);
+ read_size = addr;
+ addr = 0;
+ }
+ else
+ {
+ addr -= read_size;
+ }
- if (tmp != -1 && tmp < display_info.cursor_addr)
+ if (read_size != 0)
{
- place_cursor(tmp, CALIGN_NONE, cursor);
- free_search_buf(&search_aid);
- search_data.current = search_data.end;
- pthread_join(search_status_thread, &pthread_status);
- return error;
+ /* overlap with current address already done by fill_search_buf */
+ fill_search_buf(addr, read_size, &search_aid, SEARCH_BACKWARD);
+
+ if (search_aid.hl_start != -1)
+ {
+ place_cursor(search_aid.hl_start, CALIGN_NONE, cursor);
+ free_search_buf(&search_aid);
+ search_data.current = search_data.end;
+ pthread_join(search_status_thread, &pthread_status);
+ return error;
+ }
}
-
free_search_buf(&search_aid);
- addr -= PAGE_SIZE;
}
search_data.current = search_data.end;
@@ -915,10 +921,6 @@
else
msg_box("Beginning of file reached, wrapping");
- addr = display_info.file_size - PAGE_SIZE;
- if (address_invalid(addr))
- addr = 0;
-
search_data.start = display_info.file_size;
search_data.current = display_info.file_size;
search_data.end = display_info.cursor_addr;
@@ -930,28 +932,38 @@
pthread_attr_destroy(&attr);
/* now search future pages */
- while(addr >= display_info.cursor_addr && search_data.abort == 0)
+ addr = display_info.file_size;
+ read_size = LONG_SEARCH_BUF_SIZE;
+ while(addr >= display_info.cursor_addr && search_data.abort == 0 && read_size > 0)
{
search_data.current = addr;
- fill_search_buf(addr, PAGE_SIZE, &search_aid);
- do
+ if ((addr - read_size) < display_info.cursor_addr)
{
- tmp = search_aid.hl_start;
- buf_search(&search_aid);
- } while (search_aid.hl_start != -1);
+ read_size = addr - display_info.cursor_addr;
+ addr = display_info.cursor_addr;
+ }
+ else
+ {
+ addr -= read_size;
+ }
- if (tmp != -1 && tmp >= display_info.cursor_addr)
+ if (read_size != 0)
{
- place_cursor(tmp, CALIGN_NONE, cursor);
- free_search_buf(&search_aid);
- search_data.current = search_data.end;
- pthread_join(search_status_thread, &pthread_status);
- return error;
+ /* overlap with current address already done by fill_search_buf */
+ fill_search_buf(addr, read_size, &search_aid, SEARCH_BACKWARD);
+
+ if (search_aid.hl_start != -1)
+ {
+ place_cursor(search_aid.hl_start, CALIGN_NONE, cursor);
+ free_search_buf(&search_aid);
+ search_data.current = search_data.end;
+ pthread_join(search_status_thread, &pthread_status);
+ return error;
+ }
}
free_search_buf(&search_aid);
- addr -= PAGE_SIZE;
}
search_data.current = search_data.end;
@@ -965,23 +977,29 @@
return error;
}
-action_code_t action_move_cursor_next_search(cursor_t cursor)
+action_code_t action_move_cursor_next_search(cursor_t cursor, BOOL advance_if_current_match)
{
action_code_t error = E_SUCCESS;
search_aid_t search_aid;
off_t addr;
+ int read_size;
pthread_t search_status_thread;
pthread_attr_t attr;
void *pthread_status;
search_thread_data_t search_data;
addr = display_info.cursor_addr;
+ read_size = LONG_SEARCH_BUF_SIZE;
- fill_search_buf(addr, PAGE_SIZE, &search_aid);
+ fill_search_buf(addr, read_size, &search_aid, SEARCH_FORWARD);
-/* first search the current page */
+ /* first search to make sure the overlap doesn't cause a backward cursor jump! */
while (search_aid.hl_start != -1 && search_aid.hl_start <= display_info.cursor_addr)
+ {
+ if (!advance_if_current_match && search_aid.hl_start == display_info.cursor_addr)
+ break;
buf_search(&search_aid);
+ }
if (search_aid.hl_start != -1)
{
@@ -992,7 +1010,7 @@
free_search_buf(&search_aid);
- addr += 2*PAGE_SIZE;
+ addr += read_size;
search_data.start = display_info.cursor_addr;
search_data.current = display_info.cursor_addr;
@@ -1008,7 +1026,7 @@
while(!address_invalid(addr) && search_data.abort == 0)
{
search_data.current = addr;
- fill_search_buf(addr, PAGE_SIZE, &search_aid);
+ fill_search_buf(addr, read_size, &search_aid, SEARCH_FORWARD);
if (search_aid.hl_start != -1)
{
@@ -1020,7 +1038,7 @@
}
free_search_buf(&search_aid);
- addr += 2*PAGE_SIZE;
+ addr += read_size;
}
search_data.current = search_data.end;
@@ -1050,7 +1068,7 @@
while(addr <= display_info.cursor_addr && search_data.abort == 0)
{
search_data.current = addr;
- fill_search_buf(addr, PAGE_SIZE, &search_aid);
+ fill_search_buf(addr, read_size, &search_aid, SEARCH_FORWARD);
if (search_aid.hl_start != -1 && search_aid.hl_start <= display_info.cursor_addr)
{
@@ -1062,7 +1080,7 @@
}
free_search_buf(&search_aid);
- addr += 2*PAGE_SIZE;
+ addr += read_size;
}
search_data.current = search_data.end;
@@ -1075,23 +1093,31 @@
return error;
}
-action_code_t action_do_search(int s, char *cmd, cursor_t cursor)
+
+action_code_t action_do_search(int s, char *cmd, cursor_t cursor, search_direction_t direction)
{
action_code_t error = E_SUCCESS;
+
+ if (s == '/')
+ search_item[current_search].search_window = SEARCH_ASCII;
+ else
+ search_item[current_search].search_window = SEARCH_HEX;
+
set_search_term(cmd);
if (search_item[current_search].used == TRUE)
{
search_item[current_search].highlight = TRUE;
search_item[current_search].color = 1;
- if (s == '/')
- search_item[current_search].search_window = SEARCH_ASCII;
- else
- search_item[current_search].search_window = SEARCH_HEX;
-
print_screen(display_info.page_start);
- action_move_cursor_next_search(cursor);
+ if (user_prefs[SEARCH_IMMEDIATE].value == 1)
+ {
+ if (direction == SEARCH_FORWARD)
+ action_move_cursor_next_search(cursor, FALSE);
+ else
+ action_move_cursor_prev_search(cursor);
+ }
}
return error;
Modified: trunk/actions.h
===================================================================
--- trunk/actions.h 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/actions.h 2009-11-04 17:20:10 UTC (rev 183)
@@ -61,8 +61,9 @@
action_code_t action_visual_select_off(void);
action_code_t action_visual_select_toggle(void);
action_code_t action_move_cursor_prev_search(cursor_t cursor);
-action_code_t action_move_cursor_next_search(cursor_t cursor);
-action_code_t action_do_search(int s, char *cmd, cursor_t cursor);
+action_code_t action_move_cursor_next_search(cursor_t cursor, BOOL advance_if_current_match);
+action_code_t action_do_search(int s, char *cmd, cursor_t cursor,
+ search_direction_t direction);
action_code_t action_search_highlight(void);
action_code_t action_clear_search_highlight(void);
off_t action_get_mark(int m);
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/display.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -91,6 +91,49 @@
return FALSE;
}
+void pat_err(const char *error, const char *pattern, int index, int max_index)
+{
+ WINDOW *msgbox;
+ int pat_len, pat_offset=0, x;
+ char msgbox_line[MAX_MSG_BOX_LEN];
+
+ if (index > max_index)
+ return;
+
+ pat_len = strnlen(pattern, MSG_BOX_W - 6);
+ strncpy(msgbox_line, pattern, MSG_BOX_W - 6);
+
+ if (index > pat_len)
+ {
+ pat_offset = index - ((MSG_BOX_W - 6) / 2);
+ pat_len = strnlen(pattern + pat_offset, MSG_BOX_W - 6);
+ snprintf(msgbox_line, MSG_BOX_W - 6, "...%s", pattern + pat_offset);
+ pat_offset -= 3; /* used next for the '^' marker char, but we must place
+ it 3 chars out for the addition of '...' to the pattern */
+ }
+
+ msgbox = newwin(7, MSG_BOX_W, MSG_BOX_Y, MSG_BOX_X);
+ box(msgbox, 0, 0);
+
+ mvwaddstr(msgbox, 1, 1, "PAT ERR:");
+ mvwaddstr(msgbox, 1, 10, error);
+
+ mvwaddstr(msgbox, 3, 1, msgbox_line);
+ mvwaddstr(msgbox, 4, index - pat_offset + 1, "^");
+
+ memset(msgbox_line, 0, MAX_MSG_BOX_LEN);
+ strncat(msgbox_line, "[PRESS ANY KEY]", MAX_MSG_BOX_LEN);
+ x = ((MSG_BOX_W - 2) - strlen(msgbox_line))/2;
+ mvwaddstr(msgbox, 5, x, msgbox_line);
+
+ curs_set(0);
+ wrefresh(msgbox);
+ wgetch(msgbox);
+ curs_set(1);
+ delwin(msgbox);
+ print_screen(display_info.page_start);
+}
+
void msg_box(const char *fmt, ...)
{
WINDOW *msgbox;
@@ -641,11 +684,13 @@
screen_buf_size = PAGE_END - addr + 1;
screen_buf = (char *)malloc(screen_buf_size);
vf_get_buf(current_file, screen_buf, addr, screen_buf_size);
- fill_search_buf(addr, screen_buf_size, &search_aid);
+ fill_search_buf(addr, screen_buf_size, &search_aid, SEARCH_FORWARD);
+
print_screen_buf(addr, screen_buf, screen_buf_size, &search_aid);
free_search_buf(&search_aid);
+
free(screen_buf);
update_file_tabs_window();
}
Modified: trunk/display.h
===================================================================
--- trunk/display.h 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/display.h 2009-11-04 17:20:10 UTC (rev 183)
@@ -159,6 +159,7 @@
off_t get_addr_from_xy(int x, int y);
void destroy_screen(void);
void create_screen(void);
+void pat_err(const char *error, const char *pattern, int index, int max_index);
void msg_box(const char *fmt, ...);
BOOL msg_prompt(char *fmt, ...);
void reset_display_info(void);
Modified: trunk/help.c
===================================================================
--- trunk/help.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/help.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -66,6 +66,8 @@
" PAGE_UP KEY Page up",
" / Ascii search",
" \\ Hex search",
+ " ?/ Reverse ascii search",
+ " ?\\ Reverse hex search",
" n Next search match",
" N Previous search match",
" ",
@@ -85,6 +87,27 @@
" u Undo",
" U Redo",
" ",
+ "Searching:",
+ " Searching is \"non greedy\", meaning wildcards will match",
+ " the least number of bytes possible",
+ " ",
+ " /<pattern> Ascii search",
+ " \\<pattern> Hex search",
+ " ?/<pattern> Reverse ascii search",
+ " ?\\<pattern> Reverse hex search",
+ " Pattern options:",
+ " \\ Escape the next character (do not interpret as special char)",
+ " . Match any char/byte",
+ " ? Match the previous char/byte none or one times",
+ " * Match the previous char/byte none or more times",
+ " + Match the previous char/byte one or more times",
+ " [<range>] Match any of the chars/bytes in <range>",
+ " [^<range>] Match none of the chars/bytes in <range>",
+ " <range>:",
+ " Specify as list of characters or range with -",
+ " ascii e.g. [abc] or [a-z]",
+ " hex e.g. [04f53b] or [04-5h]",
+ " ",
"Settings:",
" Option Arguments Default Alias Effect",
" ------ --------- ------- ----- ------",
@@ -96,8 +119,9 @@
" :set blob_grouping_offset <0-n> 0 bloboff Highligh offset",
" :set columns <1-n> 0 cols Set the max cols",
" :set search_hl <on|off> on hl Search highlighting",
+ " :set search_immediate <on|off> on si Searching auto matically moves cursor to next match",
" :set ignorecase <on|off> on case Case sensativ search",
- " :set extended_regex <on|off> on eregex Extended expressions",
+ " :set max_match <0-n> 256 mm Maximum search match size (0=no max, bigger=slower)",
" ",
" > Increase blob_grouping_offset",
" < Decrease blob_grouping_offset",
Modified: trunk/key_handler.c
===================================================================
--- trunk/key_handler.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/key_handler.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -22,39 +22,47 @@
action_code_t show_set(void)
{
action_code_t error = E_SUCCESS;
- int i = 0, num_elements = 0, eq_tab = 25, len;
+ int i = 0, num_elements = 0, eq_tab1 = 25, eq_tab2 = 35, len;
char **text;
while (user_prefs[num_elements].flags != P_NONE)
num_elements++;
/* one extra for delimeter */
- text = malloc(sizeof(char *)*(num_elements+1));
+ text = malloc(sizeof(char *)*(num_elements+2));
if (text == NULL)
{
msg_box("Could not allocate memory for display window");
return E_INVALID;
}
+ text[0] = (char *)malloc(256);
+ snprintf(text[0], 256, " [Setting Name] [Alias] [Value]");
+
for(i=0; i<num_elements; i++)
{
- text[i] = (char *)malloc(256);
- snprintf(text[i], 256, " %s", user_prefs[i].name);
- len = strlen(text[i]);
- for (;len<eq_tab;len++)
- snprintf(text[i] + len, 256 - len, " ");
+ text[i+1] = (char *)malloc(256);
+ snprintf(text[i+1], 256, " %s", user_prefs[i].name);
+ len = strlen(text[i+1]);
+ for (;len<eq_tab1;len++)
+ snprintf(text[i+1] + len, 256 - len, " ");
+ snprintf(text[i+1] + len, 256 - len, "%s", user_prefs[i].short_name);
+ len = strlen(text[i+1]);
+ for (;len<eq_tab2;len++)
+ snprintf(text[i+1] + len, 256 - len, " ");
+
if (user_prefs[i].flags == P_INT)
- snprintf(text[i] + len, 256 - len, "= %d",
+ snprintf(text[i+1] + len, 256 - len, "= %d",
user_prefs[i].value);
else if (user_prefs[i].flags == P_BOOL)
- snprintf(text[i] + len, 256 - len, "= %s",
+ snprintf(text[i+1] + len, 256 - len, "= %s",
user_prefs[i].value == TRUE ? "TRUE" : "FALSE");
}
- text[i] = NULL;
+ text[i+1] = NULL;
scrollable_window_display(text);
- for(i=0; i<num_elements; i++)
+ for(i=0; i<num_elements+1; i++)
free(text[i]);
free(text);
@@ -65,7 +73,7 @@
action_code_t do_set(void)
{
action_code_t error = E_SUCCESS;
- char *tok;
+ char *tok, tmp[MAX_CMD_BUF], *ptr;
const char delimiters[] = " =";
int option, set = 1;
long value;
@@ -94,7 +102,25 @@
if (user_prefs[option].flags == P_BOOL)
{
- user_prefs[option].value = set;
+ tok = strtok(NULL, delimiters);
+
+ if (tok == NULL)
+ {
+ user_prefs[option].value = set;
+ }
+ else
+ {
+ strncpy(tmp, tok, MAX_CMD_BUF-1);
+ for(ptr=tmp;*ptr;ptr++)
+ *ptr=toupper(*ptr);
+ if (strncmp("FALSE", tmp, MAX_CMD_BUF) == 0 ||
+ strncmp("OFF", tmp, MAX_CMD_BUF) == 0 ||
+ strncmp("NO", tmp, MAX_CMD_BUF) == 0)
+ set = set == 0 ? 1 : 0;
+
+ user_prefs[option].value = set;
+ }
+
break;
}
@@ -434,22 +460,44 @@
action_code_t do_search(int c, cursor_t cursor)
{
cmd_hist_t *search_hist;
- char *cmd, prompt[2];
+ char *cmd, prompt[3];
+ search_direction_t direction = SEARCH_FORWARD;
+ if (c == '?')
+ {
+ direction = SEARCH_BACKWARD;
+ prompt[0] = c;
+ prompt[1] = 0;
+ werase(window_list[WINDOW_STATUS]);
+ mvwprintw(window_list[WINDOW_STATUS], 0, 0, prompt);
+ wrefresh(window_list[WINDOW_STATUS]);
+ c = getch();
+ while (c != '/' && c != '\\' && c != ESC)
+ {
+ flash();
+ c = getch();
+ }
+ prompt[1] = c;
+ prompt[2] = 0;
+ werase(window_list[WINDOW_STATUS]);
+ }
+ else
+ {
+ prompt[0] = c;
+ prompt[1] = 0;
+ }
+
if (c == '/')
search_hist = ascii_search_hist;
else
search_hist = hex_search_hist;
- prompt[0] = c;
- prompt[1] = 0;
-
werase(window_list[WINDOW_STATUS]);
cmd = creadline(prompt, window_list[WINDOW_STATUS], 0, 0, search_hist);
if (cmd)
{
- action_do_search(c, cmd, cursor);
+ action_do_search(c, cmd, cursor, direction);
free(cmd);
}
@@ -548,7 +596,7 @@
action_cursor_move_page_up(CURSOR_VIRTUAL);
return display_info.virtual_cursor_addr;
case 'n':
- action_move_cursor_next_search(CURSOR_VIRTUAL);
+ action_move_cursor_next_search(CURSOR_VIRTUAL, TRUE);
return display_info.virtual_cursor_addr;
case 'N':
action_move_cursor_prev_search(CURSOR_VIRTUAL);
@@ -556,6 +604,7 @@
case ':':
do_cmd_line(CURSOR_VIRTUAL);
return display_info.virtual_cursor_addr;
+ case '?':
case '/':
case '\\':
do_search(c, CURSOR_VIRTUAL);
@@ -1202,15 +1251,15 @@
action_redo(multiplier);
break;
case 'n':
- action_move_cursor_next_search(CURSOR_REAL);
+ action_move_cursor_next_search(CURSOR_REAL, TRUE);
break;
case 'N':
action_move_cursor_prev_search(CURSOR_REAL);
break;
- case '?':
case ':':
do_cmd_line(CURSOR_REAL);
break;
+ case '?':
case '/':
case '\\':
do_search(c, CURSOR_REAL);
Modified: trunk/key_handler.h
===================================================================
--- trunk/key_handler.h 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/key_handler.h 2009-11-04 17:20:10 UTC (rev 183)
@@ -19,5 +19,6 @@
void handle_key(int c);
+int is_hex(int c);
#endif /* __KEY_HANDLER_H__ */
Modified: trunk/search.c
===================================================================
--- trunk/search.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/search.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -9,23 +9,202 @@
#include <regex.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "search.h"
#include "display.h"
#include "app_state.h"
#include "user_prefs.h"
+#include "key_handler.h" /* for is_hex(), consider moving this func */
search_item_t search_item[MAX_SEARCHES];
int current_search = 0;
-regmatch_t matches[MAX_SEARCH_MATCHES];
+void search_state_reset(search_state_t *search_state)
+{
+ int i;
+ search_state->criteria_index = 0;
+ for (i=0; i<search_item[current_search].compiled_pattern.criteria_count; i++)
+ search_state->match_state[i] = UNFULFILLED;
+}
+int inline matches(unsigned char byte, match_criteria_t *criteria)
+{
+ int i;
+
+ if (search_item[current_search].search_window == SEARCH_ASCII &&
+ user_prefs[IGNORECASE].value != 0)
+ {
+ for (i=0; i<criteria->range_count; i++)
+ {
+ if (toupper(byte) == toupper(criteria->range[i]))
+ return 1;
+ }
+ }
+ else
+ {
+ for (i=0; i<criteria->range_count; i++)
+ {
+ if (byte == criteria->range[i])
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+search_result_t rollback(unsigned char byte, search_state_t *search_state)
+{
+ int i;
+ compiled_pattern_t *cpat = &search_item[current_search].compiled_pattern;
+
+ for (i=search_state->criteria_index-1; i>=0; i--)
+ {
+ if (search_state->match_state[i] == FULFILLED &&
+ cpat->criteria[i]->wildcard == NONE_OR_ONE)
+ {
+ search_state->match_state[i] = UNIQUELY_FULFILLED;
+ return INCOMPLETE_MATCH;
+ }
+
+ if (search_state->match_state[i] != UNIQUELY_FULFILLED)
+ {
+ if (matches(byte, cpat->criteria[i]))
+ {
+ search_state->criteria_index = i+1;
+ /* now try to advance to the next non-wildcard */
+ if (matches(byte, cpat->criteria[i+1]))
+ {
+ search_state->criteria_index = i+2;
+ search_state->match_state[i+1] = UNIQUELY_FULFILLED;
+ }
+
+ return INCOMPLETE_MATCH;
+ }
+
+ search_state->match_state[i] = UNFULFILLED;
+ }
+ }
+
+ return NO_MATCH;
+}
+
+search_result_t feed_search(char byte, search_state_t *search_state)
+{
+ int i;
+ compiled_pattern_t *cpat = &search_item[current_search].compiled_pattern;
+
+ for (i=0; i<=search_state->criteria_index; i++)
+ {
+ if (i >= cpat->criteria_count)
+ return NO_MATCH;
+
+ if (search_state->match_state[i] != UNIQUELY_FULFILLED)
+ {
+ if (matches(byte, cpat->criteria[i]))
+ {
+ /* handle match */
+ if ((i+1) == cpat->criteria_count)
+ return MATCH_FOUND;
+
+ switch (cpat->criteria[i]->wildcard)
+ {
+ case NO_WILDCARD:
+ case ONE_ONLY:
+ search_state->match_state[i] = UNIQUELY_FULFILLED;
+ break;
+ case NONE_OR_ONE:
+ if (search_state->match_state[i] == UNFULFILLED)
+ {
+ search_state->match_state[i] = FULFILLED;
+ if (i == search_state->criteria_index)
+ search_state->criteria_index++; /* check also next criteria since
+ this can be an empty set */
+ }
+ else
+ search_state->match_state[i] = UNIQUELY_FULFILLED;
+ break;
+ case NONE_OR_MORE:
+ search_state->match_state[i] = FULFILLED;
+ if (i == search_state->criteria_index)
+ search_state->criteria_index++; /* check also next criteria since
+ this can be an empty set */
+ break;
+ case ONE_OR_MORE:
+ if (search_state->match_state[i] == FULFILLED)
+ search_state->criteria_index++; /* check also next criteria since
+ this can be an empty set */
+ search_state->match_state[i] = FULFILLED;
+ break;
+ default:
+ return MATCH_ERROR;
+ break;
+ }
+
+ if (i == search_state->criteria_index)
+ {
+ search_state->criteria_index++;
+ return INCOMPLETE_MATCH;
+ }
+
+ }
+ else
+ {
+ /* handle unmatch */
+ switch (cpat->criteria[i]->wildcard)
+ {
+ case NO_WILDCARD:
+ case ONE_ONLY:
+ if (search_state->match_state[i] == UNFULFILLED)
+ return rollback(byte, search_state);
+ break;
+ case NONE_OR_ONE:
+ if (search_state->match_state[i] == UNFULFILLED &&
+ i == search_state->criteria_index)
+ search_state->criteria_index++; /* check also next criteria since
+ this can be an empty set */
+ search_state->match_state[i] = UNIQUELY_FULFILLED;
+ break;
+ case NONE_OR_MORE:
+ search_state->match_state[i] = UNIQUELY_FULFILLED;
+ if (i == search_state->criteria_index)
+ search_state->criteria_index++; /* check also next criteria since
+ this can be an empty set */
+ break;
+ case ONE_OR_MORE:
+ if (search_state->match_state[i] == UNFULFILLED)
+ return rollback(byte, search_state);
+ else
+ {
+ search_state->match_state[i] = UNIQUELY_FULFILLED;
+ if (i == search_state->criteria_index)
+ search_state->criteria_index++; /* check also next criteria since
+ this can be an empty set */
+ }
+ break;
+ default:
+ return MATCH_ERROR;
+ break;
+ }
+
+ }
+ }
+ }
+
+ return INCOMPLETE_MATCH;
+}
+
void buf_search(search_aid_t *search_aid)
{
- int next_search, error, start_remainder, end_remainder;
+ search_state_t search_state;
+ search_result_t result;
+ int start_offset = 0, end_offset = 0;
if (search_aid == NULL)
return;
+ if (search_aid->buf_size < 1)
+ return;
+
if (search_item[current_search].used == FALSE)
{
search_aid->hl_start = -1;
@@ -33,81 +212,332 @@
return;
}
+ if (search_aid->hl_start == -1)
+ start_offset = 0;
+ else
+ start_offset = search_aid->hl_start - search_aid->buf_start_addr + 1;
+
do
{
- if (search_aid->hl_end == -1) /* could wrap! , might not want this */
- next_search = 0;
- else
- next_search = search_aid->hl_start - search_aid->buf_start_addr + 1;
+ end_offset = 0;
+ search_state_reset(&search_state);
+ do
+ {
+ result = feed_search(search_aid->buf[start_offset + end_offset], &search_state);
+ if (result == MATCH_ERROR)
+ {
+ update_status("SEARCH ERROR! BUG?");
+ return;
+ }
+ end_offset++;
+ } while( result == INCOMPLETE_MATCH &&
+ (start_offset + end_offset) < search_aid->buf_size &&
+ (user_prefs[MAX_MATCH].value ?
+ (end_offset - start_offset) < user_prefs[MAX_MATCH].value :
+ 1)
+ );
- if (search_item[current_search].search_window == SEARCH_HEX)
- next_search *= 2;
+ if (result == MATCH_FOUND)
+ {
+ search_aid->hl_start = search_aid->buf_start_addr + start_offset;
+ search_aid->hl_end = search_aid->hl_start + end_offset; /* -1? */
+ }
- error = regexec(&search_item[current_search].compiled,
- search_aid->buf + next_search,
- MAX_SEARCH_MATCHES,
- matches,
- REG_NOTBOL|REG_NOTEOL);
+ start_offset++;
+ } while(result != MATCH_FOUND && start_offset < search_aid->buf_size);
- if (error == REG_NOMATCH)
- {
- search_aid->hl_start = -1;
- search_aid->hl_end = -1;
- }
- else if (search_item[current_search].search_window == SEARCH_HEX)
- {
- search_aid->hl_start = matches[0].rm_so + next_search;
- start_remainder = search_aid->hl_start % 2;
- search_aid->hl_start /= 2;
- search_aid->hl_start += search_aid->buf_start_addr;
- search_aid->hl_end = matches[0].rm_eo + next_search;
- end_remainder = search_aid->hl_end % 2;
- search_aid->hl_end /= 2;
- search_aid->hl_end += search_aid->buf_start_addr;
- }
- else /* search_window == SEARCH_ASCII */
- {
- search_aid->hl_start = search_aid->buf_start_addr + matches[0].rm_so + next_search;
- search_aid->hl_end = search_aid->buf_start_addr + matches[0].rm_eo + next_search;
- start_remainder = 0;
- end_remainder = 0;
- }
- } while ((start_remainder != 0 || end_remainder != 0) && error != REG_NOMATCH);
+ if (result != MATCH_FOUND)
+ {
+ search_aid->hl_start = -1;
+ search_aid->hl_end = -1;
+ }
+
}
+void free_compiled_pattern(compiled_pattern_t *cpat)
+{
+ int i;
+ for (i=0; i<cpat->criteria_count; i++)
+ free(cpat->criteria[i]);
+ cpat->criteria_count = 0;
+}
+
void set_search_term(char *pattern)
{
- int error, len, flags = 0;
- char *error_text;
+ int i, j, k, v, len;
+ match_criteria_t *c = NULL;
+ int escape = 0, buildrange = 0, buildset = 0, not = 0;
+ unsigned char tmp_range[MAX_RANGE_COUNT], str2hex[2], prev_char, value;
+ compiled_pattern_t *cpat = &search_item[current_search].compiled_pattern;
- if (user_prefs[IGNORECASE].value)
- flags |= REG_ICASE;
- if (user_prefs[IGNORECASE].value)
- flags |= REG_EXTENDED;
+ free_compiled_pattern(cpat);
- regfree(&search_item[current_search].compiled);
+ search_item[current_search].used = TRUE;
+ strncpy(search_item[current_search].pattern, pattern, MAX_SEARCH_PAT_LEN);
- error = regcomp(&search_item[current_search].compiled,
- pattern,
- flags);
- if (error)
+ len = strnlen(pattern, MAX_SEARCH_PAT_LEN);
+
+ for (i=0; i<len; i++)
{
- search_item[current_search].used = FALSE;
+ if (!escape)
+ {
+ switch(pattern[i])
+ {
+ case '\\':
+ escape = 1;
+ continue;
+ case '.':
+ if (buildset == 1 || buildrange == 1)
+ {
+ pat_err("Invalid char for set or range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ c = malloc(sizeof(match_criteria_t));
+ c->range_count = MAX_RANGE_COUNT;
+ for (j=0; j<MAX_RANGE_COUNT; j++)
+ c->range[j] = j;
+ c->wildcard = ONE_ONLY;
+ cpat->criteria[cpat->criteria_count] = c;
+ cpat->criteria_count++;
+ continue;
+ case '?':
+ if (buildset == 1 || buildrange == 1)
+ {
+ pat_err("Invalid char for set or range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (c == NULL)
+ {
+ pat_err("? must proceed a valid set or char",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ c->wildcard = NONE_OR_ONE;
+ c = NULL;
+ continue;
+ case '+':
+ if (buildset == 1 || buildrange == 1)
+ {
+ pat_err("Invalid char for set or range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (c == NULL)
+ {
+ pat_err("? must proceed a valid set or char",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ c->wildcard = ONE_OR_MORE;
+ c = NULL;
+ continue;
+ case '*':
+ if (buildset == 1 || buildrange == 1)
+ {
+ pat_err("Invalid char for set or range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (c == NULL)
+ {
+ pat_err("? must proceed a valid set or char",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ c->wildcard = NONE_OR_MORE;
+ c = NULL;
+ continue;
+ case '[':
+ if (buildset == 1 || buildrange == 1)
+ {
+ pat_err("Invalid char for set or range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ buildset = 1;
+ c = malloc(sizeof(match_criteria_t));
+ c->range_count = 0;
+ c->wildcard = ONE_ONLY;
+ cpat->criteria[cpat->criteria_count] = c;
+ cpat->criteria_count++;
+ continue;
+ case ']':
+ if (buildset == 0)
+ {
+ pat_err("No active set",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (buildrange == 1)
+ {
+ pat_err("Invalid char for range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (c->range_count == 0)
+ {
+ pat_err("Empty range invalid",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ buildset = 0;
+ if (not) /* invert the selection */
+ {
+ for(j=0, v=0; j<MAX_RANGE_COUNT; j++)
+ {
+ for(k=0; k<c->range_count; k++)
+ {
+ if (c->range[k] == j)
+ break;
+ }
+ if (k == c->range_count)
+ {
+ tmp_range[v] = j;
+ v++;
+ }
+ }
+ c->range_count = v;
+ memcpy(c->range, tmp_range, v);
+ }
+ continue;
+ case '-':
+ if (buildset == 0)
+ {
+ pat_err("Can only build range within a set",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (buildrange == 1)
+ {
+ pat_err("Already building range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (c == NULL)
+ {
+ pat_err("- must proceed a valid character",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ buildrange = 1;
+ continue;
+ case '^':
+ if (buildset == 0)
+ {
+ pat_err("Can only negate within a set",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (buildrange == 1)
+ {
+ pat_err("Invalid char for range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ not = 1;
+ continue;
+ default:
+ break;
+ }
+ }
- len = regerror(error, &search_item[current_search].compiled, NULL, 0);
- error_text = (char *)malloc(len);
- regerror(error, &search_item[current_search].compiled, error_text, len);
+ value = pattern[i];
- msg_box("Invalid search: \"%s\" %s", pattern, error_text);
+ if (search_item[current_search].search_window == SEARCH_HEX)
+ {
+ if ((i+1) >= len)
+ {
+ pat_err("Hex chars should have two nibbles",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
- free(error_text);
+ if (!is_hex(pattern[i]))
+ {
+ pat_err("Invalid hex digit",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ if (!is_hex(pattern[i+1]))
+ {
+ pat_err("Invalid hex digit",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+
+ str2hex[1] = 0;
+ str2hex[0] = pattern[i++];
+ value = (char)(strtol(str2hex, NULL, 16) & 0xF);
+ value = value << 4;
+ str2hex[0] = pattern[i];
+ value |= (char)(strtol(str2hex, NULL, 16) & 0xF);
+ }
+
+ if (buildrange)
+ {
+ if (c->range_count < 1)
+ {
+ pat_err("Invalid range",
+ pattern, i, MAX_SEARCH_PAT_LEN);
+ search_item[current_search].used = FALSE;
+ return;
+ }
+ prev_char = c->range[c->range_count - 1];
+ if (value > prev_char)
+ {
+ for(j=value; j>prev_char; j--)
+ {
+ c->range[c->range_count] = j;
+ c->range_count++;
+ }
+ }
+ else
+ {
+ for(j=value; j<prev_char; j++)
+ {
+ c->range[c->range_count] = j;
+ c->range_count++;
+ }
+ }
+ buildrange = 0;
+ }
+ else if (buildset)
+ {
+ c->range[c->range_count] = value;
+ c->range_count++;
+ }
+ else /* normal char or escaped special char not in a set/range */
+ {
+ c = malloc(sizeof(match_criteria_t));
+ c->range[0] = value;
+ c->range_count = 1;
+ c->wildcard = ONE_ONLY;
+ cpat->criteria[cpat->criteria_count] = c;
+ cpat->criteria_count++;
+ }
}
- else
- {
- search_item[current_search].used = TRUE;
- strncpy(search_item[current_search].pattern, pattern, MAX_SEARCH_LEN);
- }
}
void search_init(void)
@@ -125,89 +555,75 @@
for (i=0; i<MAX_SEARCHES; i++)
{
if (search_item[i].used == TRUE)
- {
- regfree(&search_item[i].compiled);
- search_item[i].used = FALSE;
- }
+ free_compiled_pattern(&search_item[i].compiled_pattern);
+ search_item[i].used = FALSE;
}
}
-void fill_search_buf(off_t addr, int display_size, search_aid_t *search_aid)
+void fill_search_buf(off_t addr, int display_size, search_aid_t *search_aid, search_direction_t direction)
{
off_t a;
- char *tmp;
- int i, size;
+ search_aid_t tmp_aid;
if (search_aid == NULL)
return;
search_aid->hl_start = -1;
search_aid->hl_end = -1;
- search_aid->remainder = 0;
search_aid->display_addr = addr;
- a = addr - display_size;
+ a = addr - user_prefs[MAX_MATCH].value;
if (address_invalid(a))
a = 0;
search_aid->buf_start_addr = a;
- a = addr + (2*display_size);
+ a = addr + display_size + user_prefs[MAX_MATCH].value;
if (address_invalid(a))
- a = display_info.file_size;
+ a = display_info.file_size - 1;
search_aid->buf_size = a - search_aid->buf_start_addr;
- if (search_item[current_search].search_window == SEARCH_ASCII)
+ search_aid->buf = (char *)malloc(search_aid->buf_size + 1);
+ if (search_aid->buf == NULL)
{
- search_aid->buf = (char *)malloc(search_aid->buf_size + 1);
- vf_get_buf(current_file,
- search_aid->buf,
- search_aid->buf_start_addr,
- search_aid->buf_size);
- search_aid->buf[search_aid->buf_size] = 0;
+ msg_box("Could not allocate memory for search buf");
+ return;
}
- else /* search_window == SEARCH_HEX */
+ vf_get_buf(current_file,
+ search_aid->buf,
+ search_aid->buf_start_addr,
+ search_aid->buf_size);
+
+ tmp_aid = *search_aid;
+
+ buf_search(search_aid); /* find the first valid match in the buffer */
+ while (search_aid->hl_start != -1) /* while we continue to have valid matches */
{
- tmp = (char *)malloc(search_aid->buf_size);
- if (tmp == NULL)
+ if (direction == SEARCH_FORWARD)
{
- msg_box("Could not allocate temporary memory for search buf");
- return;
+ if (search_aid->hl_end >= addr) /* find the first valid match which has an end
+ p oint past the display addr */
+ break;
}
- vf_get_buf(current_file,
- tmp,
- search_aid->buf_start_addr,
- search_aid->buf_size);
- size = search_aid->buf_size;
- search_aid->buf_size *= 2;
- search_aid->buf = (char *)malloc(search_aid->buf_size + 1);
- if (search_aid->buf == NULL)
+ else
{
- free(tmp);
- msg_box("Could not allocate memory for search buf");
- return;
+ if (search_aid->hl_start < (addr + display_size)) /* find the last valid match
+ which has a start point
+ before the display addr */
+ tmp_aid = *search_aid;
+ else
+ break;
}
- search_aid->buf[search_aid->buf_size] = 0;
- for (i=0; i<size; i++)
- {
- search_aid->buf[(2*i) ] = HEX((tmp[i] >> 4) & 0xF);
- search_aid->buf[(2*i)+1] = HEX((tmp[i] >> 0) & 0xF);
- }
- free(tmp);
+
+ buf_search(search_aid); /* if the condition is not met find the next match */
}
- buf_search(search_aid);
- while (search_aid->hl_start != -1)
- {
- if (search_aid->hl_end >= addr)
- break;
+ if (direction == SEARCH_BACKWARD)
+ *search_aid = tmp_aid;
- buf_search(search_aid);
- }
-
}
@@ -220,5 +636,7 @@
return;
free(search_aid->buf);
+
+ search_aid->buf = NULL;
}
Modified: trunk/search.h
===================================================================
--- trunk/search.h 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/search.h 2009-11-04 17:20:10 UTC (rev 183)
@@ -7,15 +7,15 @@
*
*************************************************************/
-#include <regex.h>
#include "virt_file.h"
#ifndef __SEARCH_H__
#define __SEARCH_H__
#define MAX_SEARCHES 8
-#define MAX_SEARCH_LEN 256
-#define MAX_SEARCH_MATCHES 32
+#define MAX_RANGE_COUNT 256
+#define MAX_SEARCH_PAT_LEN 256
+#define LONG_SEARCH_BUF_SIZE (1024*1024*2) /* 2MB */
typedef enum
{
@@ -23,10 +23,59 @@
SEARCH_ASCII
} search_window_t;
+typedef enum
+{
+ SEARCH_BACKWARD,
+ SEARCH_FORWARD
+} search_direction_t;
+
+typedef enum
+{
+ NO_MATCH,
+ INCOMPLETE_MATCH,
+ MATCH_FOUND,
+ MATCH_ERROR
+} search_result_t;
+
+typedef enum
+{
+ NO_WILDCARD,
+ NONE_OR_ONE,
+ NONE_OR_MORE,
+ ONE_OR_MORE,
+ ONE_ONLY
+} wildcard_t;
+
+typedef enum
+{
+ UNFULFILLED,
+ FULFILLED,
+ UNIQUELY_FULFILLED
+} match_state_t;
+
+typedef struct search_state_s
+{
+ int criteria_index;
+ match_state_t match_state[MAX_SEARCH_PAT_LEN];
+} search_state_t;
+
+typedef struct match_criteria_s
+{
+ unsigned char range[256];
+ int range_count;
+ wildcard_t wildcard;
+} match_criteria_t;
+
+typedef struct compiled_pattern_s
+{
+ int criteria_count;
+ match_criteria_t *criteria[MAX_SEARCH_PAT_LEN];
+} compiled_pattern_t;
+
typedef struct search_item_s
{
- char pattern[MAX_SEARCH_LEN];
- regex_t compiled;
+ char pattern[MAX_SEARCH_PAT_LEN];
+ compiled_pattern_t compiled_pattern;
BOOL used;
BOOL highlight;
int color;
@@ -41,7 +90,6 @@
off_t display_addr;
off_t hl_start;
off_t hl_end;
- int remainder;
} search_aid_t;
extern search_item_t search_item[];
@@ -51,7 +99,7 @@
void set_search_term(char *pattern);
void search_init(void);
void search_cleanup(void);
-void fill_search_buf(off_t addr, int display_size, search_aid_t *search_aid);
+void fill_search_buf(off_t addr, int display_size, search_aid_t *search_aid, search_direction_t direction);
void free_search_buf(search_aid_t *search_aid);
#endif /* __SEARCH_H__ */
Modified: trunk/user_prefs.c
===================================================================
--- trunk/user_prefs.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/user_prefs.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -9,7 +9,7 @@
#include "user_prefs.h"
/*------------------------------------------------*/
-/* [name] [short_name] [value] [default] [min] [max] [flags]*/
+/* [name] [short_name] [value] [default] [min] [max] [flags]*/
user_pref_t user_prefs[] = {
{ "binary", "bin", 0, 0, 0, 0, P_BOOL },
{ "little_endian", "le", 0, 0, 0, 0, P_BOOL },
@@ -18,8 +18,9 @@
{ "blob_grouping_offset", "bloboff", 0, 0, 0, 0, P_INT },
{ "columns", "cols", 0, 0, 1, 0, P_INT },
{ "search_hl", "hl", 1, 1, 0, 0, P_BOOL },
- { "ignorecase", "case", 1, 1, 0, 0, P_BOOL },
- { "extended_regex", "eregex", 1, 1, 0, 0, P_BOOL },
+ { "search_immediate", "si", 1, 1, 0, 0, P_BOOL },
+ { "ignorecase", "ic", 0, 0, 0, 0, P_BOOL },
+ { "max_match", "mm", 256, 256, 0, 0, P_INT },
{ "", "", 0, 0, 0, 0, P_NONE },
};
Modified: trunk/user_prefs.h
===================================================================
--- trunk/user_prefs.h 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/user_prefs.h 2009-11-04 17:20:10 UTC (rev 183)
@@ -41,8 +41,9 @@
BLOB_GROUPING_OFFSET,
MAX_COLS,
SEARCH_HL,
+ SEARCH_IMMEDIATE,
IGNORECASE,
- EXTENDED_REGEX
+ MAX_MATCH
} user_pref_e;
extern user_pref_t user_prefs[];
Modified: trunk/vf_backend.c
===================================================================
--- trunk/vf_backend.c 2009-11-04 16:51:29 UTC (rev 182)
+++ trunk/vf_backend.c 2009-11-04 17:20:10 UTC (rev 183)
@@ -766,19 +766,125 @@
---------------------------*/
size_t _get_buf(vbuf_t * vb, char *dest, off_t offset, size_t len)
{
- off_t i;
- char ret = 0;
- size_t ret_sum = 0;
+ vbuf_t *tmp = NULL;
+ off_t tmp_offset = 0, shift = 0;
+ size_t tmp_len = 0, read_len = 0, result = 0;
- for(i = offset; i < offset + len; i++)
+ /* make sure we're still in the buf */
+ if(offset + len > vb->start + vb->size)
+ return 0;
+
+ tmp = vb->first_child;
+ tmp_offset = offset;
+ tmp_len = len;
+
+ while(NULL != tmp && 0 != tmp_len)
{
- *(dest + ret_sum) = _get_char(vb, &ret, offset + ret_sum);
- if(0 == ret)
- return ret_sum;
+ if (tmp->active == 0)
+ {
+ tmp = tmp->next;
+ continue;
+ }
- ret_sum += ret;
+ if(tmp_offset < tmp->start)
+ {
+ if(tmp_offset + tmp_len < tmp->start)
+ read_len = tmp_len;
+ else
+ read_len = tmp->start - tmp_offset;
+
+ /* switch current type and cpy all data */
+ switch(vb->buf_type)
+ {
+ case TYPE_FILE:
+ fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
+ break;
+ case TYPE_INSERT: /* no break */
+ case TYPE_REPLACE:
+ memcpy(dest + len - tmp_len, vb->buf + tmp_offset + shift - vb->start, read_len);
+ result = read_len;
+ break;
+ case TYPE_DELETE: /* no break -- this should not occur */
+ default:
+ return len - tmp_len; /* error */
+ }
+
+ tmp_len -= result;
+ tmp_offset += result;
+ }
+ else if(tmp_offset < tmp->start + tmp->size)
+ {
+ switch (tmp->buf_type)
+ {
+ case TYPE_REPLACE: /* no break */
+ case TYPE_INSERT:
+
+ if (tmp->buf_type == TYPE_INSERT)
+ shift -= tmp->size;
+
+ if(tmp_offset + tmp_len < tmp->start + tmp->size)
+ read_len = tmp_len;
+ else
+ read_len = tmp->start + tmp->size - tmp_offset;
+
+ result = _get_buf(tmp, dest + len - tmp_len, tmp_offset, read_len);
+
+ tmp_len -= result;
+ tmp_offset += result;
+ break;
+ case TYPE_DELETE:
+ shift += tmp->size;
+ break;
+ default:
+ break;
+ }
+ tmp = tmp->next;
+ }
+ else
+ {
+ if (tmp->buf_type == TYPE_INSERT)
+ shift -= tmp->size;
+ else if (tmp->buf_type == TYPE_DELETE)
+ shift += tmp->size;
+
+ tmp = tmp->next;
+ }
}
- return ret_sum;
+ if(0 != tmp_len)
+ {
+ if(tmp_offset < vb->start + vb->size)
+ {
+
+ if(tmp_offset + tmp_len < vb->start + vb->size)
+ read_len = tmp_len;
+ else
+ read_len = vb->start + vb->size - tmp_offset;
+
+ /* switch current type and cpy all data */
+ switch(vb->buf_type)
+ {
+ case TYPE_FILE:
+ fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
+ break;
+ case TYPE_INSERT: /* no break */
+ case TYPE_REPLACE:
+ memcpy(dest + len - tmp_len, vb->buf + tmp_offset + shift - vb->start, read_len);
+ result = read_len;
+ break;
+ case TYPE_DELETE: /* no break -- this should not occur */
+ default:
+ return len - tmp_len; /* error */
+ }
+
+ tmp_len -= result;
+ tmp_offset += result;
+ }
+ }
+
+ return len - tmp_len;
}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-04 16:51:39
|
Revision: 182
http://bviplus.svn.sourceforge.net/bviplus/?rev=182&view=rev
Author: spacegctc
Date: 2009-11-04 16:51:29 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
Revert one hunk from previous commit which was supposed to be for debug but got comitted
Modified Paths:
--------------
branches/new_search/vf_backend.c
Modified: branches/new_search/vf_backend.c
===================================================================
--- branches/new_search/vf_backend.c 2009-11-04 15:56:00 UTC (rev 181)
+++ branches/new_search/vf_backend.c 2009-11-04 16:51:29 UTC (rev 182)
@@ -768,7 +768,7 @@
{
vbuf_t *tmp = NULL;
off_t tmp_offset = 0, shift = 0;
- off_t tmp_len = 0, read_len = 0, result = 0;
+ size_t tmp_len = 0, read_len = 0, result = 0;
/* make sure we're still in the buf */
if(offset + len > vb->start + vb->size)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-04 15:56:08
|
Revision: 181
http://bviplus.svn.sourceforge.net/bviplus/?rev=181&view=rev
Author: spacegctc
Date: 2009-11-04 15:56:00 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
Fix a bug in search where highlighting might be turned on for a partially formed search term when there is a search compile error.
Fix a display problem in the error box displayed when compiling the search term fails because the second nibble in a hex byte is not a valid hex character.
Reduce the amount of vf_get_buf's by not filling the search buffer if search is not being used.
Fix a problem in the new _get_buf() where we used fseek instead of fseeko, so large files were broken!
Modified Paths:
--------------
branches/new_search/display.c
branches/new_search/search.c
branches/new_search/vf_backend.c
Modified: branches/new_search/display.c
===================================================================
--- branches/new_search/display.c 2009-11-03 20:34:37 UTC (rev 180)
+++ branches/new_search/display.c 2009-11-04 15:56:00 UTC (rev 181)
@@ -676,7 +676,7 @@
{
int screen_buf_size;
char *screen_buf;
- search_aid_t search_aid;
+ search_aid_t search_aid, *sa_p = NULL;
display_info.page_start = addr;
display_info.page_end = PAGE_END;
@@ -685,11 +685,16 @@
screen_buf = (char *)malloc(screen_buf_size);
vf_get_buf(current_file, screen_buf, addr, screen_buf_size);
- fill_search_buf(addr, screen_buf_size, &search_aid, SEARCH_FORWARD);
+ if (search_item[current_search].used == TRUE)
+ {
+ fill_search_buf(addr, screen_buf_size, &search_aid, SEARCH_FORWARD);
+ sa_p = &search_aid;
+ }
- print_screen_buf(addr, screen_buf, screen_buf_size, &search_aid);
+ print_screen_buf(addr, screen_buf, screen_buf_size, sa_p);
- free_search_buf(&search_aid);
+ if (search_item[current_search].used == TRUE)
+ free_search_buf(&search_aid);
free(screen_buf);
update_file_tabs_window();
Modified: branches/new_search/search.c
===================================================================
--- branches/new_search/search.c 2009-11-03 20:34:37 UTC (rev 180)
+++ branches/new_search/search.c 2009-11-04 15:56:00 UTC (rev 181)
@@ -272,7 +272,6 @@
free_compiled_pattern(cpat);
- search_item[current_search].used = TRUE;
strncpy(search_item[current_search].pattern, pattern, MAX_SEARCH_PAT_LEN);
len = strnlen(pattern, MAX_SEARCH_PAT_LEN);
@@ -482,17 +481,17 @@
if (!is_hex(pattern[i+1]))
{
pat_err("Invalid hex digit",
- pattern, i, MAX_SEARCH_PAT_LEN);
+ pattern, i+1, MAX_SEARCH_PAT_LEN);
search_item[current_search].used = FALSE;
return;
}
str2hex[1] = 0;
str2hex[0] = pattern[i++];
- value = (char)(strtol(str2hex, NULL, 16) & 0xF);
+ value = (char)(strtol((char *)str2hex, NULL, 16) & 0xF);
value = value << 4;
str2hex[0] = pattern[i];
- value |= (char)(strtol(str2hex, NULL, 16) & 0xF);
+ value |= (char)(strtol((char *)str2hex, NULL, 16) & 0xF);
}
if (buildrange)
@@ -538,6 +537,8 @@
cpat->criteria_count++;
}
}
+
+ search_item[current_search].used = TRUE;
}
void search_init(void)
Modified: branches/new_search/vf_backend.c
===================================================================
--- branches/new_search/vf_backend.c 2009-11-03 20:34:37 UTC (rev 180)
+++ branches/new_search/vf_backend.c 2009-11-04 15:56:00 UTC (rev 181)
@@ -768,7 +768,7 @@
{
vbuf_t *tmp = NULL;
off_t tmp_offset = 0, shift = 0;
- size_t tmp_len = 0, read_len = 0, result = 0;
+ off_t tmp_len = 0, read_len = 0, result = 0;
/* make sure we're still in the buf */
if(offset + len > vb->start + vb->size)
@@ -797,7 +797,7 @@
switch(vb->buf_type)
{
case TYPE_FILE:
- fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ fseeko(vb->fp, tmp_offset + shift, SEEK_SET);
result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
break;
case TYPE_INSERT: /* no break */
@@ -866,7 +866,7 @@
switch(vb->buf_type)
{
case TYPE_FILE:
- fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ fseeko(vb->fp, tmp_offset + shift, SEEK_SET);
result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
break;
case TYPE_INSERT: /* no break */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2009-11-03 20:34:43
|
Revision: 180
http://bviplus.svn.sourceforge.net/bviplus/?rev=180&view=rev
Author: spacegctc
Date: 2009-11-03 20:34:37 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
Increase search buffer size to actually 2MB
Greatly improve the performance of _get_buf()
Modified Paths:
--------------
branches/new_search/search.h
branches/new_search/vf_backend.c
Modified: branches/new_search/search.h
===================================================================
--- branches/new_search/search.h 2009-11-03 13:05:48 UTC (rev 179)
+++ branches/new_search/search.h 2009-11-03 20:34:37 UTC (rev 180)
@@ -15,7 +15,7 @@
#define MAX_SEARCHES 8
#define MAX_RANGE_COUNT 256
#define MAX_SEARCH_PAT_LEN 256
-#define LONG_SEARCH_BUF_SIZE (1024*2) /* 2MB */
+#define LONG_SEARCH_BUF_SIZE (1024*1024*2) /* 2MB */
typedef enum
{
Modified: branches/new_search/vf_backend.c
===================================================================
--- branches/new_search/vf_backend.c 2009-11-03 13:05:48 UTC (rev 179)
+++ branches/new_search/vf_backend.c 2009-11-03 20:34:37 UTC (rev 180)
@@ -766,19 +766,125 @@
---------------------------*/
size_t _get_buf(vbuf_t * vb, char *dest, off_t offset, size_t len)
{
- off_t i;
- char ret = 0;
- size_t ret_sum = 0;
+ vbuf_t *tmp = NULL;
+ off_t tmp_offset = 0, shift = 0;
+ size_t tmp_len = 0, read_len = 0, result = 0;
- for(i = offset; i < offset + len; i++)
+ /* make sure we're still in the buf */
+ if(offset + len > vb->start + vb->size)
+ return 0;
+
+ tmp = vb->first_child;
+ tmp_offset = offset;
+ tmp_len = len;
+
+ while(NULL != tmp && 0 != tmp_len)
{
- *(dest + ret_sum) = _get_char(vb, &ret, offset + ret_sum);
- if(0 == ret)
- return ret_sum;
+ if (tmp->active == 0)
+ {
+ tmp = tmp->next;
+ continue;
+ }
- ret_sum += ret;
+ if(tmp_offset < tmp->start)
+ {
+ if(tmp_offset + tmp_len < tmp->start)
+ read_len = tmp_len;
+ else
+ read_len = tmp->start - tmp_offset;
+
+ /* switch current type and cpy all data */
+ switch(vb->buf_type)
+ {
+ case TYPE_FILE:
+ fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
+ break;
+ case TYPE_INSERT: /* no break */
+ case TYPE_REPLACE:
+ memcpy(dest + len - tmp_len, vb->buf + tmp_offset + shift - vb->start, read_len);
+ result = read_len;
+ break;
+ case TYPE_DELETE: /* no break -- this should not occur */
+ default:
+ return len - tmp_len; /* error */
+ }
+
+ tmp_len -= result;
+ tmp_offset += result;
+ }
+ else if(tmp_offset < tmp->start + tmp->size)
+ {
+ switch (tmp->buf_type)
+ {
+ case TYPE_REPLACE: /* no break */
+ case TYPE_INSERT:
+
+ if (tmp->buf_type == TYPE_INSERT)
+ shift -= tmp->size;
+
+ if(tmp_offset + tmp_len < tmp->start + tmp->size)
+ read_len = tmp_len;
+ else
+ read_len = tmp->start + tmp->size - tmp_offset;
+
+ result = _get_buf(tmp, dest + len - tmp_len, tmp_offset, read_len);
+
+ tmp_len -= result;
+ tmp_offset += result;
+ break;
+ case TYPE_DELETE:
+ shift += tmp->size;
+ break;
+ default:
+ break;
+ }
+ tmp = tmp->next;
+ }
+ else
+ {
+ if (tmp->buf_type == TYPE_INSERT)
+ shift -= tmp->size;
+ else if (tmp->buf_type == TYPE_DELETE)
+ shift += tmp->size;
+
+ tmp = tmp->next;
+ }
}
- return ret_sum;
+ if(0 != tmp_len)
+ {
+ if(tmp_offset < vb->start + vb->size)
+ {
+
+ if(tmp_offset + tmp_len < vb->start + vb->size)
+ read_len = tmp_len;
+ else
+ read_len = vb->start + vb->size - tmp_offset;
+
+ /* switch current type and cpy all data */
+ switch(vb->buf_type)
+ {
+ case TYPE_FILE:
+ fseek(vb->fp, tmp_offset + shift, SEEK_SET);
+ result = fread(dest + len - tmp_len, 1, read_len, vb->fp);
+ break;
+ case TYPE_INSERT: /* no break */
+ case TYPE_REPLACE:
+ memcpy(dest + len - tmp_len, vb->buf + tmp_offset + shift - vb->start, read_len);
+ result = read_len;
+ break;
+ case TYPE_DELETE: /* no break -- this should not occur */
+ default:
+ return len - tmp_len; /* error */
+ }
+
+ tmp_len -= result;
+ tmp_offset += result;
+ }
+ }
+
+ return len - tmp_len;
}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|