Changeset 17783 for gsdl/trunk/common-src
- Timestamp:
- 2008-11-07T13:41:18+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/common-src/src/gdbmedit/txt2db/txt2db.cpp
r15230 r17783 49 49 50 50 void print_usage (char *program_name) { 51 cerr << "usage: " << program_name << " [options] database-name \n\n";52 cerr << "options: \n";53 cerr << " -append append to existing database \n\n";51 cerr << "usage: " << program_name << " [options] database-name" << endl << endl; 52 cerr << "options:" << endl; 53 cerr << " -append append to existing database" << endl << endl; 54 54 } 55 55 … … 77 77 dbname = argv[2]; 78 78 } else { 79 cerr << argv[1] << " is not a valid option. \n\n";79 cerr << argv[1] << " is not a valid option." << endl << endl; 80 80 print_usage (argv[0]); 81 81 exit (0); … … 95 95 #endif 96 96 if (dbf == NULL) { 97 cerr << "couldn't create " << dbname << "\n";97 cerr << "couldn't create " << dbname << endl; 98 98 exit (0); 99 99 } … … 113 113 } 114 114 if (!cin.eof()) cin.get(c); // skip ] 115 while (!cin.eof() && (c == '\n' || c == ' r')) cin.get(c);115 while (!cin.eof() && (c == '\n' || c == '\r')) cin.get(c); 116 116 117 117 // look for 70 dashes 118 118 tmp = ""; 119 119 while (!cin.eof() && (num_dashes < 70)) { 120 if (c == '\n' || c == '\r') {120 if (c == '\n') { 121 121 tmp.push_back ((unsigned char)c); 122 num_dashes = 0; 123 124 } else if (c == '\r') { 125 // Here we are able to process both Windows-specific text files 126 // (containing carriage-return, newline) and Linux text files 127 // (containing only newline characters) by ignoring the Windows' 128 // carriage-return altogether so that we produce a uniform database 129 // file from either system's type of text file. 130 // If we don't ignore the carriage return here, txt.gz files 131 // produced on Windows cause a GS library running on Linux to break. 122 132 num_dashes = 0; 123 133 124 134 } else if (c == '-') { 125 135 tmp.push_back ((unsigned char)c); … … 141 151 key_data.dptr = key.getcstr(); 142 152 if (key_data.dptr == NULL) { 143 cerr << "NULL key_data.dptr \n";153 cerr << "NULL key_data.dptr" << endl; 144 154 exit (0); 145 155 } … … 150 160 value_data.dptr = value.getcstr(); 151 161 if (value_data.dptr == NULL) { 152 cerr << "NULL value_data.dptr \n";162 cerr << "NULL value_data.dptr" << endl; 153 163 exit (0); 154 164 } … … 157 167 // store the value 158 168 if (gdbm_store (dbf, key_data, value_data, GDBM_REPLACE) < 0) { 159 cerr << "gdbm_store returned an error \n";169 cerr << "gdbm_store returned an error" << endl; 160 170 exit (0); 161 171 }
Note:
See TracChangeset
for help on using the changeset viewer.