]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/lex.c
- Add code to ensure that reserved but unused volumes
[bacula/bacula] / bacula / src / lib / lex.c
index 9f98b6c476df2c8a6a39b2e43a880b3f0ca613e4..fdeb700ec4d4a32a3e0228e34cd02fbb3cbd3733 100644 (file)
@@ -61,7 +61,6 @@ int scan_to_next_not_eol(LEX * lc)
    return token;
 }
 
-
 /*
  * Format a scanner error message
  */
@@ -80,10 +79,19 @@ static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
                 _("Problem probably begins at line %d.\n"), lc->begin_line_no);
    } else {
       more[0] = 0;
-   }
-   e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"
+   }  
+   if (lc->line_no > 0) {
+      e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"
 "            : line %d, col %d of file %s\n%s\n%s"),
-      buf, lc->line_no, lc->col_no, lc->fname, lc->line, more);
+         buf, lc->line_no, lc->col_no, lc->fname, lc->line, more);
+   } else {
+      e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"), buf);
+   }
+}
+
+void lex_set_default_error_handler(LEX *lf)
+{
+   lf->scan_error = s_err;
 }
 
 
@@ -137,7 +145,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
    if ((fd = fopen(fname, "r")) == NULL) {
       return NULL;
    }
-   Dmsg1(2000, "Open config file: %s\n", fname);
+   Dmsg1(400, "Open config file: %s\n", fname);
    nf = (LEX *)malloc(sizeof(LEX));
    if (lf) {
       memcpy(nf, lf, sizeof(LEX));
@@ -148,15 +156,15 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
       lf = nf;                        /* start new packet */
       memset(lf, 0, sizeof(LEX));
    }
-   lf->fd = fd;
-   lf->fname = fname;
-   lf->state = lex_none;
-   lf->ch = L_EOL;
    if (scan_error) {
       lf->scan_error = scan_error;
    } else {
-      lf->scan_error = s_err;
+      lex_set_default_error_handler(lf);
    }
+   lf->fd = fd;
+   lf->fname = fname;
+   lf->state = lex_none;
+   lf->ch = L_EOL;
    Dmsg1(2000, "Return lex=%x\n", lf);
    return lf;
 }
@@ -182,6 +190,7 @@ int lex_get_char(LEX *lf)
       }
       lf->line_no++;
       lf->col_no = 0;
+      Dmsg2(400, "fget line=%d %s", lf->line_no, lf->line);
    }
    lf->ch = (uint8_t)lf->line[lf->col_no];
    if (lf->ch == 0) {