Debian Codegraph @

storage/innobase/pars/make_flex.sh

raw
1 #!/bin/bash
2 #
3 # Copyright (c) 1994, 2026, Oracle and/or its affiliates.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License, version 2.0,
7 # as published by the Free Software Foundation.
8 #
9 # This program is designed to work with certain software (including
10 # but not limited to OpenSSL) that is licensed under separate terms,
11 # as designated in a particular file or component or in included license
12 # documentation. The authors of MySQL hereby grant you an additional
13 # permission to link the program and your derivative works with the
14 # separately licensed software that they have either included with
15 # the program or referenced in the documentation.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License, version 2.0, for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #
26 # generate lexer files from flex input files.
27
28 set -eu
29
30 TMPFILE=_flex_tmp.cc
31 OUTFILE=lexyy.cc
32
33 flex -o $TMPFILE pars0lex.l
34
35 # AIX needs its includes done in a certain order, so include "univ.i" first
36 # to be sure we get it right.
37 echo '#include "univ.i"' > $OUTFILE
38 echo 'static char *yytext;' >> $OUTFILE
39
40 # flex assigns a pointer to an int in one place without a cast, resulting in
41 # a warning on Win64. Add the cast. Also define some symbols as static.
42 sed -e '
43 s/'"$TMPFILE"'/'"$OUTFILE"'/;
44 s/\<register\> *//;
45 s/\(int offset = \)\((yy_c_buf_p) - (yytext_ptr)\);/\1(int)(\2);/;
46 s/\(void yy\(restart\|_\(delete\|flush\)_buffer\)\)/static \1/;
47 s/\(void yy_switch_to_buffer\)/[[maybe_unused]] static \1/;
48 s/\(void yy\(push\|pop\)_buffer_state\)/[[maybe_unused]] static \1/;
49 s/\(YY_BUFFER_STATE yy_create_buffer\)/static \1/;
50 s/^void yyset_extra.*;//;
51 s/\(\(int\|void\) yy[gs]et_\)/[[maybe_unused]] static \1/;
52 s/\(void \*\?yy\(\(re\)\?alloc\|free\)\)/static \1/;
53 s/\(extern \)\?\(int yy\(leng\|lineno\|_flex_debug\)\)/static \2/;
54 s/\(int yylex_destroy\)/[[maybe_unused]] static \1/;
55 s/^\(\(FILE\|char\) *\* *yyget\)/[[maybe_unused]] static \1/;
56 s/^\(extern \)\?\(\(FILE\|char\) *\* *yy\)/static \2/;
57 s/^static FILE \*yyin = .*0, \*yyout = .*0;//;
58 s/^static int yy\(_flex_debug\|lineno\);//;
59 s/^static char \*yytext;//;
60 ' < $TMPFILE >> $OUTFILE
61
62 rm $TMPFILE