[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs buffer.c extras.c hex.c html.c qe.c qe.h
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs buffer.c extras.c hex.c html.c qe.c qe.h |
Date: |
Sun, 20 Apr 2008 12:01:34 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/04/20 12:01:34
Modified files:
. : buffer.c extras.c hex.c html.c qe.c qe.h
Log message:
better separation of function pointers and void*
use CmdFunc typedef for generic command function pointers
no longer use \e for escape use \033 instead
use memcpy trick to prevent gcc warning on dlsym in -pedantic mode
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/qemacs/extras.c?cvsroot=qemacs&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/qemacs/hex.c?cvsroot=qemacs&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/qemacs/html.c?cvsroot=qemacs&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.86&r2=1.87
Patches:
Index: buffer.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/buffer.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- buffer.c 15 Apr 2008 23:24:03 -0000 1.40
+++ buffer.c 20 Apr 2008 12:01:34 -0000 1.41
@@ -825,7 +825,7 @@
if (!b->log_buffer)
return;
- if (s->qe_state->last_cmd_func != do_undo)
+ if (s->qe_state->last_cmd_func != (CmdFunc)do_undo)
b->log_current = 0;
if (b->log_current == 0) {
Index: extras.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/extras.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- extras.c 18 Apr 2008 14:39:08 -0000 1.4
+++ extras.c 20 Apr 2008 12:01:34 -0000 1.5
@@ -48,7 +48,7 @@
size1 = s1->b->total_size;
size2 = s2->b->total_size;
- if (qs->last_cmd_func == do_compare_windows
+ if (qs->last_cmd_func == (CmdFunc)do_compare_windows
&& (eb_nextc(s1->b, s1->offset, &offset1) !=
eb_nextc(s2->b, s2->offset, &offset2))) {
/* Try to resync: just skip in parallel */
Index: hex.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/hex.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- hex.c 5 Apr 2008 18:16:30 -0000 1.25
+++ hex.c 20 Apr 2008 12:01:34 -0000 1.26
@@ -202,7 +202,7 @@
c = buf[i];
if (c < 32 &&
(c != '\r' && c != '\n' && c != '\t' &&
- c != '\e' && c != '\b' && c != '\f'))
+ c != '\033' && c != '\b' && c != '\f'))
return 1;
}
return 0;
Index: html.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/html.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- html.c 8 Apr 2008 06:54:44 -0000 1.17
+++ html.c 20 Apr 2008 12:01:34 -0000 1.18
@@ -548,7 +548,7 @@
if (!hs->up_to_date)
return;
- if (s->qe_state->last_cmd_func != do_up_down)
+ if (s->qe_state->last_cmd_func != (CmdFunc)do_up_down)
up_down_last_x = -1;
html_move_up_down1(s, dir, 0);
@@ -837,7 +837,7 @@
c = *p;
if (c == '\0')
break;
- if (c < 32 && (c != '\r' && c != '\n' && c != '\t' && c != '\e'))
+ if (c < 32 && (c != '\r' && c != '\n' && c != '\t' && c != '\033'))
return 0;
if (stristart((const char *)p, "<HTML", NULL))
score = 100;
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- qe.c 19 Apr 2008 09:03:58 -0000 1.86
+++ qe.c 20 Apr 2008 12:01:34 -0000 1.87
@@ -699,7 +699,7 @@
return;
if (argval == NO_ARG) {
- if (s->qe_state->last_cmd_func != do_append_next_kill) {
+ if (s->qe_state->last_cmd_func != (CmdFunc)do_append_next_kill) {
eb_nextc(s->b, s->offset, &offset1);
eb_delete(s->b, s->offset, offset1 - s->offset);
return;
@@ -733,7 +733,7 @@
s->region_style = 0;
if (argval == NO_ARG) {
- if (s->qe_state->last_cmd_func != do_append_next_kill) {
+ if (s->qe_state->last_cmd_func != (CmdFunc)do_append_next_kill) {
eb_prevc(s->b, s->offset, &offset1);
if (offset1 < s->offset) {
s->offset = eb_delete_range(s->b, offset1, s->offset);
@@ -854,7 +854,7 @@
DisplayState ds1, *ds = &ds1;
CursorContext cm;
- if (s->qe_state->last_cmd_func != do_up_down)
+ if (s->qe_state->last_cmd_func != (CmdFunc)do_up_down)
up_down_last_x = -1;
get_cursor_pos(s, &cm);
@@ -1447,7 +1447,7 @@
}
len = p2 - p1;
b = qs->yank_buffers[qs->yank_current];
- if (!b || !dir || qs->last_cmd_func != do_append_next_kill) {
+ if (!b || !dir || qs->last_cmd_func != (CmdFunc)do_append_next_kill) {
/* append kill if last command was kill already */
b = new_yank_buffer(qs);
}
@@ -1456,7 +1456,7 @@
if (dir) {
eb_delete(s->b, p1, len);
s->offset = p1;
- qs->this_cmd_func = do_append_next_kill;
+ qs->this_cmd_func = (CmdFunc)do_append_next_kill;
}
selection_activate(qs->screen);
}
@@ -1524,14 +1524,14 @@
s->offset += size;
}
}
- qs->this_cmd_func = do_yank;
+ qs->this_cmd_func = (CmdFunc)do_yank;
}
void do_yank_pop(EditState *s)
{
QEmacsState *qs = s->qe_state;
- if (qs->last_cmd_func != do_yank) {
+ if (qs->last_cmd_func != (CmdFunc)do_yank) {
put_status(s, "Previous command was not a yank");
return;
}
@@ -1863,6 +1863,7 @@
s->offset = eb_goto_char(s->b, max(0, pos));
return;
case '%':
+ /* CG: should not require long long for this */
pos = pos * (long long)s->b->total_size / 100;
if (rel)
pos += s->offset;
@@ -3488,7 +3489,7 @@
{
switch (sig) {
case CMD_void:
- ((void (*)(void))func.func)();
+ (*func.func)();
break;
case CMD_ES: /* ES, no other arguments */
(*func.ES)(args[0].s);
@@ -4874,7 +4875,7 @@
index = minibuffer_history_index + dir;
if (index < 0 || index >= hist->nb_items)
return;
- if (qs->last_cmd_func != do_history) {
+ if (qs->last_cmd_func != (CmdFunc)do_history) {
/* save currently edited line */
eb_get_contents(s->b, buf, sizeof(buf));
set_string(hist, hist->nb_items - 1, buf);
@@ -7578,9 +7579,9 @@
static void init_all_modules(void)
{
int (*initcall)(void);
- void **ptr;
+ int (**ptr)(void);
- ptr = (void **)(void *)&__initcall_first;
+ ptr = (int (**)(void))(void *)&__initcall_first;
for (;;) {
/* NOTE: if bound checking is on, a '\0' is inserted between
each initialized 'void *' */
@@ -7625,6 +7626,7 @@
FindFileState *ffst;
char filename[MAX_FILENAME_SIZE];
void *h;
+ void *sym;
int (*init_func)(void);
ec = qs->ec;
@@ -7642,7 +7644,20 @@
filename, error);
continue;
}
- init_func = dlsym(h, "__qe_module_init");
+#if 0
+ /* Writing: init_func = (int (*)(void))dlsym(handle, "xxx");
+ * would seem more natural, but the C99 standard leaves
+ * casting from "void *" to a function pointer undefined.
+ * The assignment used below is the POSIX.1-2003 (Technical
+ * Corrigendum 1) workaround; see the Rationale for the
+ * POSIX specification of dlsym().
+ */
+ *(void **)(&init_func) = dlsym(h, "__qe_module_init");
+ //init_func = (int (*)(void))dlsym(h, "__qe_module_init");
+#else
+ sym = dlsym(h, "__qe_module_init");
+ memcpy(&init_func, &sym, sizeof(sym));
+#endif
if (!init_func) {
dlclose(h);
put_status(NULL,
@@ -7652,11 +7667,11 @@
}
/* all is OK: we can init the module now */
- init_func();
+ (*init_func)();
}
find_file_close(ffst);
-done:
+ done:
qs->ec = ec;
}
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- qe.h 18 Apr 2008 16:25:07 -0000 1.86
+++ qe.h 20 Apr 2008 12:01:34 -0000 1.87
@@ -1142,6 +1142,8 @@
int lineno;
} QErrorContext;
+typedef void (*CmdFunc)(void);
+
struct QEmacsState {
QEditScreen *screen;
//struct QEDisplay *first_dpy;
@@ -1187,8 +1189,8 @@
int flag_split_window_change_focus;
int backspace_is_control_h;
/* XXX: move these to ec */
- void *last_cmd_func; /* last executed command function call */
- void *this_cmd_func; /* current executing command */
+ CmdFunc last_cmd_func; /* last executed command function call */
+ CmdFunc this_cmd_func; /* current executing command */
/* keyboard macros */
int defining_macro;
int executing_macro;
@@ -1270,7 +1272,7 @@
} CmdArg;
typedef union CmdProto {
- void *func;
+ void (*func)(void);
void (*ES)(EditState *);
void (*ESi)(EditState *, int);
void (*ESs)(EditState *, const char *);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs buffer.c extras.c hex.c html.c qe.c qe.h,
Charlie Gordon <=