qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.c qe.h shell.c tty.c util.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c qe.h shell.c tty.c util.c
Date: Sat, 09 Dec 2006 19:47:20 +0000

CVSROOT:        /cvsroot/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        06/12/09 19:47:20

Modified files:
        .              : qe.c qe.h shell.c tty.c util.c 

Log message:
        added missing licence header
        fixed typos
        added constness
        comments about potential problems
        identified 64 bit portability problem
        fixed small issue in get_default_path()
        allow signed numbers in config file
        added comments about old code for reference (tty.c, shell.c)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.13&r2=1.14

Patches:
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- qe.c        27 Apr 2006 15:22:26 -0000      1.27
+++ qe.c        9 Dec 2006 19:47:20 -0000       1.28
@@ -1126,7 +1126,7 @@
         return 0;
 }
 
-/* XXX: would need two pass in the general case (first search line,
+/* XXX: would need two passes in the general case (first search line,
    then colunm */
 static int mouse_goto_func(DisplayState *ds,
                            int offset1, int offset2, int line_num,
@@ -3147,6 +3147,14 @@
    - void (*)(EditState *, const char *, const char *); (6)
    - void (*)(EditState *, const char *, const char *, const char *); (2)
 */
+/* FIXME: fix this for 64 bit architectures where
+ * sizeof(void*) != sizeof(int)
+ * First argument is always EditState*, handling all P / I combinations
+ * requires 1 + 2 + 4 + 8 + 16 = 31 cases of which only 7 are used.
+ * long arguments would still not be supported if these cannot be
+ * passed as pointers (but long arguments are not supported anyway).
+ * should pass function signature for direct dispatch.
+ */
 void call_func(void *func, int nb_args, void **args, 
                unsigned char *args_type)
 {
@@ -4773,6 +4781,8 @@
     EditState *e;
     EditBuffer *b1;
     
+    // FIXME: used to delete windows containing the buffer ???
+
     /* find a new buffer to switch to */
     for (b1 = qs->first_buffer; b1 != NULL; b1 = b1->next) {
         if (b1 != b && !(b1->flags & BF_SYSTEM))
@@ -4816,7 +4826,7 @@
         filename = s->b->filename;
     }
     canonize_absolute_path(buf1, sizeof(buf1), filename);
-    splitpath(buf, buf_size, NULL, 0, filename);
+    splitpath(buf, buf_size, NULL, 0, buf1);
 }
 
 static ModeDef *probe_mode(EditState *s, int mode, uint8_t *buf, int len)
@@ -5288,7 +5298,7 @@
     va_start(ap, fmt);
     len = vsprintf(q, fmt, ap);
     q += len;
-    *pp = q; ;
+    *pp = q;
     va_end(ap);
 }
 
@@ -5464,6 +5474,15 @@
     default:
         if (KEY_SPECIAL(ch)) {
             /* exit search mode */
+#if 0
+            // FIXME: behaviour from qemacs-0.3pre13
+            if (is->found_offset >= 0) {
+                s->b->mark = is->found_offset;
+            } else {
+                s->b->mark = is->start_offset;
+            }
+            put_status(s, "Marked");
+#endif
             s->b->mark = is->start_offset;
             put_status(s, "Mark saved where search started");
             /* repost key */
@@ -5789,6 +5808,7 @@
     qs->status_shadow[0] = '\0';
 
     if (resized) {
+        /* CG: should compute column count w/ default count */
         put_status(NULL, "Screen is now %d by %d (%d rows)",
                    width, height, height / new_status_height);
     }
@@ -5825,7 +5845,7 @@
     qs->active_window = e;
 }
 
-/* Delete a window and try to resize other window so that it get
+/* Delete a window and try to resize other windows so that it gets
    covered. If force is not true, do not accept to kill window if it
    is the only window or if it is the minibuffer window. */
 void do_delete_window(EditState *s, int force)
@@ -6557,6 +6577,7 @@
                 }
             }
             skip_spaces(&p);
