Skip to content

Commit 8812aee

Browse files
committed
Use rwlscanstring in rwldilex
1 parent 5eac407 commit 8812aee

File tree

2 files changed

+11
-45
lines changed

2 files changed

+11
-45
lines changed

src/rwldilex.l

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
* History
1616
*
17+
* bengsig 25-may-2023 - Use rwlscanstring.c
1718
* bengsig 15-may-2023 - statisticsonly
1819
* bengsig 8-mar-2023 - Normal Distributed random
1920
* bengsig 9-jan-2023 - CQN Project
@@ -49,6 +50,7 @@
4950

5051
#define YYSTYPE RWLZSTYPE
5152
#define YY_DECL sb4 rwlzlex(void *yylval_param, void *yyscanner)
53+
#define RWL_IN_DILEX // make rwlscanstring.c do the right thing
5254

5355
%}
5456

@@ -64,50 +66,9 @@
6466
}
6567

6668
/*LEXTAG:RWL_Z_STRING_CONST*/
67-
\"(\\.|[^\\"])*\" { // mostly like rwllexer.l
68-
text *in, *ut;
69-
/* copy string and remove " at ends */
70-
rwm->sval = rwlstrdup(rwm, (text *)yytext+1);
71-
if ('"' == yytext[yyleng-1])
72-
{
73-
rwm->sval[yyleng-2] = 0;
74-
}
75-
/* handle \ escapes */
76-
for (ut=in=rwm->sval; *in; ut++, in++)
77-
{
78-
if ('\n' == *in)
79-
rwm->loc.lineno++;
80-
if (*in == '\\')
81-
{
82-
in++;
83-
switch (*in)
84-
{
85-
case '\\': *ut='\\'; break;
86-
case '\"': *ut='\"'; break;
87-
case 'n': *ut='\n'; break;
88-
case 't': *ut='\t'; break;
89-
case 'r': *ut='\r'; break;
90-
case 'e': *ut='\e'; break;
91-
case 0: goto end_of_string;
92-
default:
93-
*ut= *in;
94-
rwlerror(rwm, RWL_ERROR_INVALID_ESCAPE_NO_POS, *in);
95-
break;
96-
}
97-
}
98-
else
99-
*ut = *in;
100-
}
101-
end_of_string:
102-
*ut = 0;
103-
rwm->slen = rwlstrlen(rwm->sval);
104-
if (rwm->slen>RWL_MAX_STRING_LENGTH)
105-
{
106-
rwlerror(rwm, RWL_ERROR_STRING_TOO_LONG, RWL_MAX_STRING_LENGTH);
107-
rwm->slen=RWL_MAX_STRING_LENGTH;
108-
rwm->sval[rwm->slen] = 0;
109-
}
110-
return RWL_Z_STRING_CONST;
69+
\"(\\.|[^\\"])*\" {
70+
// Use this tag in vi: rwlscanstring
71+
#include "rwlscanstring.c"
11172
}
11273

11374
/*LEXTAG:RWL_Z_DOUBLE_CONST*/

src/rwlscanstring.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
*
1414
* History
1515
*
16+
* bengsig 25-may-2023 - Also use in rwldilex.l
1617
* bengsig 04-jul-2022 - Creation
1718
*/
1819

1920
// This code should NOT be compiled stand alone, but only
20-
// included from rwllexer.l and rwlarglex.l
21+
// included from rwllexer.l, rwldilex.l and rwlarglex.l
2122

2223
#ifdef NEVER
2324
// This makes ctags and cscope add contents
@@ -77,7 +78,11 @@ ub4 rwlscanstring(void)
7778
rwm->sval[rwm->slen] = 0;
7879
}
7980
#ifndef RWL_IN_ARGLEX
81+
# ifdef RWL_IN_DILEX
82+
return RWL_Z_STRING_CONST;
83+
# else
8084
if (!rwm->ifdirbit) return RWL_T_STRING_CONST;
85+
# endif
8186
#endif
8287

8388
}

0 commit comments

Comments
 (0)