Mercurial > ~dholland > hg > tradcpp > index.cgi
comparison main.c @ 143:ed45f2d8d3bc
Don't use the <err.h> functions.
There are still people out there using legacy systems that are missing
them.
author | David A. Holland |
---|---|
date | Sat, 13 Jul 2013 12:47:20 -0400 |
parents | 26ee741196d1 |
children | 1a7de2c68290 |
comparison
equal
deleted
inserted
replaced
142:26ee741196d1 | 143:ed45f2d8d3bc |
---|---|
31 #include <stdio.h> | 31 #include <stdio.h> |
32 #include <stdarg.h> | 32 #include <stdarg.h> |
33 #include <stdlib.h> | 33 #include <stdlib.h> |
34 #include <string.h> | 34 #include <string.h> |
35 #include <errno.h> | 35 #include <errno.h> |
36 #include <err.h> | |
37 | 36 |
38 #include "version.h" | 37 #include "version.h" |
39 #include "config.h" | 38 #include "config.h" |
40 #include "utils.h" | 39 #include "utils.h" |
41 #include "array.h" | 40 #include "array.h" |
141 { | 140 { |
142 struct place p2; | 141 struct place p2; |
143 char *val; | 142 char *val; |
144 | 143 |
145 if (*str == '\0') { | 144 if (*str == '\0') { |
146 warnx("-D: macro name expected"); | 145 complain(NULL, "-D: macro name expected"); |
147 die(); | 146 die(); |
148 } | 147 } |
149 | 148 |
150 val = strchr(str, '='); | 149 val = strchr(str, '='); |
151 if (val != NULL) { | 150 if (val != NULL) { |
165 static | 164 static |
166 void | 165 void |
167 commandline_undef(const struct place *p, char *str) | 166 commandline_undef(const struct place *p, char *str) |
168 { | 167 { |
169 if (*str == '\0') { | 168 if (*str == '\0') { |
170 warnx("-D: macro name expected"); | 169 complain(NULL, "-D: macro name expected"); |
171 die(); | 170 die(); |
172 } | 171 } |
173 commandline_macro_add(p, str, p, NULL); | 172 commandline_macro_add(p, str, p, NULL); |
174 } | 173 } |
175 | 174 |
372 static | 371 static |
373 void | 372 void |
374 commandline_addincpath(struct stringarray *arr, char *s) | 373 commandline_addincpath(struct stringarray *arr, char *s) |
375 { | 374 { |
376 if (*s == '\0') { | 375 if (*s == '\0') { |
377 warnx("Empty include path"); | 376 complain(NULL, "Empty include directory"); |
378 die(); | 377 die(); |
379 } | 378 } |
380 stringarray_add(arr, s, NULL); | 379 stringarray_add(arr, s, NULL); |
381 } | 380 } |
382 | 381 |
489 commandline_addincpath_user_withprefix(const struct place *p, char *dir) | 488 commandline_addincpath_user_withprefix(const struct place *p, char *dir) |
490 { | 489 { |
491 char *s; | 490 char *s; |
492 | 491 |
493 if (commandline_prefix == NULL) { | 492 if (commandline_prefix == NULL) { |
494 warnx("-iprefix needed"); | 493 complain(NULL, "-iprefix needed"); |
495 die(); | 494 die(); |
496 } | 495 } |
497 s = dostrdup3(commandline_prefix, "/", dir); | 496 s = dostrdup3(commandline_prefix, "/", dir); |
498 freestringlater(s); | 497 freestringlater(s); |
499 commandline_addincpath_user(p, s); | 498 commandline_addincpath_user(p, s); |
504 commandline_addincpath_late_withprefix(const struct place *p, char *dir) | 503 commandline_addincpath_late_withprefix(const struct place *p, char *dir) |
505 { | 504 { |
506 char *s; | 505 char *s; |
507 | 506 |
508 if (commandline_prefix == NULL) { | 507 if (commandline_prefix == NULL) { |
509 warnx("-iprefix needed"); | 508 complain(NULL, "-iprefix needed"); |
510 die(); | 509 die(); |
511 } | 510 } |
512 s = dostrdup3(commandline_prefix, "/", dir); | 511 s = dostrdup3(commandline_prefix, "/", dir); |
513 freestringlater(s); | 512 freestringlater(s); |
514 commandline_addincpath_late(p, s); | 513 commandline_addincpath_late(p, s); |
521 (void)p; | 520 (void)p; |
522 | 521 |
523 if (!strcmp(std, "krc")) { | 522 if (!strcmp(std, "krc")) { |
524 return; | 523 return; |
525 } | 524 } |
526 warnx("Standard %s not supported by this preprocessor", std); | 525 complain(NULL, "Standard %s not supported by this preprocessor", std); |
527 die(); | 526 die(); |
528 } | 527 } |
529 | 528 |
530 static | 529 static |
531 void | 530 void |
534 (void)p; | 533 (void)p; |
535 | 534 |
536 if (!strcmp(lang, "c") || !strcmp(lang, "assembler-with-cpp")) { | 535 if (!strcmp(lang, "c") || !strcmp(lang, "assembler-with-cpp")) { |
537 return; | 536 return; |
538 } | 537 } |
539 warnx("Language %s not supported by this preprocessor", lang); | 538 complain(NULL, "Language %s not supported by this preprocessor", lang); |
540 die(); | 539 die(); |
541 } | 540 } |
542 | 541 |
543 //////////////////////////////////////////////////////////// | 542 //////////////////////////////////////////////////////////// |
544 // complex modes | 543 // complex modes |
548 commandline_iremap(const struct place *p, char *str) | 547 commandline_iremap(const struct place *p, char *str) |
549 { | 548 { |
550 (void)p; | 549 (void)p; |
551 /* XXX */ | 550 /* XXX */ |
552 (void)str; | 551 (void)str; |
553 warnx("-iremap not supported"); | 552 complain(NULL, "-iremap not supported"); |
554 die(); | 553 die(); |
555 } | 554 } |
556 | 555 |
557 static | 556 static |
558 void | 557 void |
564 (void)p; | 563 (void)p; |
565 | 564 |
566 t = strchr(s, '='); | 565 t = strchr(s, '='); |
567 if (t == NULL) { | 566 if (t == NULL) { |
568 /* should not happen */ | 567 /* should not happen */ |
569 warnx("Invalid tabstop"); | 568 complain(NULL, "Invalid tabstop"); |
570 die(); | 569 die(); |
571 } | 570 } |
572 t++; | 571 t++; |
573 errno = 0; | 572 errno = 0; |
574 val = strtoul(t, &t, 10); | 573 val = strtoul(t, &t, 10); |
575 if (errno || *t != '\0') { | 574 if (errno || *t != '\0') { |
576 warnx("Invalid tabstop"); | 575 complain(NULL, "Invalid tabstop"); |
577 die(); | 576 die(); |
578 } | 577 } |
579 if (val > 64) { | 578 if (val > 64) { |
580 warnx("Preposterously large tabstop"); | 579 complain(NULL, "Preposterously large tabstop"); |
581 die(); | 580 die(); |
582 } | 581 } |
583 mode.input_tabstop = val; | 582 mode.input_tabstop = val; |
584 } | 583 } |
585 | 584 |
918 | 917 |
919 for (i=0; i<num_arg_options; i++) { | 918 for (i=0; i<num_arg_options; i++) { |
920 r = strcmp(opt, arg_options[i].string); | 919 r = strcmp(opt, arg_options[i].string); |
921 if (r == 0) { | 920 if (r == 0) { |
922 if (arg == NULL) { | 921 if (arg == NULL) { |
923 warnx("Option -%s requires an argument", opt); | 922 complain(NULL, |
923 "Option -%s requires an argument", | |
924 opt); | |
924 die(); | 925 die(); |
925 } | 926 } |
926 arg_options[i].func(argplace, arg); | 927 arg_options[i].func(argplace, arg); |
927 return true; | 928 return true; |
928 } | 929 } |