Update of /cvsroot/tmux/tmux
In directory vz-cvs-2.sog:/tmp/cvs-serv22190
Modified Files:
cmd-new-session.c cmd-rename-session.c cmd.c session.c tmux.h
Log Message:
|PatchSet 884
|Date: 2011/04/06 22:51:31
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|Change so that an empty session name always means the current sessions
|even if given with, for example, -t '', and explicitly forbid empty
|session names and those containing a : when they are created.
Index: cmd.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- cmd.c 6 Apr 2011 22:24:01 -0000 1.151
+++ cmd.c 6 Apr 2011 22:29:26 -0000 1.152
@@ -724,6 +724,12 @@
if (arglen != 0 && tmparg[arglen - 1] == ':')
tmparg[arglen - 1] = '\0';
+ /* An empty session name is the current session. */
+ if (*tmparg == '\0') {
+ xfree (tmparg);
+ return (cmd_current_session(ctx, prefer_unattached));
+ }
+
/* Find the session, if any. */
s = cmd_lookup_session(tmparg, &ambiguous);
@@ -839,7 +845,7 @@
lookup_session:
if (ambiguous)
goto not_found;
- if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)
+ if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL)
goto no_session;
if (sp != NULL)
@@ -980,7 +986,7 @@
lookup_session:
if (ambiguous)
goto not_found;
- if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)
+ if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL)
goto no_session;
if (sp != NULL)
Index: session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/session.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- session.c 15 Feb 2011 15:09:52 -0000 1.88
+++ session.c 6 Apr 2011 22:29:26 -0000 1.89
@@ -163,6 +163,13 @@
RB_INSERT(sessions, &dead_sessions, s);
}
+/* Check a session name is valid: not empty and no colons. */
+int
+session_check_name(const char *name)
+{
+ return (*name != '\0' && strchr(name, ':') == NULL);
+}
+
/* Update session active time. */
void
session_update_activity(struct session *s)
Index: cmd-new-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-session.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- cmd-new-session.c 6 Apr 2011 22:24:00 -0000 1.85
+++ cmd-new-session.c 6 Apr 2011 22:29:26 -0000 1.86
@@ -68,9 +68,15 @@
u_int sx, sy, i;
newname = args_get(args, 's');
- if (newname != NULL && session_find(newname) != NULL) {
- ctx->error(ctx, "duplicate session: %s", newname);
- return (-1);
+ if (newname != NULL) {
+ if (!session_check_name(newname)) {
+ ctx->error(ctx, "bad session name: %s", newname);
+ return (-1);
+ }
+ if (session_find(newname) != NULL) {
+ ctx->error(ctx, "duplicate session: %s", newname);
+ return (-1);
+ }
}
target = args_get(args, 't');
Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.617
retrieving revision 1.618
diff -u -d -r1.617 -r1.618
--- tmux.h 6 Apr 2011 22:24:01 -0000 1.617
+++ tmux.h 6 Apr 2011 22:29:26 -0000 1.618
@@ -1974,6 +1974,7 @@
struct environ *, struct termios *, int, u_int, u_int,
char **);
void session_destroy(struct session *);
+int session_check_name(const char *);
void session_update_activity(struct session *);
struct session *session_next_session(struct session *);
struct session *session_previous_session(struct session *);
Index: cmd-rename-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-rename-session.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmd-rename-session.c 6 Apr 2011 22:24:01 -0000 1.23
+++ cmd-rename-session.c 6 Apr 2011 22:29:26 -0000 1.24
@@ -46,6 +46,10 @@
const char *newname;
newname = args->argv[0];
+ if (!session_check_name(newname)) {
+ ctx->error(ctx, "bad session name: %s", newname);
+ return (-1);
+ }
if (session_find(newname) != NULL) {
ctx->error(ctx, "duplicate session: %s", newname);
return (-1);
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs