[NCF-271]

Fix bug introduced by [NCF-267].
The bug was that octal constants that had
the highest bit set (e.g. '\200')
were not recognized as proper octal
constants. Fix was to keep as integer
until it was needed as an 8-bit byte.
This commit is contained in:
dmh 2013-09-26 10:10:26 -06:00
parent 1aef893cea
commit 850af2d435
8 changed files with 889 additions and 1127 deletions

View File

@ -10,6 +10,11 @@ information, where '[NCF-XXX]' refers to https://www.unidata.ucar.edu/jira/brows
### 4.3.1-rc4 Released TBD
Fix bug introduced by [NCF-267] where octal constants above
'\177' were not recognized as proper octal constants. [NCF-271]
[NCF-271]:https://bugtracking.unidata.ucar.edu/browse/NCF-271
### 4.3.1-rc3 Released 2013-09-24
* Modify ncgen to support NUL characters in character array

View File

@ -4,9 +4,14 @@ dimensions:
variables:
char cdata(n) ;
char cdata2(n) ;
// global attributes:
:global = "x\000y" ;
:global = "x\000y" ;
:byte_att = '\000','\001','\002','\177','\200','\201','\376','\377';
data:
cdata = "abc\000def" ;
cdata2 = '\000','\001','\002','\177','\200','\201','\376','\377';
}

View File

@ -3,10 +3,14 @@ dimensions:
n = 8 ;
variables:
char cdata(n) ;
char cdata2(n) ;
// global attributes:
:global = "x\000y" ;
:byte_att = 0b, 1b, 2b, 127b, -128b, -127b, -2b, -1b ;
data:
cdata = "abc\000def" ;
cdata2 = "\000\001\002\177\200\201\376\377" ;
}

View File

@ -618,7 +618,8 @@ unescapehex(const char* s)
/*
* Given a pointer to a string of the form
* 'ddd', return the corresponding octal byte
* 'ddd', return the corresponding
* unsigned octal byte
*/
int
@ -708,6 +709,10 @@ unescape(
case '4': case '5': case '6': case '7':
/* t now points to octal */
b = unescapeoct(t);
if(b < 0) {
derror("Bad octal constant: %s",yytext);
b = 0;
}
t += 3;
*p++ = ((char)b);
break;

View File

@ -513,19 +513,21 @@ NIL|nil|Nil {
return lexdebug(BYTE_CONST);
}
\'\\[0-7][0-7][0-7]\' {
byte_val = unescapeoct(&yytext[2]);
if(byte_val < 0) {
int oct = unescapeoct(&yytext[2]);
if(oct < 0) {
sprintf(errstr,"bad octal character constant: %s",(char*)yytext);
yyerror(errstr);
}
byte_val = (unsigned int)oct;
return lexdebug(BYTE_CONST);
}
\'\\[xX][0-9a-fA-F][0-9a-fA-F]\' {
byte_val = unescapehex(&yytext[3]);
int hex = unescapehex(&yytext[3]);
if(byte_val < 0) {
sprintf(errstr,"bad hex character constant: %s",(char*)yytext);
yyerror(errstr);
}
byte_val = (unsigned int)hex;
return lexdebug(BYTE_CONST);
}
\'\\.\' {

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 2.6.4. */
/* A Bison parser, made by GNU Bison 3.0. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@ -26,13 +26,13 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_NCG_NCGEN_TAB_H_INCLUDED
# define YY_NCG_NCGEN_TAB_H_INCLUDED
/* Enabling traces. */
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
@ -40,69 +40,68 @@
extern int ncgdebug;
#endif
/* Tokens. */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
NC_UNLIMITED_K = 258,
CHAR_K = 259,
BYTE_K = 260,
SHORT_K = 261,
INT_K = 262,
FLOAT_K = 263,
DOUBLE_K = 264,
UBYTE_K = 265,
USHORT_K = 266,
UINT_K = 267,
INT64_K = 268,
UINT64_K = 269,
IDENT = 270,
TERMSTRING = 271,
CHAR_CONST = 272,
BYTE_CONST = 273,
SHORT_CONST = 274,
INT_CONST = 275,
INT64_CONST = 276,
UBYTE_CONST = 277,
USHORT_CONST = 278,
UINT_CONST = 279,
UINT64_CONST = 280,
FLOAT_CONST = 281,
DOUBLE_CONST = 282,
DIMENSIONS = 283,
VARIABLES = 284,
NETCDF = 285,
DATA = 286,
TYPES = 287,
COMPOUND = 288,
ENUM = 289,
OPAQUE = 290,
OPAQUESTRING = 291,
GROUP = 292,
PATH = 293,
FILLMARKER = 294,
NIL = 295,
_FILLVALUE = 296,
_FORMAT = 297,
_STORAGE = 298,
_CHUNKSIZES = 299,
_DEFLATELEVEL = 300,
_SHUFFLE = 301,
_ENDIANNESS = 302,
_NOFILL = 303,
_FLETCHER32 = 304,
DATASETID = 305
};
enum yytokentype
{
NC_UNLIMITED_K = 258,
CHAR_K = 259,
BYTE_K = 260,
SHORT_K = 261,
INT_K = 262,
FLOAT_K = 263,
DOUBLE_K = 264,
UBYTE_K = 265,
USHORT_K = 266,
UINT_K = 267,
INT64_K = 268,
UINT64_K = 269,
IDENT = 270,
TERMSTRING = 271,
CHAR_CONST = 272,
BYTE_CONST = 273,
SHORT_CONST = 274,
INT_CONST = 275,
INT64_CONST = 276,
UBYTE_CONST = 277,
USHORT_CONST = 278,
UINT_CONST = 279,
UINT64_CONST = 280,
FLOAT_CONST = 281,
DOUBLE_CONST = 282,
DIMENSIONS = 283,
VARIABLES = 284,
NETCDF = 285,
DATA = 286,
TYPES = 287,
COMPOUND = 288,
ENUM = 289,
OPAQUE = 290,
OPAQUESTRING = 291,
GROUP = 292,
PATH = 293,
FILLMARKER = 294,
NIL = 295,
_FILLVALUE = 296,
_FORMAT = 297,
_STORAGE = 298,
_CHUNKSIZES = 299,
_DEFLATELEVEL = 300,
_SHUFFLE = 301,
_ENDIANNESS = 302,
_NOFILL = 303,
_FLETCHER32 = 304,
DATASETID = 305
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
/* Line 2077 of yacc.c */
#line 131 "ncgen.y"
#line 131 "ncgen.y" /* yacc.c:1909 */
Symbol* sym;
unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/
@ -111,29 +110,15 @@ int nctype; /* for tracking attribute list type*/
Datalist* datalist;
NCConstant constant;
/* Line 2077 of yacc.c */
#line 117 "ncgen.tab.h"
} YYSTYPE;
#line 114 "ncgen.tab.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE ncglval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int ncgparse (void *YYPARSE_PARAM);
#else
int ncgparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int ncgparse (void);
#else
int ncgparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */

