summaryrefslogtreecommitdiffstats
path: root/debian/patches/fixes/Allow-.js-preference-files-to-set-locked-prefs-with-lockP.patch
blob: b77465002b3ad1a21ae7ae3adb765e586605a46c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From: Mike Hommey <glandium@debian.org>
Date: Sat, 21 Jun 2008 02:48:46 +0200
Subject: Allow .js preference files to set locked prefs with lockPref()

---
 modules/libpref/parser/src/lib.rs | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/modules/libpref/parser/src/lib.rs b/modules/libpref/parser/src/lib.rs
index 3a0ad2c..ae884a6 100644
--- a/modules/libpref/parser/src/lib.rs
+++ b/modules/libpref/parser/src/lib.rs
@@ -11,7 +11,7 @@
 //! ```text
 //! <pref-file>   = <pref>*
 //! <pref>        = <pref-spec> "(" <pref-name> "," <pref-value> <pref-attrs> ")" ";"
-//! <pref-spec>   = "user_pref" | "pref" | "sticky_pref" // in default pref files
+//! <pref-spec>   = "user_pref" | "pref" | "sticky_pref | lockPref" // in default pref files
 //! <pref-spec>   = "user_pref"                          // in user pref files
 //! <pref-name>   = <string-literal>
 //! <pref-value>  = <string-literal> | "true" | "false" | <int-value>
@@ -169,6 +169,7 @@ enum Token {
     // Keywords
     Pref,       // pref
     StickyPref, // sticky_pref
+    LockPref,   // lockPref
     UserPref,   // user_pref
     True,       // true
     False,      // false
@@ -291,7 +292,7 @@ struct KeywordInfo {
     token: Token,
 }
 
-const KEYWORD_INFOS: [KeywordInfo; 7] = [
+const KEYWORD_INFOS: [KeywordInfo; 8] = [
     // These are ordered by frequency.
     KeywordInfo {
         string: b"pref",
@@ -321,6 +322,10 @@ const KEYWORD_INFOS: [KeywordInfo; 7] = [
         string: b"sticky_pref",
         token: Token::StickyPref,
     },
+    KeywordInfo {
+        string: b"lock_pref",
+        token: Token::LockPref,
+    },
 ];
 
 struct Parser<'t> {
@@ -373,14 +378,11 @@ impl<'t> Parser<'t> {
         // this will be either the first token of a new pref, or EOF.
         loop {
             // <pref-spec>
-            let (pref_value_kind, mut is_sticky) = match token {
-                Token::Pref if self.kind == PrefValueKind::Default => {
-                    (PrefValueKind::Default, false)
-                }
-                Token::StickyPref if self.kind == PrefValueKind::Default => {
-                    (PrefValueKind::Default, true)
-                }
-                Token::UserPref => (PrefValueKind::User, false),
+            let (pref_value_kind, mut is_sticky, mut is_locked) = match token {
+                Token::Pref => (PrefValueKind::Default, false, false),
+                Token::StickyPref => (PrefValueKind::Default, true, false),
+                Token::LockPref => (PrefValueKind::Default, false, true),
+                Token::UserPref => (PrefValueKind::User, false, false),
                 Token::SingleChar(EOF) => return !self.has_errors,
                 _ => {
                     token = self.error_and_recover(
@@ -490,7 +492,6 @@ impl<'t> Parser<'t> {
             };
 
             // ("," <pref-attr>)*   // default pref files only
-            let mut is_locked = false;
             let mut has_attrs = false;
             if self.kind == PrefValueKind::Default {
                 let ok = loop {