2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: rescan.c /main/1 1996/04/21 19:24:17 drk $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company
26 * (c) Copyright 1993, 1994 International Business Machines Corp.
27 * (c) Copyright 1993, 1994 Novell, Inc.
28 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
31 #include <EUSCompat.h>
43 #define ENDMARKERSYMBOL '$'
44 #define DURATIONSYMBOL '#'
45 #define FRONTWEEKSYMBOL '+'
46 #define REARWEEKSYMBOL '-'
47 #define MINUTESYMBOL 'M'
48 #define DAILYSYMBOL 'D'
49 #define WEEKLYSYMBOL 'W'
50 #define LASTDAYSYMBOL "LD"
51 #define MONTHPOSSYMBOL "MP"
52 #define MONTHDAYSYMBOL "MD"
53 #define YEARDAYSYMBOL "YD"
54 #define YEARMONTHSYMBOL "YM"
55 #define SUNSYMBOL "SU"
56 #define MONSYMBOL "MO"
57 #define TUESYMBOL "TU"
58 #define WEDSYMBOL "WE"
59 #define THUSYMBOL "TH"
60 #define FRISYMBOL "FR"
61 #define SATSYMBOL "SA"
63 static int scanbuf(char **inbuf, char *, int *);
65 /* The rule that needs to be parsed is passed to yylex() through this var */
68 char _DtCm_yytext[128];
76 _DtCm_yylval.number = 0;
78 token = scanbuf(&_DtCm_rule_buf, _DtCm_yytext, &yylen);
80 sscanf(_DtCm_yytext, "%d", &_DtCm_yylval.number);
82 strcpy(_DtCm_yylval.date, _DtCm_yytext);
97 char *yystart = yytext;
99 memset(yytext, '\0', *yylen);
100 yytext[*yylen - 1] = '\0';
101 (*yylen)--; /* Leave room for trailing '\0' */
118 /* Keep whitespace out of text */
121 /* State remains 0 */
122 } else if (isdigit(c)) {
123 if (**buf == '+' || **buf == '-') /* 1+ or 2- */
127 } else if (isalpha(c)) {
132 } else if (c == ENDMARKERSYMBOL) {
134 } else if (c == DURATIONSYMBOL) {
136 } else if (c == '\0') {
146 /* Stay in state 1 and get rest of number */
148 } else if (isspace(c) || c == '\0') {
149 /* Hit a delimiter. Put it back into the
150 * input buffer and keep it out of the token
154 yytext--; (*yylen)++;
162 /* Get a command or weekday */
163 if (strcmp(yystart, MONTHPOSSYMBOL) == 0) {
164 return(MONTHPOSCOMMAND);
165 } else if (strcmp(yystart, MONTHDAYSYMBOL) == 0) {
166 return(MONTHDAYCOMMAND);
167 } else if (strcmp(yystart, YEARDAYSYMBOL) == 0) {
168 return(YEARDAYCOMMAND);
169 } else if (strcmp(yystart, YEARMONTHSYMBOL) == 0) {
170 return(YEARMONTHCOMMAND);
171 } else if (strcmp(yystart, LASTDAYSYMBOL) == 0) {
173 } else if (strcmp(yystart, SUNSYMBOL) == 0) {
175 } else if (strcmp(yystart, MONSYMBOL) == 0) {
177 } else if (strcmp(yystart, TUESYMBOL) == 0) {
179 } else if (strcmp(yystart, WEDSYMBOL) == 0) {
181 } else if (strcmp(yystart, THUSYMBOL) == 0) {
183 } else if (strcmp(yystart, FRISYMBOL) == 0) {
185 } else if (strcmp(yystart, SATSYMBOL) == 0) {
191 /* Get a weeknumber */
192 if (c == FRONTWEEKSYMBOL) {
193 int num = lastchar - '0';
210 } else if (c == REARWEEKSYMBOL) {
211 int num = lastchar - '0';
231 /* Found a single letter...probably a command */
233 /* We expect an interval to follow a command */
234 if (isdigit(c) == 0) return(ERROR);
236 /* Backup to before digit */
238 yytext--; (*yylen)++;
244 return(DAILYCOMMAND);
246 return(MINUTECOMMAND);
248 return(WEEKLYCOMMAND);
253 /* Reading an ISO 8601 date */
254 if (isspace(c) || c == '\0') {
255 /* Hit a delimiter. Put it back into the
256 * input buffer and keep it out of the token
260 yytext--; (*yylen)++;
268 /* Should never get to */