qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs dired.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs dired.c
Date: Fri, 2 Oct 2020 16:18:27 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        20/10/02 16:18:27

Modified files:
        .              : dired.c 

Log message:
        improve filelist_display_hook filename extraction

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.82&r2=1.83

Patches:
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- dired.c     28 May 2019 04:27:34 -0000      1.82
+++ dired.c     2 Oct 2020 20:18:26 -0000       1.83
@@ -1416,7 +1416,7 @@
 
     offset = eb_goto_bol(s->b, s->offset);
     len = eb_fgets(s->b, buf, sizeof(buf), offset, &offset);
-    buf[len] = '\0';
+    buf[len] = '\0';   /* strip the trailing newline if any */
 
     if (s->x1 == 0 && s->y1 == 0 && s->width != qs->width
     &&  *buf && !strequal(buf, filelist_last_buf)) {
@@ -1427,15 +1427,23 @@
         makepath(filename, sizeof(filename), dir, buf);
         target_line = 0;
         if (access(filename, R_OK)) {
-            for (i = 0; i < len; i++) {
-                if (buf[i] == ':' || buf[i] == *"()") {
+            /* try parsing an error message: `:` or `(` a linenumber */
+            i = strcspn(buf, ":(");
+            if (i < len) {
+                char c = buf[i];
                     buf[i] = '\0';
+                makepath(filename, sizeof(filename), dir, buf);
+                buf[i] = c;
                     target_line = strtol(buf + i + 1, NULL, 10);
-                    break;
-                }
             }
-            if (*buf) {
-                makepath(filename, sizeof(filename), dir, buf);
+            i = 0;
+            while (access(filename, R_OK)) {
+                /* try skipping initial words */
+                i += strcspn(buf + i, " ");
+                i += strspn(buf + i, " ");
+                if (i == len)
+                    break;
+                makepath(filename, sizeof(filename), dir, buf + i);
             }
         }
         if (!access(filename, R_OK)) {



reply via email to

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