From b0e6c2a9c839659090dd6d5448ab617bb0509d8a Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Wed, 1 Nov 2006 04:53:27 +0000 Subject: [PATCH] Ignore UTF-8 marker at the start of .conf files. Add stab2cv to 3rd party dependencies. This is a utility I wrote that is licensed under the GPL and available on SourceForge. It converts the stab debugging info generated by gcc into Codeview format. Currently it just translates function names to global symbols. This is sufficient to get reasonable stack traces from Dr Watson and to look at minidumps. Fix bug # 699 - winbacula client crashes whilerunning bat scripts. Enable Windows XP look and feel for the tray icons and wx-console. Add Windows specific FileSet example to bacula-dir.conf. Reorganize Start menu so that documentation and configuration are in subfolders. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3589 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/lib/lex.c | 32 ++++++++++++++++++++++++++++++++ bacula/src/lib/lex.h | 5 ++++- bacula/src/lib/parse_conf.c | 5 ++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index 13b2cb9ab2..2fa93a7d13 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -324,6 +324,7 @@ lex_get_token(LEX *lf, int expect) int ch; int token = T_NONE; bool esc_next = false; + int unicode_count = 0; Dmsg0(dbglvl, "enter lex_get_token\n"); while (token == T_NONE) { @@ -395,6 +396,16 @@ lex_get_token(LEX *lf, int expect) lf->state = lex_include; begin_str(lf, 0); break; + case 0xEF: + if (lf->line_no != 1 || lf->col_no != 1) + { + lf->state = lex_string; + begin_str(lf, ch); + break; + } + lf->state = lex_unicode_mark; + unicode_count = 1; + break; default: lf->state = lex_string; begin_str(lf, ch); @@ -526,6 +537,27 @@ lex_get_token(LEX *lf, int expect) } add_str(lf, ch); break; + case lex_unicode_mark: + if (ch == L_EOF) { + token = T_ERROR; + break; + } + unicode_count++; + if (unicode_count == 2) { + if (ch != 0xBB) { + token = T_ERROR; + break; + } + } else if (unicode_count == 3) { + if (ch != 0xBF) { + token = T_ERROR; + break; + } + token = T_UNICODE_MARK; + lf->state = lex_none; + break; + } + break; } Dmsg4(dbglvl, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state), lex_tok_to_str(token), ch); diff --git a/bacula/src/lib/lex.h b/bacula/src/lib/lex.h index 1a05225d0e..bf0bd1aac1 100644 --- a/bacula/src/lib/lex.h +++ b/bacula/src/lib/lex.h @@ -46,6 +46,8 @@ #define T_COMMA 111 #define T_EOL 112 #define T_ERROR 200 +#define T_UNICODE_MARK 201 + /* * The following will be returned only if * the appropriate expect flag has been set @@ -69,7 +71,8 @@ enum lex_state { lex_identifier, lex_string, lex_quoted_string, - lex_include + lex_include, + lex_unicode_mark }; /* Lex scan options */ diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index fb18ada83c..b3f6804312 100755 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -813,6 +813,9 @@ parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type) if (token == T_EOL) { break; } + if (token == T_UNICODE_MARK) { + break; + } if (token != T_IDENTIFIER) { scan_err1(lc, _("Expected a Resource name identifier, got: %s"), lc->str); return 0; @@ -827,7 +830,7 @@ parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type) } if (state == p_none) { scan_err1(lc, _("expected resource name, got: %s"), lc->str); - return 0; + return 0; } break; case p_resource: -- 2.39.5