-
Notifications
You must be signed in to change notification settings - Fork 0
/
htmldc3.cpp
2225 lines (1905 loc) · 70.6 KB
/
htmldc3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef RCSID
static char RCSid[] =
"$Header$";
#endif
/*
* Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved.
*
* Please see the accompanying license file, LICENSE.TXT, for information
* on using and copying this software.
*/
/*
Name
htmldc3.cpp - HTML TADS Debugger Configuration reader for TADS 3 makefiles
Function
Reads TADS 3 makefiles into debugger configuration objects. Parses
the compiler options from the makefile and stores them as debugger
configuration variables.
Notes
Modified
07/11/99 MJRoberts - Creation
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "os.h"
#include "tadshtml.h"
#include "htmldcfg.h"
#include "htmlhash.h"
/* tads 3 headers */
#include "tccmdutl.h"
/* ------------------------------------------------------------------------ */
/*
* Certain variables are convenient to keep in absolute format while in
* memory, but for project portability reasons they should be in relative
* format (if possible) in the saved config file.
*/
static const char *abs_rel_vars[] = {
"build:symfile path",
"build:objfile path",
"build:source",
"build:rlsgam",
"build:exe",
"auto-script:dir",
"build:installer prog",
"build:zipfile",
"build:srczipfile",
"build:webpage dir",
"breakpoints:file",
"mdi win list",
"mdi win title"
};
/*
* Some variables use a filename as the element portion of the variable
* name - e.g., "src win pos:thing.t". In memory, we store these using
* absolute paths; but in the config file, we want to use relative paths.
* We convert the element portion of the variables listed here between
* relative and absolute paths when reading and writing the config file.
*/
static const char *abs_rel_name_vars[] = {
"src win pos",
"src win edit mode",
"src win selrange",
"src win split",
"line wrap",
};
/*
* Convert a relative path (as stored in the config file) to an absolute
* path (for storage in our in-memory config variable list).
*/
static void rel_var_to_abs(char *buf, size_t buflen, const char *val,
const char *projdir, const char *tadsdir)
{
/* check for an installation-relative value */
if (memcmp(val, "%tads%", 6) == 0)
{
/* return the full path relative to the project folder */
os_build_full_path(buf, buflen, tadsdir, val + 6);
return;
}
/* check for a stuttered leading % - if found, skip the extra % */
if (val[0] == '%' && val[1] == '%')
val += 1;
/* if the path is relative, it's relative to the project directory */
if (!os_is_file_absolute(val))
{
os_build_full_path(buf, buflen, projdir, val);
return;
}
/* it's already relative - copy it as-is */
safe_strcpy(buf, buflen, val);
}
/*
* Stutter a leading '%' in a relativized file name
*/
static void abs_var_to_rel_pct(char *buf, size_t buflen)
{
if (buf[0] == '%' && buflen >= 3)
{
buf[buflen-2] = '\0';
memmove(buf + 1, buf, strlen(buf));
buf[0] = '%';
}
}
/*
* Convert an absolute path (as stored in our memory config list) to a
* relative path (for storage in the config file).
*/
static void abs_var_to_rel(char *buf, size_t buflen, const char *val,
const char *projdir, const char *tadsdir)
{
/* if it's in the project directory, make it relative */
if (os_is_file_in_dir(val, projdir, TRUE, TRUE))
{
/* get the relative path */
os_get_rel_path(buf, buflen, projdir, val);
/* stutter any leading '%' */
abs_var_to_rel_pct(buf, buflen);
/* done */
return;
}
/* if it's in the install directory, make it relative to that */
if (os_is_file_in_dir(val, tadsdir, TRUE, TRUE))
{
/* start with @tads@ */
safe_strcpy(buf, buflen, "%tads%");
size_t len = strlen(buf);
/* add the relative path within the install directory */
os_get_rel_path(buf + len, buflen - len, tadsdir, val);
/* return the result */
return;
}
/* it's already relative - copy it as-is */
safe_strcpy(buf, buflen, val);
/* stutter any leading '%' */
abs_var_to_rel_pct(buf, buflen);
}
/* ------------------------------------------------------------------------ */
/*
* Option file comment parsing states
*/
enum comment_state_t
{
/* start of file - haven't parsed anything yet */
COMMENT_START,
/* parsing file header comments */
COMMENT_HEADER,
/* parsing source file list header comments */
COMMENT_SOURCES,
/* parsing a discarded comment */
COMMENT_DISCARD
};
/*
* Option file helper object
*/
class CConfigOptHelper: public CTcOptFileHelper
{
public:
CConfigOptHelper(CHtmlDebugConfig *config,
const char *projdir, const char *tadsdir)
{
/* remember my debugger configuration object */
config_ = config;
/* remember the project and install directories */
projdir_ = projdir;
tadsdir_ = tadsdir;
/* we haven't found the first comment yet */
cur_comment_ = COMMENT_START;
cur_idx_ = 0;
/* we've found no foreign configuration data yet */
fc_idx_ = 0;
/* we haven't found any configuration data yet */
found_config_ = FALSE;
}
/* allocate an option string */
char *alloc_opt_file_str(size_t len)
{ return (char *)th_malloc(len); }
/* free an option string previously allocated */
void free_opt_file_str(char *str)
{ th_free(str); }
/* note a non-comment line */
void process_non_comment_line(const char *)
{
/* if we're parsing a comment, mark it as no longer in progress */
switch(cur_comment_)
{
case COMMENT_DISCARD:
/* we've been discarding a comment; keep doing so */
break;
case COMMENT_START:
/*
* we're still waiting for the file header comment, but we
* found a non-comment first - there's no file header, so
* simply ignore any comments we find until we find something
* we explicitly recognize
*/
cur_comment_ = COMMENT_DISCARD;
break;
default:
/*
* for any other type of comment we've been processing, we're
* done with that block of comment lines, so discard any other
* comments we encounter until we find something we recognize
*/
cur_comment_ = COMMENT_DISCARD;
break;
}
}
/* process a comment */
void process_comment_line(const char *str)
{
/* check for a special comment section flag */
if (strcmp(str, "##sources") == 0)
{
/* enter the source files block comment */
cur_comment_ = COMMENT_SOURCES;
cur_idx_ = 0;
/* don't store the ##sources line with the block */
return;
}
/* check our state */
switch(cur_comment_)
{
case COMMENT_DISCARD:
/* discarding - ignore the comment */
break;
case COMMENT_START:
/* we're waiting for the file header comment block - enter it */
cur_comment_ = COMMENT_HEADER;
cur_idx_ = 0;
/* FALL THROUGH to process the header comment line */
case COMMENT_HEADER:
/* add this to the header comment list */
config_->setval("makefile", "header_comment", cur_idx_++, str);
break;
case COMMENT_SOURCES:
/* add this to the sources comment list */
config_->setval("makefile", "sources_comment", cur_idx_++, str);
break;
}
}
/* process a configuration line */
void process_config_line(const char *id, const char *str, int is_id_line)
{
const char *start;
CStringBuf varname;
CStringBuf elename;
const char *typ;
size_t typ_len;
const char *val;
const char *p;
/*
* If we haven't found any configuration data yet, make a note that
* we have now found configuration data. If we save an updated
* configuration back to this file, we might want to know whether
* or not any tool-generated configuration data were ever present,
* because if not, the file was probably created manually, so we
* might want to warn about overwriting it.
*/
if (!found_config_)
{
/* note it in the configuration records */
config_->setval("makefile", "found_auto_config_data", TRUE);
/*
* note that we've found config data, so we don't flag it again
* in the configuration
*/
found_config_ = TRUE;
}
/*
* if this isn't part of our configuration section, simply save it
* verbatim, so that we can store it when we save the file
*/
if (stricmp(id, "devsys") != 0)
{
/* save this line in the foreign config list */
config_->setval("makefile", "foreign_config", fc_idx_++, str);
/* we're done with this line */
return;
}
/*
* it's ours - if this is the ID line itself, ignore it, since we
* have no need to store it explicitly
*/
if (is_id_line)
return;
/*
* This is one of our lines. There are two possible storage
* formats:
*
* varname:elename:type:val
*. *len varname-of-length-len:type:val
*
* Where 'varname' is the variable name, 'elename' is the element
* name (essentially a second-level portion of the variable name),
* 'type' is a type name, and 'val' is the value, encoded
* according to the type.
*
* If the line starts with '*len', where 'len' is a decimal
* number, then 'len' gives the number of bytes in the variable
* name; we ignore any embedded colons in that stretch of
* characters. This allows for variable/element names that
* contain multiple colons.
*
* The valid types are:
*
* S: the value is in the form "idx:val", where 'idx' is the
* numeric index of the string in the string array, and 'val' is
* the string itself.
*
* I: the value is an integer, encoded as a decimal number.
*
* R: the value is a rectangle's coordinates in the form
* "x1,y1,x2,y2", where each subvalue is an integer encoded as a
* decimal number.
*
* C: the value is a color in the form "r,g,b", where each subvalue
* is an integer encoded as a decimal number.
*
* B: binary data encoded as a series of hex pairs, with no spaces
* (for example, the string "\001\002\003\n" would be encoded as
* 0102030A).
*/
/* skip leading spaces */
for (p = str ; is_space(*p) ; ++p) ;
/* check for a length prefix */
if (*p == '*')
{
/* scan the length */
++p;
int len = atoi(p);
/* skip to the next space, then skip intervening whitespace */
for ( ; *p != '\0' && !is_space(*p) ; ++p) ;
for ( ; is_space(*p) ; ++p) ;
/* scan and save the variable name */
for (start = p ; *p != ':' && *p != '\0' && len != 0 ;
++p, --len) ;
varname.set(start, p - start);
/* skip the colon */
if (*p == ':' && len != 0)
++p, --len;
/*
* scan the element name - this name is opaque, so take
* everything for the remaining length, even if we find an
* embedded colon
*/
for (start = p ; *p != '\0' && len != 0 ; ++p, --len) ;
/* if the element name is non-null, remember it */
if (p != start)
elename.set(start, p - start);
/*
* we should be looking at a colon now - if not, then the line
* isn't well-formed, so ignore it
*/
if (*p != ':')
return;
}
else
{
/* scan and save the variable name */
for (start = p ; *p != ':' && *p != '\0' ; ++p) ;
varname.set(start, p - start);
/* skip the colon */
if (*p == ':')
++p;
/* scan the element name */
for (start = p ; *p != ':' && *p != '\0' ; ++p) ;
/* if the element name is non-null, remember it */
if (p != start)
elename.set(start, p - start);
}
/* skip the colon */
if (*p == ':')
++p;
/* find the end of the type name */
for (typ = p ; *p != ':' && *p != '\0' ; ++p) ;
typ_len = p - typ;
/* skip the colon */
if (*p == ':')
++p;
/* the value follows */
val = p;
/*
* If this is a variable that uses a filename as the element
* portion of the name, convert the element name to absolute path
* format if it's given in relative format.
*/
for (int i = 0 ; i < countof(abs_rel_name_vars) ; ++i)
{
if (strcmp(varname.get(), abs_rel_name_vars[i]) == 0)
{
/* found it - convert to an absolute path */
char absbuf[OSFNMAX];
rel_var_to_abs(absbuf, sizeof(absbuf), elename.get(),
projdir_, tadsdir_);
/* store it */
elename.set(absbuf);
/* no need to look any further */
break;
}
}
/*
* if the line doesn't look well-formed, ignore it - we must have a
* non-empty variable name, and a one-character type code
*/
if (varname.get() == 0
|| get_strlen(varname.get()) == 0
|| typ_len != 1)
return;
/* check the type code */
switch(typ[0])
{
case 'S':
/* string */
{
/* get the index value */
int idx = atoi(val);
/* skip to the colon */
for ( ; *val != ':' && *val != '\0' ; ++val) ;
/* if we didn't find the colon, it's not well-formed */
if (*val != ':')
return;
/* skip the colon */
++val;
/* store the value */
config_->setval(varname.get(), elename.get(), idx, val);
}
break;
case 'I':
/* integer */
config_->setval(varname.get(), elename.get(), atoi(val));
break;
case 'R':
/* rectangle */
{
long x1, y1, x2, y2;
CHtmlRect rc;
/* scan the four coordinates */
sscanf(val, "%ld,%ld,%ld,%ld", &x1, &y1, &x2, &y2);
/* set up the rectangle structure */
rc.set(x1, y1, x2, y2);
/* store the value */
config_->setval(varname.get(), elename.get(), &rc);
}
break;
case 'C':
/* color */
{
/* scan the red, green, and blue values */
int r, g, b;
sscanf(val, "%d,%d,%d", &r, &g, &b);
/* store the color */
config_->setval_color(varname.get(), elename.get(),
HTML_make_color(r, g, b));
}
break;
case 'B':
/* binary data */
{
/* if the value length isn't even, it's not well-formed */
size_t len = strlen(val);
if ((len & 1) != 0)
return;
/*
* allocate a buffer for room for the converted data - we
* need one byte in the buffer for each two characters in
* the value string, since each two characters in the value
* encode one byte
*/
unsigned char *binval = (unsigned char *)th_malloc(len / 2);
/* convert the value to bytes */
for (unsigned char *dst = binval ; *val != '\0' ; val += 2)
{
/*
* if we don't have two hex digits, it's not
* well-formed, so ignore it
*/
if (!is_hex_digit(*val) || !is_hex_digit(*(val+1)))
{
/* it's not well-formed - ignore the string */
th_free(binval);
return;
}
/* add this byte to the buffer */
*dst++ = ((ascii_hex_to_int(*val) << 4)
+ ascii_hex_to_int(*val));
}
/* store the value */
config_->setval_bytes(varname.get(), elename.get(),
binval, len/2);
/* we're done with the conversion buffer */
th_free(binval);
}
break;
}
}
protected:
/* my debugger configuration object */
CHtmlDebugConfig *config_;
/* local file system name of folder containing the project */
const char *projdir_;
/* TADS install directory path */
const char *tadsdir_;
/* current comment state */
comment_state_t cur_comment_;
/* string index of next line of current comment to be stored */
int cur_idx_;
/* string index of next line of foreign configuration data */
int fc_idx_;
/* flag: we've found a configuration section */
int found_config_;
};
/* ------------------------------------------------------------------------ */
/*
* Service routine - append an argument string to an option. If the
* argument contains any spaces, we'll put it in quotes.
*/
static void append_option_arg(CStringBuf *buf, const char *arg)
{
const char *p;
/* scan the argument for spaces */
for (p = arg ; *p != '\0' ; ++p)
{
/* if it's a space or a quote, stop scanning */
if (is_space(*p) || *p == '"')
break;
}
/* if we found no spaces or quotes, append it without quotes */
if (*p == '\0')
{
/* the string doesn't need quoting, so append it and we're done */
buf->append(arg);
return;
}
/* append the open quote */
buf->append_inc("\"", 128);
/* append each character, stuttering each quote */
for (p = arg ; *p != '\0' ; ++p)
{
/* add this character */
buf->append_inc(p, 1, 128);
/* if it's a quote within the string, stutter it */
if (*p == '"')
buf->append_inc("\"", 128);
}
/* append the closing quote */
buf->append("\"");
}
/* ------------------------------------------------------------------------ */
/*
* Set a string index value, converting it from URL to local notation, and
* expanding it relative to a given base path.
*/
void CHtmlDebugConfig::setval_rel_url(const char *var, const char *subvar,
int idx, const char *val,
const char *base_path)
{
/* convert from URL notation to local conventions */
char buf[OSFNMAX];
os_cvt_url_dir(buf, sizeof(buf), val);
/*
* if the result is a relative filename or path, build the full path
* using the given base path
*/
if (!os_is_file_absolute(buf) && base_path != 0 && base_path[0] != '\0')
{
/* copy it into another buffer for a moment */
char buf2[OSFNMAX];
strcpy(buf2, buf);
/* combine it with the base path */
os_build_full_path(buf, sizeof(buf), base_path, buf2);
}
/* store the local form internally */
setval(var, subvar, idx, buf);
}
/* ------------------------------------------------------------------------ */
/*
* Read a .t3m file (T3 makefile)
*/
int CHtmlDebugConfig::load_t3m_file(const textchar_t *fname,
const char *sys_lib_path,
const char *tads_path)
{
int i;
char *p;
CStringBuf optbuf;
/* extract the project file path */
char proj_path[OSFNMAX];
os_get_path_name(proj_path, sizeof(proj_path), fname);
/* set up the config reader */
CConfigOptHelper opt_helper(this, proj_path, tads_path);
/* assume any resource folders are to include subfolder contents */
int res_recurse = TRUE;
/* we don't have any -I, -D, or -U options yet */
int inc_idx = 0, def_idx = 0, undef_idx = 0;
/* we don't have any -F options yet */
int symdir_idx = 0, objdir_idx = 0, srcdir_idx = 0;
/* we have no extra options yet */
int extra_idx = 0;
/* we have no source files yet */
int src_idx = 0;
/* we have no resource files yet */
int res_idx = 0;
/* open the file - give up immediately if we can't */
osfildef *fp = osfoprt(fname, OSFTTEXT);
if (fp == 0)
return 1;
/* get rid of all of the existing option table entries */
hashtab_->delete_all_entries();
/* parse the file once, to get the argument count */
int argc = CTcCommandUtil::parse_opt_file(fp, 0, 0);
/* allocate space for the argument list */
char **argv = (char **)th_malloc(argc * sizeof(argv[0]));
/*
* Seek back to the start of the file and parse it again now that we
* have a place to store the argument vector.
*/
osfseek(fp, 0, OSFSK_SET);
CTcCommandUtil::parse_opt_file(fp, argv, &opt_helper);
/* done with the file */
osfcls(fp);
/* set OFF defaults for all boolean options without explicit negatives */
setval("makefile", "debug", FALSE);
setval("build", "use_charmap", FALSE);
setval("makefile", "clean_mode", FALSE);
setval("makefile", "compile_only", FALSE);
setval("build", "verbose errors", FALSE);
setval("build", "warnings as errors", FALSE);
setval("makefile", "pp_only", FALSE);
setval("makefile", "list_includes", FALSE);
setval("build", "gen sourceTextGroup", FALSE);
/* parse the t3m options */
for (i = 0 ; i < argc && argv[i][0] == '-' ; ++i)
{
/*
* if we have a "-source" or "-lib" argument, we're done with
* options, and we're on to the module list
*/
if (strcmp(argv[i], "-source") == 0
|| strcmp(argv[i], "-lib") == 0)
break;
/* find out which option we have */
switch(argv[i][1])
{
case 'd':
/* debug mode - note it */
setval("makefile", "debug", TRUE);
break;
case 'D':
/* add preprocessor symbol definition */
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 1);
if (p != 0)
setval("build", "defines", def_idx++, p);
break;
case 'U':
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 1);
if (p != 0)
setval("build", "undefs", undef_idx++, p);
break;
case 'c':
/* see what follows */
switch (argv[i][2])
{
case 's':
/* it's a character set specification */
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 2);
if (p != 0)
{
setval("build", "use_charmap", TRUE);
setval("build", "charmap", 0, p);
}
break;
case 'l':
/* check for "-clean" */
if (strcmp(argv[i], "-clean") == 0)
{
/* set "clean" mode */
setval("makefile", "clean_mode", TRUE);
}
break;
case '\0':
/* set compile-only (no link) mode */
setval("makefile", "compile_only", TRUE);
break;
}
break;
case 'a':
/* see what follows */
switch(argv[i][2])
{
case 'l':
/* force only the link phase */
setval("makefile", "force_link", TRUE);
break;
case '\0':
setval("makefile", "force_build", TRUE);
break;
}
break;
case 'G':
/* check code generation options */
if (strcmp(argv[i], "-Gstg") == 0)
{
/* set sourceTextGroup mode */
setval("build", "gen sourceTextGroup", TRUE);
}
break;
case 'v':
/* set verbose mode */
setval("build", "verbose errors", TRUE);
break;
case 'I':
/* add a #include path */
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 1);
if (p != 0)
setval_rel_url("build", "includes", inc_idx++, p, proj_path);
break;
case 'o':
/* set the image file name */
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 1);
if (p != 0)
setval_rel_url("makefile", "image_file", 0, p, proj_path);
break;
case 'O':
switch(argv[i][2])
{
case 's':
/* string capture file - set up a string with the option */
optbuf.set("-Os ");
/* get the argument */
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 2);
if (p != 0)
{
/* add the "-Os file" option to the extra options list */
append_option_arg(&optbuf, p);
setval("build", "extra options",
extra_idx++, optbuf.get());
}
break;
}
break;
case 'F':
/* output path settings - see which one we're setting */
switch(argv[i][2])
{
char sw;
case 's':
case 'o':
case 'y':
case 'a':
/* remember the sub-option */
sw = argv[i][2];
/* read the path argument */
p = CTcCommandUtil::get_opt_arg(argc, argv, &i, 2);
if (p != 0)
{
/* set the appropriate build variable */
switch(sw)
{
case 's':
setval_rel_url("build", "srcfile path", srcdir_idx++,
p, proj_path);
break;
case 'o':
setval_rel_url("build", "objfile path", objdir_idx++,
p, proj_path);
break;
case 'y':
setval_rel_url("build", "symfile path", symdir_idx++,
p, proj_path);
break;
case 'a':
setval_rel_url("build", "asmfile", 0, p, proj_path);
break;
}
}
break;
default:
/* unrecognize option - ignore it */
break;
}
break;
case 'n':
/* check what we have */
if (strcmp(argv[i], "-nopre") == 0)
{
/* explicitly turn off preinit mode */
setval("build", "run preinit", FALSE);
}
else if (strcmp(argv[i], "-nobanner") == 0)
{
/* add this to the extra options */
setval("build", "extra options", extra_idx++, argv[i]);
}
else if (strcmp(argv[i], "-nodef") == 0)
{
/* don't add the default modules */
setval("build", "keep default modules", FALSE);
}
else if (strcmp(argv[i], "-Gstg") == 0)
{
/* generate sourceTextGroup properties */
setval("build", "gen sourceTextGroup", TRUE);
}
break;
case 'p':
/* check what we have */
if (strcmp(argv[i], "-pre") == 0)
{
/* explicitly turn on preinit mode */
setval("build", "run preinit", TRUE);
}
break;
case 'P':
/*
* A preprocess-only mode. The plain -P generates
* preprocessed source to standard output; -Pi generates only
* a list of names of #included files to standard output.
*/
if (strcmp(argv[i], "-P") == 0)
{
/* set preprocess-only mode */
setval("makefile", "pp_only", TRUE);
}
else if (strcmp(argv[i], "-Pi") == 0)
{
/* set list-includes mode */
setval("makefile", "list_includes", TRUE);
}
break;
case 'q':
/* quiet mode - add this to the extra options */
setval("build", "extra options", extra_idx++, argv[i]);
break;
case 't':
/* add this to the extra options */
if (strcmp(argv[i], "-test") == 0)
setval("build", "extra options", extra_idx++, argv[i]);
break;
case 'w':
/* check for -we or -w# options */
if (argv[i][2] == 'e')
{
/* treat warnings as errors */
setval("build", "warnings as errors", TRUE);
}
else if (isdigit(argv[i][2]))
{