]>
Commit | Line | Data |
---|---|---|
4ee9c684 | 1 | /* Parse and display command line options. |
1384ae99 | 2 | Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
3 | 2009, 2010 | |
764f1175 | 4 | Free Software Foundation, Inc. |
4ee9c684 | 5 | Contributed by Andy Vaught |
6 | ||
c84b470d | 7 | This file is part of GCC. |
4ee9c684 | 8 | |
c84b470d | 9 | GCC is free software; you can redistribute it and/or modify it under |
10 | the terms of the GNU General Public License as published by the Free | |
bdabe786 | 11 | Software Foundation; either version 3, or (at your option) any later |
c84b470d | 12 | version. |
4ee9c684 | 13 | |
c84b470d | 14 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 | for more details. | |
4ee9c684 | 18 | |
19 | You should have received a copy of the GNU General Public License | |
bdabe786 | 20 | along with GCC; see the file COPYING3. If not see |
21 | <http://www.gnu.org/licenses/>. */ | |
4ee9c684 | 22 | |
4ee9c684 | 23 | #include "config.h" |
24 | #include "system.h" | |
25 | #include "coretypes.h" | |
26 | #include "tree.h" | |
27 | #include "flags.h" | |
28 | #include "intl.h" | |
29 | #include "opts.h" | |
e3d1ab2b | 30 | #include "toplev.h" /* For save_decoded_options. */ |
4ee9c684 | 31 | #include "options.h" |
0452cf51 | 32 | #include "params.h" |
4ee9c684 | 33 | #include "tree-inline.h" |
4ee9c684 | 34 | #include "gfortran.h" |
3b6a4b41 | 35 | #include "target.h" |
2ecc6bc5 | 36 | #include "cpp.h" |
7cbc820e | 37 | #include "diagnostic-core.h" /* For sorry. */ |
c6418a4e | 38 | #include "tm.h" |
4ee9c684 | 39 | |
40 | gfc_option_t gfc_option; | |
41 | ||
42 | ||
83a65a0d | 43 | /* Set flags that control warnings and errors for different |
82860817 | 44 | Fortran standards to their default values. Keep in sync with |
45 | libgfortran/runtime/compile_options.c (init_compile_options). */ | |
83a65a0d | 46 | |
47 | static void | |
48 | set_default_std_flags (void) | |
49 | { | |
50 | gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL | |
ff4425cf | 51 | | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77 |
a3b81b0f | 52 | | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY; |
83a65a0d | 53 | gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY; |
54 | } | |
55 | ||
82860817 | 56 | |
e88d34f6 | 57 | /* Return language mask for Fortran options. */ |
58 | ||
59 | unsigned int | |
60 | gfc_option_lang_mask (void) | |
61 | { | |
62 | return CL_Fortran; | |
63 | } | |
64 | ||
65 | ||
82860817 | 66 | /* Get ready for options handling. Keep in sync with |
67 | libgfortran/runtime/compile_options.c (init_compile_options). */ | |
4ee9c684 | 68 | |
e88d34f6 | 69 | void |
70 | gfc_init_options (unsigned int decoded_options_count, | |
71 | struct cl_decoded_option *decoded_options) | |
4ee9c684 | 72 | { |
8594da07 | 73 | gfc_source_file = NULL; |
4ee9c684 | 74 | gfc_option.module_dir = NULL; |
75 | gfc_option.source_form = FORM_UNKNOWN; | |
40da2b01 | 76 | gfc_option.fixed_line_length = 72; |
77 | gfc_option.free_line_length = 132; | |
766398ac | 78 | gfc_option.max_continue_fixed = 255; |
79 | gfc_option.max_continue_free = 255; | |
4ee9c684 | 80 | gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN; |
bbaaa7b1 | 81 | gfc_option.max_subrecord_length = 0; |
d6c9e9d7 | 82 | gfc_option.flag_max_array_constructor = 65535; |
18f0b7df | 83 | gfc_option.convert = GFC_CONVERT_NATIVE; |
bbaaa7b1 | 84 | gfc_option.record_marker = 0; |
6c4b9654 | 85 | gfc_option.dump_parse_tree = 0; |
4ee9c684 | 86 | |
87 | gfc_option.warn_aliasing = 0; | |
e27238e0 | 88 | gfc_option.warn_ampersand = 0; |
9a709107 | 89 | gfc_option.warn_character_truncation = 0; |
92f4d1c4 | 90 | gfc_option.warn_array_temp = 0; |
5ae82d58 | 91 | gfc_option.gfc_warn_conversion = 0; |
721f64bf | 92 | gfc_option.warn_conversion_extra = 0; |
4ee9c684 | 93 | gfc_option.warn_implicit_interface = 0; |
94 | gfc_option.warn_line_truncation = 0; | |
95 | gfc_option.warn_surprising = 0; | |
35d6528e | 96 | gfc_option.warn_tabs = 1; |
97 | gfc_option.warn_underflow = 1; | |
a34926ba | 98 | gfc_option.warn_intrinsic_shadow = 0; |
99 | gfc_option.warn_intrinsics_std = 0; | |
58601acb | 100 | gfc_option.warn_align_commons = 1; |
4acad347 | 101 | gfc_option.warn_unused_dummy_argument = 0; |
b6be0ac5 | 102 | gfc_option.max_errors = 25; |
4ee9c684 | 103 | |
d52febd5 | 104 | gfc_option.flag_all_intrinsics = 0; |
d9c2d9a5 | 105 | gfc_option.flag_default_double = 0; |
106 | gfc_option.flag_default_integer = 0; | |
107 | gfc_option.flag_default_real = 0; | |
4ee9c684 | 108 | gfc_option.flag_dollar_ok = 0; |
109 | gfc_option.flag_underscoring = 1; | |
9c6cdcae | 110 | gfc_option.flag_whole_file = 1; |
bdaed7d2 | 111 | gfc_option.flag_f2c = 0; |
112 | gfc_option.flag_second_underscore = -1; | |
4ee9c684 | 113 | gfc_option.flag_implicit_none = 0; |
14af4f75 | 114 | |
115 | /* Default value of flag_max_stack_var_size is set in gfc_post_options. */ | |
116 | gfc_option.flag_max_stack_var_size = -2; | |
117 | ||
09638e2c | 118 | gfc_option.flag_range_check = 1; |
4ee9c684 | 119 | gfc_option.flag_pack_derived = 0; |
120 | gfc_option.flag_repack_arrays = 0; | |
9e3a9b8b | 121 | gfc_option.flag_preprocessed = 0; |
0fda8d07 | 122 | gfc_option.flag_automatic = 1; |
0e0aee06 | 123 | gfc_option.flag_backslash = 0; |
ef63afed | 124 | gfc_option.flag_module_private = 0; |
99798ba4 | 125 | gfc_option.flag_backtrace = 0; |
17000b91 | 126 | gfc_option.flag_allow_leading_underscore = 0; |
b7fcd3f9 | 127 | gfc_option.flag_dump_core = 0; |
4e8e57b0 | 128 | gfc_option.flag_external_blas = 0; |
129 | gfc_option.blas_matmul_limit = 30; | |
b549d2a5 | 130 | gfc_option.flag_cray_pointer = 0; |
8594da07 | 131 | gfc_option.flag_d_lines = -1; |
5ae82d58 | 132 | gfc_option.gfc_flag_openmp = 0; |
56c7c2d7 | 133 | gfc_option.flag_sign_zero = 1; |
14af4f75 | 134 | gfc_option.flag_recursive = 0; |
a28eb9a8 | 135 | gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF; |
136 | gfc_option.flag_init_integer_value = 0; | |
137 | gfc_option.flag_init_real = GFC_INIT_REAL_OFF; | |
138 | gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF; | |
139 | gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF; | |
140 | gfc_option.flag_init_character_value = (char)0; | |
58601acb | 141 | gfc_option.flag_align_commons = 1; |
54564d01 | 142 | gfc_option.flag_protect_parens = 1; |
a28eb9a8 | 143 | |
8c84a5de | 144 | gfc_option.fpe = 0; |
ad8ed98e | 145 | gfc_option.rtcheck = 0; |
76daec3c | 146 | gfc_option.coarray = GFC_FCOARRAY_NONE; |
8c84a5de | 147 | |
40441bde | 148 | flag_errno_math = 0; |
fb063c92 | 149 | flag_associative_math = -1; |
4ee9c684 | 150 | |
83a65a0d | 151 | set_default_std_flags (); |
4ee9c684 | 152 | |
3b6a4b41 | 153 | /* -fshort-enums can be default on some targets. */ |
6f092e31 | 154 | flag_short_enums = targetm.default_short_enums (); |
3b6a4b41 | 155 | |
2ecc6bc5 | 156 | /* Initialize cpp-related options. */ |
e88d34f6 | 157 | gfc_cpp_init_options (decoded_options_count, decoded_options); |
4ee9c684 | 158 | } |
159 | ||
160 | ||
8594da07 | 161 | /* Determine the source form from the filename extension. We assume |
162 | case insensitivity. */ | |
163 | ||
164 | static gfc_source_form | |
165 | form_from_filename (const char *filename) | |
166 | { | |
8594da07 | 167 | static const struct |
168 | { | |
169 | const char *extension; | |
170 | gfc_source_form form; | |
171 | } | |
172 | exttype[] = | |
173 | { | |
174 | { | |
175 | ".f90", FORM_FREE} | |
176 | , | |
177 | { | |
178 | ".f95", FORM_FREE} | |
179 | , | |
180 | { | |
f30a3c31 | 181 | ".f03", FORM_FREE} |
182 | , | |
183 | { | |
ff4425cf | 184 | ".f08", FORM_FREE} |
185 | , | |
186 | { | |
8594da07 | 187 | ".f", FORM_FIXED} |
188 | , | |
189 | { | |
190 | ".for", FORM_FIXED} | |
191 | , | |
192 | { | |
ed19cf5f | 193 | ".ftn", FORM_FIXED} |
194 | , | |
195 | { | |
8594da07 | 196 | "", FORM_UNKNOWN} |
197 | }; /* sentinel value */ | |
198 | ||
199 | gfc_source_form f_form; | |
200 | const char *fileext; | |
201 | int i; | |
202 | ||
203 | /* Find end of file name. Note, filename is either a NULL pointer or | |
204 | a NUL terminated string. */ | |
205 | i = 0; | |
206 | while (filename[i] != '\0') | |
207 | i++; | |
208 | ||
209 | /* Find last period. */ | |
210 | while (i >= 0 && (filename[i] != '.')) | |
211 | i--; | |
212 | ||
213 | /* Did we see a file extension? */ | |
214 | if (i < 0) | |
215 | return FORM_UNKNOWN; /* Nope */ | |
216 | ||
217 | /* Get file extension and compare it to others. */ | |
218 | fileext = &(filename[i]); | |
219 | ||
220 | i = -1; | |
221 | f_form = FORM_UNKNOWN; | |
222 | do | |
223 | { | |
224 | i++; | |
225 | if (strcasecmp (fileext, exttype[i].extension) == 0) | |
226 | { | |
227 | f_form = exttype[i].form; | |
228 | break; | |
229 | } | |
230 | } | |
231 | while (exttype[i].form != FORM_UNKNOWN); | |
232 | ||
233 | return f_form; | |
234 | } | |
235 | ||
236 | ||
4ee9c684 | 237 | /* Finalize commandline options. */ |
238 | ||
239 | bool | |
240 | gfc_post_options (const char **pfilename) | |
241 | { | |
9e3a9b8b | 242 | const char *filename = *pfilename, *canon_source_file = NULL; |
a0d72493 | 243 | char *source_path; |
244 | int i; | |
4ee9c684 | 245 | |
c6418a4e | 246 | /* Excess precision other than "fast" requires front-end |
247 | support. */ | |
248 | if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD | |
249 | && TARGET_FLT_EVAL_METHOD_NON_DEFAULT) | |
250 | sorry ("-fexcess-precision=standard for Fortran"); | |
251 | flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | |
252 | ||
16669ccd | 253 | /* Whole program needs whole file mode. */ |
15c77ab7 | 254 | if (flag_whole_program) |
16669ccd | 255 | gfc_option.flag_whole_file = 1; |
15c77ab7 | 256 | |
6756f4d2 | 257 | /* Enable whole-file mode if LTO is in effect. */ |
7bfefa9d | 258 | if (flag_lto || flag_whopr) |
6756f4d2 | 259 | gfc_option.flag_whole_file = 1; |
7bfefa9d | 260 | |
fb063c92 | 261 | /* Fortran allows associative math - but we cannot reassociate if |
262 | we want traps or signed zeros. Cf. also flag_protect_parens. */ | |
263 | if (flag_associative_math == -1) | |
264 | flag_associative_math = (!flag_trapping_math && !flag_signed_zeros); | |
265 | ||
ad8ed98e | 266 | /* -fbounds-check is equivalent to -fcheck=bounds */ |
267 | if (flag_bounds_check) | |
268 | gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS; | |
269 | ||
71278019 | 270 | if (flag_compare_debug) |
271 | gfc_option.dump_parse_tree = 0; | |
272 | ||
4ee9c684 | 273 | /* Verify the input file name. */ |
274 | if (!filename || strcmp (filename, "-") == 0) | |
275 | { | |
276 | filename = ""; | |
277 | } | |
278 | ||
9e3a9b8b | 279 | if (gfc_option.flag_preprocessed) |
280 | { | |
281 | /* For preprocessed files, if the first tokens are of the form # NUM. | |
282 | handle the directives so we know the original file name. */ | |
283 | gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file); | |
284 | if (gfc_source_file == NULL) | |
285 | gfc_source_file = filename; | |
286 | else | |
287 | *pfilename = gfc_source_file; | |
288 | } | |
289 | else | |
290 | gfc_source_file = filename; | |
291 | ||
292 | if (canon_source_file == NULL) | |
293 | canon_source_file = gfc_source_file; | |
8594da07 | 294 | |
a0d72493 | 295 | /* Adds the path where the source file is to the list of include files. */ |
296 | ||
9e3a9b8b | 297 | i = strlen (canon_source_file); |
298 | while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i])) | |
a0d72493 | 299 | i--; |
1bcc6eb8 | 300 | |
a0d72493 | 301 | if (i != 0) |
302 | { | |
48d8ad5a | 303 | source_path = (char *) alloca (i + 1); |
9e3a9b8b | 304 | memcpy (source_path, canon_source_file, i); |
a0d72493 | 305 | source_path[i] = 0; |
55c4c509 | 306 | gfc_add_include_path (source_path, true, true); |
a0d72493 | 307 | } |
308 | else | |
55c4c509 | 309 | gfc_add_include_path (".", true, true); |
a0d72493 | 310 | |
9e3a9b8b | 311 | if (canon_source_file != gfc_source_file) |
e47a6f81 | 312 | gfc_free (CONST_CAST (char *, canon_source_file)); |
9e3a9b8b | 313 | |
8594da07 | 314 | /* Decide which form the file will be read in as. */ |
315 | ||
316 | if (gfc_option.source_form != FORM_UNKNOWN) | |
317 | gfc_current_form = gfc_option.source_form; | |
318 | else | |
319 | { | |
320 | gfc_current_form = form_from_filename (filename); | |
321 | ||
322 | if (gfc_current_form == FORM_UNKNOWN) | |
323 | { | |
324 | gfc_current_form = FORM_FREE; | |
7698a624 | 325 | gfc_warning_now ("Reading file '%s' as free form", |
9e3a9b8b | 326 | (filename[0] == '\0') ? "<stdin>" : filename); |
8594da07 | 327 | } |
328 | } | |
329 | ||
330 | /* If the user specified -fd-lines-as-{code|comments} verify that we're | |
331 | in fixed form. */ | |
332 | if (gfc_current_form == FORM_FREE) | |
333 | { | |
334 | if (gfc_option.flag_d_lines == 0) | |
335 | gfc_warning_now ("'-fd-lines-as-comments' has no effect " | |
7698a624 | 336 | "in free form"); |
8594da07 | 337 | else if (gfc_option.flag_d_lines == 1) |
1bcc6eb8 | 338 | gfc_warning_now ("'-fd-lines-as-code' has no effect in free form"); |
8594da07 | 339 | } |
4ee9c684 | 340 | |
675e3934 | 341 | /* If -pedantic, warn about the use of GNU extensions. */ |
342 | if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0) | |
343 | gfc_option.warn_std |= GFC_STD_GNU; | |
c667e11d | 344 | /* -std=legacy -pedantic is effectively -std=gnu. */ |
345 | if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0) | |
346 | gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY; | |
675e3934 | 347 | |
bdaed7d2 | 348 | /* If the user didn't explicitly specify -f(no)-second-underscore we |
349 | use it if we're trying to be compatible with f2c, and not | |
350 | otherwise. */ | |
351 | if (gfc_option.flag_second_underscore == -1) | |
352 | gfc_option.flag_second_underscore = gfc_option.flag_f2c; | |
353 | ||
14af4f75 | 354 | if (!gfc_option.flag_automatic && gfc_option.flag_max_stack_var_size != -2 |
355 | && gfc_option.flag_max_stack_var_size != 0) | |
356 | gfc_warning_now ("Flag -fno-automatic overwrites -fmax-stack-var-size=%d", | |
357 | gfc_option.flag_max_stack_var_size); | |
358 | else if (!gfc_option.flag_automatic && gfc_option.flag_recursive) | |
359 | gfc_warning_now ("Flag -fno-automatic overwrites -frecursive"); | |
5ae82d58 | 360 | else if (!gfc_option.flag_automatic && gfc_option.gfc_flag_openmp) |
14af4f75 | 361 | gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by " |
362 | "-fopenmp"); | |
363 | else if (gfc_option.flag_max_stack_var_size != -2 | |
364 | && gfc_option.flag_recursive) | |
365 | gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d", | |
366 | gfc_option.flag_max_stack_var_size); | |
367 | else if (gfc_option.flag_max_stack_var_size != -2 | |
5ae82d58 | 368 | && gfc_option.gfc_flag_openmp) |
14af4f75 | 369 | gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive " |
370 | "implied by -fopenmp", | |
371 | gfc_option.flag_max_stack_var_size); | |
372 | ||
a7bdd774 | 373 | /* Implement -frecursive as -fmax-stack-var-size=-1. */ |
374 | if (gfc_option.flag_recursive) | |
14af4f75 | 375 | gfc_option.flag_max_stack_var_size = -1; |
376 | ||
a7bdd774 | 377 | /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */ |
5ae82d58 | 378 | if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.gfc_flag_openmp |
a7bdd774 | 379 | && gfc_option.flag_automatic) |
380 | { | |
381 | gfc_option.flag_recursive = 1; | |
382 | gfc_option.flag_max_stack_var_size = -1; | |
383 | } | |
384 | ||
14af4f75 | 385 | /* Set default. */ |
386 | if (gfc_option.flag_max_stack_var_size == -2) | |
387 | gfc_option.flag_max_stack_var_size = 32768; | |
388 | ||
7f2e183b | 389 | /* Implement -fno-automatic as -fmax-stack-var-size=0. */ |
390 | if (!gfc_option.flag_automatic) | |
391 | gfc_option.flag_max_stack_var_size = 0; | |
e27238e0 | 392 | |
393 | if (pedantic) | |
77a6cc7e | 394 | { |
395 | gfc_option.warn_ampersand = 1; | |
396 | gfc_option.warn_tabs = 0; | |
397 | } | |
7f2e183b | 398 | |
7ea64434 | 399 | if (pedantic && gfc_option.flag_whole_file) |
400 | gfc_option.flag_whole_file = 2; | |
401 | ||
2ecc6bc5 | 402 | gfc_cpp_post_options (); |
403 | ||
404 | /* FIXME: return gfc_cpp_preprocess_only (); | |
405 | ||
406 | The return value of this function indicates whether the | |
407 | backend needs to be initialized. On -E, we don't need | |
408 | the backend. However, if we return 'true' here, an | |
409 | ICE occurs. Initializing the backend doesn't hurt much, | |
410 | hence, for now we can live with it as is. */ | |
4ee9c684 | 411 | return false; |
412 | } | |
413 | ||
414 | ||
415 | /* Set the options for -Wall. */ | |
416 | ||
417 | static void | |
b232d73d | 418 | set_Wall (int setting) |
4ee9c684 | 419 | { |
b232d73d | 420 | gfc_option.warn_aliasing = setting; |
421 | gfc_option.warn_ampersand = setting; | |
5ae82d58 | 422 | gfc_option.gfc_warn_conversion = setting; |
b232d73d | 423 | gfc_option.warn_line_truncation = setting; |
b232d73d | 424 | gfc_option.warn_surprising = setting; |
425 | gfc_option.warn_tabs = !setting; | |
426 | gfc_option.warn_underflow = setting; | |
a34926ba | 427 | gfc_option.warn_intrinsic_shadow = setting; |
428 | gfc_option.warn_intrinsics_std = setting; | |
b232d73d | 429 | gfc_option.warn_character_truncation = setting; |
4acad347 | 430 | gfc_option.warn_unused_dummy_argument = setting; |
b232d73d | 431 | |
278e3a1f | 432 | warn_unused = setting; |
b232d73d | 433 | warn_return_type = setting; |
434 | warn_switch = setting; | |
6bda7b34 | 435 | warn_uninitialized = setting; |
4ee9c684 | 436 | } |
437 | ||
438 | ||
439 | static void | |
440 | gfc_handle_module_path_options (const char *arg) | |
441 | { | |
442 | ||
443 | if (gfc_option.module_dir != NULL) | |
db96818c | 444 | gfc_fatal_error ("gfortran: Only one -J option allowed"); |
4ee9c684 | 445 | |
3f1e4cec | 446 | gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2); |
4ee9c684 | 447 | strcpy (gfc_option.module_dir, arg); |
448 | strcat (gfc_option.module_dir, "/"); | |
3dc083ce | 449 | |
55c4c509 | 450 | gfc_add_include_path (gfc_option.module_dir, true, false); |
4ee9c684 | 451 | } |
452 | ||
1bcc6eb8 | 453 | |
8c84a5de | 454 | static void |
455 | gfc_handle_fpe_trap_option (const char *arg) | |
456 | { | |
457 | int result, pos = 0, n; | |
458 | static const char * const exception[] = { "invalid", "denormal", "zero", | |
1bcc6eb8 | 459 | "overflow", "underflow", |
8c84a5de | 460 | "precision", NULL }; |
461 | static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL, | |
462 | GFC_FPE_ZERO, GFC_FPE_OVERFLOW, | |
463 | GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION, | |
464 | 0 }; | |
465 | ||
466 | while (*arg) | |
467 | { | |
468 | while (*arg == ',') | |
469 | arg++; | |
1bcc6eb8 | 470 | |
8c84a5de | 471 | while (arg[pos] && arg[pos] != ',') |
472 | pos++; | |
1bcc6eb8 | 473 | |
8c84a5de | 474 | result = 0; |
475 | for (n = 0; exception[n] != NULL; n++) | |
476 | { | |
477 | if (exception[n] && strncmp (exception[n], arg, pos) == 0) | |
478 | { | |
479 | gfc_option.fpe |= opt_exception[n]; | |
480 | arg += pos; | |
481 | pos = 0; | |
482 | result = 1; | |
483 | break; | |
484 | } | |
485 | } | |
1bcc6eb8 | 486 | if (!result) |
8c84a5de | 487 | gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg); |
488 | } | |
489 | } | |
490 | ||
1bcc6eb8 | 491 | |
76daec3c | 492 | static void |
493 | gfc_handle_coarray_option (const char *arg) | |
494 | { | |
495 | if (strcmp (arg, "none") == 0) | |
496 | gfc_option.coarray = GFC_FCOARRAY_NONE; | |
497 | else if (strcmp (arg, "single") == 0) | |
498 | gfc_option.coarray = GFC_FCOARRAY_SINGLE; | |
499 | else | |
500 | gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg); | |
501 | } | |
502 | ||
503 | ||
ad8ed98e | 504 | static void |
505 | gfc_handle_runtime_check_option (const char *arg) | |
506 | { | |
507 | int result, pos = 0, n; | |
508 | static const char * const optname[] = { "all", "bounds", "array-temps", | |
3a60b071 | 509 | "recursion", "do", "pointer", |
510 | "mem", NULL }; | |
ad8ed98e | 511 | static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS, |
512 | GFC_RTCHECK_ARRAY_TEMPS, | |
7f1bd03f | 513 | GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO, |
3a60b071 | 514 | GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM, |
ad8ed98e | 515 | 0 }; |
516 | ||
517 | while (*arg) | |
518 | { | |
519 | while (*arg == ',') | |
520 | arg++; | |
521 | ||
522 | while (arg[pos] && arg[pos] != ',') | |
523 | pos++; | |
524 | ||
525 | result = 0; | |
526 | for (n = 0; optname[n] != NULL; n++) | |
527 | { | |
528 | if (optname[n] && strncmp (optname[n], arg, pos) == 0) | |
529 | { | |
530 | gfc_option.rtcheck |= optmask[n]; | |
531 | arg += pos; | |
532 | pos = 0; | |
533 | result = 1; | |
534 | break; | |
535 | } | |
536 | } | |
537 | if (!result) | |
538 | gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg); | |
539 | } | |
540 | } | |
541 | ||
542 | ||
4ee9c684 | 543 | /* Handle command-line options. Returns 0 if unrecognized, 1 if |
544 | recognized and handled. */ | |
1bcc6eb8 | 545 | |
b78351e5 | 546 | bool |
1f3db819 | 547 | gfc_handle_option (size_t scode, const char *arg, int value, |
b78351e5 | 548 | int kind ATTRIBUTE_UNUSED, |
549 | const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED) | |
4ee9c684 | 550 | { |
b78351e5 | 551 | bool result = true; |
4ee9c684 | 552 | enum opt_code code = (enum opt_code) scode; |
553 | ||
2ecc6bc5 | 554 | if (gfc_cpp_handle_option (scode, arg, value) == 1) |
b78351e5 | 555 | return true; |
2ecc6bc5 | 556 | |
4ee9c684 | 557 | switch (code) |
558 | { | |
559 | default: | |
b78351e5 | 560 | result = false; |
4ee9c684 | 561 | break; |
562 | ||
563 | case OPT_Wall: | |
b232d73d | 564 | set_Wall (value); |
4ee9c684 | 565 | break; |
566 | ||
567 | case OPT_Waliasing: | |
568 | gfc_option.warn_aliasing = value; | |
569 | break; | |
570 | ||
e27238e0 | 571 | case OPT_Wampersand: |
572 | gfc_option.warn_ampersand = value; | |
573 | break; | |
574 | ||
92f4d1c4 | 575 | case OPT_Warray_temporaries: |
576 | gfc_option.warn_array_temp = value; | |
577 | break; | |
578 | ||
9a709107 | 579 | case OPT_Wcharacter_truncation: |
580 | gfc_option.warn_character_truncation = value; | |
581 | break; | |
582 | ||
4ee9c684 | 583 | case OPT_Wconversion: |
5ae82d58 | 584 | gfc_option.gfc_warn_conversion = value; |
4ee9c684 | 585 | break; |
586 | ||
721f64bf | 587 | case OPT_Wconversion_extra: |
588 | gfc_option.warn_conversion_extra = value; | |
589 | break; | |
590 | ||
4ee9c684 | 591 | case OPT_Wimplicit_interface: |
592 | gfc_option.warn_implicit_interface = value; | |
593 | break; | |
594 | ||
e6bbcce0 | 595 | case OPT_Wimplicit_procedure: |
596 | gfc_option.warn_implicit_procedure = value; | |
597 | break; | |
598 | ||
4ee9c684 | 599 | case OPT_Wline_truncation: |
600 | gfc_option.warn_line_truncation = value; | |
601 | break; | |
602 | ||
fa7b6574 | 603 | case OPT_Wreturn_type: |
604 | warn_return_type = value; | |
605 | break; | |
606 | ||
4ee9c684 | 607 | case OPT_Wsurprising: |
608 | gfc_option.warn_surprising = value; | |
609 | break; | |
610 | ||
35d6528e | 611 | case OPT_Wtabs: |
612 | gfc_option.warn_tabs = value; | |
613 | break; | |
614 | ||
615 | case OPT_Wunderflow: | |
616 | gfc_option.warn_underflow = value; | |
617 | break; | |
618 | ||
a34926ba | 619 | case OPT_Wintrinsic_shadow: |
620 | gfc_option.warn_intrinsic_shadow = value; | |
621 | break; | |
622 | ||
58601acb | 623 | case OPT_Walign_commons: |
624 | gfc_option.warn_align_commons = value; | |
625 | break; | |
626 | ||
4acad347 | 627 | case OPT_Wunused_dummy_argument: |
628 | gfc_option.warn_unused_dummy_argument = value; | |
629 | break; | |
630 | ||
d52febd5 | 631 | case OPT_fall_intrinsics: |
632 | gfc_option.flag_all_intrinsics = 1; | |
633 | break; | |
634 | ||
635 | case OPT_fautomatic: | |
636 | gfc_option.flag_automatic = value; | |
637 | break; | |
638 | ||
17000b91 | 639 | case OPT_fallow_leading_underscore: |
640 | gfc_option.flag_allow_leading_underscore = value; | |
641 | break; | |
642 | ||
d52febd5 | 643 | case OPT_fbackslash: |
644 | gfc_option.flag_backslash = value; | |
645 | break; | |
b549d2a5 | 646 | |
99798ba4 | 647 | case OPT_fbacktrace: |
648 | gfc_option.flag_backtrace = value; | |
649 | break; | |
650 | ||
da6ffc6d | 651 | case OPT_fcheck_array_temporaries: |
ad8ed98e | 652 | gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS; |
da6ffc6d | 653 | break; |
654 | ||
b7fcd3f9 | 655 | case OPT_fdump_core: |
656 | gfc_option.flag_dump_core = value; | |
657 | break; | |
658 | ||
b549d2a5 | 659 | case OPT_fcray_pointer: |
660 | gfc_option.flag_cray_pointer = value; | |
661 | break; | |
4ee9c684 | 662 | |
bdaed7d2 | 663 | case OPT_ff2c: |
664 | gfc_option.flag_f2c = value; | |
665 | break; | |
666 | ||
4ee9c684 | 667 | case OPT_fdollar_ok: |
668 | gfc_option.flag_dollar_ok = value; | |
669 | break; | |
670 | ||
4e8e57b0 | 671 | case OPT_fexternal_blas: |
672 | gfc_option.flag_external_blas = value; | |
673 | break; | |
674 | ||
675 | case OPT_fblas_matmul_limit_: | |
676 | gfc_option.blas_matmul_limit = value; | |
677 | break; | |
678 | ||
8594da07 | 679 | case OPT_fd_lines_as_code: |
680 | gfc_option.flag_d_lines = 1; | |
681 | break; | |
682 | ||
683 | case OPT_fd_lines_as_comments: | |
684 | gfc_option.flag_d_lines = 0; | |
685 | break; | |
686 | ||
4ee9c684 | 687 | case OPT_fdump_parse_tree: |
6c4b9654 | 688 | gfc_option.dump_parse_tree = value; |
4ee9c684 | 689 | break; |
690 | ||
691 | case OPT_ffixed_form: | |
692 | gfc_option.source_form = FORM_FIXED; | |
693 | break; | |
694 | ||
83016156 | 695 | case OPT_ffixed_line_length_none: |
696 | gfc_option.fixed_line_length = 0; | |
697 | break; | |
698 | ||
699 | case OPT_ffixed_line_length_: | |
700 | if (value != 0 && value < 7) | |
701 | gfc_fatal_error ("Fixed line length must be at least seven."); | |
702 | gfc_option.fixed_line_length = value; | |
703 | break; | |
704 | ||
4ee9c684 | 705 | case OPT_ffree_form: |
706 | gfc_option.source_form = FORM_FREE; | |
707 | break; | |
708 | ||
764f1175 | 709 | case OPT_fopenmp: |
5ae82d58 | 710 | gfc_option.gfc_flag_openmp = value; |
764f1175 | 711 | break; |
712 | ||
83016156 | 713 | case OPT_ffree_line_length_none: |
714 | gfc_option.free_line_length = 0; | |
715 | break; | |
716 | ||
717 | case OPT_ffree_line_length_: | |
59c3f3e8 | 718 | if (value != 0 && value < 4) |
719 | gfc_fatal_error ("Free line length must be at least three."); | |
83016156 | 720 | gfc_option.free_line_length = value; |
721 | break; | |
722 | ||
4ee9c684 | 723 | case OPT_funderscoring: |
724 | gfc_option.flag_underscoring = value; | |
725 | break; | |
726 | ||
83aeedb9 | 727 | case OPT_fwhole_file: |
a5fe80bd | 728 | gfc_option.flag_whole_file = value; |
83aeedb9 | 729 | break; |
730 | ||
4ee9c684 | 731 | case OPT_fsecond_underscore: |
732 | gfc_option.flag_second_underscore = value; | |
733 | break; | |
734 | ||
9a61fba1 | 735 | case OPT_static_libgfortran: |
736 | #ifndef HAVE_LD_STATIC_DYNAMIC | |
737 | gfc_fatal_error ("-static-libgfortran is not supported in this " | |
738 | "configuration"); | |
739 | #endif | |
740 | break; | |
741 | ||
4ee9c684 | 742 | case OPT_fimplicit_none: |
743 | gfc_option.flag_implicit_none = value; | |
744 | break; | |
745 | ||
99227731 | 746 | case OPT_fintrinsic_modules_path: |
55c4c509 | 747 | gfc_add_include_path (arg, false, false); |
99227731 | 748 | gfc_add_intrinsic_modules_path (arg); |
749 | break; | |
750 | ||
d6c9e9d7 | 751 | case OPT_fmax_array_constructor_: |
752 | gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535; | |
753 | break; | |
754 | ||
b6be0ac5 | 755 | case OPT_fmax_errors_: |
756 | gfc_option.max_errors = value; | |
757 | break; | |
758 | ||
4ee9c684 | 759 | case OPT_fmax_stack_var_size_: |
760 | gfc_option.flag_max_stack_var_size = value; | |
761 | break; | |
762 | ||
ef63afed | 763 | case OPT_fmodule_private: |
764 | gfc_option.flag_module_private = value; | |
765 | break; | |
766 | ||
09638e2c | 767 | case OPT_frange_check: |
768 | gfc_option.flag_range_check = value; | |
769 | break; | |
770 | ||
4ee9c684 | 771 | case OPT_fpack_derived: |
772 | gfc_option.flag_pack_derived = value; | |
773 | break; | |
774 | ||
775 | case OPT_frepack_arrays: | |
776 | gfc_option.flag_repack_arrays = value; | |
777 | break; | |
778 | ||
9e3a9b8b | 779 | case OPT_fpreprocessed: |
780 | gfc_option.flag_preprocessed = value; | |
781 | break; | |
782 | ||
4ee9c684 | 783 | case OPT_fmax_identifier_length_: |
784 | if (value > GFC_MAX_SYMBOL_LEN) | |
b71883de | 785 | gfc_fatal_error ("Maximum supported identifier length is %d", |
4ee9c684 | 786 | GFC_MAX_SYMBOL_LEN); |
787 | gfc_option.max_identifier_length = value; | |
788 | break; | |
789 | ||
d9c2d9a5 | 790 | case OPT_fdefault_integer_8: |
791 | gfc_option.flag_default_integer = value; | |
4ee9c684 | 792 | break; |
793 | ||
d9c2d9a5 | 794 | case OPT_fdefault_real_8: |
795 | gfc_option.flag_default_real = value; | |
4ee9c684 | 796 | break; |
797 | ||
d9c2d9a5 | 798 | case OPT_fdefault_double_8: |
799 | gfc_option.flag_default_double = value; | |
4ee9c684 | 800 | break; |
801 | ||
a28eb9a8 | 802 | case OPT_finit_local_zero: |
803 | gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; | |
804 | gfc_option.flag_init_integer_value = 0; | |
805 | gfc_option.flag_init_real = GFC_INIT_REAL_ZERO; | |
806 | gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE; | |
807 | gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON; | |
808 | gfc_option.flag_init_character_value = (char)0; | |
809 | break; | |
810 | ||
811 | case OPT_finit_logical_: | |
812 | if (!strcasecmp (arg, "false")) | |
813 | gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE; | |
814 | else if (!strcasecmp (arg, "true")) | |
815 | gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE; | |
816 | else | |
817 | gfc_fatal_error ("Unrecognized option to -finit-logical: %s", | |
818 | arg); | |
819 | break; | |
820 | ||
821 | case OPT_finit_real_: | |
822 | if (!strcasecmp (arg, "zero")) | |
823 | gfc_option.flag_init_real = GFC_INIT_REAL_ZERO; | |
824 | else if (!strcasecmp (arg, "nan")) | |
825 | gfc_option.flag_init_real = GFC_INIT_REAL_NAN; | |
2b6bc4f2 | 826 | else if (!strcasecmp (arg, "snan")) |
827 | gfc_option.flag_init_real = GFC_INIT_REAL_SNAN; | |
a28eb9a8 | 828 | else if (!strcasecmp (arg, "inf")) |
829 | gfc_option.flag_init_real = GFC_INIT_REAL_INF; | |
830 | else if (!strcasecmp (arg, "-inf")) | |
831 | gfc_option.flag_init_real = GFC_INIT_REAL_NEG_INF; | |
832 | else | |
833 | gfc_fatal_error ("Unrecognized option to -finit-real: %s", | |
834 | arg); | |
2ecc6bc5 | 835 | break; |
a28eb9a8 | 836 | |
837 | case OPT_finit_integer_: | |
838 | gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; | |
839 | gfc_option.flag_init_integer_value = atoi (arg); | |
840 | break; | |
841 | ||
842 | case OPT_finit_character_: | |
843 | if (value >= 0 && value <= 127) | |
844 | { | |
845 | gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON; | |
846 | gfc_option.flag_init_character_value = (char)value; | |
847 | } | |
848 | else | |
849 | gfc_fatal_error ("The value of n in -finit-character=n must be " | |
850 | "between 0 and 127"); | |
851 | break; | |
852 | ||
4ee9c684 | 853 | case OPT_I: |
55c4c509 | 854 | gfc_add_include_path (arg, true, false); |
4ee9c684 | 855 | break; |
856 | ||
857 | case OPT_J: | |
4ee9c684 | 858 | gfc_handle_module_path_options (arg); |
ca9ccc0d | 859 | break; |
db96818c | 860 | |
56c7c2d7 | 861 | case OPT_fsign_zero: |
862 | gfc_option.flag_sign_zero = value; | |
863 | break; | |
db96818c | 864 | |
8c84a5de | 865 | case OPT_ffpe_trap_: |
866 | gfc_handle_fpe_trap_option (arg); | |
867 | break; | |
868 | ||
4ee9c684 | 869 | case OPT_std_f95: |
a3b81b0f | 870 | gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77 |
871 | | GFC_STD_F2008_OBS; | |
4ee9c684 | 872 | gfc_option.warn_std = GFC_STD_F95_OBS; |
766398ac | 873 | gfc_option.max_continue_fixed = 19; |
874 | gfc_option.max_continue_free = 39; | |
4ee9c684 | 875 | gfc_option.max_identifier_length = 31; |
e27238e0 | 876 | gfc_option.warn_ampersand = 1; |
35d6528e | 877 | gfc_option.warn_tabs = 0; |
4ee9c684 | 878 | break; |
879 | ||
880 | case OPT_std_f2003: | |
d6583a5f | 881 | gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 |
a3b81b0f | 882 | | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS; |
d6583a5f | 883 | gfc_option.warn_std = GFC_STD_F95_OBS; |
4ee9c684 | 884 | gfc_option.max_identifier_length = 63; |
e27238e0 | 885 | gfc_option.warn_ampersand = 1; |
77a6cc7e | 886 | gfc_option.warn_tabs = 0; |
4ee9c684 | 887 | break; |
888 | ||
ff4425cf | 889 | case OPT_std_f2008: |
890 | gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 | |
a3b81b0f | 891 | | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS; |
892 | gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS; | |
ff4425cf | 893 | gfc_option.max_identifier_length = 63; |
894 | gfc_option.warn_ampersand = 1; | |
895 | gfc_option.warn_tabs = 0; | |
896 | break; | |
897 | ||
4ee9c684 | 898 | case OPT_std_gnu: |
83a65a0d | 899 | set_default_std_flags (); |
c667e11d | 900 | break; |
901 | ||
902 | case OPT_std_legacy: | |
83a65a0d | 903 | set_default_std_flags (); |
c667e11d | 904 | gfc_option.warn_std = 0; |
d6583a5f | 905 | break; |
906 | ||
a34926ba | 907 | case OPT_Wintrinsics_std: |
908 | gfc_option.warn_intrinsics_std = value; | |
4ee9c684 | 909 | break; |
3b6a4b41 | 910 | |
911 | case OPT_fshort_enums: | |
4aafe913 | 912 | /* Handled in language-independent code. */ |
3b6a4b41 | 913 | break; |
15774a8b | 914 | |
915 | case OPT_fconvert_little_endian: | |
18f0b7df | 916 | gfc_option.convert = GFC_CONVERT_LITTLE; |
15774a8b | 917 | break; |
918 | ||
919 | case OPT_fconvert_big_endian: | |
18f0b7df | 920 | gfc_option.convert = GFC_CONVERT_BIG; |
15774a8b | 921 | break; |
922 | ||
923 | case OPT_fconvert_native: | |
18f0b7df | 924 | gfc_option.convert = GFC_CONVERT_NATIVE; |
15774a8b | 925 | break; |
926 | ||
927 | case OPT_fconvert_swap: | |
18f0b7df | 928 | gfc_option.convert = GFC_CONVERT_SWAP; |
15774a8b | 929 | break; |
f23886ab | 930 | |
931 | case OPT_frecord_marker_4: | |
932 | gfc_option.record_marker = 4; | |
933 | break; | |
934 | ||
935 | case OPT_frecord_marker_8: | |
936 | gfc_option.record_marker = 8; | |
937 | break; | |
bbaaa7b1 | 938 | |
939 | case OPT_fmax_subrecord_length_: | |
940 | if (value > MAX_SUBRECORD_LENGTH) | |
1bcc6eb8 | 941 | gfc_fatal_error ("Maximum subrecord length cannot exceed %d", |
942 | MAX_SUBRECORD_LENGTH); | |
bbaaa7b1 | 943 | |
944 | gfc_option.max_subrecord_length = value; | |
14af4f75 | 945 | break; |
946 | ||
947 | case OPT_frecursive: | |
1684aeab | 948 | gfc_option.flag_recursive = value; |
14af4f75 | 949 | break; |
58601acb | 950 | |
951 | case OPT_falign_commons: | |
952 | gfc_option.flag_align_commons = value; | |
953 | break; | |
ad8ed98e | 954 | |
54564d01 | 955 | case OPT_fprotect_parens: |
956 | gfc_option.flag_protect_parens = value; | |
957 | break; | |
958 | ||
ad8ed98e | 959 | case OPT_fcheck_: |
960 | gfc_handle_runtime_check_option (arg); | |
961 | break; | |
962 | ||
76daec3c | 963 | case OPT_fcoarray_: |
964 | gfc_handle_coarray_option (arg); | |
965 | break; | |
4ee9c684 | 966 | } |
967 | ||
968 | return result; | |
969 | } | |
e3d1ab2b | 970 | |
971 | ||
972 | /* Return a string with the options passed to the compiler; used for | |
973 | Fortran's compiler_options() intrinsic. */ | |
974 | ||
975 | char * | |
976 | gfc_get_option_string (void) | |
977 | { | |
978 | unsigned j; | |
979 | size_t len, pos; | |
980 | char *result; | |
981 | ||
982 | /* Determine required string length. */ | |
983 | ||
984 | len = 0; | |
985 | for (j = 1; j < save_decoded_options_count; j++) | |
986 | { | |
987 | switch (save_decoded_options[j].opt_index) | |
988 | { | |
989 | case OPT_o: | |
990 | case OPT_d: | |
991 | case OPT_dumpbase: | |
992 | case OPT_dumpdir: | |
993 | case OPT_auxbase: | |
994 | case OPT_quiet: | |
995 | case OPT_version: | |
996 | case OPT_fintrinsic_modules_path: | |
997 | /* Ignore these. */ | |
998 | break; | |
999 | default: | |
1000 | /* Ignore file names. */ | |
1001 | if (save_decoded_options[j].orig_option_with_args_text[0] == '-') | |
1002 | len += 1 | |
1003 | + strlen (save_decoded_options[j].orig_option_with_args_text); | |
1004 | } | |
1005 | } | |
1006 | ||
1007 | result = (char *) gfc_getmem (len); | |
1008 | ||
1009 | pos = 0; | |
1010 | for (j = 1; j < save_decoded_options_count; j++) | |
1011 | { | |
1012 | switch (save_decoded_options[j].opt_index) | |
1013 | { | |
1014 | case OPT_o: | |
1015 | case OPT_d: | |
1016 | case OPT_dumpbase: | |
1017 | case OPT_dumpdir: | |
1018 | case OPT_auxbase: | |
1019 | case OPT_quiet: | |
1020 | case OPT_version: | |
1021 | case OPT_fintrinsic_modules_path: | |
1022 | /* Ignore these. */ | |
1023 | continue; | |
1024 | ||
1025 | case OPT_cpp_: | |
1026 | /* Use "-cpp" rather than "-cpp=<temporary file>". */ | |
1027 | len = 4; | |
1028 | break; | |
1029 | ||
1030 | default: | |
1031 | /* Ignore file names. */ | |
1032 | if (save_decoded_options[j].orig_option_with_args_text[0] != '-') | |
1033 | continue; | |
1034 | ||
1035 | len = strlen (save_decoded_options[j].orig_option_with_args_text); | |
1036 | } | |
1037 | ||
1038 | memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len); | |
1039 | pos += len; | |
1040 | result[pos++] = ' '; | |
1041 | } | |
1042 | ||
1043 | result[--pos] = '\0'; | |
1044 | return result; | |
1045 | } |