Пример #1
0
void count_file (FILE *file, const char *filename,
                 struct options *opts, struct counts *totals) {
   if (! is_plain_file (file, filename)) return;
   struct counts file_counts = {0, 0, 0};
   bool spaces = true;
   for (;;) {
      int byte = fgetc (file);
      if (byte == EOF) break;
      ++file_counts.chars;
      if (byte == '\n') ++file_counts.lines;
      if (isspace (byte)) {
         spaces = true;
      }else if (spaces) {
         ++file_counts.words;
         spaces = false;
      }
   }
   print_count (opts, &file_counts, filename);
   totals->lines += file_counts.lines;
   totals->words += file_counts.words;
   totals->chars += file_counts.chars;
}
Пример #2
0
bool is_idx_file(const boost::filesystem::directory_entry &dir_entry)
{
	return is_plain_file(dir_entry) && strcasecmp(dir_entry.path().extension().string().c_str(), ".idx") == 0;
}