@@ -29,7 +29,7 @@ using namespace std;
2929
3030void usage () {
3131 printf (
32- " countwin v1.0 Copyright (C) 2019 Benjamin Jean-Marie Tremblay \n "
32+ " countwin v1.1 Copyright (C) 2019 Benjamin Jean-Marie Tremblay \n "
3333 " \n "
3434 " Usage: countwin [options] -a [alphabet] -i [filename] -o [filename] \n "
3535 " echo [string] | countwin [options] -a [alphabet] > [filename] \n "
@@ -56,7 +56,7 @@ string make_row(string START, string STOP, vector<unsigned int> counts,
5656
5757 for (size_t i = 0 ; i < counts.size (); ++i) {
5858 if (counts[i] > 0 || !nozero)
59- out += START + " \t " + STOP + " \t " + klets[i] + " \t " + to_string (counts[i]) + " \n " ;
59+ out += START + ' \t ' + STOP + ' \t ' + klets[i] + ' \t ' + to_string (counts[i]) + ' \n ' ;
6060 }
6161
6262 return out;
@@ -103,8 +103,8 @@ int main(int argc, char **argv) {
103103 case ' i' : if (optarg) {
104104 infile.open (optarg);
105105 if (infile.bad ()) {
106- cerr << " Error: file not found" << endl ;
107- cerr << " Run countwin -h to see usage." << endl ;
106+ cerr << " Error: file not found\n " ;
107+ cerr << " Run countwin -h to see usage.\n " ;
108108 exit (EXIT_FAILURE );
109109 }
110110 has_file = true ;
@@ -114,8 +114,8 @@ int main(int argc, char **argv) {
114114 case ' o' : if (optarg) {
115115 outfile.open (optarg);
116116 if (outfile.bad ()) {
117- cerr << " Error: could not create outfile" << endl ;
118- cerr << " Run countwin -h to see usage." << endl ;
117+ cerr << " Error: could not create outfile\n " ;
118+ cerr << " Run countwin -h to see usage.\n " ;
119119 exit (EXIT_FAILURE );
120120 }
121121 has_out = true ;
@@ -150,41 +150,41 @@ int main(int argc, char **argv) {
150150 }
151151
152152 if (ku < 1 ) {
153- cerr << " Error: k must be greater than 0" << endl ;
154- cerr << " Run countwin -h to see usage." << endl ;
153+ cerr << " Error: k must be greater than 0\n " ;
154+ cerr << " Run countwin -h to see usage.\n " ;
155155 exit (EXIT_FAILURE );
156156 }
157157
158158 k = ku;
159159
160160 if (!has_file) {
161161 if (isatty (STDIN_FILENO )) {
162- cerr << " Error: missing input" << endl ;
163- cerr << " Run countwin -h to see usage." << endl ;
162+ cerr << " Error: missing input\n " ;
163+ cerr << " Run countwin -h to see usage.\n " ;
164164 exit (EXIT_FAILURE );
165165 }
166166 }
167167
168168 if (alph.length () < 1 ) {
169- cerr << " Error: missing alphabet" << endl ;
169+ cerr << " Error: missing alphabet\n " ;
170170 exit (EXIT_FAILURE );
171171 }
172172
173173 if (!has_win) {
174174 window = k;
175175 } else {
176176 if (window < k) {
177- cerr << " Error: window size must be equal to or greater than k" << endl ;
178- cerr << " Run countwin -h to see usage." << endl ;
177+ cerr << " Error: window size must be equal to or greater than k\n " ;
178+ cerr << " Run countwin -h to see usage.\n " ;
179179 exit (EXIT_FAILURE );
180180 }
181181 }
182182
183183 if (!has_step) step = window;
184184
185185 if (step < 1 || step > window) {
186- cerr << " Error: step size must be between 1 and window size" << endl ;
187- cerr << " Run countwin -h to see usage." << endl ;
186+ cerr << " Error: step size must be between 1 and window size\n " ;
187+ cerr << " Run countwin -h to see usage.\n " ;
188188 exit (EXIT_FAILURE );
189189 }
190190
@@ -196,9 +196,9 @@ int main(int argc, char **argv) {
196196 klets = make_klets (lets_uniq, k);
197197
198198 if (has_file) {
199- outfile << " START\t STOP\t LET\t COUNT" << endl ;
199+ outfile << " START\t STOP\t LET\t COUNT\n " ;
200200 } else {
201- cout << " START\t STOP\t LET\t COUNT" << endl ;
201+ cout << " START\t STOP\t LET\t COUNT\n " ;
202202 }
203203
204204 /* initialise */
@@ -210,8 +210,8 @@ int main(int argc, char **argv) {
210210 }
211211 STOP = START + seq.length () - 1 ;
212212 if (seq.length () < k) {
213- cerr << " Error: sequence cannot be smaller than k" << endl ;
214- cerr << " Run countwin -h to see usage." << endl ;
213+ cerr << " Error: sequence cannot be smaller than k\n " ;
214+ cerr << " Run countwin -h to see usage.\n " ;
215215 exit (EXIT_FAILURE );
216216 }
217217 counts = count_klets (vector<char >(seq.begin (), seq.end ()), lets_uniq, k, alphlen);
0 commit comments