hotspot/src/share/vm/classfile/compactHashtable.cpp
changeset 35868 bf29f15cdf30
parent 34659 3a7071043457
child 37995 92aec042a43b
equal deleted inserted replaced
35867:e20281e87b93 35868:bf29f15cdf30
   363   _line_no ++;
   363   _line_no ++;
   364   return true;
   364   return true;
   365 }
   365 }
   366 
   366 
   367 int HashtableTextDump::skip(char must_be_char) {
   367 int HashtableTextDump::skip(char must_be_char) {
   368   corrupted_if(remain() < 1);
   368   corrupted_if(remain() < 1, "Truncated");
   369   corrupted_if(*_p++ != must_be_char);
   369   corrupted_if(*_p++ != must_be_char, "Unexpected character");
   370   return 0;
   370   return 0;
   371 }
   371 }
   372 
   372 
   373 void HashtableTextDump::skip_past(char c) {
   373 void HashtableTextDump::skip_past(char c) {
   374   for (;;) {
   374   for (;;) {
   375     corrupted_if(remain() < 1);
   375     corrupted_if(remain() < 1, "Truncated");
   376     if (*_p++ == c) {
   376     if (*_p++ == c) {
   377       return;
   377       return;
   378     }
   378     }
   379   }
   379   }
   380 }
   380 }
   381 
   381 
   382 void HashtableTextDump::check_version(const char* ver) {
   382 void HashtableTextDump::check_version(const char* ver) {
   383   int len = (int)strlen(ver);
   383   int len = (int)strlen(ver);
   384   corrupted_if(remain() < len);
   384   corrupted_if(remain() < len, "Truncated");
   385   if (strncmp(_p, ver, len) != 0) {
   385   if (strncmp(_p, ver, len) != 0) {
   386     quit("wrong version of hashtable dump file", _filename);
   386     quit("wrong version of hashtable dump file", _filename);
   387   }
   387   }
   388   _p += len;
   388   _p += len;
   389   skip_newline();
   389   skip_newline();
   449 }
   449 }
   450 
   450 
   451 jchar HashtableTextDump::unescape(const char* from, const char* end, int count) {
   451 jchar HashtableTextDump::unescape(const char* from, const char* end, int count) {
   452   jchar value = 0;
   452   jchar value = 0;
   453 
   453 
   454   corrupted_if(from + count > end);
   454   corrupted_if(from + count > end, "Truncated");
   455 
   455 
   456   for (int i=0; i<count; i++) {
   456   for (int i=0; i<count; i++) {
   457     char c = *from++;
   457     char c = *from++;
   458     switch (c) {
   458     switch (c) {
   459     case '0': case '1': case '2': case '3': case '4':
   459     case '0': case '1': case '2': case '3': case '4':
   484 
   484 
   485   for (; n > 0 && from < end; n--) {
   485   for (; n > 0 && from < end; n--) {
   486     if (*from != '\\') {
   486     if (*from != '\\') {
   487       *to++ = *from++;
   487       *to++ = *from++;
   488     } else {
   488     } else {
   489       corrupted_if(from + 2 > end);
   489       corrupted_if(from + 2 > end, "Truncated");
   490       char c = from[1];
   490       char c = from[1];
   491       from += 2;
   491       from += 2;
   492       switch (c) {
   492       switch (c) {
   493       case 'x':
   493       case 'x':
   494         {
   494         {
   505       default:
   505       default:
   506         corrupted(_p, "Unsupported character");
   506         corrupted(_p, "Unsupported character");
   507       }
   507       }
   508     }
   508     }
   509   }
   509   }
   510   corrupted_if(n > 0); // expected more chars but file has ended
   510   corrupted_if(n > 0, "Truncated"); // expected more chars but file has ended
   511   _p = from;
   511   _p = from;
   512   skip_newline();
   512   skip_newline();
   513 }
   513 }
   514 
   514 
   515 // NOTE: the content is NOT the same as
   515 // NOTE: the content is NOT the same as