]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/lex.c
Remove obsolete .cvsignore files.
[bacula/bacula] / bacula / src / lib / lex.c
index 13b2cb9ab2a4ab1c0da93132631bf0a204797d7f..8eb6df75dbbe3543eb221a2b932122b041a1ffa1 100644 (file)
@@ -7,20 +7,32 @@
  *
  */
 /*
-   Copyright (C) 2000-2006 Kern Sibbald
+   Bacula® - The Network Backup Solution
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
+   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
 
- */
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 
 #include "bacula.h"
 #include "lex.h"
@@ -324,6 +336,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 +408,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 +549,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);