View File

@ -1322,7 +1322,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( ncgtext, ncgleng, 1, ncgout )) {} } while (0)
#define ECHO fwrite( ncgtext, ncgleng, 1, ncgout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -1333,7 +1333,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
unsigned n; \
int n; \
for ( n = 0; n < max_size && \
(c = getc( ncgin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -2000,29 +2000,31 @@ case 42:
YY_RULE_SETUP
#line 515 "ncgen.l"
{
byte_val = unescapeoct(&ncgtext[2]);
if(byte_val < 0) {
int oct = unescapeoct(&ncgtext[2]);
if(oct < 0) {
sprintf(errstr,"bad octal character constant: %s",(char*)ncgtext);
yyerror(errstr);
}
byte_val = (unsigned int)oct;
return lexdebug(BYTE_CONST);
}
YY_BREAK
case 43:
YY_RULE_SETUP
#line 523 "ncgen.l"
#line 524 "ncgen.l"
{
byte_val = unescapehex(&ncgtext[3]);
int hex = unescapehex(&ncgtext[3]);
if(byte_val < 0) {
sprintf(errstr,"bad hex character constant: %s",(char*)ncgtext);
yyerror(errstr);
}
byte_val = (unsigned int)hex;
return lexdebug(BYTE_CONST);
}
YY_BREAK
case 44:
YY_RULE_SETUP
#line 531 "ncgen.l"
#line 533 "ncgen.l"
{
switch ((char)ncgtext[2]) {
case 'a': byte_val = '\007'; break; /* not everyone under-
@ -2044,7 +2046,7 @@ YY_RULE_SETUP
case 45:
/* rule 45 can match eol */
YY_RULE_SETUP
#line 549 "ncgen.l"
#line 551 "ncgen.l"
{
lineno++ ;
break;
@ -2052,7 +2054,7 @@ YY_RULE_SETUP
YY_BREAK
case 46:
YY_RULE_SETUP
#line 554 "ncgen.l"
#line 556 "ncgen.l"
{/*initial*/
BEGIN(ST_C_COMMENT);
break;
@ -2061,21 +2063,21 @@ YY_RULE_SETUP
case 47:
/* rule 47 can match eol */
YY_RULE_SETUP
#line 559 "ncgen.l"
#line 561 "ncgen.l"
{/* continuation */
break;
}
YY_BREAK
case 48:
YY_RULE_SETUP
#line 563 "ncgen.l"
#line 565 "ncgen.l"
{/* final */
BEGIN(INITIAL);
break;
}
YY_BREAK
case YY_STATE_EOF(ST_C_COMMENT):
#line 568 "ncgen.l"
#line 570 "ncgen.l"
{/* final, error */
fprintf(stderr,"unterminated /**/ comment");
BEGIN(INITIAL);
@ -2084,17 +2086,17 @@ case YY_STATE_EOF(ST_C_COMMENT):
YY_BREAK
case 49:
YY_RULE_SETUP
#line 574 "ncgen.l"
#line 576 "ncgen.l"
{/* Note: this next rule will not work for UTF8 characters */
return lexdebug(ncgtext[0]) ;
}
YY_BREAK
case 50:
YY_RULE_SETUP
#line 577 "ncgen.l"
#line 579 "ncgen.l"
ECHO;
YY_BREAK
#line 2098 "lex.ncg.c"
#line 2100 "lex.ncg.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -3093,7 +3095,7 @@ void ncgfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 577 "ncgen.l"
#line 579 "ncgen.l"
static int