All pastes #384713 Raw Edit

Something

public cpp v1 · immutable
·published 2007-03-07 07:56 UTC
rendered paste body
function readBlock(sFilename) {  // &#1055;&#1088;&#1086;&#1074;&#1077;&#1088;&#1103;&#1077;&#1084;, &#1086;&#1090;&#1082;&#1088;&#1099;&#1083;&#1080; &#1083;&#1080; &#1084;&#1099; &#1091;&#1078;&#1077; &#1101;&#1090;&#1086;&#1090; &#1092;&#1072;&#1081;&#1083;  if (!aOpenedFiles.contains(sFilename)) {    // &#1063;&#1080;&#1090;&#1072;&#1077;&#1084; &#1074;&#1077;&#1089;&#1100; &#1092;&#1072;&#1081;&#1083;    sFileContent = readEntireFile(sFilename);    // &#1056;&#1072;&#1079;&#1073;&#1080;&#1074;&#1072;&#1077;&#1084; &#1092;&#1072;&#1081;&#1083; &#1085;&#1072; &#1073;&#1083;&#1086;&#1082;&#1080; &#1087;&#1086; &#1088;&#1077;&#1075;&#1091;&#1083;&#1103;&#1088;&#1085;&#1086;&#1084;&#1091; &#1074;&#1099;&#1088;&#1072;&#1078;&#1077;&#1085;&#1080;&#1102; &#1080; &#1074;&#1083;&#1086;&#1078;&#1077;&#1085;&#1085;&#1099;&#1084;&#1080; &#1089;&#1082;&#1086;&#1073;&#1082;&#1072;&#1084;&#1080; &#1074;&#1099;&#1073;&#1080;&#1088;&#1072;&#1077;&#1084; &#1073;&#1083;&#1086;&#1082;&#1080; &#1086;&#1090;&#1089;&#1077;&#1082;&#1072;&#1103; &#1074;&#1077;&#1076;&#1091;&#1097;&#1080;&#1077; &#1080; &#1079;&#1072;&#1074;&#1077;&#1088;&#1096;&#1072;&#1102;&#1097;&#1080;&#1077; &#1087;&#1077;&#1088;&#1077;&#1085;&#1086;&#1089;&#1099;. &#1042; &#1082;&#1088;&#1072;&#1081;&#1085;&#1077;&#1084; &#1089;&#1083;&#1091;&#1095;&#1072;&#1077; &#1086;&#1090;&#1089;&#1077;&#1095;&#1077;&#1085;&#1080;&#1077; &#1087;&#1077;&#1088;&#1077;&#1085;&#1086;&#1089;&#1086;&#1074; &#1084;&#1086;&#1078;&#1085;&#1086; &#1074;&#1099;&#1085;&#1077;&#1089;&#1090;&#1080; &#1086;&#1090;&#1076;&#1077;&#1083;&#1100;&#1085;&#1099;&#1084; &#1086;&#1087;&#1077;&#1088;&#1072;&#1090;&#1086;&#1088;&#1086;&#1084;    aBlocks = sFileContent.getRegExpMatches('/(?<:<-STAT->|<-BREAK->)[\n\r]*(.*[^\n\r])[\n\r]*(?:<-END->|<-BREAK->)/');    // &#1057;&#1086;&#1093;&#1088;&#1072;&#1085;&#1103;&#1077;&#1084; &#1084;&#1072;&#1089;&#1089;&#1080;&#1074; &#1073;&#1083;&#1086;&#1082;&#1086;&#1074; (&#1085;&#1077; &#1094;&#1077;&#1083;&#1099;&#1077; &#1089;&#1090;&#1088;&#1082;&#1080;, &#1072; &#1089;&#1086;&#1074;&#1087;&#1072;&#1076;&#1077;&#1085;&#1080;&#1103; &#1087;&#1086; &#1074;&#1085;&#1091;&#1090;&#1088;&#1077;&#1085;&#1085;&#1080;&#1084; &#1089;&#1082;&#1086;&#1073;&#1082;&#1072;&#1084; &#1074; &#1088;&#1077;&#1075;&#1091;&#1083;&#1103;&#1088;&#1082;&#1077;)    aOpenedFiles.add(sFilename, aBlocks[1]);    // &#1059;&#1089;&#1090;&#1072;&#1085;&#1072;&#1074;&#1083;&#1080;&#1074;&#1072;&#1077;&#1084; &#1091;&#1082;&#1072;&#1079;&#1072;&#1090;&#1077;&#1083;&#1100; &#1085;&#1072; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1073;&#1083;&#1086;&#1082;    aPointers.add(sFilename, 0);  }  // &#1055;&#1088;&#1086;&#1074;&#1077;&#1088;&#1103;&#1077;&#1084; &#1085;&#1072;&#1083;&#1080;&#1095;&#1080;&#1077; &#1073;&#1083;&#1086;&#1082;&#1086;&#1074;  if (aOpenedFiles[sFilename].length == 0) {    // &#1041;&#1083;&#1086;&#1082;&#1086;&#1074; &#1085;&#1077;&#1090;, &#1074;&#1086;&#1079;&#1074;&#1088;&#1072;&#1097;&#1072;&#1077;&#1084; &#1087;&#1091;&#1089;&#1090;&#1091;&#1102; &#1089;&#1090;&#1088;&#1086;&#1082;&#1091;.    return '';  }  // &#1042;&#1099;&#1073;&#1080;&#1088;&#1072;&#1077;&#1084; &#1086;&#1095;&#1077;&#1088;&#1077;&#1076;&#1085;&#1086;&#1081; &#1073;&#1083;&#1086;&#1082;  sBlock = aOpenedFiles[sFilename][aPointers[sFilename]];  // &#1055;&#1077;&#1088;&#1077;&#1084;&#1077;&#1097;&#1072;&#1077;&#1084; &#1091;&#1082;&#1072;&#1079;&#1072;&#1090;&#1077;&#1083;&#1100; &#1073;&#1083;&#1086;&#1082;&#1072;  aPointers[sFilename]++;  // &#1055;&#1088;&#1086;&#1074;&#1077;&#1088;&#1103;&#1077;&#1084; &#1091;&#1082;&#1072;&#1079;&#1072;&#1090;&#1077;&#1083;&#1100; &#1073;&#1083;&#1086;&#1082;&#1072; &#1080; &#1079;&#1072;&#1094;&#1080;&#1082;&#1083;&#1080;&#1074;&#1072;&#1077;&#1084; &#1077;&#1075;&#1086;  if (aPointers[sFilename] == aOpenedFiles[sFilename].length) {    aPointers[sFilename] = 0;  }  // &#1042;&#1086;&#1079;&#1074;&#1088;&#1072;&#1097;&#1072;&#1077;&#1084; &#1073;&#1083;&#1086;&#1082;  return sBlock;}