diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-28 23:20:22 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-28 23:20:22 +0300 |
commit | 4a49f5341ae9005c9ffbd7620efaecffcdfda79f (patch) | |
tree | 53ba2d6a638bd9b83747ebd6899931ab89d13ca0 /mh/mh_whatnow.c | |
parent | 697384c64dadb0a4db97136a6cbcf2166c48897b (diff) | |
download | mailutils-4a49f5341ae9005c9ffbd7620efaecffcdfda79f.tar.gz mailutils-4a49f5341ae9005c9ffbd7620efaecffcdfda79f.tar.bz2 |
Add wordsplit module.
The wordsplit module (borrowed from another project of mine, called 'grecs')
provides a flexible and powerful mechanism for parsing input in a way
similar to posix-shell. In particular, the POSIX function wordexp is
a subset of the wordsplit functionality.
The argcv module is now deprecated.
* include/mailutils/wordsplit.h: New file.
* include/mailutils/Makefile.am (pkginclude_HEADERS): Add wordsplit.h
* libmailutils/string/wordsplit.c: New file.
* libmailutils/string/Makefile.am (libstring_la_SOURCES): Add wordsplit.c.
* include/mailutils/argcv.h (mu_argcv_join): New proto.
(mu_argcv_get, mu_argcv_get_n, mu_argcv_get_np)
(mu_argcv_unquote_char, mu_argcv_quote_char)
(mu_argcv_quoted_length, mu_argcv_unquote_copy)
(mu_argcv_quote_copy): Mark as deprecated.
* include/mailutils/mailutils.h: Include wordsplit.h.
* libmailutils/tests/wsp.c: New file.
* libmailutils/tests/.gitignore: List wsp.
* libmailutils/tests/wordsplit.at: New file.
* libmailutils/tests/Makefile.am (noinst_PROGRAMS): Add wsp
(TESTSUITE_AT): Add wordsplit.at.
* libmailutils/tests/argcv.c: Define MU_ARCGV_DEPRECATED to
avoid deprecation warnings.
* libmailutils/tests/testsuite.at: Include wordsplit.at.
* libmailutils/base/argcvfree.c: New file.
* libmailutils/base/argcvjoin.c: New file.
* libmailutils/base/argcvrem.c: New file.
* libmailutils/base/Makefile.am (libbase_la_SOURCES): Add new files.
* libmailutils/base/argcv.c: Define MU_ARCGV_DEPRECATED to
avoid deprecation warnings.
(argcv_string, argcv_free, argv_free)
(mu_argcv_remove): Rewrite in separate modules.
* comsat/comsat.h: Include wordsplit.h.
* imap4d/imap4d.h: Likewise.
* mail/mail.h: Likewise.
* mh/mh.h: Likewise.
* readmsg/readmsg.h: Likewise.
* comsat/action.c: Use wordsplit.
* imap4d/fetch.c: Likewise.
* lib/mailcap.c: Likewise.
* libmailutils/auth/mu_auth.c: Likewise.
* libmailutils/base/mutil.c: Likewise.
* libmailutils/cfg/format.c: Likewise.
* libmailutils/cfg/lexer.l: Likewise.
* libmailutils/cfg/parser.y: Likewise.
* libmailutils/diag/gdebug.c: Likewise.
* libmailutils/mailer/mailer.c: Likewise.
* libmailutils/server/acl.c: Likewise.
* libmailutils/stream/prog_stream.c: Likewise.
* libmailutils/tests/listop.c: Likewise.
* libmailutils/url/create.c: Likewise.
* libmu_auth/ldap.c: Likewise.
* libmu_auth/radius.c: Likewise.
* libmu_sieve/sieve.l: Likewise.
* libproto/mailer/mbox.c: Likewise.
* libproto/mailer/smtp.c: Likewise.
* libproto/mailer/smtp_gsasl.c: Likewise.
* mail/mailline.c: Likewise.
* mail/mailvar.c: Likewise.
* mail/send.c: Likewise.
* mail/util.c: Likewise.
* mh/folder.c: Likewise.
* mh/mh_alias.y: Likewise.
* mh/mh_argp.c: Likewise.
* mh/mh_init.c: Likewise.
* mh/mh_list.c: Likewise.
* mh/mh_msgset.c: Likewise.
* mh/mh_sequence.c: Likewise.
* mh/mh_whatnow.c: Likewise.
* mh/mh_sequence.c: Likewise.
* mh/mh_whatnow.c: Likewise.
* mh/mhn.c: Likewise.
* mh/send.c: Likewise.
* movemail/movemail.c: Likewise.
* mu/shell.c: Likewise.
* readmsg/readmsg.c: Likewise.
* testsuite/smtpsend.c: Likewise.
* pop3d/popauth.c: Use wordsplit.
Use simplified input format (username and password delimited
by any amount of whitespace).
Read/produce old format if invoked with the --compatibility option.
* examples/aclck.c: Use wordsplit instead of argcv.
* examples/header.c: Likewise.
* examples/mta.c: Likewise.
* examples/.gitignore: Remove pop3client.
* examples/Makefile.am: Remove pop3client.
* po/POTFILES.in: Add new files.
Diffstat (limited to 'mh/mh_whatnow.c')
-rw-r--r-- | mh/mh_whatnow.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c index 672481083..6582fd8b3 100644 --- a/mh/mh_whatnow.c +++ b/mh/mh_whatnow.c @@ -328,28 +328,30 @@ _whatnow (struct mh_whatnow_env *wh, struct action_tab *tab) { char *line = NULL; size_t size = 0; - int argc; - char **argv; + struct mu_wordsplit ws; handler_fp fun; printf ("%s ", wh->prompt); getline (&line, &size, stdin); if (!line) continue; - rc = mu_argcv_get (line, "", "#", &argc, &argv); + + ws.ws_comment = "#"; + rc = mu_wordsplit (line, &ws, MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT); free (line); if (rc) { - mu_argcv_free (argc, argv); + mu_error (_("cannot split line `%s': %s"), line, + mu_wordsplit_strerror (&ws)); break; } - fun = func (tab, argv[0]); + fun = func (tab, ws.ws_wordv[0]); if (fun) - rc = fun (wh, argc, argv, &status); + rc = fun (wh, ws.ws_wordc, ws.ws_wordv, &status); else rc = 0; - mu_argcv_free (argc, argv); + mu_wordsplit_free (&ws); } while (rc == 0); return status; |