Selaa lähdekoodia

fix runaway default packing, array range syntax

David Rose 21 vuotta sitten
vanhempi
sitoutus
0810adaa2c

+ 5 - 1
direct/src/dcparser/dcArrayParameter.cxx

@@ -251,7 +251,11 @@ generate_hash(HashGenerator &hashgen) const {
 ////////////////////////////////////////////////////////////////////
 bool DCArrayParameter::
 pack_default_value(DCPackData &pack_data, bool &pack_error) const {
-  if (has_default_value()) {
+  // We only want to call up if the DCField can pack the value
+  // immediately--we don't trust the DCField to generate the default
+  // value (since it doesn't know how large the minimum length array
+  // is).
+  if (_has_default_value && !_default_value_stale) {
     return DCField::pack_default_value(pack_data, pack_error);
   }
 

+ 1 - 1
direct/src/dcparser/dcPacker.I

@@ -85,7 +85,7 @@ get_num_nested_fields() const {
 ////////////////////////////////////////////////////////////////////
 INLINE bool DCPacker::
 more_nested_fields() const {
-  return (_current_field != (DCPackerInterface *)NULL);
+  return (_current_field != (DCPackerInterface *)NULL && !_pack_error);
 }
 
 ////////////////////////////////////////////////////////////////////

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 301 - 293
direct/src/dcparser/dcParser.cxx.prebuilt


+ 28 - 0
direct/src/dcparser/dcParser.yxx

@@ -160,6 +160,7 @@ dc_cleanup_parser() {
 %type <str> optional_name
 %type <u.s_uint> char_or_uint
 %type <u.s_uint> small_unsigned_integer
+%type <u.s_uint> small_negative_integer
 %type <u.int64> signed_integer
 %type <u.uint64> unsigned_integer
 %type <u.real> char_or_number
@@ -779,6 +780,13 @@ uint_range:
   if (!uint_range.add_range($1, $3)) {
     yyerror("Overlapping range");
   }
+}
+	| char_or_uint small_negative_integer
+{
+  uint_range.clear();
+  if (!uint_range.add_range($1, $2)) {
+    yyerror("Overlapping range");
+  }
 }
 	| uint_range ',' char_or_uint
 {
@@ -791,6 +799,12 @@ uint_range:
   if (!uint_range.add_range($3, $5)) {
     yyerror("Overlapping range");
   }
+}
+	| uint_range ',' char_or_uint small_negative_integer
+{
+  if (!uint_range.add_range($3, $4)) {
+    yyerror("Overlapping range");
+  }
 }
 	;
 
@@ -856,6 +870,20 @@ small_unsigned_integer:
 }
 	;
 
+small_negative_integer:
+	SIGNED_INTEGER
+{
+  $$ = (unsigned int)-$1;
+  if ($1 >= 0) {
+    yyerror("Syntax error.");
+
+  } else if ($$ != -$1) {
+    yyerror("Number out of range.");
+    $$ = 1;
+  }
+}
+	;
+
 signed_integer:
         SIGNED_INTEGER
 	;

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä