[augeas-devel] augeas: master - * src/parser.y: properly initialize yylloc

David Lutterkort lutter at fedoraproject.org
Mon Nov 30 15:18:51 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=112e9433c3c387f9223d9f770765e539b1897c8f
Commit:        112e9433c3c387f9223d9f770765e539b1897c8f
Parent:        51cfb5af2805ff602c8b1f398b13cf4930c688b4
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Mon Nov 30 07:13:24 2009 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Nov 30 07:17:36 2009 -0800

* src/parser.y: properly initialize yylloc

Fixes ticket #96
---
 src/parser.y                        |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/parser.y b/src/parser.y
index 4e67e0d..b0a52b5 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -24,7 +24,6 @@ int augl_parse_file(struct augeas *aug, const char *name, struct term **term);
 typedef void *yyscan_t;
 typedef struct info YYLTYPE;
 #define YYLTYPE_IS_DECLARED 1
-#define YYLTYPE_IS_TRIVIAL 1
 /* The lack of reference counting on filename is intentional */
 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
   do {                                                                  \
@@ -53,6 +52,15 @@ typedef struct info YYLTYPE;
 %parse-param    {yyscan_t scanner}
 %lex-param      {yyscan_t scanner}
 
+%initial-action {
+  @$.first_line   = 1;
+  @$.first_column = 0;
+  @$.last_line    = 1;
+  @$.last_column  = 0;
+  @$.filename     = augl_get_extra(scanner)->filename;
+  @$.error        = augl_get_extra(scanner)->error;
+};
+
 %token <string> DQUOTED   /* "foo" */
 %token <string> REGEXP    /* /[ \t]+/ */
 %token <string> LIDENT UIDENT QIDENT
@@ -512,7 +520,6 @@ void augl_error(struct info *locp,
   MEMZERO(&info, 1);
   info.ref = string.ref = UINT_MAX;
   info.filename = &string;
-  info.error = locp->error;
 
   if (locp != NULL) {
     info.first_line   = locp->first_line;
@@ -520,12 +527,14 @@ void augl_error(struct info *locp,
     info.last_line    = locp->last_line;
     info.last_column  = locp->last_column;
     info.filename->str = locp->filename->str;
+    info.error = locp->error;
   } else if (scanner != NULL) {
     info.first_line   = augl_get_lineno(scanner);
     info.first_column = augl_get_column(scanner);
     info.last_line    = augl_get_lineno(scanner);
     info.last_column  = augl_get_column(scanner);
     info.filename     = augl_get_extra(scanner)->filename;
+    info.error        = augl_get_extra(scanner)->error;
   } else if (*term != NULL && (*term)->info != NULL) {
     memcpy(&info, (*term)->info, sizeof(info));
   } else {
diff --git a/tests/modules/fail_empty_module.aug b/tests/modules/fail_empty_module.aug
new file mode 100644
index 0000000..e69de29




More information about the augeas-devel mailing list