mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Github issue 134:
Their is an ambiguity in the DAP2 spec. Section A.2 of the dap2 spec says: "...The backslash character (.\.) MAY be used as a single-character quoting mechanism only within quoted-string and comment constructs. quoted-pair = "\" CHAR ..." The underlying problem was to allow for " chars inside strings by using \". However, this definition is overbroad. It is not stated: 1. if the backslash is to be left in the string or not. 2. There is also an unstated, but related issue of what to do about e.g. '\n';convert to newline or not. This change is to conform to libdap and it does the following: 1. The backslash is left in the string 2. Things like \n are left as is and it is assumed that higher level code will decide what to do with e.g. \n.
This commit is contained in:
parent
758b840697
commit
370bd15166
28
oc2/daplex.c
28
oc2/daplex.c
@ -9,7 +9,11 @@
|
||||
#include "daptab.h"
|
||||
|
||||
#undef URLCVT /* NEVER turn this on */
|
||||
|
||||
#define DAP2ENCODE
|
||||
#ifdef DAP2ENCODE
|
||||
#define KEEPSLASH
|
||||
#endif
|
||||
|
||||
/* Forward */
|
||||
static void dumptoken(DAPlexstate* lexstate);
|
||||
@ -132,18 +136,30 @@ daplex(YYSTYPE* lvalp, DAPparsestate* state)
|
||||
int more = 1;
|
||||
/* We have a string token; will be reported as WORD_STRING */
|
||||
while(more && (c=*(++p))) {
|
||||
#ifdef DAP2ENCODE
|
||||
if(c == '"')
|
||||
if(c == '"') {
|
||||
more = 0;
|
||||
else if(c == '\\') {
|
||||
/* Remove spec ambiguity by convering \c to c
|
||||
for any character c */
|
||||
continue;
|
||||
}
|
||||
#ifdef DAP2ENCODE
|
||||
if(c == '\\') {
|
||||
/* Resolve spec ambiguity about handling of \c:
|
||||
1. !KEEPSLASH: convert \c to c for any character c
|
||||
2. KEEPSLASH: convert \c to \c for any character c;
|
||||
that is, keep the backslash.
|
||||
It is clear that the problem being addressed was \".
|
||||
But it is unclear what to to do about \n: convert to
|
||||
Ascii LF or leave as \n.
|
||||
This code will leave as \n and assume higher levels
|
||||
of code will address the issue.
|
||||
*/
|
||||
#ifdef KEEPSLASH
|
||||
dapaddyytext(lexstate,c);
|
||||
#endif
|
||||
c=*(++p);
|
||||
if(c == '\0') more = 0;
|
||||
}
|
||||
#else /*Non-standard*/
|
||||
switch (c) {
|
||||
case '"': more=0; break;
|
||||
case '\\':
|
||||
c=*(++p);
|
||||
switch (c) {
|
||||
|
Loading…
Reference in New Issue
Block a user