1 /* 2 * Copyright (c) 1993, 19801990 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)mkmakefile.c 8.1 (Berkeley) 6/6/93 34 * $FreeBSD: src/usr.sbin/config/mkmakefile.c,v 1.51.2.3 2001/01/23 00:09:32 peter Exp $ 35 * $DragonFly: src/usr.sbin/config/mkmakefile.c,v 1.14 2005/01/12 00:26:03 cpressey Exp $ 36 */ 37 38 /* 39 * Build the makefile for the system, from 40 * the information in the 'files' files and the 41 * additional files for the machine being compiled to. 42 */ 43 44 #include <ctype.h> 45 #include <err.h> 46 #include <stdio.h> 47 #include <string.h> 48 #include <sys/param.h> 49 #include "y.tab.h" 50 #include "config.h" 51 #include "configvers.h" 52 53 #define next_word(fp, wd) \ 54 { \ 55 char *word; \ 56 \ 57 word = get_word(fp); \ 58 if (word == (char *)EOF) \ 59 return; \ 60 else \ 61 wd = word; \ 62 } 63 #define next_quoted_word(fp, wd) \ 64 { \ 65 char *word; \ 66 \ 67 word = get_quoted_word(fp); \ 68 if (word == (char *)EOF) \ 69 return; \ 70 else \ 71 wd = word; \ 72 } 73 74 static struct file_list *fcur; 75 76 static char *tail(char *); 77 static void do_clean(FILE *); 78 static void do_rules(FILE *); 79 static void do_sfiles(FILE *); 80 static void do_mfiles(FILE *); 81 static void do_cfiles(FILE *); 82 static void do_objs(FILE *); 83 static void do_before_depend(FILE *); 84 static int opteq(char *, char *); 85 static void read_files(void); 86 87 /* 88 * Lookup a file, by name. 89 */ 90 static struct file_list * 91 fl_lookup(char *file) 92 { 93 struct file_list *fp; 94 95 for (fp = ftab; fp != NULL; fp = fp->f_next) { 96 if (strcmp(fp->f_fn, file) == 0) 97 return(fp); 98 } 99 return(0); 100 } 101 102 /* 103 * Lookup a file, by final component name. 104 */ 105 static struct file_list * 106 fltail_lookup(char *file) 107 { 108 struct file_list *fp; 109 110 for (fp = ftab; fp != NULL; fp = fp->f_next) { 111 if (strcmp(tail(fp->f_fn), tail(file)) == 0) 112 return(fp); 113 } 114 return(0); 115 } 116 117 /* 118 * Make a new file list entry 119 */ 120 static struct file_list * 121 new_fent(void) 122 { 123 struct file_list *fp; 124 125 fp = malloc(sizeof(*fp)); 126 bzero(fp, sizeof(*fp)); 127 if (fcur == NULL) 128 fcur = ftab = fp; 129 else 130 fcur->f_next = fp; 131 fcur = fp; 132 return(fp); 133 } 134 135 /* 136 * Build the makefile from the skeleton 137 */ 138 void 139 makefile(void) 140 { 141 FILE *ifp, *ofp; 142 char line[BUFSIZ]; 143 struct opt *op; 144 int versreq; 145 146 read_files(); 147 snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename); 148 ifp = fopen(line, "r"); 149 if (ifp == NULL) { 150 snprintf(line, sizeof(line), "Makefile.%s", machinename); 151 ifp = fopen(line, "r"); 152 } 153 if (ifp == NULL) 154 err(1, "%s", line); 155 ofp = fopen(path("Makefile.new"), "w"); 156 if (ofp == NULL) 157 err(1, "%s", path("Makefile.new")); 158 fprintf(ofp, "KERN_IDENT=%s\n", raisestr(ident)); 159 fprintf(ofp, "IDENT="); 160 if (profiling) 161 fprintf(ofp, " -DGPROF"); 162 163 if (cputype == 0) { 164 printf("cpu type must be specified\n"); 165 exit(1); 166 } 167 fprintf(ofp, "\n"); 168 for (op = mkopt; op != NULL; op = op->op_next) 169 fprintf(ofp, "%s=%s\n", op->op_name, op->op_value); 170 if (debugging) 171 fprintf(ofp, "DEBUG=-g\n"); 172 if (profiling) { 173 fprintf(ofp, "PROF=-pg\n"); 174 fprintf(ofp, "PROFLEVEL=%d\n", profiling); 175 } 176 if (*srcdir != '\0') 177 fprintf(ofp,"S=%s\n", srcdir); 178 while (fgets(line, BUFSIZ, ifp) != 0) { 179 if (*line != '%') { 180 fprintf(ofp, "%s", line); 181 continue; 182 } 183 if (strcmp(line, "%BEFORE_DEPEND\n") == 0) 184 do_before_depend(ofp); 185 else if (strcmp(line, "%OBJS\n") == 0) 186 do_objs(ofp); 187 else if (strcmp(line, "%MFILES\n") == 0) 188 do_mfiles(ofp); 189 else if (strcmp(line, "%CFILES\n") == 0) 190 do_cfiles(ofp); 191 else if (strcmp(line, "%SFILES\n") == 0) 192 do_sfiles(ofp); 193 else if (strcmp(line, "%RULES\n") == 0) 194 do_rules(ofp); 195 else if (strcmp(line, "%CLEAN\n") == 0) 196 do_clean(ofp); 197 else if (strncmp(line, "%VERSREQ=", sizeof("%VERSREQ=") - 1) == 0) { 198 versreq = atoi(line + sizeof("%VERSREQ=") - 1); 199 if (versreq != CONFIGVERS) { 200 fprintf(stderr, "ERROR: version of config(8) does not match kernel!\n"); 201 fprintf(stderr, "config version = %d, ", CONFIGVERS); 202 fprintf(stderr, "version required = %d\n\n", versreq); 203 fprintf(stderr, "Make sure that /usr/src/usr.sbin/config is in sync\n"); 204 fprintf(stderr, "with your /usr/src/sys and install a new config binary\n"); 205 fprintf(stderr, "before trying this again.\n\n"); 206 fprintf(stderr, "If running the new config fails check your config\n"); 207 fprintf(stderr, "file against the GENERIC or LINT config files for\n"); 208 fprintf(stderr, "changes in config syntax, or option/device naming\n"); 209 fprintf(stderr, "conventions\n\n"); 210 exit(1); 211 } 212 } else 213 fprintf(stderr, 214 "Unknown %% construct in generic makefile: %s", 215 line); 216 } 217 fclose(ifp); 218 fclose(ofp); 219 moveifchanged(path("Makefile.new"), path("Makefile")); 220 } 221 222 /* 223 * Read in the information about files used in making the system. 224 * Store it in the ftab linked list. 225 */ 226 static void 227 read_files(void) 228 { 229 FILE *fp; 230 struct file_list *tp, *pf; 231 struct device *dp; 232 struct device *save_dp; 233 struct opt *op; 234 char *wd, *this, *needs, *special, *depends, *clean, *warning; 235 char fname[MAXPATHLEN]; 236 int nreqs, first = 1, configdep, isdup, std, filetype, 237 imp_rule, no_obj, before_depend, mandatory; 238 239 ftab = 0; 240 save_dp = NULL; 241 if (ident == NULL) { 242 printf("no ident line specified\n"); 243 exit(1); 244 } 245 snprintf(fname, sizeof(fname), "../../conf/files"); 246 openit: 247 fp = fopen(fname, "r"); 248 if (fp == NULL) 249 err(1, "%s", fname); 250 next: 251 /* 252 * filename [ standard | mandatory | optional ] [ config-dependent ] 253 * [ dev* | profiling-routine ] [ no-obj ] 254 * [ compile-with "compile rule" [no-implicit-rule] ] 255 * [ dependency "dependency-list"] [ before-depend ] 256 * [ clean "file-list"] [ warning "text warning" ] 257 */ 258 wd = get_word(fp); 259 if (wd == (char *)EOF) { 260 fclose(fp); 261 if (first == 1) { 262 first++; 263 snprintf(fname, sizeof(fname), 264 "../../conf/files.%s", machinename); 265 fp = fopen(fname, "r"); 266 if (fp != NULL) 267 goto next; 268 snprintf(fname, sizeof(fname), 269 "files.%s", machinename); 270 goto openit; 271 } 272 if (first == 2) { 273 first++; 274 snprintf(fname, sizeof(fname), 275 "files.%s", raisestr(ident)); 276 fp = fopen(fname, "r"); 277 if (fp != NULL) 278 goto next; 279 } 280 return; 281 } 282 if (wd == 0) 283 goto next; 284 if (wd[0] == '#') 285 { 286 while (((wd = get_word(fp)) != (char *)EOF) && wd) 287 ; 288 goto next; 289 } 290 this = strdup(wd); 291 next_word(fp, wd); 292 if (wd == 0) { 293 printf("%s: No type for %s.\n", 294 fname, this); 295 exit(1); 296 } 297 if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) 298 isdup = 1; 299 else 300 isdup = 0; 301 tp = 0; 302 if (first == 3 && pf == NULL && (tp = fltail_lookup(this)) != NULL) { 303 if (tp->f_type != INVISIBLE || tp->f_flags) 304 printf("%s: Local file %s overrides %s.\n", 305 fname, this, tp->f_fn); 306 else 307 printf("%s: Local file %s could override %s" 308 " with a different kernel configuration.\n", 309 fname, this, tp->f_fn); 310 } 311 nreqs = 0; 312 special = NULL; 313 depends = NULL; 314 clean = NULL; 315 warning = NULL; 316 configdep = 0; 317 needs = NULL; 318 std = mandatory = 0; 319 imp_rule = 0; 320 no_obj = 0; 321 before_depend = 0; 322 filetype = NORMAL; 323 if (strcmp(wd, "standard") == 0) 324 std = 1; 325 /* 326 * If an entry is marked "mandatory", config will abort if it's 327 * not called by a configuration line in the config file. Apart 328 * from this, the device is handled like one marked "optional". 329 */ 330 else if (strcmp(wd, "mandatory") == 0) 331 mandatory = 1; 332 else if (strcmp(wd, "optional") != 0) { 333 printf("%s: %s must be optional, mandatory or standard\n", 334 fname, this); 335 printf("Your version of config(8) is out of sync with your kernel source.\n"); 336 exit(1); 337 } 338 nextparam: 339 next_word(fp, wd); 340 if (wd == NULL) 341 goto doneparam; 342 if (strcmp(wd, "config-dependent") == 0) { 343 configdep++; 344 goto nextparam; 345 } 346 if (strcmp(wd, "no-obj") == 0) { 347 no_obj++; 348 goto nextparam; 349 } 350 if (strcmp(wd, "no-implicit-rule") == 0) { 351 if (special == NULL) { 352 printf("%s: alternate rule required when " 353 "\"no-implicit-rule\" is specified.\n", 354 fname); 355 } 356 imp_rule++; 357 goto nextparam; 358 } 359 if (strcmp(wd, "before-depend") == 0) { 360 before_depend++; 361 goto nextparam; 362 } 363 if (strcmp(wd, "dependency") == 0) { 364 next_quoted_word(fp, wd); 365 if (wd == NULL) { 366 printf("%s: %s missing compile command string.\n", 367 fname, this); 368 exit(1); 369 } 370 depends = strdup(wd); 371 goto nextparam; 372 } 373 if (strcmp(wd, "clean") == 0) { 374 next_quoted_word(fp, wd); 375 if (wd == NULL) { 376 printf("%s: %s missing clean file list.\n", 377 fname, this); 378 exit(1); 379 } 380 clean = strdup(wd); 381 goto nextparam; 382 } 383 if (strcmp(wd, "compile-with") == 0) { 384 next_quoted_word(fp, wd); 385 if (wd == NULL) { 386 printf("%s: %s missing compile command string.\n", 387 fname, this); 388 exit(1); 389 } 390 special = strdup(wd); 391 goto nextparam; 392 } 393 if (strcmp(wd, "warning") == 0) { 394 next_quoted_word(fp, wd); 395 if (wd == NULL) { 396 printf("%s: %s missing warning text string.\n", 397 fname, this); 398 exit(1); 399 } 400 warning = strdup(wd); 401 goto nextparam; 402 } 403 nreqs++; 404 if (strcmp(wd, "local") == 0) { 405 filetype = LOCAL; 406 goto nextparam; 407 } 408 if (strcmp(wd, "no-depend") == 0) { 409 filetype = NODEPEND; 410 goto nextparam; 411 } 412 if (strcmp(wd, "device-driver") == 0) { 413 printf("%s: `device-driver' flag obsolete.\n", fname); 414 exit(1); 415 } 416 if (strcmp(wd, "profiling-routine") == 0) { 417 filetype = PROFILING; 418 goto nextparam; 419 } 420 if (needs == 0 && nreqs == 1) 421 needs = strdup(wd); 422 if (isdup) 423 goto invis; 424 for (dp = dtab; dp != NULL; save_dp = dp, dp = dp->d_next) 425 if (strcmp(dp->d_name, wd) == 0) { 426 if (std && dp->d_type == PSEUDO_DEVICE && 427 dp->d_count <= 0) 428 dp->d_count = 1; 429 goto nextparam; 430 } 431 if (mandatory) { 432 printf("%s: mandatory device \"%s\" not found\n", 433 fname, wd); 434 exit(1); 435 } 436 if (std) { 437 dp = malloc(sizeof(*dp)); 438 bzero(dp, sizeof(*dp)); 439 init_dev(dp); 440 dp->d_name = strdup(wd); 441 dp->d_type = PSEUDO_DEVICE; 442 dp->d_count = 1; 443 save_dp->d_next = dp; 444 goto nextparam; 445 } 446 for (op = opt; op != NULL; op = op->op_next) 447 if (op->op_value == 0 && opteq(op->op_name, wd)) { 448 if (nreqs == 1) { 449 free(needs); 450 needs = NULL; 451 } 452 goto nextparam; 453 } 454 invis: 455 while ((wd = get_word(fp)) != 0) 456 ; 457 if (tp == NULL) 458 tp = new_fent(); 459 tp->f_fn = this; 460 tp->f_type = INVISIBLE; 461 tp->f_needs = needs; 462 tp->f_flags = isdup; 463 tp->f_special = special; 464 tp->f_depends = depends; 465 tp->f_clean = clean; 466 tp->f_warn = warning; 467 goto next; 468 469 doneparam: 470 if (std == 0 && nreqs == 0) { 471 printf("%s: what is %s optional on?\n", 472 fname, this); 473 exit(1); 474 } 475 476 if (wd != NULL) { 477 printf("%s: syntax error describing %s\n", 478 fname, this); 479 exit(1); 480 } 481 if (filetype == PROFILING && profiling == 0) 482 goto next; 483 if (tp == NULL) 484 tp = new_fent(); 485 tp->f_fn = this; 486 tp->f_type = filetype; 487 tp->f_flags = 0; 488 if (configdep) 489 tp->f_flags |= CONFIGDEP; 490 if (imp_rule) 491 tp->f_flags |= NO_IMPLCT_RULE; 492 if (no_obj) 493 tp->f_flags |= NO_OBJ; 494 if (before_depend) 495 tp->f_flags |= BEFORE_DEPEND; 496 if (imp_rule) 497 tp->f_flags |= NO_IMPLCT_RULE; 498 if (no_obj) 499 tp->f_flags |= NO_OBJ; 500 tp->f_needs = needs; 501 tp->f_special = special; 502 tp->f_depends = depends; 503 tp->f_clean = clean; 504 tp->f_warn = warning; 505 if (pf && pf->f_type == INVISIBLE) 506 pf->f_flags = 1; /* mark as duplicate */ 507 goto next; 508 } 509 510 static int 511 opteq(char *cp, char *dp) 512 { 513 char c, d; 514 515 for (;; cp++, dp++) { 516 if (*cp != *dp) { 517 c = isupper(*cp) ? tolower(*cp) : *cp; 518 d = isupper(*dp) ? tolower(*dp) : *dp; 519 if (c != d) 520 return(0); 521 } 522 if (*cp == 0) 523 return(1); 524 } 525 } 526 527 static void 528 do_before_depend(FILE *fp) 529 { 530 struct file_list *tp; 531 int lpos, len; 532 533 fputs("BEFORE_DEPEND=", fp); 534 lpos = 15; 535 for (tp = ftab; tp != NULL; tp = tp->f_next) 536 if (tp->f_flags & BEFORE_DEPEND) { 537 len = strlen(tp->f_fn); 538 if ((len = 3 + len) + lpos > 72) { 539 lpos = 8; 540 fputs("\\\n\t", fp); 541 } 542 if (tp->f_flags & NO_IMPLCT_RULE) 543 fprintf(fp, "%s ", tp->f_fn); 544 else 545 fprintf(fp, "$S/%s ", tp->f_fn); 546 lpos += len + 1; 547 } 548 if (lpos != 8) 549 putc('\n', fp); 550 } 551 552 static void 553 do_objs(FILE *fp) 554 { 555 struct file_list *tp; 556 int lpos, len; 557 char *cp, och, *sp; 558 559 fprintf(fp, "OBJS="); 560 lpos = 6; 561 for (tp = ftab; tp != NULL; tp = tp->f_next) { 562 if (tp->f_type == INVISIBLE || tp->f_flags & NO_OBJ) 563 continue; 564 sp = tail(tp->f_fn); 565 cp = sp + (len = strlen(sp)) - 1; 566 och = *cp; 567 *cp = 'o'; 568 if (len + lpos > 72) { 569 lpos = 8; 570 fprintf(fp, "\\\n\t"); 571 } 572 fprintf(fp, "%s ", sp); 573 lpos += len + 1; 574 *cp = och; 575 } 576 if (lpos != 8) 577 putc('\n', fp); 578 } 579 580 static void 581 do_cfiles(FILE *fp) 582 { 583 struct file_list *tp; 584 int lpos, len; 585 586 fputs("CFILES=", fp); 587 lpos = 8; 588 for (tp = ftab; tp != NULL; tp = tp->f_next) 589 if (tp->f_type != INVISIBLE && tp->f_type != NODEPEND) { 590 len = strlen(tp->f_fn); 591 if (tp->f_fn[len - 1] != 'c') 592 continue; 593 if ((len = 3 + len) + lpos > 72) { 594 lpos = 8; 595 fputs("\\\n\t", fp); 596 } 597 if (tp->f_type != LOCAL) 598 fprintf(fp, "$S/%s ", tp->f_fn); 599 else 600 fprintf(fp, "%s ", tp->f_fn); 601 602 lpos += len + 1; 603 } 604 if (lpos != 8) 605 putc('\n', fp); 606 } 607 608 static void 609 do_mfiles(FILE *fp) 610 { 611 struct file_list *tp; 612 int lpos, len; 613 614 fputs("MFILES=", fp); 615 lpos = 8; 616 for (tp = ftab; tp != NULL; tp = tp->f_next) 617 if (tp->f_type != INVISIBLE) { 618 len = strlen(tp->f_fn); 619 if (tp->f_fn[len - 1] != 'm' || tp->f_fn[len - 2] != '.') 620 continue; 621 if ((len = 3 + len) + lpos > 72) { 622 lpos = 8; 623 fputs("\\\n\t", fp); 624 } 625 fprintf(fp, "$S/%s ", tp->f_fn); 626 lpos += len + 1; 627 } 628 if (lpos != 8) 629 putc('\n', fp); 630 } 631 632 static void 633 do_sfiles(FILE *fp) 634 { 635 struct file_list *tp; 636 int lpos, len; 637 638 fputs("SFILES=", fp); 639 lpos = 8; 640 for (tp = ftab; tp != NULL; tp = tp->f_next) 641 if (tp->f_type != INVISIBLE) { 642 len = strlen(tp->f_fn); 643 if (tp->f_fn[len - 1] != 'S' && tp->f_fn[len - 1] != 's') 644 continue; 645 if ((len = 3 + len) + lpos > 72) { 646 lpos = 8; 647 fputs("\\\n\t", fp); 648 } 649 fprintf(fp, "$S/%s ", tp->f_fn); 650 lpos += len + 1; 651 } 652 if (lpos != 8) 653 putc('\n', fp); 654 } 655 656 657 static char * 658 tail(char *fn) 659 { 660 char *cp; 661 662 cp = strrchr(fn, '/'); 663 if (cp == 0) 664 return(fn); 665 return(cp + 1); 666 } 667 668 /* 669 * Create the makerules for each file 670 * which is part of the system. 671 * Devices are processed with the special c2 option -i 672 * which avoids any problem areas with i/o addressing 673 * (e.g. for the VAX); assembler files are processed by as. 674 */ 675 static void 676 do_rules(FILE *f) 677 { 678 char *cp, *np, och, *tp; 679 struct file_list *ftp; 680 char *special; 681 682 for (ftp = ftab; ftp != NULL; ftp = ftp->f_next) { 683 if (ftp->f_type == INVISIBLE) 684 continue; 685 if (ftp->f_warn != NULL) 686 printf("WARNING: %s\n", ftp->f_warn); 687 cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; 688 och = *cp; 689 if (ftp->f_flags & NO_IMPLCT_RULE) { 690 if (ftp->f_depends) 691 fprintf(f, "%s: %s\n", np, ftp->f_depends); 692 else 693 fprintf(f, "%s: \n", np); 694 } 695 else { 696 *cp = '\0'; 697 if (och == 'o') { 698 fprintf(f, "%so:\n\t-cp $S/%so .\n\n", 699 tail(np), np); 700 continue; 701 } 702 if (ftp->f_depends) 703 fprintf(f, "%so: $S/%s%c %s\n", tail(np), 704 np, och, ftp->f_depends); 705 else 706 fprintf(f, "%so: $S/%s%c\n", tail(np), 707 np, och); 708 } 709 tp = tail(np); 710 special = ftp->f_special; 711 if (special == NULL) { 712 const char *ftype = NULL; 713 static char cmd[128]; 714 715 switch (ftp->f_type) { 716 717 case NORMAL: 718 ftype = "NORMAL"; 719 break; 720 721 case PROFILING: 722 if (!profiling) 723 continue; 724 ftype = "PROFILE"; 725 break; 726 727 default: 728 printf("config: don't know rules for %s\n", np); 729 break; 730 } 731 snprintf(cmd, sizeof(cmd), "${%s_%c%s}", 732 ftype, toupper(och), 733 ftp->f_flags & CONFIGDEP ? "_C" : ""); 734 special = cmd; 735 } 736 *cp = och; 737 fprintf(f, "\t%s\n\n", special); 738 } 739 } 740 741 static void 742 do_clean(FILE *fp) 743 { 744 struct file_list *tp; 745 int lpos, len; 746 747 fputs("CLEAN=", fp); 748 lpos = 7; 749 for (tp = ftab; tp != NULL; tp = tp->f_next) 750 if (tp->f_clean) { 751 len = strlen(tp->f_clean); 752 if (len + lpos > 72) { 753 lpos = 8; 754 fputs("\\\n\t", fp); 755 } 756 fprintf(fp, "%s ", tp->f_clean); 757 lpos += len + 1; 758 } 759 if (lpos != 8) 760 putc('\n', fp); 761 } 762 763 char * 764 raisestr(char *str) 765 { 766 char *cp = str; 767 768 while (*str) { 769 if (islower(*str)) 770 *str = toupper(*str); 771 str++; 772 } 773 return(cp); 774 } 775