]> cygwin.com Git - cygwin-apps/setup.git/blame - inilex.l
2002-04-26 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / inilex.l
CommitLineData
23c9e63c
DD
1%{
2/*
3 * Copyright (c) 2000, Red Hat, Inc.
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 as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * A copy of the GNU General Public License can be found at
11 * http://www.gnu.org/
12 *
13 * Written by DJ Delorie <dj@cygnus.com>
14 *
15 */
16
17/* tokenize the setup.ini files. We parse a string which we've
18 previously downloaded. The program must call ini_init() to specify
19 that string. */
20
b11b49f3 21#include "win32.h"
23c9e63c
DD
22#include <string.h>
23
24#include "ini.h"
25#include "iniparse.h"
3c054baf 26#include "String++.h"
23c9e63c
DD
27
28#define YY_INPUT(buf,result,max_size) { result = ini_getchar(buf, max_size); }
29
30static int ini_getchar(char *buf, int max_size);
b24c88b3 31static void ignore_line (void);
23c9e63c
DD
32
33%}
34
b11b49f3 35/*%option debug */
23c9e63c 36%option noyywrap
b11b49f3
DD
37%option yylineno
38%option never-interactive
39
9522028b 40STR [a-zA-Z0-9_./+-]+
23c9e63c
DD
41
42%%
43
5e0464a1
RC
44\"[^"]*\" { yylval = new char [strlen (yytext+1) + 1];
45 strcpy (yylval, yytext+1);
23c9e63c
DD
46 yylval[strlen (yylval)-1] = 0;
47 return STRING; }
48
49"setup-timestamp:" return SETUP_TIMESTAMP;
13d27274 50"setup-version:" return SETUP_VERSION;
f6100b6f 51"version:" return PACKAGEVERSION;
23c9e63c
DD
52"install:" return INSTALL;
53"source:" return SOURCE;
54"sdesc:" return SDESC;
55"ldesc:" return LDESC;
56
38c97581
CF
57"category:" return CATEGORY;
58"requires:" return REQUIRES;
59
c46a33a9
CF
60"apath:" return APATH;
61"ppath:" return PPATH;
62
63"include-setup:" return INCLUDE_SETUP;
64
c46a33a9
CF
65"download-url:" return DOWNLOAD_URL;
66
b11b49f3
DD
67^{STR}":" ignore_line ();
68
23c9e63c
DD
69"[curr]" return T_CURR;
70"[test]" return T_TEST;
13d27274 71"[exp]" return T_TEST;
23c9e63c 72"[prev]" return T_PREV;
b11b49f3 73"["{STR}"]" return T_UNKNOWN;
23c9e63c 74
5e0464a1
RC
75{STR} { yylval = new char [strlen(yytext) + 1];
76 strcpy (yylval, yytext);
23c9e63c
DD
77 return STRING; }
78
fb2cd8f6 79[ \t\r]+ /* do nothing */;
b11b49f3 80
fb2cd8f6 81"#".*\n { return '\n'; }
23c9e63c 82
fb2cd8f6
CF
83\n { return *yytext; }
84. { return *yytext; }
23c9e63c
DD
85
86%%
87
341988b9
RC
88#include "io_stream.h"
89
90static io_stream *input_stream = 0;
bb849dbd 91extern char *parse_mirror;
341988b9 92
23c9e63c 93void
3c054baf 94ini_init(io_stream *stream, String const &mirror)
23c9e63c 95{
341988b9 96 input_stream = stream;
bb849dbd 97 if (parse_mirror)
5e0464a1 98 delete[] parse_mirror;
3c054baf 99 parse_mirror = mirror.cstr();
23c9e63c
DD
100}
101
102static int
103ini_getchar(char *buf, int max_size)
104{
341988b9 105 if (input_stream)
23c9e63c 106 {
341988b9
RC
107 ssize_t len = input_stream->read (buf, max_size);
108 if (len < 1)
109 {
110 len = 0;
111 input_stream = 0;
23c9e63c 112 }
341988b9 113 return len;
23c9e63c 114 }
341988b9 115 return 0;
23c9e63c 116}
b11b49f3
DD
117
118static void
119ignore_line ()
120{
121 char c;
341988b9 122 while ((c = yyinput ()))
b11b49f3
DD
123 {
124 if (c == EOF)
125 return;
126 if (c == '\n')
127 return;
128 }
129}
This page took 0.043148 seconds and 5 git commands to generate.