+            /* CG: unfinished comments silently unsupported */
         }
         if (p[0] == '/' && p[1] == '/')
             continue;
@@ -6648,8 +6669,8 @@
             
             skip_spaces(&p);
             if (sep) {
-                /* Should test for arg list too short. */
-                /* Could supply default arguments. */
+                /* CG: Should test for arg list too short. */
+                /* CG: Could supply default arguments. */
                 if (!expect_token(&p, sep))
                     goto fail;
             }
@@ -6657,11 +6678,12 @@
 
             switch (args_type[i]) {
             case CMD_ARG_INT:
-                if (!isdigit(*p)) {
+                args[i] = (void *)strtol(p, (char**)&q, 0);
+                if (q == p) {
                     put_status(s, "Number expected for arg %d", i);
                     goto fail;
                 }
-                args[i] = (void *)strtol(p, (char**)&p, 0);
+                p = q;
                 break;
             case CMD_ARG_STRING:
                 if (*p != '\"') {

Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- qe.h        8 Jul 2005 09:30:44 -0000       1.23
+++ qe.h        9 Dec 2006 19:47:20 -0000       1.24
@@ -1,3 +1,23 @@
+/*
+ * QEmacs, tiny but powerful multimode editor
+ *
+ * Copyright (c) 2000,2001 Fabrice Bellard.
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
 #ifndef QE_H
 #define QE_H
 
@@ -99,11 +119,10 @@
 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);
-void css_union_rect(CSSRect *a, CSSRect *b);
-static inline int css_is_null_rect(CSSRect *a)
+void css_union_rect(CSSRect *a, const CSSRect *b);
+static inline int css_is_null_rect(const CSSRect *a)
 {
-    return (a->x2 <= a->x1 ||
-            a->y2 <= a->y1);
+    return (a->x2 <= a->x1 || a->y2 <= a->y1);
 }
 static inline void css_set_rect(CSSRect *a, int x1, int y1, int x2, int y2)
 {
@@ -113,7 +132,7 @@
     a->y2 = y2;
 }
 /* return true if a and b intersect */
-static inline int css_is_inter_rect(CSSRect *a, CSSRect *b)
+static inline int css_is_inter_rect(const CSSRect *a, const CSSRect *b)
 {
     return (!(a->x2 <= b->x1 ||
               a->x1 >= b->x2 ||
@@ -121,6 +140,7 @@
               a->y1 >= b->y2));
 }
 
+/* CG: what about \v and \f */
 static inline int css_is_space(int ch)
 {
     return (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t');
@@ -457,7 +477,7 @@
 
 struct EditBuffer;
 
-/* each buffer modification can be catched with this callback */
+/* Each buffer modification can be caught with this callback */
 typedef void (*EditBufferCallback)(struct EditBuffer *,
                                    void *opaque,
                                    enum LogOperation op,
@@ -502,7 +522,7 @@
     QECharset *charset;
 
     /* undo system */
-    int save_log;    /* if true, each buffer operation is loged */
+    int save_log;    /* if true, each buffer operation is logged */
     int log_new_index, log_current;
     struct EditBuffer *log_buffer;
     int nb_logs;
@@ -806,7 +826,7 @@
        again in the same state */
     ModeSavedData *(*mode_save_data)(EditState *s);
 
-    /* low level display functions (must be NULL to use text relatedx
+    /* low level display functions (must be NULL to use text related
        functions)*/
     void (*display_hook)(EditState *);
     void (*display)(EditState *);
@@ -1158,7 +1178,7 @@
 void set_color(unsigned int *buf, int len, int style);
 
 void do_char(EditState *s, int key);
-void do_switch_to_buffer(EditState *s, const char *bufname);;
+void do_switch_to_buffer(EditState *s, const char *bufname);
 void do_set_mode(EditState *s, ModeDef *m, ModeSavedData *saved_data);
 void text_move_left_right_visual(EditState *s, int dir);
 void text_move_word_left_right(EditState *s, int dir);

Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- shell.c     8 Jul 2005 09:30:44 -0000       1.17
+++ shell.c     9 Dec 2006 19:47:20 -0000       1.18
@@ -128,7 +128,7 @@
 
     pty_fd = get_pty(tty_name);
     if (pty_fd < 0) {
-        put_status(NULL, "cannot get tty");
+        put_status(NULL, "run_process: cannot get tty");
         return -1;
     }
     fcntl(pty_fd, F_SETFL, O_NONBLOCK);
@@ -141,7 +141,7 @@
     
     pid = fork();
     if (pid < 0) {
-        put_status(NULL, "cannot fork");
+        put_status(NULL, "run_process: cannot fork");
         return -1;
     }
     if (pid == 0) {
@@ -571,9 +571,13 @@
             }
             break;
         case 14:        /* ^N  SO = shift out */
+            // was in qemacs-0.3.1.g2.gw
+            //eb_set_charset(s->b, &charset_8859_1);
             s->shifted = 1;
             break;
         case 15:        /* ^O  SI = shift in */
+            // was in qemacs-0.3.1.g2.gw
+            //eb_set_charset(s->b, &charset_cp1125);
             s->shifted = 0;
             break;
         default:
@@ -952,6 +956,7 @@
             /* if still not killed, then try harder (useful for
                shells) */
             kill(s->pid, SIGKILL);
+           /* CG: should add timeout facility and error message */
             while (waitpid(s->pid, &status, 0) != s->pid);
         }
         s->pid = -1;

Index: tty.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/tty.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- tty.c       8 Jul 2005 09:30:44 -0000       1.16
+++ tty.c       9 Dec 2006 19:47:20 -0000       1.17
@@ -657,6 +657,9 @@
                             buf[2] = '\017';
                             buf[3] = '\0';
                         } else {
+                            // was in qemacs-0.3.1.g2.gw/tty.c:
+                            // if (cc == 0x2500 || cc == 'x')
+                            //    strcpy(buf, "\016x\017");
                             unicode_to_charset(buf, cc, s->charset);
                         }
                         if (x != s->width - 1 || y != s->height - 1)

Index: util.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/util.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- util.c      27 Apr 2006 15:24:14 -0000      1.13
+++ util.c      9 Dec 2006 19:47:20 -0000       1.14
@@ -22,7 +22,7 @@
 #ifdef WIN32
 #include <sys/timeb.h>
 
-/* XXX: not suffisant, but OK for basic operations */
+/* XXX: not sufficient, but OK for basic operations */
 int fnmatch(const char *pattern, const char *string, int flags)
 {
     if (pattern[0] == '*')
@@ -236,12 +236,14 @@
         if (*path1 == '~' && (path1[1] == '\0' || path1[1] == '/')) {
             homedir = getenv("HOME");
             if (homedir) {
+                /* CG: should test for trailing slash */
                 pstrcpy(path, sizeof(path), homedir);
                 pstrcat(path, sizeof(path), path1 + 1);
                 goto next;
             }
         }
         /* CG: not sufficient for windows drives */
+        /* CG: should test result */
         getcwd(cwd, sizeof(cwd));
 #ifdef WIN32
         path_win_to_unix(cwd);
@@ -805,7 +807,7 @@
 }
 
 /* a = a union b */
-void css_union_rect(CSSRect *a, CSSRect *b)
+void css_union_rect(CSSRect *a, const CSSRect *b)
 {
     if (css_is_null_rect(b))
         return;
@@ -941,7 +943,7 @@
 
 /**
  * Add a memory region to a dynamic string. In case of allocation
- * failure, the data is not added. The dynamic string is guaranted to
+ * failure, the data is not added. The dynamic string is guaranteed to
  * be 0 terminated, although it can be longer if it contains zeros.
  *
  * @return 0 if OK, -1 if allocation error.  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]