1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
30 ER: Table was made extra large, because there seems to be a problem with the
31 chaining. An nlist->next is sometimes overwritten somewhere, which
32 results in a SIGSEGV. I canceled the GDB with watchpoint after 2 days, though...
33 It works this way for now...
37 static Nlist
*nlist
[NLSIZE
];
46 static const struct kwtab kwtab
[] =
49 {"ifdef", KIFDEF
, ISKW
},
50 {"ifndef", KIFNDEF
, ISKW
},
51 {"elif", KELIF
, ISKW
},
52 {"else", KELSE
, ISKW
},
53 {"endif", KENDIF
, ISKW
},
54 {"include", KINCLUDE
, ISKW
},
55 {"include_next", KINCLUDENEXT
, ISKW
},
56 {"import", KIMPORT
, ISKW
},
57 {"define", KDEFINE
, ISKW
},
58 {"undef", KUNDEF
, ISKW
},
59 {"line", KLINE
, ISKW
},
60 {"error", KERROR
, ISKW
},
61 {"pragma", KPRAGMA
, ISKW
},
62 {"ident", KIDENT
, ISKW
},
63 {"eval", KEVAL
, ISKW
},
64 {"defined", KDEFINED
, ISDEFINED
+ ISUNCHANGE
},
65 {"machine", KMACHINE
, ISDEFINED
+ ISUNCHANGE
},
66 {"__LINE__", KLINENO
, ISMAC
+ ISUNCHANGE
},
67 {"__FILE__", KFILE
, ISMAC
+ ISUNCHANGE
},
68 {"__DATE__", KDATE
, ISMAC
+ ISUNCHANGE
},
69 {"__TIME__", KTIME
, ISMAC
+ ISUNCHANGE
},
70 {"__STDC__", KSTDC
, ISUNCHANGE
},
74 unsigned long namebit
[077 + 1];
79 struct kwtab
const *kp
;
82 static Token deftoken
[1] = {{NAME
, 0, 7, (uchar
*) "defined", 0}};
83 static Tokenrow deftr
= {deftoken
, deftoken
, deftoken
+ 1, 1};
85 for (kp
= kwtab
; kp
->kw
; kp
++)
87 t
.t
= (uchar
*) kp
->kw
;
88 t
.len
= strlen(kp
->kw
);
90 np
->flag
= (char) kp
->flag
;
91 np
->val
= (char) kp
->val
;
92 if (np
->val
== KDEFINED
)
103 lookup(Token
* tp
, int install
)
110 for (cp
= tp
->t
, cpe
= cp
+ tp
->len
; cp
< cpe
;)
116 if (*tp
->t
== *np
->name
&& tp
->len
== (unsigned int)np
->len
117 && strncmp((char *)tp
->t
, (char *)np
->name
, tp
->len
) == 0)
129 np
->name
= newstring(tp
->t
, tp
->len
, 0);
132 quickset(tp
->t
[0], tp
->len
> 1 ? tp
->t
[1] : 0);
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */