summaryrefslogtreecommitdiff
path: root/mh/mh_alias_gram.y
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-06-13 17:47:19 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-06-13 17:47:19 +0300
commit82e2f8ee6a860c427d69d1a3652945356f27920e (patch)
tree0a141d04a4f6a138b23918bfd3a2f4c3aa20aafb /mh/mh_alias_gram.y
parent4f24c098704dd28622d1d653945388a4abbfb434 (diff)
downloadmailutils-82e2f8ee6a860c427d69d1a3652945356f27920e.tar.gz
mailutils-82e2f8ee6a860c427d69d1a3652945356f27920e.tar.bz2
Switch mh_aliases to line tracker
* mh/mh.h (ali_parse_error): Remove. * mh/mh_alias_gram.y: Simplify parser. Use location tracking. * mh/mh_alias_lex.l: Switch to mu_linetrack facility * mh/tests/ali.at: Update expected location.
Diffstat (limited to 'mh/mh_alias_gram.y')
-rw-r--r--mh/mh_alias_gram.y46
1 files changed, 28 insertions, 18 deletions
diff --git a/mh/mh_alias_gram.y b/mh/mh_alias_gram.y
index 0d6bffcc2..d7229983a 100644
--- a/mh/mh_alias_gram.y
+++ b/mh/mh_alias_gram.y
@@ -20,6 +20,8 @@
#include <pwd.h>
#include <grp.h>
#include <sys/types.h>
+#include <mailutils/locus.h>
+#include <mailutils/yyloc.h>
struct mh_alias
{
@@ -31,7 +33,7 @@ struct mh_alias
static mu_list_t alias_list;
static mu_list_t
-list_create_or_die ()
+list_create_or_die (void)
{
int status;
mu_list_t list;
@@ -39,7 +41,7 @@ list_create_or_die ()
status = mu_list_create (&list);
if (status)
{
- ali_parse_error (_("can't create list: %s"), mu_strerror (status));
+ mu_error (_("can't create list: %s"), mu_strerror (status));
exit (1);
}
return list;
@@ -86,6 +88,17 @@ ali_list_to_string (mu_list_t *plist)
return string;
}
+static void
+ali_append (struct mh_alias *ali)
+{
+ if (ali)
+ {
+ if (!alias_list)
+ alias_list = list_create_or_die ();
+ mu_list_append (alias_list, ali);
+ }
+}
+
static mu_list_t unix_group_to_list (char *name);
static mu_list_t unix_gid_to_list (char *name);
static mu_list_t unix_passwd_to_list (void);
@@ -101,37 +114,34 @@ int yylex (void);
struct mh_alias *alias;
}
+%token EOL
%token <string> STRING
%type <list> address_list address_group string_list
%type <string> address
%type <alias> alias
+%locations
+
%%
-input : /* empty */
- | alias_list
- | alias_list nl
- | nl alias_list
- | nl alias_list nl
+input : alias_list
;
alias_list : alias
{
- if (!alias_list)
- alias_list = list_create_or_die ();
- mu_list_append (alias_list, $1);
+ ali_append ($1);
}
- | alias_list nl alias
+ | alias_list EOL alias
{
- mu_list_append (alias_list, $3);
+ ali_append ($3);
}
;
-nl : '\n'
- | nl '\n'
- ;
-
-alias : STRING ':' { ali_verbatim (1); } address_group
+alias : /* empty */
+ {
+ $$ = NULL;
+ }
+ | STRING ':' { ali_verbatim (1); } address_group
{
ali_verbatim (0);
$$ = mu_alloc (sizeof (*$$));
@@ -489,7 +499,7 @@ unix_passwd_to_list ()
}
int
-mh_read_aliases ()
+mh_read_aliases (void)
{
const char *p;

Return to:

Send suggestions and report system problems to the System administrator.