Changeset 11157

Show
Ignore:
Timestamp:
2008-09-02 13:34:04 (3 months ago)
Author:
olly
Message:

Backport change from trunk:
examples/copydatabase.cc: Use C++ forms of C headers. Only treat
'\' as a directory separator on platforms where it is. Update
counter every 13 counting up to the end so that the digits all
"rotate" and the counter ends up on the exact total.

Location:
branches/1.0/xapian-core
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/xapian-core/ChangeLog

    r11156 r11157  
     1Tue Sep 02 12:33:51 GMT 2008  Olly Betts <olly@survex.com> 
     2 
     3        * Backport change from trunk: 
     4        * examples/copydatabase.cc: Use C++ forms of C headers.  Only treat 
     5          '\' as a directory separator on platforms where it is.  Update 
     6          counter every 13 counting up to the end so that the digits all 
     7          "rotate" and the counter ends up on the exact total. 
     8 
    19Tue Sep 02 12:06:26 GMT 2008  Olly Betts <olly@survex.com> 
    210 
  • branches/1.0/xapian-core/examples/copydatabase.cc

    r9075 r11157  
    22 * @brief Perform a document-by-document copy of one or more Xapian databases. 
    33 */ 
    4 /* Copyright (C) 2006,2007 Olly Betts 
     4/* Copyright (C) 2006,2007,2008 Olly Betts 
    55 * 
    66 * This program is free software; you can redistribute it and/or modify 
     
    2626#include <iostream> 
    2727 
    28 #include <math.h> // For log10(). 
    29 #include <stdlib.h> // For exit(). 
    30 #include <string.h> // For strcmp() and strrchr(). 
     28#include <cmath> // For log10(). 
     29#include <cstdlib> // For exit(). 
     30#include <cstring> // For strcmp() and strrchr(). 
    3131 
    3232using namespace std; 
     
    8282        // Find the leaf-name of the database path for reporting progress. 
    8383        const char * leaf = strrchr(src, '/'); 
     84#if defined __WIN32__ || defined __EMX__ 
    8485        if (!leaf) leaf = strrchr(src, '\\'); 
     86#endif 
    8587        if (leaf) ++leaf; else leaf = src; 
    8688 
     
    98100                db_out.add_document(db_in.get_document(*it)); 
    99101 
     102                // Update for the first 10, and then every 13th document 
     103                // counting back from the end (this means that all the 
     104                // digits "rotate" and the counter ends up on the exact 
     105                // total. 
    100106                ++c; 
    101                 // Update for the first 10, and then every 10th document. 
    102                 if (c <= 10 || c % 10 == 0) { 
     107                if (c <= 10 || (dbsize - c) % 13 == 0) { 
    103108                    cout << '\r' << leaf << ": "; 
    104109                    cout << setw(width) << c << '/' << dbsize << flush; 
     
    117122            ++spellword; 
    118123        } 
    119         cout << " Done." << endl; 
     124        cout << " done." << endl; 
    120125 
    121126        cout << "Copying synonym data..." << flush; 
     
    130135            ++synkey; 
    131136        } 
    132         cout << " Done." << endl; 
     137        cout << " done." << endl; 
    133138    } 
    134139