Mon, 16 Jul 2012 16:15:16 +0300
- The output cmd-line argument is now optional - one is generated from the input file if not given.
- All data is now buffered before being written into the file. This way, no incomplete data is written in case an error occurrs.
0 | 1 | /* |
2 | * botc source code | |
3 | * Copyright (C) 2012 Santeri `Dusk` Piippo | |
4 | * All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright notice, | |
10 | * this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, | |
12 | * this list of conditions and the following disclaimer in the documentation | |
13 | * and/or other materials provided with the distribution. | |
3 | 14 | * 3. Neither the name of the developer nor the names of its contributors may |
15 | * be used to endorse or promote products derived from this software without | |
16 | * specific prior written permission. | |
0 | 17 | * 4. Redistributions in any form must be accompanied by information on how to |
18 | * obtain complete source code for the software and any accompanying | |
19 | * software that uses the software. The source code must either be included | |
20 | * in the distribution or be available for no more than the cost of | |
21 | * distribution plus a nominal fee, and must be freely redistributable | |
22 | * under reasonable conditions. For an executable file, complete source | |
23 | * code means the source code for all modules it contains. It does not | |
24 | * include source code for modules or files that typically accompany the | |
25 | * major components of the operating system on which the executable file | |
26 | * runs. | |
27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
38 | * POSSIBILITY OF SUCH DAMAGE. | |
39 | */ | |
40 | ||
41 | #include <stdio.h> | |
42 | #include <stdlib.h> | |
43 | #include <string.h> | |
44 | #include "common.h" | |
45 | ||
46 | #include "str.h" | |
47 | #include "scriptreader.h" | |
48 | #include "objwriter.h" | |
2
bb2c45522eb6
Added event definitions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
49 | #include "events.h" |
6
0005527cad62
Command definitions are now read into memory.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
50 | #include "commands.h" |
20
d7b13805d1e0
Added string table and support for string parameters in commands.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
51 | #include "stringtable.h" |
22
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
52 | #include "variables.h" |
0 | 53 | |
54 | #include "bots.h" | |
55 | #include "botcommands.h" | |
56 | ||
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
57 | bool fexists (char* path) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
58 | if (FILE* test = fopen (path, "r")) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
59 | fclose (test); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
60 | return true; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
61 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
62 | return false; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
63 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
64 | |
0 | 65 | int main (int argc, char** argv) { |
21
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
66 | // Intepret command-line parameters: |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
67 | // -l: list commands |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
68 | if (argc == 2 && !strcmp (argv[1], "-l")) { |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
69 | ReadCommands (); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
70 | printf ("Begin list of commands:\n"); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
71 | printf ("------------------------------------------------------\n"); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
72 | |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
73 | CommandDef* comm; |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
74 | ITERATE_COMMANDS (comm) |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
75 | printf ("%s\n", GetCommandPrototype (comm).chars()); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
76 | |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
77 | printf ("------------------------------------------------------\n"); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
78 | printf ("End of command list\n"); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
79 | exit (0); |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
80 | } |
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
81 | |
16
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
82 | // Print header |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
83 | str header; |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
84 | str headerline = "-="; |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
85 | header.appendformat ("%s version %d.%d.%d", APPNAME, VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION); |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
86 | headerline.repeat ((header.len()/2)-1); |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
87 | headerline += '-'; |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
88 | printf ("%s\n%s\n", header.chars(), headerline.chars()); |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
89 | |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
90 | if (argc < 2) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
91 | fprintf (stderr, "usage: %s: <infile> [outfile]\n", argv[0]); |
0 | 92 | exit (1); |
93 | } | |
94 | ||
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
95 | str outfile; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
96 | if (argc < 3) |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
97 | outfile = ObjectFileName (argv[1]); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
98 | else |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
99 | outfile = argv[2]; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
100 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
101 | // If we'd end up writing into an existing file, |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
102 | // ask the user if we want to overwrite it |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
103 | if (fexists (outfile)) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
104 | // Additional warning if the paths are the same |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
105 | str warning; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
106 | #ifdef FILE_CASEINSENSITIVE |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
107 | if (!outfile.icompare (argv[1])) |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
108 | #else |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
109 | if (!outfile.compare (argv[1])) |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
110 | #endif |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
111 | { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
112 | warning = "\nWARNING: Output file is the same as the input file. "; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
113 | warning += "Answering yes here will destroy the source!\n"; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
114 | warning += "Continue nevertheless?"; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
115 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
116 | printf ("output file `%s` already exists! overwrite?%s (y/n) ", outfile.chars(), warning.chars()); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
117 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
118 | char ans; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
119 | fgets (&ans, 2, stdin); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
120 | if (ans != 'y') { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
121 | printf ("abort\n"); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
122 | exit (1); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
123 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
124 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
125 | |
6
0005527cad62
Command definitions are now read into memory.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
126 | // Read definitions |
16
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
127 | printf ("Reading definitions...\n"); |
2
bb2c45522eb6
Added event definitions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
128 | ReadEvents (); |
6
0005527cad62
Command definitions are now read into memory.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
129 | ReadCommands (); |
2
bb2c45522eb6
Added event definitions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
130 | |
22
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
131 | // Init stuff |
21
ae602e667879
Added -l command line parameter, if given, botc will list all available commands and exit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
132 | InitStringTable(); |
22
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
133 | InitVariables (); |
20
d7b13805d1e0
Added string table and support for string parameters in commands.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
134 | |
1
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
135 | // Prepare reader and writer |
2
bb2c45522eb6
Added event definitions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
136 | ScriptReader *r = new ScriptReader (argv[1]); |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
137 | ObjWriter *w = new ObjWriter (outfile); |
0 | 138 | |
1
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
139 | // We're set, begin parsing :) |
16
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
140 | printf ("Parsing script..\n"); |
0 | 141 | r->BeginParse (w); |
142 | ||
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
143 | // Parse done, print statistics and write to file |
22
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
144 | unsigned int globalcount = CountGlobalVars (); |
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
145 | printf ("%u global variable%s\n", globalcount, PLURAL (globalcount)); |
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
146 | printf ("%d state%s written\n", g_NumStates, PLURAL (g_NumStates)); |
b48e10ca8832
Added rudimentary global var support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
147 | printf ("%d event%s written\n", g_NumEvents, PLURAL (g_NumEvents)); |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
148 | w->WriteToFile (); |
16
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
149 | |
393359908179
Added mainloop/onenter/onexit support, fixed state writing.. this thing can compile the script for the `jumping arghbot` now!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
150 | // Clear out the junk |
0 | 151 | delete r; |
152 | delete w; | |
153 | } | |
154 | ||
155 | void error (const char* text, ...) { | |
156 | PERFORM_FORMAT (text, c); | |
157 | fprintf (stderr, "error: %s", c); | |
158 | exit (1); | |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
159 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
160 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
161 | char* ObjectFileName (str s) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
162 | // Locate the extension and chop it out |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
163 | unsigned int extdot = s.last ("."); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
164 | if (extdot != s.len() && extdot >= s.len()-4) |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
165 | s.trim (s.len() - extdot); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
166 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
167 | // Add new ".o" extension |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
168 | s += ".o"; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
169 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
170 | return s.chars(); |
0 | 171 | } |