edit_update(fileage, TOP);
- /* make sure word is still mis-spelt (i.e. when multi-errors) */
- if (findnextstr(TRUE, fileage, beginx_top, prevanswer) != NULL)
- {
- do_replace_highlight(TRUE, prevanswer);
+ while (1) {
+
+ /* make sure word is still mis-spelt (i.e. when multi-errors) */
+ if (findnextstr(TRUE, fileage, beginx_top, prevanswer) != NULL) {
+
+ /* find wholewords only */
+ if (!is_whole_word(current_x, current, prevanswer))
+ continue;
+
+ do_replace_highlight(TRUE, prevanswer);
- /* allow replace word to be corrected */
- i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
+ /* allow replace word to be corrected */
+ i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
_("Edit a replacement"));
- do_replace_highlight(FALSE, prevanswer);
+ do_replace_highlight(FALSE, prevanswer);
- /* start from the start of this line again */
- current = fileage;
- current_x = beginx_top;
+ /* start from the start of this line again */
+ current = fileage;
+ current_x = beginx_top;
- search_last_line = FALSE;
+ search_last_line = FALSE;
- if (strcmp(prevanswer,answer) != 0) {
- j = i;
- do_replace_loop(prevanswer, fileage, &beginx_top, TRUE, &j);
+ if (strcmp(prevanswer,answer) != 0) {
+ j = i;
+ do_replace_loop(prevanswer, fileage, &beginx_top, TRUE, &j);
+ }
}
+
+ break;
}
/* restore the search/replace strings */
int open_file(char *filename, int insert, int quiet);
int do_writeout(char *path, int exiting);
int do_gotoline(long defline);
+int is_whole_word(int curr_pos, filestruct *fileptr, char *searchword);
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
int wholewords, int *i);
/* Now in move.c */
}
}
+int is_whole_word(int curr_pos, filestruct *fileptr, char *searchword)
+{
+ /* start of line or previous character not a letter */
+ if ((curr_pos < 1) || (!isalpha((int) fileptr->data[curr_pos-1])))
+
+ /* end of line or next character not a letter */
+ if (((curr_pos + strlen(searchword)) == strlen(fileptr->data))
+ || (!isalpha((int) fileptr->data[curr_pos + strlen(searchword)])))
+
+ return TRUE;
+
+ return FALSE;
+}
+
filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
char *needle)
{
break;
/* Make sure only whole words are found */
- if (wholewords)
- {
- /* start of line or previous character not a letter */
- if ((current_x == 0) || (!isalpha((int) fileptr->data[current_x-1])))
- {
- /* end of line or next character not a letter */
- if (((current_x + strlen(prevanswer)) == strlen(fileptr->data))
- || (!isalpha((int) fileptr->data[current_x + strlen(prevanswer)])))
- ;
- else
- continue;
- }
- else
- continue;
- }
+ if ((wholewords) && (!is_whole_word(current_x, fileptr, prevanswer)))
+ continue;
/* If we're here, we've found the search string */
if (!replaceall) {