[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs bufed.c buffer.c charset.c charsetmore.c...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs bufed.c buffer.c charset.c charsetmore.c... |
Date: |
Tue, 08 Jan 2008 03:42:58 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/01/08 03:42:57
Modified files:
. : bufed.c buffer.c charset.c charsetmore.c
clang.c dired.c image.c input.c latex-mode.c
qe.c qe.h shell.c util.c x11.c
cp : cpdata.txt
libqhtml : css.c cssparse.c xmlparse.c
Log message:
changed API for completion functions:
- use CompleteState struct
- use complete_test for each potential match with simple prefix
comparison
added new smart string compare function qe_collate to sort strings in
lexicographical order but sort numeric portions in numerical order
use qe_collate in popup lists and dired
removed redundant alias "iso8859-2"
added strequal(a,b) as an alias for !strcmp(a,b)
this function makes string collation with strcmp more explicit
this even fixed a spurious bug in do_set_emulation
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/bufed.c?cvsroot=qemacs&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/qemacs/charset.c?cvsroot=qemacs&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/qemacs/charsetmore.c?cvsroot=qemacs&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/qemacs/image.c?cvsroot=qemacs&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/qemacs/input.c?cvsroot=qemacs&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/qemacs/latex-mode.c?cvsroot=qemacs&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/qemacs/x11.c?cvsroot=qemacs&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/qemacs/cp/cpdata.txt?cvsroot=qemacs&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/qemacs/libqhtml/css.c?cvsroot=qemacs&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/qemacs/libqhtml/cssparse.c?cvsroot=qemacs&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/qemacs/libqhtml/xmlparse.c?cvsroot=qemacs&r1=1.16&r2=1.17
Patches:
Index: bufed.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/bufed.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- bufed.c 4 Jan 2008 23:04:11 -0000 1.14
+++ bufed.c 8 Jan 2008 03:42:53 -0000 1.15
@@ -190,7 +190,7 @@
/* if active buffer is found, go directly on it */
for (i = 0; i < bs->items.nb_items; i++) {
- if (!strcmp(bs->items.items[i]->str, b0->name)) {
+ if (strequal(bs->items.items[i]->str, b0->name)) {
e->offset = eb_goto_pos(e->b, i, 0);
break;
}
Index: buffer.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/buffer.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- buffer.c 4 Jan 2008 22:24:38 -0000 1.31
+++ buffer.c 8 Jan 2008 03:42:54 -0000 1.32
@@ -486,7 +486,7 @@
/* add mark move callback */
eb_add_callback(b, eb_offset_callback, &b->mark);
- if (!strcmp(name, "*trace*"))
+ if (strequal(name, "*trace*"))
qs->trace_buffer = b;
return b;
@@ -568,7 +568,7 @@
b = qs->first_buffer;
while (b != NULL) {
- if (!strcmp(b->name, name))
+ if (strequal(b->name, name))
return b;
b = b->next;
}
@@ -593,7 +593,7 @@
b = qs->first_buffer;
while (b != NULL) {
/* XXX: should also use stat to ensure this is same file */
- if (!strcmp(b->filename, filename))
+ if (strequal(b->filename, filename))
return b;
b = b->next;
}
Index: charset.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/charset.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- charset.c 7 Jan 2008 16:25:22 -0000 1.16
+++ charset.c 8 Jan 2008 03:42:54 -0000 1.17
@@ -257,22 +257,22 @@
*pp = charset;
}
-void charset_completion(StringArray *cs, const char *input)
+void charset_completion(CompleteState *cp)
{
QECharset *charset;
char name[32];
const char *p, *q;
for (charset = first_charset; charset != NULL; charset = charset->next) {
- if (strxstart(charset->name, input, NULL))
- add_string(cs, charset->name);
+ if (strxstart(charset->name, cp->current, NULL))
+ add_string(&cp->cs, charset->name);
if (charset->aliases) {
for (q = p = charset->aliases;; q++) {
if (*q == '\0' || *q == '|') {
if (q > p) {
pstrncpy(name, sizeof(name), p, q - p);
- if (strxstart(name, input, NULL))
- add_string(cs, name);
+ if (strxstart(name, cp->current, NULL))
+ add_string(&cp->cs, name);
}
if (*q == '\0')
break;
Index: charsetmore.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/charsetmore.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- charsetmore.c 3 Jan 2008 09:51:30 -0000 1.12
+++ charsetmore.c 8 Jan 2008 03:42:54 -0000 1.13
@@ -47,7 +47,7 @@
static QECharset charset_8859_2 = {
"8859-2",
- "ISO-8859-2|iso-ir-101|latin2|l2|iso-latin2|iso8859-2",
+ "ISO-8859-2|iso-ir-101|latin2|l2|iso-latin2",
decode_8bit_init,
NULL,
encode_8bit,
Index: clang.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/clang.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- clang.c 4 Jan 2008 23:04:11 -0000 1.26
+++ clang.c 8 Jan 2008 03:42:54 -0000 1.27
@@ -479,10 +479,7 @@
}
*q = '\0';
- if (!eoi_found &&
- (!strcmp(buf1, "if") ||
- !strcmp(buf1, "for") ||
- !strcmp(buf1, "while"))) {
+ if (!eoi_found && strfind("if|for|while", buf1)) {
pos = pos1 + s->indent_size;
goto end_parse;
}
Index: dired.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/dired.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- dired.c 4 Jan 2008 23:04:11 -0000 1.18
+++ dired.c 8 Jan 2008 03:42:54 -0000 1.19
@@ -104,11 +104,11 @@
}
}
if (mode & DIRED_SORT_EXTENSION) {
- res = strcmp(extension(dip1->name), extension(dip2->name));
+ res = qe_collate(extension(dip1->name), extension(dip2->name));
if (res)
break;
}
- res = strcmp(dip1->name, dip2->name);
+ res = qe_collate(dip1->name, dip2->name);
break;
}
return (mode & DIRED_SORT_DESCENDING) ? -res : res;
@@ -243,7 +243,7 @@
#if 1 /* CG: bad idea, but causes spurious bugs */
/* exclude redundant '.' and '..' */
- if (!strcmp(p, ".") || !strcmp(p, ".."))
+ if (strequal(p, ".") || strequal(p, ".."))
continue;
#endif
pstrcpy(line, sizeof(line), p);
@@ -526,7 +526,7 @@
/* CG: target file should be an argument to this command */
for (i = 0; i < hs->items.nb_items; i++) {
if (get_dired_filename(e, filename, sizeof(filename), i)
- && !strcmp(filename, b0->filename)) {
+ && strequal(filename, b0->filename)) {
index = i;
break;
}
Index: image.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/image.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- image.c 4 Jan 2008 23:04:11 -0000 1.16
+++ image.c 8 Jan 2008 03:42:55 -0000 1.17
@@ -716,7 +716,7 @@
for (i = 0; i < PIX_FMT_NB; i++) {
name = avcodec_get_pix_fmt_name(i);
- if (!strcmp(name, pix_fmt_str))
+ if (strequal(name, pix_fmt_str))
goto found;
}
put_status(e, "Unknown pixel format");
@@ -786,15 +786,14 @@
return pos;
}
-static void pixel_format_completion(StringArray *cs, const char *input)
+static void pixel_format_completion(CompleteState *cp)
{
int i;
const char *name;
for (i = 0; i < PIX_FMT_NB; i++) {
name = avcodec_get_pix_fmt_name(i);
- if (strstart(name, input, NULL))
- add_string(cs, name);
+ complete_test(cp, name);
}
}
Index: input.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/input.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- input.c 3 Jan 2008 18:31:25 -0000 1.16
+++ input.c 8 Jan 2008 03:42:55 -0000 1.17
@@ -289,13 +289,12 @@
}
#endif
-static void input_completion(StringArray *cs, const char *input)
+static void input_completion(CompleteState *cp)
{
InputMethod *m;
for (m = input_methods; m != NULL; m = m->next) {
- if (strstart(m->name, input, NULL))
- add_string(cs, m->name);
+ complete_test(cp, m->name);
}
}
@@ -304,7 +303,7 @@
InputMethod *m;
for (m = input_methods; m != NULL; m = m->next) {
- if (!strcmp(m->name, name))
+ if (strequal(m->name, name))
return m;
}
return NULL;
Index: latex-mode.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/latex-mode.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- latex-mode.c 7 Jan 2008 16:25:22 -0000 1.25
+++ latex-mode.c 8 Jan 2008 03:42:55 -0000 1.26
@@ -198,13 +198,13 @@
#undef INIT_TAIL
};
-static void latex_completion(StringArray *cs, const char *input)
+static void latex_completion(CompleteState *cp)
{
struct latex_function *func;
for (func = latex_funcs; func->name; func++) {
- if (strxstart(func->name, input, NULL))
- add_string(cs, func->name);
+ if (strxstart(func->name, cp->current, NULL))
+ add_string(&cp->cs, func->name);
}
}
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- qe.c 7 Jan 2008 16:25:22 -0000 1.61
+++ qe.c 8 Jan 2008 03:42:55 -0000 1.62
@@ -110,14 +110,13 @@
}
}
-void mode_completion(StringArray *cs, const char *input)
+void mode_completion(CompleteState *cp)
{
- QEmacsState *qs = &qe_state;
+ QEmacsState *qs = cp->s->qe_state;
ModeDef *m;
for (m = qs->first_mode; m != NULL; m = m->next) {
- if (strstart(m->name, input, NULL))
- add_string(cs, m->name);
+ complete_test(cp, m->name);
}
}
@@ -127,7 +126,7 @@
ModeDef *m;
for (m = qs->first_mode; m != NULL; m = m->next) {
- if (!strcmp(m->name, name))
+ if (strequal(m->name, name))
return m;
}
return NULL;
@@ -143,7 +142,7 @@
d = qs->first_cmd;
while (d != NULL) {
while (d->name != NULL) {
- if (!strcmp(cmd_name, d->name))
+ if (strequal(cmd_name, d->name))
return d;
d++;
}
@@ -281,16 +280,15 @@
}
}
-void command_completion(StringArray *cs, const char *input)
+void command_completion(CompleteState *cp)
{
- QEmacsState *qs = &qe_state;
+ QEmacsState *qs = cp->s->qe_state;
CmdDef *d;
d = qs->first_cmd;
while (d != NULL) {
while (d->name != NULL) {
- if (strstart(d->name, input, NULL))
- add_string(cs, d->name);
+ complete_test(cp, d->name);
d++;
}
d = d->action.next;
@@ -360,13 +358,13 @@
{
QEmacsState *qs = s->qe_state;
- if (!strcmp(name, "epsilon")) {
+ if (strequal(name, "epsilon")) {
qs->flag_split_window_change_focus = 1;
} else
- if (!strcmp(name, "emacs") || !strcmp(name, "xemacs")) {
+ if (strequal(name, "emacs") || strequal(name, "xemacs")) {
qs->flag_split_window_change_focus = 0;
} else
- if (!strcmp(name, "vi") || strcmp(name, "vim")) {
+ if (strequal(name, "vi") || strequal(name, "vim")) {
put_status(s, "emulation '%s' not available yet", name);
} else {
put_status(s, "unknown emulation '%s'", name);
@@ -1952,7 +1950,7 @@
if (s->flags & WF_MODELINE) {
s->mode->mode_line(s, buf, sizeof(buf));
- if (strcmp(buf, s->modeline_shadow) != 0) {
+ if (!strequal(buf, s->modeline_shadow)) {
print_at_byte(s->screen,
s->xleft,
s->ytop + s->height,
@@ -2048,15 +2046,14 @@
apply_style(style, style_index);
}
-void style_completion(StringArray *cs, const char *input)
+void style_completion(CompleteState *cp)
{
int i;
QEStyleDef *style;
for (i = 0; i < QE_STYLE_NB; i++) {
style = &qe_styles[i];
- if (strstart(style->name, input, NULL))
- add_string(cs, style->name);
+ complete_test(cp, style->name);
}
}
@@ -2067,7 +2064,7 @@
for (i = 0; i < QE_STYLE_NB; i++) {
style = &qe_styles[i];
- if (!strcmp(style->name, name))
+ if (strequal(style->name, name))
return style;
}
return NULL;
@@ -2117,9 +2114,10 @@
case 3:
/* XXX: cannot handle inherit correctly */
v = style->font_style;
- if (!strcmp(value, "italic")) {
+ if (strequal(value, "italic")) {
v |= QE_STYLE_ITALIC;
- } else if (!strcmp(value, "normal")) {
+ } else
+ if (strequal(value, "normal")) {
v &= ~QE_STYLE_ITALIC;
}
style->font_style = v;
@@ -2127,15 +2125,16 @@
case 4:
/* XXX: cannot handle inherit correctly */
v = style->font_style;
- if (!strcmp(value, "bold")) {
+ if (strequal(value, "bold")) {
v |= QE_STYLE_BOLD;
- } else if (!strcmp(value, "normal")) {
+ } else
+ if (strequal(value, "normal")) {
v &= ~QE_STYLE_BOLD;
}
style->font_style = v;
break;
case 5:
- if (!strcmp(value, "inherit")) {
+ if (strequal(value, "inherit")) {
style->font_size = 0;
} else {
style->font_size = strtol(value, NULL, 0);
@@ -2143,9 +2142,10 @@
break;
case 6:
/* XXX: cannot handle inherit correctly */
- if (!strcmp(value, "none")) {
+ if (strequal(value, "none")) {
style->font_style &= ~QE_STYLE_UNDERLINE;
- } else if (!strcmp(value, "underline")) {
+ } else
+ if (strequal(value, "underline")) {
style->font_style |= QE_STYLE_UNDERLINE;
}
break;
@@ -3467,10 +3467,10 @@
/* XXX: currently, default input is handled non generically */
def_input[0] = '\0';
es->default_input[0] = '\0';
- if (!strcmp(completion_name, "file")) {
+ if (strequal(completion_name, "file")) {
get_default_path(s, def_input, sizeof(def_input));
} else
- if (!strcmp(completion_name, "buffer")) {
+ if (strequal(completion_name, "buffer")) {
EditBuffer *b;
if (d->action.ESs == do_switch_to_buffer)
b = predict_switch_to_buffer(s);
@@ -4082,7 +4082,7 @@
if (qs->screen->dpy.dpy_init == dummy_dpy_init) {
eb_format_message(qs, "*errors*", buf);
} else {
- if (strcmp(buf, qs->status_shadow) != 0) {
+ if (!strequal(buf, qs->status_shadow)) {
print_at_byte(qs->screen,
0, qs->screen->height - qs->status_height,
qs->screen->width, qs->status_height,
@@ -4276,7 +4276,7 @@
static const char *file_completion_ignore_extensions =
"|bak|bin|dll|exe|o|so|obj|a|gz|tgz";
-void file_completion(StringArray *cs, const char *input)
+void file_completion(CompleteState *cp)
{
FindFileState *ffst;
char path[MAX_FILENAME_SIZE];
@@ -4285,7 +4285,7 @@
const char *base;
int len;
- splitpath(path, sizeof(path), file, sizeof(file), input);
+ splitpath(path, sizeof(path), file, sizeof(file), cp->current);
pstrcat(file, sizeof(file), "*");
ffst = find_file_open(*path ? path : ".", file);
@@ -4295,7 +4295,7 @@
base = basename(filename);
/* ignore . and .. to force direct match if
* single entry in directory */
- if (!strcmp(base, ".") || !strcmp(base, ".."))
+ if (strequal(base, ".") || strequal(base, ".."))
continue;
/* ignore known backup files */
len = strlen(base);
@@ -4310,36 +4310,38 @@
*/
if (!stat(filename, &sb) && S_ISDIR(sb.st_mode))
pstrcat(filename, sizeof(filename), "/");
- add_string(cs, filename);
+ add_string(&cp->cs, filename);
}
find_file_close(ffst);
}
-void buffer_completion(StringArray *cs, const char *input)
+void buffer_completion(CompleteState *cp)
{
- QEmacsState *qs = &qe_state;
+ QEmacsState *qs = cp->s->qe_state;
EditBuffer *b;
for (b = qs->first_buffer; b != NULL; b = b->next) {
- if (!(b->flags & BF_SYSTEM) && strstart(b->name, input, NULL))
- add_string(cs, b->name);
+ if (!(b->flags & BF_SYSTEM))
+ complete_test(cp, b->name);
}
}
/* register a new completion method */
void register_completion(const char *name, CompletionFunc completion_func)
{
+ QEmacsState *qs = &qe_state;
CompletionEntry **lp, *p;
p = qe_malloc(CompletionEntry);
if (!p)
return;
+
p->name = name;
p->completion_func = completion_func;
p->next = NULL;
- lp = &qe_state.first_completion;
+ lp = &qs->first_completion;
while (*lp != NULL)
lp = &(*lp)->next;
*lp = p;
@@ -4350,18 +4352,39 @@
CompletionEntry *p;
if (name[0] != '\0') {
- for (p = qe_state.first_completion; p != NULL; p = p->next)
- if (!strcmp(p->name, name))
+ for (p = qe_state.first_completion; p != NULL; p = p->next) {
+ if (strequal(p->name, name))
return p->completion_func;
}
+ }
return NULL;
}
+static void complete_start(EditState *s, CompleteState *cp)
+{
+ memset(cp, 0, sizeof(*cp));
+ cp->s = s;
+ cp->len = eb_get_contents(s->b, cp->current, sizeof(cp->current) - 1);
+}
+
+void complete_test(CompleteState *cp, const char *str)
+{
+ if (!memcmp(str, cp->current, cp->len))
+ add_string(&cp->cs, str);
+}
+
+static void complete_end(CompleteState *cp)
+{
+ free_strings(&cp->cs);
+}
+
static int completion_sort_func(const void *p1, const void *p2)
{
StringItem *item1 = *(StringItem **)p1;
StringItem *item2 = *(StringItem **)p2;
- return strcmp(item1->str, item2->str);
+
+ /* Use natural sort: keep numbers in order */
+ return qe_collate(item1->str, item2->str);
}
static void (*minibuffer_cb)(void *opaque, char *buf);
@@ -4381,22 +4404,19 @@
void do_completion(EditState *s)
{
QEmacsState *qs = s->qe_state;
- char input[1024];
- int len, count, i, match_len, c;
- StringArray cs;
+ int count, i, match_len, c;
+ CompleteState cs;
StringItem **outputs;
EditState *e;
int w, h, h1, w1;
- if (!completion_function) {
+ if (!completion_function)
return;
- }
- len = eb_get_contents(s->b, input, sizeof(input));
- memset(&cs, 0, sizeof(cs));
- (*completion_function)(&cs, input);
- count = cs.nb_items;
- outputs = cs.items;
+ complete_start(s, &cs);
+ (*completion_function)(&cs);
+ count = cs.cs.nb_items;
+ outputs = cs.cs.items;
#if 0
printf("count=%d\n", count);
for (i = 0; i < count; i++)
@@ -4406,7 +4426,7 @@
if (count == 0)
goto the_end;
/* compute the longest match len */
- match_len = len;
+ match_len = cs.len;
for (;;) {
/* Potential UTF-8 issue: should use utility function */
c = outputs[0]->str[match_len];
@@ -4418,7 +4438,7 @@
match_len++;
}
no_match:
- if (match_len > len) {
+ if (match_len > cs.len) {
/* add the possible chars */
eb_write(s->b, 0, outputs[0]->str, match_len);
s->offset = match_len;
@@ -4458,7 +4478,7 @@
}
}
the_end:
- free_strings(&cs);
+ complete_end(&cs);
}
/* space does completion only if a completion method is defined */
@@ -4483,6 +4503,7 @@
static void set_minibuffer_str(EditState *s, const char *str)
{
int len;
+
eb_delete(s->b, 0, s->b->total_size);
len = strlen(str);
eb_write(s->b, 0, (u8 *)str, len);
@@ -4497,7 +4518,7 @@
if (name[0] == '\0')
return NULL;
for (p = qs->first_history; p != NULL; p = p->next) {
- if (!strcmp(p->name, name))
+ if (strequal(p->name, name))
return &p->history;
}
/* not found: allocate history list */
@@ -4884,7 +4905,7 @@
if (!reply)
return;
- yes_replied = (strcmp(reply, "yes") == 0);
+ yes_replied = strequal(reply, "yes");
qe_free(&reply);
if (!yes_replied)
return;
@@ -6745,7 +6766,7 @@
q++;
}
/* simplistic 1 level if block skip feature */
- if (!strcmp(cmd, "if")) {
+ if (strequal(cmd, "if")) {
if (!expect_token(&p, '('))
goto fail;
skip = !strtol(p, (char**)&p, 0);
@@ -7029,8 +7050,8 @@
p = first_cmd_options;
while (p != NULL) {
while (p->name != NULL) {
- if (!strcmp(p->name, r2) ||
- (p->shortname && !strcmp(p->shortname, r1))) {
+ if (strequal(p->name, r2) ||
+ (p->shortname && strequal(p->shortname, r1))) {
if (p->flags & CMD_OPT_ARG) {
if (_optind >= argc) {
put_status(NULL,
@@ -7368,7 +7389,7 @@
const char *p;
p = basename(argv[0]);
- if (!strcmp(p, "ffplay"))
+ if (strequal(p, "ffplay"))
is_player = 1;
else
is_player = 0;
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- qe.h 7 Jan 2008 16:25:23 -0000 1.57
+++ qe.h 8 Jan 2008 03:42:56 -0000 1.58
@@ -148,6 +148,13 @@
} StringArray;
#define NULL_STRINGARRAY { 0, 0, NULL }
+typedef struct CompleteState {
+ StringArray cs;
+ struct EditState *s;
+ char current[MAX_FILENAME_SIZE];
+ int len;
+} CompleteState;
+
/* media definitions */
#define CSS_MEDIA_TTY 0x0001
#define CSS_MEDIA_SCREEN 0x0002
@@ -227,9 +234,13 @@
return (qe_inrange(c, 'A', 'Z') ? c + 'a' - 'A' : c);
}
+int qe_collate(const char *s1, const char *s2);
void qe_strtolower(char *buf, int buf_size, const char *str);
void skip_spaces(const char **pp);
+static inline int strequal(const char *s1, const char *s2) {
+ return !strcmp(s1, s2);
+}
int strfind(const char *list, const char *s);
int strcasefind(const char *list, const char *s);
const void *memstr(const void *buf, int size, const char *str);
@@ -259,7 +270,7 @@
int strtokeys(const char *keystr, unsigned int *keys, int max_keys);
void keytostr(char *buf, int buf_size, int key);
int to_hex(int key);
-void color_completion(StringArray *cs, const char *input);
+void color_completion(CompleteState *cp);
int css_define_color(const char *name, const char *value);
int css_get_color(unsigned int *color_ptr, const char *p);
int css_get_font_family(const char *str);
@@ -451,7 +462,7 @@
int utf8_to_unicode(unsigned int *dest, int dest_length,
const char *str);
-void charset_completion(StringArray *cs, const char *charset_str);
+void charset_completion(CompleteState *cp);
QECharset *find_charset(const char *str);
void charset_decode_init(CharsetDecodeState *s, QECharset *charset);
void charset_decode_close(CharsetDecodeState *s);
@@ -718,6 +729,10 @@
EditBuffer *next; /* next editbuffer in qe_state buffer list */
char name[MAX_BUFFERNAME_SIZE]; /* buffer name */
char filename[MAX_FILENAME_SIZE]; /* file name */
+
+ /* Should keep a stat buffer to check for file type and
+ * asynchronous modifications
+ */
};
/* high level buffer type handling */
@@ -1247,7 +1262,7 @@
{ 0, 0, NULL, { NULL }, CMD_void, 0 }
void qe_register_mode(ModeDef *m);
-void mode_completion(StringArray *cs, const char *input);
+void mode_completion(CompleteState *cp);
void qe_register_cmd_table(CmdDef *cmds, ModeDef *m);
void qe_register_binding(int key, const char *cmd_name,
const char *mode_names);
@@ -1403,7 +1418,7 @@
extern CmdDef minibuffer_commands[];
extern CmdDef less_commands[];
-typedef void (*CompletionFunc)(StringArray *cs, const char *input);
+typedef void (*CompletionFunc)(CompleteState *cp);
typedef struct CompletionEntry {
const char *name;
@@ -1411,15 +1426,17 @@
struct CompletionEntry *next;
} CompletionEntry;
+void complete_test(CompleteState *cp, const char *str);
+
void register_completion(const char *name, CompletionFunc completion_func);
void put_status(EditState *s, const char *fmt, ...) __attr_printf(2,3);
void put_error(EditState *s, const char *fmt, ...) __attr_printf(2,3);
void minibuffer_edit(const char *input, const char *prompt,
StringArray *hist, CompletionFunc completion_func,
void (*cb)(void *opaque, char *buf), void *opaque);
-void command_completion(StringArray *cs, const char *input);
-void file_completion(StringArray *cs, const char *input);
-void buffer_completion(StringArray *cs, const char *input);
+void command_completion(CompleteState *cp);
+void file_completion(CompleteState *cp);
+void buffer_completion(CompleteState *cp);
#ifdef WIN32
static inline int is_user_input_pending(void) {
@@ -1475,9 +1492,11 @@
void do_switch_to_buffer(EditState *s, const char *bufname);
void do_break(EditState *s);
void do_insert_file(EditState *s, const char *filename);
+// should take argument?
void do_save_buffer(EditState *s);
void do_write_file(EditState *s, const char *filename);
void do_write_region(EditState *s, const char *filename);
+// should take argument?
void do_isearch(EditState *s, int dir);
void do_query_replace(EditState *s, const char *search_str,
const char *replace_str);
@@ -1581,7 +1600,7 @@
void do_set_indent_tabs_mode(EditState *s, int mode);
void display_window_borders(EditState *e);
QEStyleDef *find_style(const char *name);
-void style_completion(StringArray *cs, const char *input);
+void style_completion(CompleteState *cp);
void do_define_color(EditState *e, const char *name, const char *value);
void do_set_style(EditState *e, const char *stylestr,
const char *propstr, const char *value);
Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- shell.c 4 Jan 2008 23:04:11 -0000 1.39
+++ shell.c 8 Jan 2008 03:42:56 -0000 1.40
@@ -1378,7 +1378,7 @@
}
if (line_num >= 1) {
if (line_num != last_line_num ||
- strcmp(filename, last_filename) != 0) {
+ !strequal(filename, last_filename)) {
last_line_num = line_num;
pstrcpy(last_filename, sizeof(last_filename), filename);
break;
Index: util.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/util.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- util.c 7 Jan 2008 16:25:23 -0000 1.34
+++ util.c 8 Jan 2008 03:42:56 -0000 1.35
@@ -30,7 +30,7 @@
if (pattern[0] == '*')
return 0;
else
- return strcmp(pattern, string) != 0;
+ return !strequal(pattern, string);
}
#else
@@ -390,6 +390,40 @@
pstrcpy(filename, filename_size, base);
}
+/* smart compare strings, lexicographical order, but collate numbers in
+ * numeric order */
+int qe_collate(const char *s1, const char *s2)
+{
+ int last, c1, c2, res, flags;
+
+ last = '\0';
+ for (;;) {
+ c1 = (unsigned char)*s1++;
+ c2 = (unsigned char)*s2++;
+ if (c1 == c2) {
+ last = c1;
+ if (c1 == '\0')
+ return 0;
+ } else {
+ break;
+ }
+ }
+ res = (c1 < c2) ? -1 : 1;
+ for (;;) {
+ flags = qe_isdigit(c1) * 2 + qe_isdigit(c2);
+ if (flags == 3) {
+ last = c1;
+ c1 = (unsigned char)*s1++;
+ c2 = (unsigned char)*s2++;
+ } else {
+ break;
+ }
+ }
+ if (!qe_isdigit(last) || flags == 0)
+ return res;
+ return (flags == 1) ? -1 : 1;
+}
+
/* Should return int, length of converted string? */
void qe_strtolower(char *buf, int size, const char *str)
{
@@ -691,7 +725,7 @@
return val;
s = s1 + 1;
} else {
- if (!strcmp(s, str))
+ if (strequal(s, str))
return val;
else
break;
@@ -922,7 +956,7 @@
static ColorDef *custom_colors;
static int nb_custom_colors;
-void color_completion(StringArray *cs, const char *input)
+void color_completion(CompleteState *cp)
{
ColorDef const *def;
int count;
@@ -934,8 +968,8 @@
count = nb_css_colors;
}
while (count > 0) {
- if (strxstart(def->name, input, NULL))
- add_string(cs, def->name);
+ if (strxstart(def->name, cp->current, NULL))
+ add_string(&cp->cs, def->name);
def++;
count--;
}
Index: x11.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/x11.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- x11.c 4 Jan 2008 22:24:40 -0000 1.21
+++ x11.c 8 Jan 2008 03:42:56 -0000 1.22
@@ -726,13 +726,13 @@
get_entry(NULL, 0, &p);
get_entry(NULL, 0, &p); /* family */
get_entry(buf, sizeof(buf), &p); /* weight */
- if (!((!strcmp(buf, "bold") && (style & QE_STYLE_BOLD)) ||
- (!strcmp(buf, "medium") && !(style & QE_STYLE_BOLD))))
+ if (!((strequal(buf, "bold") && (style & QE_STYLE_BOLD)) ||
+ (strequal(buf, "medium") && !(style & QE_STYLE_BOLD))))
dist += 3;
get_entry(buf, sizeof(buf), &p); /* slant */
- if (!((!strcmp(buf, "o") && (style & QE_STYLE_ITALIC)) ||
- (!strcmp(buf, "i") && (style & QE_STYLE_ITALIC)) ||
- (!strcmp(buf, "r") && !(style & QE_STYLE_ITALIC))))
+ if (!((strequal(buf, "o") && (style & QE_STYLE_ITALIC)) ||
+ (strequal(buf, "i") && (style & QE_STYLE_ITALIC)) ||
+ (strequal(buf, "r") && !(style & QE_STYLE_ITALIC))))
dist += 3;
get_entry(NULL, 0, &p); /* swidth */
get_entry(NULL, 0, &p); /* adstyle */
@@ -745,7 +745,7 @@
get_entry(NULL, 0, &p); /* pixsize */
get_entry(NULL, 0, &p); /* pixsize */
/* always favor unicode encoding */
- if (strcmp(p, "iso10646-1") != 0)
+ if (!strequal(p, "iso10646-1"))
dist += 3;
if (dist < dist_min) {
Index: cp/cpdata.txt
===================================================================
RCS file: /cvsroot/qemacs/qemacs/cp/cpdata.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cp/cpdata.txt 3 Jan 2008 09:51:32 -0000 1.5
+++ cp/cpdata.txt 8 Jan 2008 03:42:57 -0000 1.6
@@ -10,7 +10,7 @@
[8859-2]
ISO 8859-2 (Central European)
-"ISO-8859-2", "8859-2", "iso-ir-101", "latin2", "l2","iso-latin2", "iso8859-2"
+"ISO-8859-2", "8859-2", "iso-ir-101", "latin2", "l2","iso-latin2"
include 8859-2.TXT
[8859-3]
Index: libqhtml/css.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/libqhtml/css.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- libqhtml/css.c 7 Jan 2008 16:25:23 -0000 1.16
+++ libqhtml/css.c 8 Jan 2008 03:42:57 -0000 1.17
@@ -305,7 +305,7 @@
pp = &hash_ident[hash_str(str, CSS_IDENT_HASH_SIZE)];
p = *pp;
while (p != NULL) {
- if (!strcmp(str, p->str)) {
+ if (strequal(str, p->str)) {
return p->id;
}
p = p->hash_next;
Index: libqhtml/cssparse.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/libqhtml/cssparse.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- libqhtml/cssparse.c 7 Jan 2008 16:25:23 -0000 1.14
+++ libqhtml/cssparse.c 8 Jan 2008 03:42:57 -0000 1.15
@@ -266,7 +266,7 @@
p++;
goto next;
}
- if (!strcmp(def->name, property))
+ if (strequal(def->name, property))
break;
def++;
}
@@ -343,13 +343,13 @@
unit = CSS_UNIT_NONE;
if (type & CSS_TYPE_AUTO) {
- if (!strcmp(buf, "auto")) {
+ if (strequal(buf, "auto")) {
val = CSS_AUTO;
goto got_val;
}
}
if (!(type & CSS_TYPE_NOINHERIT)) {
- if (!strcmp(buf, "inherit")) {
+ if (strequal(buf, "inherit")) {
val = CSS_INHERIT;
goto got_val;
}
Index: libqhtml/xmlparse.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/libqhtml/xmlparse.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- libqhtml/xmlparse.c 7 Jan 2008 16:25:23 -0000 1.16
+++ libqhtml/xmlparse.c 8 Jan 2008 03:42:57 -0000 1.17
@@ -64,7 +64,7 @@
name = e->name;
if (!name)
break;
- if (!strcmp(str, name))
+ if (strequal(str, name))
return e->val;
e++;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs bufed.c buffer.c charset.c charsetmore.c...,
Charlie Gordon <=