Make the filename syntax more palatable. 1.3.5interim
authorMark Wooding <mdw@distorted.org.uk>
Tue, 8 Apr 2008 10:57:13 +0000 (11:57 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 8 Apr 2008 11:45:12 +0000 (12:45 +0100)
Quotes are needed for talking about too many interesting files.  In
particular, it's nice to be able to refer to, say, /tmp/.X11-unix/X0
from the command-line without quotes.

This change introduces a new function conf_fname which extends the word
characters appropriately during a read, and makes the various clients --
file, un, and exec -- actually use it rather than calling conf_name
directly.

conf.c
debian/changelog
exec.c
file.c
fwd.1.in
fwd.h
un.c

diff --git a/conf.c b/conf.c
index da40b2e..73cb20e 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -369,4 +369,22 @@ void conf_name(scanner *sc, char delim, dstr *d)
 #undef f_bra
 }
 
+/* --- @conf_fname@ --- *
+ *
+ * Arguments:  @scanner *sc@ = pointer to scanner
+ *             @dstr *d@ = pointer to dynamic string for output
+ *
+ * Returns:    ---
+ *
+ * Use:                Reads a file name from the input and stores it in @d@.
+ */
+
+void conf_fname(scanner *sc, dstr *d)
+{
+  const char fnchars[] = ".-+,";
+  conf_undelim(sc, fnchars, fnchars);
+  conf_name(sc, '/', d);
+  conf_undelim(sc, 0, 0);
+}
+
 /*----- That's all, folks -------------------------------------------------*/
index 47794d1..8fff2c0 100644 (file)
@@ -1,3 +1,9 @@
+fwd (1.3.5interim) experimental; urgency=low
+
+  * Improve filename syntax.
+
+ -- Mark Wooding <mdw@distorted.org.uk>  Tue, 08 Apr 2008 12:42:21 +0100
+
 fwd (1.3.5) experimental; urgency=low
 
   * Rename package to fwd.
diff --git a/exec.c b/exec.c
index b82eeea..753fc4c 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -752,7 +752,7 @@ static int exec_option(xdata *x, scanner *sc)
     token(sc);
     if (sc->t == '=')
       token(sc);
-    conf_name(sc, '/', &d);
+    conf_fname(sc, &d);
     xo->dir = xstrdup(d.buf);
     dstr_destroy(&d);
     CONF_ACCEPT;
@@ -766,7 +766,7 @@ static int exec_option(xdata *x, scanner *sc)
     token(sc);
     if (sc->t == '=')
       token(sc);
-    conf_name(sc, '/', &d);
+    conf_fname(sc, &d);
     xo->root = xstrdup(d.buf);
     dstr_destroy(&d);
     CONF_ACCEPT;
diff --git a/file.c b/file.c
index 47b4943..31e1e07 100644 (file)
--- a/file.c
+++ b/file.c
@@ -230,7 +230,7 @@ static void file_fspec(fspec *f, scanner *sc)
       error(sc, "parse error, expected file descriptor");
   } else {
     dstr d = DSTR_INIT;
-    conf_name(sc, '/', &d);
+    conf_fname(sc, &d);
     f->type = FTYPE_NAME;
     f->u.name = xstrdup(d.buf);
     dstr_destroy(&d);
index e5ecf6c..ef1190c 100644 (file)
--- a/fwd.1.in
+++ b/fwd.1.in
@@ -1260,7 +1260,8 @@ just logs a message about the signal and continues.
 .\"--------------------------------------------------------------------------
 .SH "BUGS"
 .
-The syntax for IP addresses and filenames is nasty.
+The syntax for IP addresses and filenames is nasty.  (The filename
+syntax used to be even nastier, though.)
 .PP
 IPv6 is not supported yet.  Because of
 .BR fwd 's
diff --git a/fwd.h b/fwd.h
index 2da55a3..b45f397 100644 (file)
--- a/fwd.h
+++ b/fwd.h
@@ -565,6 +565,18 @@ extern int conf_prefix(scanner */*sc*/, const char */*p*/);
 
 extern void conf_name(scanner */*sc*/, char /*delim*/, dstr */*d*/);
 
+/* --- @conf_fname@ --- *
+ *
+ * Arguments:  @scanner *sc@ = pointer to scanner
+ *             @dstr *d@ = pointer to dynamic string for output
+ *
+ * Returns:    ---
+ *
+ * Use:                Reads a file name from the input and stores it in @d@.
+ */
+
+extern void conf_fname(scanner */*sc*/, dstr */*d*/);
+
 /*----- Reference-counted file descriptors --------------------------------*/
 
 typedef struct reffd {
diff --git a/un.c b/un.c
index c0e62ca..c1e1e4d 100644 (file)
--- a/un.c
+++ b/un.c
@@ -47,7 +47,7 @@ static addr *un_read(scanner *sc, unsigned type)
   dstr d = DSTR_INIT;
   un_addr *ua;
 
-  conf_name(sc, '/', &d);
+  conf_fname(sc, &d);
   ua = xmalloc(sizeof(addr) +
               offsetof(struct sockaddr_un, sun_path) +
               d.len + 1);