qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs arabic.c charset.c charsetjis.c clang.c ...


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs arabic.c charset.c charsetjis.c clang.c ...
Date: Mon, 10 Dec 2007 13:28:08 +0000

CVSROOT:        /cvsroot/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        07/12/10 13:28:08

Modified files:
        .              : arabic.c charset.c charsetjis.c clang.c qe.c 
                         shell.c tty.c util.c win32.c x11.c 
        libqhtml       : css.c 

Log message:
        fixed function key mapping issues in X11 and Wndz
        fixed C lang colorizer for some multiline stuff, wide char/strings
        use countof() macro
        cosmetics

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/arabic.c?cvsroot=qemacs&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/qemacs/charset.c?cvsroot=qemacs&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/qemacs/charsetjis.c?cvsroot=qemacs&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/qemacs/win32.c?cvsroot=qemacs&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/qemacs/x11.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/libqhtml/css.c?cvsroot=qemacs&r1=1.9&r2=1.10

Patches:
Index: arabic.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/arabic.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- arabic.c    3 Dec 2007 16:12:40 -0000       1.5
+++ arabic.c    10 Dec 2007 13:28:07 -0000      1.6
@@ -198,7 +198,7 @@
 {
     int i;
 
-    for (i = 0; i < (int)(sizeof(transparent)/sizeof(transparent[0])); i++) {
+    for (i = 0; i < countof(transparent); i++) {
         if (transparent[i] == ch)
             return 1;
     }

Index: charset.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/charset.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- charset.c   6 Dec 2007 15:28:29 -0000       1.9
+++ charset.c   10 Dec 2007 13:28:08 -0000      1.10
@@ -382,7 +382,7 @@
     n = charset->max_char - charset->min_char + 1;
     for (i = 0; i < n; i++)
         *table++ = charset->private_table[i];
-    for (i = charset->max_char + 1; i < 256;i++)
+    for (i = charset->max_char + 1; i < 256; i++)
         *table++ = i;
 }
 
@@ -394,7 +394,8 @@
 
     if (c < charset->min_char) {
         /* nothing to do */
-    } else if (c > charset->max_char && c <= 0xff) {
+    } else
+    if (c > charset->max_char && c <= 0xff) {
         /* nothing to do */
     } else {
         n = charset->max_char - charset->min_char + 1;

Index: charsetjis.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/charsetjis.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- charsetjis.c        6 Dec 2007 17:43:47 -0000       1.2
+++ charsetjis.c        10 Dec 2007 13:28:08 -0000      1.3
@@ -133,7 +133,7 @@
 {
     if (c <= 0x7f) {
         *q++ = c;
-    } else if (c >= 0xff61 && c <= 0xFF9F) {
+    } else if (c >= 0xff61 && c <= 0xff9f) {
         *q++ = 0x8e;
         *q++ = c - 0xff61 + 0xa1;
     } else {

Index: clang.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/clang.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- clang.c     10 Dec 2007 11:03:36 -0000      1.11
+++ clang.c     10 Dec 2007 13:28:08 -0000      1.12
@@ -59,6 +59,7 @@
 /* colorization states */
 enum {
     C_COMMENT = 1,
+    C_COMMENT1,
     C_STRING,
     C_STRING_Q,
     C_PREPROCESS,
@@ -81,6 +82,8 @@
     switch (state) {
     case C_COMMENT:
         goto parse_comment;
+    case C_COMMENT1:
+        goto parse_comment1;
     case C_STRING:
     case C_STRING_Q:
         goto parse_string;
@@ -113,23 +116,39 @@
                     }
                 }
                 set_color(p_start, p - p_start, QE_STYLE_COMMENT);
-            } else if (*p == '/') {
+            } else
+            if (*p == '/') {
                 /* line comment */
-                while (*p != '\n') 
-                    p++;
+            parse_comment1:
+                state = C_COMMENT1;
+                p = buf + len;
                 set_color(p_start, p - p_start, QE_STYLE_COMMENT);
+                if (p > buf && (p[-1] & CHAR_MASK) != '\\') 
+                    state = 0;
             }
             break;
         case '#':
             /* preprocessor */
         parse_preprocessor:
+            state = C_PREPROCESS;
+            /* incorrect if preprocessing line contains a comment */
             p = buf + len;
             set_color(p_start, p - p_start, QE_STYLE_PREPROCESS);
-            if (p > buf && (p[-1] & CHAR_MASK) == '\\') 
-                state = C_PREPROCESS;
-            else
+            if (p > buf && (p[-1] & CHAR_MASK) != '\\') 
                 state = 0;
             goto the_end;
+        case 'L':
+            if (p[1] == '\'') {
+                p++;
+                state = C_STRING_Q;
+                goto string;
+            }
+            if (p[1] == '\"') {
+                p++;
+                state = C_STRING;
+                goto string;
+            }
+            goto normal;
         case '\'':
             state = C_STRING_Q;
             goto string;
@@ -139,6 +158,7 @@
         string:
             p++;
         parse_string:
+            /* XXX: separate styles for string and char const? */
             while (*p != '\n') {
                 if (*p == '\\') {
                     p++;
@@ -162,10 +182,12 @@
             type_decl = 0;
             break;
         default:
+        normal:
             if ((c >= 'a' && c <= 'z') ||
                 (c >= 'A' && c <= 'Z') || 
                 (c == '_')) {
                 
+                /* XXX: should handle inplace and support :: */
                 l = get_c_keyword(kbuf, sizeof(kbuf), &p);
                 p1 = p;
                 while (*p == ' ' || *p == '\t')
@@ -192,11 +214,7 @@
                         type_decl = 1;
 
                     if (type_decl) {
-                        if (*p == '(') {
-                            /* function definition case */
-                            set_color(p_start, p1 - p_start, 
QE_STYLE_FUNCTION);
-                            type_decl = 1;
-                        } else if (p_start == buf) {
+                        if (p_start == buf) {
                             /* assume type if first column */
                             set_color(p_start, p1 - p_start, QE_STYLE_TYPE);
                         } else {

Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- qe.c        9 Dec 2007 23:31:39 -0000       1.37
+++ qe.c        10 Dec 2007 13:28:08 -0000      1.38
@@ -3905,7 +3905,7 @@
     QEFont *font;
     CSSRect rect;
 
-    len = utf8_to_unicode(ubuf, sizeof(ubuf) / sizeof(ubuf[0]), str);
+    len = utf8_to_unicode(ubuf, countof(ubuf), str);
     get_style(NULL, &style, style_index);
 
     /* clip rectangle */

Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23

Index: tty.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/tty.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- tty.c       3 Dec 2007 16:10:39 -0000       1.22
+++ tty.c       10 Dec 2007 13:28:08 -0000      1.23
@@ -423,7 +423,7 @@
             ts->input_state = IS_CSI2;
             break;
         case '~':
-            if (ts->input_param < 
(int)(sizeof(csi_lookup)/sizeof(csi_lookup[0]))) {
+            if (ts->input_param < countof(csi_lookup)) {
                 ch = csi_lookup[ts->input_param];
                 goto the_end;
             }

Index: util.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/util.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- util.c      6 Dec 2007 17:43:48 -0000       1.20
+++ util.c      10 Dec 2007 13:28:08 -0000      1.21
@@ -504,7 +504,7 @@
     for (p1 = p; *p1 && *p1 != ' '; p1++)
         continue;
 
-    for (i = 0; i < (int)(sizeof(keycodes)/sizeof(keycodes[0])); i++) {
+    for (i = 0; i < countof(keycodes); i++) {
         if (strstart(p, keystr[i], &q) && q == p1) {
             key = keycodes[i];
             *pp = p1;
@@ -512,6 +512,7 @@
         }
     }
 #if 0
+    /* Cannot do this because KEY_F1..KEY_F20 are not consecutive */
     if (p[0] == 'f' && p[1] >= '1' && p[1] <= '9') {
         i = p[1] - '0';
         p += 2;
@@ -582,7 +583,7 @@
     
     buf_init(&out, buf, buf_size);
 
-    for (i = 0; i < (int)(sizeof(keycodes)/sizeof(keycodes[0])); i++) {
+    for (i = 0; i < countof(keycodes); i++) {
         if (keycodes[i] == key) {
             buf_puts(&out, keystr[i]);
             return;
@@ -595,9 +596,13 @@
     if (key >= KEY_CTRL('a') && key <= KEY_CTRL('z')) {
         buf_printf(&out, "C-%c", key + 'a' - 1);
     } else
+#if 0
+    /* Cannot do this because KEY_F1..KEY_F20 are not consecutive */
     if (key >= KEY_F1 && key <= KEY_F20) {
         buf_printf(&out, "f%d", key - KEY_F1 + 1);
-    } else {
+    } else
+#endif
+    {
         buf_putc_utf8(&out, key);
     }
 }
@@ -646,7 +651,7 @@
     { "magenta", QERGB(0xff, 0x00, 0xff) },
     { "transparent", COLOR_TRANSPARENT },
 };
-#define nb_css_colors (int)(sizeof(css_colors) / sizeof(css_colors[0]))
+#define nb_css_colors  countof(css_colors)
 
 static ColorDef *custom_colors = css_colors;
 static int nb_custom_colors;

Index: win32.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/win32.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- win32.c     3 Dec 2007 16:10:39 -0000       1.5
+++ win32.c     10 Dec 2007 13:28:08 -0000      1.6
@@ -279,7 +279,7 @@
                 else
                     push_key(KEY_CTRL('@'));
                 break;
-            case 0x147:                        /* home */
+            case 0x147:                /* HOME */
                 push_key(KEY_HOME);
                 break;
             case 0x148:                /* UP */
@@ -310,27 +310,44 @@
                 push_key(KEY_INSERT);
                 break;
             case 0x3b:                 /* F1 */
-            case 0x3c:
-            case 0x3d:
-            case 0x3e:
-            case 0x3f:
-            case 0x40:
-            case 0x41:
-            case 0x42:
-            case 0x43:
-            case 0x44:
-            case 0x57:
-            case 0x58:                 /* F12 */
-                key = scan - 0x3b;
-                if (key > 9)
-                    key -= 0x12;
-                key += KEY_F1;
+                push_key(KEY_F1);
+                break;
+            case 0x3c:                 /* F2 */
+                push_key(KEY_F2);
+                break;
+            case 0x3d:                 /* F3 */
+                push_key(KEY_F3);
+                break;
+            case 0x3e:                 /* F4 */
                 /* we leave Alt-F4 to close the window */
-                if (alt && key == KEY_F4)
+                if (alt)
                     return DefWindowProc(hWnd, msg, wParam, lParam);
-                push_key(key);
+                push_key(KEY_F4);
+                break;
+            case 0x3f:                 /* F5 */
+                push_key(KEY_F5);
+                break;
+            case 0x40:                 /* F6 */
+                push_key(KEY_F6);
+                break;
+            case 0x41:                 /* F7 */
+                push_key(KEY_F7);
+                break;
+            case 0x42:                 /* F8 */
+                push_key(KEY_F8);
+                break;
+            case 0x43:                 /* F9 */
+                push_key(KEY_F9);
+                break;
+            case 0x44:                 /* F10 */
+                push_key(KEY_F10);
+                break;
+            case 0x57:                 /* F11 */
+                push_key(KEY_F11);
+                break;
+            case 0x58:                 /* F12 */
+                push_key(KEY_F12);
                 break;
-                  
             default: 
                 return DefWindowProc(hWnd, msg, wParam, lParam);
             }

Index: x11.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/x11.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- x11.c       6 Dec 2007 17:43:48 -0000       1.11
+++ x11.c       10 Dec 2007 13:28:08 -0000      1.12
@@ -1153,7 +1153,7 @@
         XChangeProperty(display, rq->requestor, rq->property,
                         xa_targets, 8*sizeof(target_list[0]), PropModeReplace,
                         (unsigned char *)target_list,
-                        sizeof(target_list)/sizeof(target_list[0]));
+                        countof(target_list));
     } else if (rq->target == XA_STRING) {
         /* get qemacs yank buffer */
        
@@ -1324,56 +1324,37 @@
                 }
             } else {
                 switch (keysym) {
-                case XK_F1:
-                case XK_F2:
-                case XK_F3:
-                case XK_F4:
-                case XK_F5:
-                case XK_F6:
-                case XK_F7:
-                case XK_F8:
-                case XK_F9:
-                case XK_F10:
-                case XK_F11:
-                case XK_F12:
-                    key = KEY_F1 + keysym - XK_F1;
-                    goto got_key;
-                case XK_Up:
-                    key = KEY_UP;
-                    goto got_key;
-                case XK_Down:
-                    key = KEY_DOWN;
-                    goto got_key;
-                case XK_Right:
-                    key = KEY_RIGHT;
-                    goto got_key;
-                case XK_Left:
-                    key = KEY_LEFT;
-                    goto got_key;
-                case XK_BackSpace:
-                    key = KEY_DEL;
-                    goto got_key;
-                case XK_Insert:
-                    key = KEY_INSERT;
-                    goto got_key;
-                case XK_Delete:
-                    key = KEY_DELETE;
-                    goto got_key;
-                case XK_Home:
-                    key = KEY_HOME;
-                    goto got_key;
-                case XK_End:
-                    key = KEY_END;
-                    goto got_key;
-                case XK_Prior:
-                    key = KEY_PAGEUP;
-                    goto got_key;
-                case XK_Next:
-                    key = KEY_PAGEDOWN;
-                    goto got_key;
-                case XK_ISO_Left_Tab:
-                    key = KEY_SHIFT_TAB;
-                    goto got_key;
+                case XK_F1:     key = KEY_F1;     goto got_key;
+                case XK_F2:     key = KEY_F2;     goto got_key;
+                case XK_F3:     key = KEY_F3;     goto got_key;
+                case XK_F4:     key = KEY_F4;     goto got_key;
+                case XK_F5:     key = KEY_F5;     goto got_key;
+                case XK_F6:     key = KEY_F6;     goto got_key;
+                case XK_F7:     key = KEY_F7;     goto got_key;
+                case XK_F8:     key = KEY_F8;     goto got_key;
+                case XK_F9:     key = KEY_F9;     goto got_key;
+                case XK_F10:    key = KEY_F10;    goto got_key;
+                case XK_F11:    key = KEY_F11;    goto got_key;
+                case XK_F13:    key = KEY_F13;    goto got_key;
+                case XK_F14:    key = KEY_F14;    goto got_key;
+                case XK_F15:    key = KEY_F15;    goto got_key;
+                case XK_F16:    key = KEY_F16;    goto got_key;
+                case XK_F17:    key = KEY_F17;    goto got_key;
+                case XK_F18:    key = KEY_F18;    goto got_key;
+                case XK_F19:    key = KEY_F19;    goto got_key;
+                case XK_F20:    key = KEY_F20;    goto got_key;
+                case XK_Up:     key = KEY_UP;     goto got_key;
+                case XK_Down:   key = KEY_DOWN;   goto got_key;
+                case XK_Right:  key = KEY_RIGHT;  goto got_key;
+                case XK_Left:   key = KEY_LEFT;   goto got_key;
+                case XK_BackSpace: key = KEY_DEL; goto got_key;
+                case XK_Insert: key = KEY_INSERT; goto got_key;
+                case XK_Delete: key = KEY_DELETE; goto got_key;
+                case XK_Home:   key = KEY_HOME;   goto got_key;
+                case XK_End:    key = KEY_END;    goto got_key;
+                case XK_Prior:  key = KEY_PAGEUP; goto got_key;
+                case XK_Next:   key = KEY_PAGEDOWN; goto got_key;
+                case XK_ISO_Left_Tab: key = KEY_SHIFT_TAB; goto got_key;
                 default:
                     if (len > 0) {
 #ifdef X_HAVE_UTF8_STRING

Index: libqhtml/css.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/libqhtml/css.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libqhtml/css.c      6 Dec 2007 17:43:49 -0000       1.9
+++ libqhtml/css.c      10 Dec 2007 13:28:08 -0000      1.10
@@ -3956,7 +3956,7 @@
             /* display the optional alt text */
             if (box->u.image.content_alt) {
                 font = css_select_font(scr, props);
-                len = utf8_to_unicode(ubuf, sizeof(ubuf) / sizeof(ubuf[0]), 
+                len = utf8_to_unicode(ubuf, countof(ubuf),
                                       box->u.image.content_alt);
                 /* XXX: unicode, etc... */
                 draw_text(scr, font,




reply via email to

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