Changeset 11145

Show
Ignore:
Timestamp:
2008-09-02 07:51:14 (3 months ago)
Author:
olly
Message:

bin/xapian-inspect.cc: Show the help message on start-up. Correct
the alias for next from ' ' to . Avoid reading outside of input
string when it is empty. Bug#286.

Location:
trunk/xapian-core
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/xapian-core/ChangeLog

    r11142 r11145  
     1Tue Sep 02 06:48:50 GMT 2008  Olly Betts <olly@survex.com> 
     2 
     3        * bin/xapian-inspect.cc: Show the help message on start-up.  Correct 
     4          the alias for next from ' ' to ''.  Avoid reading outside of input 
     5          string when it is empty.  Bug#286. 
     6 
    17Tue Sep 02 04:19:34 GMT 2008  Olly Betts <olly@survex.com> 
    28 
  • trunk/xapian-core/bin/xapian-inspect.cc

    r10302 r11145  
    7373} 
    7474 
     75static void 
     76show_help() 
     77{ 
     78    cout << "Commands:\n" 
     79            "next   : Next entry (alias 'n' or '')\n" 
     80            "prev   : Previous entry (alias 'p')\n" 
     81            "goto X : Goto entry X (alias 'g')\n" 
     82            "help   : Show this (alias 'h' or '?')\n" 
     83            "quit   : Quit this utility (alias 'q')" << endl; 
     84} 
     85 
    7586int 
    7687main(int argc, char **argv) 
     
    124135 
    125136        FlintCursor cursor(&table); 
    126         cursor.find_entry(""); 
     137        cursor.find_entry(string()); 
    127138        cursor.next(); 
     139 
     140        show_help(); 
     141        cout << endl; 
    128142 
    129143        while (!cin.eof()) { 
     
    141155            if (cin.eof()) break; 
    142156 
    143             if (input[input.size() - 1] == '\r') 
     157            if (endswith(input, '\r')) 
    144158                input.resize(input.size() - 1); 
    145159 
    146             if (input == "" || input == "n" || input == "next") { 
     160            if (input.empty() || input == "n" || input == "next") { 
    147161                if (cursor.after_end() || !cursor.next()) { 
    148162                    cout << "At end already." << endl; 
     
    172186                break; 
    173187            } else if (input == "h" || input == "help" || input == "?") { 
    174                 cout << "Commands:\n" 
    175                         "next   : Next entry (alias 'n' or ' ')\n" 
    176                         "prev   : Previous entry (alias 'p')\n" 
    177                         "goto X : Goto entry X (alias 'g')\n" 
    178                         "help   : Show this (alias 'h' or '?')\n" 
    179                         "quit   : Quit this utility (alias 'q')" << endl; 
     188                show_help(); 
    180189                goto wait_for_input; 
    181190            } else {