src/cline.c

changeset 57
68018eac46c3
parent 50
63477d92411d
child 59
c5409c8be36f
equal deleted inserted replaced
56:ed65f8c73fb2 57:68018eac46c3
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * Copyright 2017 Mike Becker. All rights reserved. 3 * Copyright 2018 Mike Becker. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * cline.c
27 *
28 * Created on: 23.05.2011
29 * Author: Mike
30 */ 25 */
31 26
32 #include "cline.h" 27 #include "cline.h"
33 #include "scanner.h" 28 #include "scanner.h"
34 #include "settings.h" 29 #include "settings.h"
56 "\n (separated by commas)" 51 "\n (separated by commas)"
57 "\n -r, -R - includes subdirectories" 52 "\n -r, -R - includes subdirectories"
58 "\n -v, --version - print out version information" 53 "\n -v, --version - print out version information"
59 "\n -V - turn verbose output off, print the result only" 54 "\n -V - turn verbose output off, print the result only"
60 "\n\nShortcuts:" 55 "\n\nShortcuts:"
61 "\n --exclude-cstyle-comments" 56 "\n --exclude-cstyle-comments : -E '\\s*//' -e '\\s*/\\*' '\\*/\\s*'"
62 "\n = -E \"\\s*//\" -e \"\\s*/\\*\" \"\\*/\\s*\"" 57 "\n --exclude-blank-lines : -E '^\\s*$'"
63 "\n\n" 58 "\n\n"
64 "The default call without any options is:" 59 "The default call without any options is:"
65 "\n cline ./\n\n" 60 "\n cline ./\n\n"
66 "So each file in the working directory is counted. If you want to count C" 61 "So each file in the working directory is counted. If you want to count C"
67 "\nsource code in your working directory and its subdirectories, type:" 62 "\nsource code in your working directory and its subdirectories, type:"
203 add_string(settings->regex->pattern_list, argv[t]); 198 add_string(settings->regex->pattern_list, argv[t]);
204 add_string(settings->regex->pattern_list, "$"); 199 add_string(settings->regex->pattern_list, "$");
205 } 200 }
206 if (argflags == 0) { 201 if (argflags == 0) {
207 /* SHORTCUTS */ 202 /* SHORTCUTS */
208 /* exclude-cstyle-comments */
209 if (strcmp(argv[t], "--exclude-cstyle-comments") == 0) { 203 if (strcmp(argv[t], "--exclude-cstyle-comments") == 0) {
210 add_string(settings->regex->pattern_list, "\\s*//"); 204 add_string(settings->regex->pattern_list, "\\s*//");
211 add_string(settings->regex->pattern_list, "$"); 205 add_string(settings->regex->pattern_list, "$");
212 add_string(settings->regex->pattern_list, "\\s*/\\*"); 206 add_string(settings->regex->pattern_list, "\\s*/\\*");
213 add_string(settings->regex->pattern_list, "\\*/\\s*"); 207 add_string(settings->regex->pattern_list, "\\*/\\s*");
208 } else if (strcmp(argv[t], "--exclude-blank-lines") == 0) {
209 add_string(settings->regex->pattern_list, "^\\s*$");
210 add_string(settings->regex->pattern_list, "$");
214 } 211 }
215 /* Path */ 212 /* Path */
216 else { 213 else {
217 add_string(directories, argv[t]); 214 add_string(directories, argv[t]);
218 } 215 }

mercurial