[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs buffer.c extras.c qe.c qe.h
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs buffer.c extras.c qe.c qe.h |
Date: |
Sun, 19 Jan 2014 17:25:03 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/01/19 17:25:03
Modified files:
. : buffer.c extras.c qe.c qe.h
Log message:
merge eb_is_blank_line and eb_is_empty_line, simplify paragraph commands
* simplify eb_is_blank_line
* remove eb_is_empty_linek
* simplify paragraph commands with eb_is_blank_line
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/qemacs/extras.c?cvsroot=qemacs&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.129&r2=1.130
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.125&r2=1.126
Patches:
Index: buffer.c
===================================================================
RCS file: /sources/qemacs/qemacs/buffer.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- buffer.c 16 Jan 2014 15:18:44 -0000 1.62
+++ buffer.c 19 Jan 2014 17:25:02 -0000 1.63
@@ -2009,18 +2009,21 @@
return offset;
}
-int eb_is_empty_line(EditBuffer *b, int offset)
+/* test for blank line starting at <offset>.
+ * return 0 if not blank.
+ * return 1 if blank and store start of next line in <*offset1>.
+ */
+int eb_is_blank_line(EditBuffer *b, int offset, int *offset1)
{
int c;
- for (;;) {
- c = eb_nextc(b, offset, &offset);
- if (c == '\n')
- return 1;
- if (!qe_isspace(c))
- break;
- }
+ while ((c = eb_nextc(b, offset, &offset)) != '\n') {
+ if (!qe_isblank(c))
return 0;
+ }
+ if (offset1)
+ *offset1 = offset;
+ return 1;
}
/* return offset of the end of the line containing offset */
Index: extras.c
===================================================================
RCS file: /sources/qemacs/qemacs/extras.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- extras.c 19 Jan 2014 15:33:56 -0000 1.15
+++ extras.c 19 Jan 2014 17:25:02 -0000 1.16
@@ -121,27 +121,6 @@
eb_delete_range(s->b, from, to);
}
-/* test for blank line at offset.
- * return 0 if not blank.
- * return 1 if blank and boundaries in *offset0, *offset1.
- */
-static int eb_is_blank_line(EditBuffer *b, int offset,
- int *offset0, int *offset1)
-{
- int c, bol;
-
- bol = offset = eb_goto_bol(b, offset);
- while ((c = eb_nextc(b, offset, &offset)) != '\n') {
- if (!qe_isblank(c))
- return 0;
- }
- if (offset0)
- *offset0 = bol;
- if (offset1)
- *offset1 = offset;
- return 1;
-}
-
void do_delete_blank_lines(EditState *s)
{
/* Delete blank lines:
@@ -150,15 +129,15 @@
* On nonblank line, delete any immediately following blank lines.
*/
/* XXX: should simplify */
- int from, offset, offset1, all = 0;
+ int from, offset, offset0, offset1, all = 0;
EditBuffer *b = s->b;
- offset = s->offset;
- if (eb_is_blank_line(b, offset, &offset, &offset1)) {
+ offset = eb_goto_bol(b, s->offset);
+ if (eb_is_blank_line(b, offset, &offset1)) {
if ((offset == 0 || !eb_is_blank_line(b,
- eb_prev_line(b, offset), NULL, NULL))
+ eb_prev_line(b, offset), NULL))
&& (offset1 >= b->total_size || !eb_is_blank_line(b,
- offset1, NULL, NULL))) {
+ offset1, NULL))) {
all = 1;
}
} else {
@@ -168,8 +147,10 @@
from = offset;
while (from > 0) {
- if (!eb_is_blank_line(b, eb_prev_line(b, from), &from, NULL))
+ offset0 = eb_prev_line(b, from);
+ if (!eb_is_blank_line(b, offset0, NULL))
break;
+ from = offset0;
}
if (!all) {
eb_delete_range(b, from, offset);
@@ -177,7 +158,7 @@
from = offset = eb_next_line(b, from);
}
while (offset < s->b->total_size) {
- if (!eb_is_blank_line(b, offset, NULL, &offset))
+ if (!eb_is_blank_line(b, offset, &offset))
break;
}
eb_delete_range(b, from, offset);
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -b -r1.129 -r1.130
--- qe.c 18 Jan 2014 14:57:21 -0000 1.129
+++ qe.c 19 Jan 2014 17:25:03 -0000 1.130
@@ -494,7 +494,7 @@
for (;;) {
if (offset >= b->total_size)
break;
- if (eb_is_empty_line(b, offset)) {
+ if (eb_is_blank_line(b, offset, NULL)) {
if (text_found)
break;
} else {
@@ -512,8 +512,7 @@
if (offset <= 0)
break;
/* check if only spaces */
- if (eb_is_empty_line(b, offset)) {
- offset = eb_next_line(b, offset);
+ if (eb_is_blank_line(b, offset, &offset)) {
break;
}
eb_prevc(b, offset, &offset);
@@ -539,7 +538,7 @@
if (offset <= 0)
break;
offset = eb_goto_bol(s->b, offset);
- if (!eb_is_empty_line(s->b, offset))
+ if (!eb_is_blank_line(s->b, offset, NULL))
break;
/* line just before */
eb_prevc(s->b, offset, &offset);
@@ -589,10 +588,10 @@
/* compute indent size */
indent_size = 0;
offset = eb_next_line(s->b, par_start);
- if (!eb_is_empty_line(s->b, offset)) {
+ if (!eb_is_blank_line(s->b, offset, NULL)) {
while (offset < par_end) {
c = eb_nextc(s->b, offset, &offset);
- if (!qe_isspace(c))
+ if (!qe_isblank(c))
break;
indent_size++;
}
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -b -r1.125 -r1.126
--- qe.h 16 Jan 2014 15:18:44 -0000 1.125
+++ qe.h 19 Jan 2014 17:25:03 -0000 1.126
@@ -900,7 +900,7 @@
int eb_prev_line(EditBuffer *b, int offset);
int eb_goto_bol(EditBuffer *b, int offset);
int eb_goto_bol2(EditBuffer *b, int offset, int *countp);
-int eb_is_empty_line(EditBuffer *b, int offset);
+int eb_is_blank_line(EditBuffer *b, int offset, int *offset1);
int eb_goto_eol(EditBuffer *b, int offset);
int eb_next_line(EditBuffer *b, int offset);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs buffer.c extras.c qe.c qe.h,
Charlie Gordon <=