Revision: 2588
          http://tmux.svn.sourceforge.net/tmux/?rev=2588&view=rev
Author:   tcunha
Date:     2011-08-25 21:14:23 +0000 (Thu, 25 Aug 2011)
Log Message:
-----------
Sync OpenBSD patchset 951:

Support \ for line continuation in the configuration file, from Julius
Plenz.

Modified Paths:
--------------
    trunk/cfg.c
    trunk/tmux.1

Modified: trunk/cfg.c
===================================================================
--- trunk/cfg.c 2011-08-25 21:13:45 UTC (rev 2587)
+++ trunk/cfg.c 2011-08-25 21:14:23 UTC (rev 2588)
@@ -92,22 +92,37 @@
        retval = 0;
        while ((buf = fgetln(f, &len))) {
                if (buf[len - 1] == '\n')
-                       buf[len - 1] = '\0';
+                       len--;
+
+               if (line != NULL)
+                       line = xrealloc(line, 1, strlen(line) + len + 1);
                else {
-                       line = xrealloc(line, 1, len + 1);
-                       memcpy(line, buf, len);
-                       line[len] = '\0';
-                       buf = line;
+                       line = xmalloc(len + 1);
+                       *line = '\0';
                }
+
+               /* Append buffer to line. strncat will terminate. */
+               strncat(line, buf, len);
                n++;
 
+               /* Continuation: get next line? */
+               len = strlen(line);
+               if (len > 0 && line[len - 1] == '\\') {
+                       line[len - 1] = '\0';
+                       continue;
+               }
+               buf = line;
+               line = NULL;
+
                if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
+                       xfree(buf);
                        if (cause == NULL)
                                continue;
                        cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
                        xfree(cause);
                        continue;
-               }
+               } else
+                       xfree(buf);
                if (cmdlist == NULL)
                        continue;
                cfg_cause = NULL;
@@ -131,12 +146,16 @@
                        retval = 1;
                cmd_list_free(cmdlist);
                if (cfg_cause != NULL) {
-                       cfg_add_cause(causes, "%s: %d: %s", path, n, cfg_cause);
+                       cfg_add_cause(
+                           causes, "%s: %d: %s", path, n, cfg_cause);
                        xfree(cfg_cause);
                }
        }
-       if (line != NULL)
+       if (line != NULL) {
+               cfg_add_cause(causes,
+                   "%s: %d: line continuation at end of file", path, n);
                xfree(line);
+       }
        fclose(f);
 
        return (retval);

Modified: trunk/tmux.1
===================================================================
--- trunk/tmux.1        2011-08-25 21:13:45 UTC (rev 2587)
+++ trunk/tmux.1        2011-08-25 21:14:23 UTC (rev 2588)
@@ -495,7 +495,8 @@
 Multiple commands may be specified together as part of a
 .Em command sequence .
 Each command should be separated by spaces and a semicolon;
-commands are executed sequentially from left to right.
+commands are executed sequentially from left to right and
+lines ending with a backslash continue on to the next line.
 A literal semicolon may be included by escaping it with a backslash (for
 example, when specifying a command sequence to
 .Ic bind-key ) .
@@ -511,6 +512,9 @@
 set-window-option -t:0 monitor-activity on
 
 new-window ; split-window -d
+
+bind-key R source-file ~/.tmux.conf \e; \e
+       display-message "source-file done"
 .Ed
 .Pp
 Or from

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to