예제 #1
0
파일: phase.c 프로젝트: wormt/bcc
void read_dirc( struct parse* parse, struct pos* pos ) {
   // Directives can only appear in the upmost region.
   if ( parse->region != parse->task->region_upmost ) {
      p_diag( parse, DIAG_POS_ERR, pos,
         "directive not in upmost region" );
      p_bail( parse );
   }
   if ( parse->tk == TK_IMPORT ) {
      p_read_tk( parse );
      if ( parse->source->imported ) {
         p_test_tk( parse, TK_LIT_STRING );
         p_read_tk( parse );
      }
      else {
         read_include( parse, pos, true );
      }
   }
   else if ( strcmp( parse->tk_text, "include" ) == 0 ) {
      p_read_tk( parse );
      if ( parse->source->imported ) {
         p_test_tk( parse, TK_LIT_STRING );
         p_read_tk( parse );
      }
      else {
         read_include( parse, pos, false );
      }
   }
   else if ( strcmp( parse->tk_text, "define" ) == 0 ||
      strcmp( parse->tk_text, "libdefine" ) == 0 ) {
      read_define( parse );
   }
   else if ( strcmp( parse->tk_text, "library" ) == 0 ) {
      p_read_tk( parse );
      read_library( parse, pos );
   }
   else if ( strcmp( parse->tk_text, "encryptstrings" ) == 0 ) {
      parse->task->library->encrypt_str = true;
      p_read_tk( parse );
   }
   else if ( strcmp( parse->tk_text, "nocompact" ) == 0 ) {
      parse->task->library->format = FORMAT_BIG_E;
      p_read_tk( parse );
   }
   else if (
      // NOTE: Not sure what these two are.
      strcmp( parse->tk_text, "wadauthor" ) == 0 ||
      strcmp( parse->tk_text, "nowadauthor" ) == 0 ) {
      p_diag( parse, DIAG_POS_ERR, pos, "directive `%s` not supported",
         parse->tk_text );
      p_bail( parse );
   }
   else {
      p_diag( parse, DIAG_POS_ERR, pos,
         "unknown directive '%s'", parse->tk_text );
      p_bail( parse );
   }
}
예제 #2
0
파일: co_lng.cpp 프로젝트: Strongc/proview
bool Lng::read_files( char *fname1, char *fname2, bool global, pwr_tStatus *sts)
{
  pwr_tFileName filename1, filename2;

  sprintf( filename2, fname2, get_language_str());

  dcli_translate_filename( filename1, fname1);
  dcli_translate_filename( filename2, filename2);

  ifstream fp1( filename1);
  if ( !fp1 && strcmp( fname1, "$pwr_exe/en_us/xtt_lng.dat") == 0) {
    // Try $pwr_eexe
    strcpy( fname1, "$pwr_eexe/en_us/xtt_lng.dat");
    dcli_translate_filename( filename1, fname1);
    fp1.open( filename1);
    if ( !fp1) {
      *sts = LNG__FILE;
      return false;
    }
  }
  else if ( !fp1) {
    *sts = LNG__FILE;
    return global ? false : true;
  }
  
  ifstream fp2( filename2);
  if ( !fp2 && strcmp( fname2, "$pwr_exe/%s/xtt_lng.dat") == 0) {
    // Try $pwr_eexe
    strcpy( fname2, "$pwr_eexe/%s/xtt_lng.dat");
    sprintf( filename2, fname2, get_language_str());
    dcli_translate_filename( filename2, filename2);
    fp2.open( filename2);
    if ( !fp2) {
      *sts = LNG__FILE;
      return false;
    }
  }
  else if ( !fp2) {
    *sts = LNG__FILE;
    return global ? false : true;
  }
  
  Row r1( fp1, filename1);
  Row r2( fp2, filename2);
  
  read_metadata( fp1, global, sts);
  read_metadata( fp2, global, sts);
  
  read_include( fp1, fp2, global, sts);

  bool hit = true;
  for (;;) {
    if ( hit) {
      if ( !read_line( r1))
	break;
      
      if ( !read_line( r2))
	break;
    }
    else if ( r1.lt( r2)) {
      if ( !read_line( r1))
	break;
    }
    else {
      if ( !read_line( r2))
	break;
    }
    
    hit = false;
    if ( r1.eq( r2))
      hit = true;
    if ( hit) {
      lang_sKey key;
      lang_sRecord *record;
      
      strncpy( key.text, r1.text, sizeof(key.text));
      key.type = r1.type;
      record = (lang_sRecord *) tree_Insert( sts, tree, &key);
      strcpy( record->transl, r2.text);
      // printf ( "%c %d.%d.%d '%s' '%s'\n", r1.type, r1.n1, r1.n2, r1.n3, r1.text,r2.text);
    }
  }    
  *sts = LNG__SUCCESS;
  return true;
}