00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #pragma ident "@(#) libcif/cif_lines.c 30.12 08/26/97 07:43:58"
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 #ifndef __STDC__
00139 # define const
00140 #endif
00141
00142 #define CIF_VERSION 3
00143
00144 #ifdef _ABSOFT
00145 #include "cif.h"
00146 #else
00147 #include <cif.h>
00148 #endif
00149
00150 #include <stdio.h>
00151 #include <string.h>
00152 #include <unistd.h>
00153 #include <stdlib.h>
00154 #include <sys/types.h>
00155 #include <sys/stat.h>
00156
00157 #include "cif_int.h"
00158 #include "unitrecord.h"
00159
00160 #define CIF_NOT 0
00161 #define CIF_ASCII 1
00162 #define CIF_BINARY 2
00163
00164 struct unit_list {
00165 struct Cif_generic *rptr;
00166 int recno;
00167 long filepos;
00168 };
00169
00170 struct record {
00171 struct unit_list *ul;
00172 int ulcur;
00173 int ulmax;
00174 };
00175
00176 static struct record ul;
00177 static struct record wl;
00178 static struct record nl;
00179
00180
00181
00182
00183
00184
00185 struct mod_struct {
00186 int modid;
00187 int direct;
00188 };
00189
00190 static struct mod_struct *modids = (struct mod_struct *) NULL;
00191 static int modid_max = 0;
00192 static int modid_current = 0;
00193 #define MODID_BUMP 10
00194
00195
00196 #undef Cif_Lines
00197
00198
00199 static void save_record (struct record *, struct Cif_generic *, int, long);
00200 static void print_records (struct record *, struct record *);
00201 static void print_header_records (struct record *);
00202 static int get_id (struct Cif_generic *);
00203 static int get_line (struct Cif_generic *);
00204 static int get_cpos (struct Cif_generic *);
00205 static int get_fid (struct Cif_generic *);
00206 static int get_scope (struct Cif_generic *);
00207 static int get_type (struct Cif_generic *);
00208 static int get_adjusted_scope (struct Cif_generic *);
00209
00210 static int outfd;
00211 static char *outfile = "-";
00212
00213 static int global_srcfid = 0;
00214
00215 static int global_last_scope = -1;
00216
00217
00218
00219
00220
00221
00222
00223 static int global_scope_found = 0;
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233 static int global_cif_status = 0;
00234
00235
00236
00237 int Cif_CifStatus() {
00238
00239 return( global_cif_status );
00240
00241 }
00242
00243
00244
00245 static int later_date
00246 #ifdef __STDC__
00247 (char *file_1, char *file_2)
00248 #else
00249 (file_1, file_2)
00250 char *file_1, *file_2;
00251 #endif
00252 {
00253 struct stat buf_1, buf_2;
00254
00255 (void) stat(file_1, &buf_1);
00256 (void) stat(file_2, &buf_2);
00257
00258 return(buf_2.st_mtime >= buf_1.st_mtime);
00259 }
00260
00261
00262
00263
00264
00265 static
00266 int cif_next_entry
00267 #ifdef __STDC__
00268 ( int cifd, long *cifpos, struct Cif_generic **cif_record )
00269 #else
00270 ( cifd, cifpos, cif_record )
00271 int cifd;
00272 long *cifpos;
00273 struct Cif_generic **cif_record;
00274 #endif
00275 {
00276 int rtype;
00277
00278 if ((rtype = Cif_Setpos (cifd, *cifpos)) < 0) {
00279 (void) fprintf(stderr, "libcif: set pos returns %d %s for cifd %d %ld\n",
00280 rtype,
00281 Cif_Errstring(rtype),
00282 cifd,
00283 *cifpos);
00284 }
00285
00286 if ((rtype = Cif_Getrecord (cifd, cif_record)) < 0) {
00287 (void) fprintf (stderr, "libcif: Unknown record type at %ld for %d: (%d) %s\n",
00288 *cifpos,
00289 cifd,
00290 rtype,
00291 Cif_Errstring(rtype));
00292 }
00293
00294 *cifpos = Cif_Getpos(cifd);
00295 return(rtype);
00296 }
00297
00298
00299
00300
00301
00302 char *Cif_Filename
00303 #ifdef __STDC__
00304 (int cifd)
00305 #else
00306 (cifd)
00307 int cifd;
00308 #endif
00309 {
00310 if (cifd < 0 || cifd >= CIF_FT_SIZE ||_Cif_filetbl[cifd].form == NOT_A_CIF)
00311 return ((char *) NULL);
00312 else {
00313
00314 return(_Cif_filetbl[cifd].filename);
00315
00316 }
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328 static int lines_type
00329 #ifdef __STDC__
00330 (char *cif_name)
00331 #else
00332 (cif_name)
00333 char *cif_name;
00334 #endif
00335 {
00336 int cifd;
00337 long filepos = CIF_FIRST_RECORD;
00338 int return_code;
00339 struct Cif_generic *cif_record;
00340
00341 cifd = Cif_Open(cif_name, "r", NULL, CIF_VERSION);
00342
00343 if (cifd >= 0 &&
00344 cif_next_entry(cifd, &filepos, &cif_record) == CIF_CIFHDR) {
00345
00346 global_srcfid = CIFHDR(cif_record)->srcfid;
00347
00348 return_code = (CIFHDR(cif_record)->form == CIF_FORM_SORTED);
00349 return_code &= (CIFHDR(cif_record)->bintype == CIF_FORM_LINES);
00350
00351 Cif_Close (cifd, CIF_MEM_FREE);
00352 return(return_code);
00353 }
00354 else {
00355 return(0);
00356 }
00357 }
00358
00359
00360 static char *cif_concat
00361 #ifdef _STDC__
00362 ( char *str1, char *str2 )
00363 #else
00364 ( str1, str2 )
00365 char *str1, *str2;
00366 #endif
00367 {
00368 char *return_str;
00369
00370 return_str =
00371 (char *) malloc ( (strlen( str1) + strlen(str2) + 1) * sizeof (char));
00372
00373 if (return_str == (char *) NULL) {
00374 (void) fprintf(stderr,
00375 "libcif, cif_lines error : Couldn't malloc space in cif_concat\n");
00376 exit(-1);
00377 }
00378
00379 (void) sprintf(return_str, "%s%s",str1, str2);
00380
00381 return( return_str );
00382 }
00383
00384
00385
00386
00387
00388
00389
00390
00391 char *cif_basename
00392 #ifdef __STDC__
00393 ( char *name )
00394 #else
00395 ( name )
00396 char *name;
00397 #endif
00398 {
00399 char *return_str = strrchr(name, '/');
00400
00401 if (return_str == (char *) NULL)
00402 return( name );
00403 else
00404 return( (char *) (++return_str));
00405 }
00406
00407
00408
00409
00410
00411
00412
00413 static char *cif_dirname
00414 #ifdef __STDC__
00415 ( char *name )
00416 #else
00417 ( name )
00418 char *name;
00419 #endif
00420 {
00421 int i = strlen( name ) - 1;
00422 char *dirname_tmp;
00423
00424 while ( i >= 0 &&
00425 name[i]!='/')
00426 i--;
00427
00428 if ( i > 0 ) {
00429 dirname_tmp = (char *) malloc ( (i+1) * sizeof(char));
00430 if (!dirname_tmp) {
00431 (void) fprintf(stderr,
00432 "libcif, Cif_Lines error : Couldn't malloc space in cif_dirname\n");
00433 exit(-1);
00434 }
00435 (void) strncpy(dirname_tmp, name, i);
00436 dirname_tmp[i] = '\0';
00437 }
00438 else
00439 dirname_tmp = strdup("./");
00440
00441 return(dirname_tmp);
00442 }
00443
00444
00445 int cif_VerifyCanWrite
00446 #ifdef __STDC__
00447 ( char *file )
00448 #else
00449 (file)
00450 char *file;
00451 #endif
00452 {
00453 if (!access(file,F_OK)) {
00454 if(access(file,W_OK)) {
00455
00456 return(0);
00457 }
00458 else {
00459 return(1);
00460 }
00461 }
00462 else {
00463 char *dir = cif_dirname(file);
00464 struct stat buf;
00465 int mode;
00466 char *test_file = cif_concat(dir,"/write_test");
00467 FILE *fd;
00468
00469 if (access(dir,F_OK)) {
00470
00471 (void) free(dir);
00472 (void) free(test_file);
00473 return(0);
00474 }
00475
00476 mode = stat(dir, &buf);
00477
00478 if (mode == -1) {
00479
00480 return(0);
00481 }
00482
00483 if (S_ISDIR(buf.st_mode)) {
00484 if (NULL == (fd = fopen(test_file,"w"))) {
00485
00486 (void) free(dir);
00487 (void) fclose(fd);
00488 (void) unlink(test_file);
00489 (void) free(test_file);
00490 return(0);
00491 }
00492 else {
00493 (void) free(dir);
00494 (void) fclose(fd);
00495 (void) unlink(test_file);
00496 (void) free(test_file);
00497 return(1);
00498 }
00499 }
00500 else {
00501
00502 (void) free(test_file);
00503 (void) free(dir);
00504 return(0);
00505 }
00506 }
00507 }
00508
00509
00510
00511
00512
00513
00514 static char *Cif_Make_Lines
00515 #ifdef __STDC__
00516 (char *infile, char *outfile)
00517 #else
00518 (infile, outfile)
00519 char *infile, *outfile;
00520 #endif
00521 {
00522 static int first = 1;
00523 int record_num;
00524 int rtype;
00525 int cifd;
00526 long filepos;
00527 struct Cif_generic *cif_record;
00528 int cif_ending_early = 0;
00529
00530
00531 global_cif_status = 0;
00532
00533
00534
00535
00536
00537
00538 if ((cifd = Cif_Open(infile, "r", NULL, CIF_VERSION)) < 0) {
00539 (void) fprintf (stderr ,"libcif: can't open file %s - %s\n",
00540 infile, Cif_Errstring(cifd));
00541 return((char *) NULL);
00542 }
00543
00544
00545 if ((outfd = Cif_Open(outfile, "w", NULL, CIF_VERSION)) < 0) {
00546 Cif_Close(cifd, CIF_MEM_FREE);
00547 (void) fprintf (stderr,
00548 "libcif: can't open output file %s - %s\n",outfile,
00549 Cif_Errstring(outfd));
00550 return ((char *) NULL);
00551 }
00552
00553 (void) Cif_Memmode (cifd, CIF_MEM_MANAGED);
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 if (first == 1) {
00569 ul.ul = (struct unit_list *) NULL;
00570 nl.ul = (struct unit_list *) NULL;
00571 wl.ul = (struct unit_list *) NULL;
00572 first = 0;
00573 }
00574
00575 ul.ulcur = 0; nl.ulcur = 0; wl.ulcur = 0;
00576
00577 ul.ulmax = 0; nl.ulmax = 0; wl.ulmax = 0;
00578
00579
00580 record_num = 1;
00581 filepos = Cif_Getpos(cifd);
00582 while ((rtype = Cif_Getrecord (cifd, &cif_record)) >= 0) {
00583
00584 if (rtype > CIF_MAXRECORD)
00585 (void) fprintf (stderr, "libcif: unknown record type, %d\n", rtype);
00586 else if (rtype == CIF_SUMMARY &&
00587 CIFSUM(cif_record)->fldlen < 0) {
00588 global_cif_status = CIFSUM(cif_record)->fldlen;
00589 }
00590
00591 else if (get_scope(cif_record) != 0)
00592 {
00593
00594
00595
00596
00597
00598
00599
00600 if (rtype == CIF_SUMMARY &&
00601 CIFSUM(cif_record)->fldlen < 0) {
00602 global_cif_status = CIFSUM(cif_record)->fldlen;
00603 cif_ending_early = 1;
00604 }
00605
00606
00607 if (rtype == CIF_UNIT) {
00608
00609 global_last_scope = -1;
00610 modid_current = 0;
00611
00612
00613
00614
00615 }
00616
00617 if (! unit_record[rtype] &&
00618 rtype != CIF_INCLUDE) {
00619 save_record(&nl, cif_record, record_num, filepos);
00620 }
00621 else {
00622 if (has_line[rtype]) {
00623 save_record (&wl, cif_record, record_num, filepos);
00624
00625 if (rtype == CIF_F90_BEGIN_SCOPE &&
00626 global_last_scope == -1) {
00627 global_last_scope = CIFF90BS(cif_record)->scopeid;
00628
00629 }
00630 }
00631 else {
00632 save_record (&ul, cif_record, record_num, filepos);
00633
00634
00635
00636 if (rtype == CIF_F90_USE_MODULE) {
00637
00638
00639 if (modid_max == modid_current) {
00640 modid_max += MODID_BUMP;
00641 if (modid_max == MODID_BUMP) {
00642
00643 modids = (struct mod_struct *) malloc((sizeof(struct mod_struct) * modid_max));
00644 }
00645 else {
00646 modids = (struct mod_struct *) realloc(modids, (sizeof(struct mod_struct) * modid_max));
00647 }
00648 }
00649 modids[modid_current].modid = CIFF90USE(cif_record)->modid;
00650 modids[modid_current].direct = CIFF90USE(cif_record)->direct;
00651 modid_current++;
00652
00653 }
00654 }
00655
00656 if (rtype == CIF_ENDUNIT) {
00657
00658 print_header_records (&nl);
00659 print_records (&wl, &ul);
00660
00661 ul.ulcur = 0;
00662 nl.ulcur = 0;
00663 wl.ulcur = 0;
00664
00665 (void) Cif_Release (cifd, CIF_MEM_KEEP);
00666 }
00667
00668 if (rtype == CIF_USAGE)
00669 record_num += CIFUSAGE(cif_record)->nuses;
00670 else
00671 record_num++;
00672 }
00673 filepos = Cif_Getpos(cifd);
00674 }
00675 }
00676
00677
00678
00679
00680
00681
00682
00683 if (cif_ending_early == 1) {
00684 print_records (&wl, &ul);
00685 }
00686
00687 if (nl.ulcur > 0)
00688 print_header_records (&nl);
00689
00690
00691
00692 if (rtype != CIF_EOF)
00693 (void) fprintf (stderr, "CIF error - %s\n",
00694 Cif_Errstring(rtype));
00695 (void) Cif_Close (cifd, CIF_MEM_FREE);
00696 (void) Cif_Close (outfd, CIF_MEM_KEEP);
00697 return (outfile);
00698 }
00699
00700
00701 static char *cif_convert_to_lines
00702 #ifdef __STDC__
00703 (char *filename, int keep, int *tmp_cif)
00704 #else
00705 (filename, keep, tmp_cif)
00706 char *filename;
00707 int keep;
00708 int *tmp_cif;
00709 #endif
00710 {
00711 char *value;
00712 char *cifdir = (char *) NULL;
00713 char *cifdir_file = (char *) NULL;
00714 char *outfile = (char *) NULL;
00715 char *create_cif_file = (char *) NULL;
00716 char *tmpdir = (char *) NULL;
00717
00718
00719
00720 *tmp_cif = 0;
00721
00722
00723
00724 if (lines_type( filename ) == 1)
00725 return(strdup(filename));
00726
00727
00728
00729 value = getenv("CIFDIR");
00730 if (value != (char *) NULL) {
00731 cifdir = value;
00732
00733 cifdir_file = (char *) malloc(sizeof(char) *
00734 (strlen(cifdir) +
00735 strlen(cif_basename(filename)) +
00736 3));
00737
00738 (void) sprintf(cifdir_file, "%s/%sL", cifdir, cif_basename(filename));
00739
00740 if (!access(cifdir_file, R_OK)) {
00741
00742 if (later_date(filename, cifdir_file) &&
00743 lines_type(cifdir_file) == 1) {
00744 return(cifdir_file);
00745 }
00746 }
00747 }
00748
00749
00750
00751 outfile = (char *) malloc(sizeof(char) *
00752 (strlen(filename) + 2));
00753 (void) sprintf(outfile, "%sL", filename);
00754
00755 if (!access(outfile, R_OK)) {
00756
00757 if (later_date(filename, outfile) &&
00758 lines_type(outfile) == 1) {
00759 return(outfile);
00760 }
00761 }
00762
00763
00764
00765
00766
00767 if (keep == 1) {
00768
00769
00770
00771 if (cifdir_file != (char *) NULL &&
00772 cif_VerifyCanWrite(cifdir_file)) {
00773
00774 create_cif_file = cifdir_file;
00775 }
00776 else
00777
00778
00779
00780 if (outfile != (char *) NULL &&
00781 cif_VerifyCanWrite(outfile)) {
00782
00783 create_cif_file = strdup(outfile);
00784 }
00785 }
00786
00787 if (create_cif_file == (char *) NULL) {
00788
00789
00790
00791 if (value != (char *) NULL) (void) free(value);
00792
00793 value = getenv("TMPDIR");
00794 if (value != (char *) NULL) {
00795 tmpdir = value;
00796 }
00797 else {
00798 create_cif_file = (char *) malloc(sizeof(char) *
00799 (strlen("/tmp/") +
00800 strlen(cif_basename(filename)) +
00801 7));
00802
00803 (void) sprintf(create_cif_file, "/tmp/%sXXXXXX", cif_basename(filename));
00804 (void) mktemp(create_cif_file);
00805
00806 }
00807
00808 if (create_cif_file == (char *) NULL) {
00809 create_cif_file = (char *) malloc(sizeof(char) *
00810 (strlen(tmpdir) +
00811 strlen(cif_basename(filename)) +
00812 3));
00813
00814 (void) sprintf(create_cif_file, "%s/%sL", tmpdir, cif_basename(filename));
00815 }
00816
00817
00818
00819
00820
00821
00822 *tmp_cif = 1;
00823
00824 }
00825
00826 create_cif_file = Cif_Make_Lines(filename, create_cif_file);
00827
00828
00829
00830 if (cifdir_file != (char *) NULL) (void) free(cifdir_file);
00831 if (outfile != (char *) NULL) (void) free(outfile);
00832
00833 return(create_cif_file);
00834 }
00835
00836
00837 int Cif_Lines
00838 #ifdef __STDC__
00839 (char *filename, char *optype, int *rtypes, int version, int keep)
00840 #else
00841 (filename, optype, rtypes, version, keep)
00842 char *filename;
00843 char *optype;
00844 int *rtypes;
00845 int version;
00846 int keep;
00847 #endif
00848 {
00849
00850 char *cif_name;
00851 int tmp_cif;
00852
00853
00854
00855
00856 int ret;
00857
00858 if (_cif_version == 0)
00859 _cif_version = 1;
00860
00861
00862
00863 global_scope_found = 0;
00864 global_srcfid = 0;
00865
00866
00867
00868 cif_name = cif_convert_to_lines(filename, keep, &tmp_cif);
00869
00870
00871 if (cif_name == (char *) NULL) {
00872 return(CIF_NOTCIF);
00873 }
00874
00875
00876
00877 if (version == 2) {
00878 ret = Cif_Open_V2(cif_name, optype, rtypes, version);
00879 }
00880 else {
00881 ret = Cif_Open_V3_1(cif_name, optype, rtypes, version,
00882 CIF_SUB_VERSION_3);
00883 }
00884
00885
00886
00887
00888
00889
00890
00891
00892 (void) free(cif_name);
00893
00894
00895
00896
00897
00898 if (ret >= 0) {
00899 _Cif_filetbl[ret].tmp_cif = tmp_cif;
00900 }
00901
00902
00903
00904 return(ret);
00905 }
00906
00907
00908
00909
00910
00911
00912
00913
00914 int Cif_Lines_V2_1
00915 #ifdef __STDC__
00916 (char *filename, char *optype, int *rtypes, int version, int keep, int sub_version)
00917 #else
00918 (filename, optype, rtypes, version, keep, sub_version)
00919 char *filename;
00920 char *optype;
00921 int *rtypes;
00922 int version;
00923 int keep;
00924 int sub_version;
00925 #endif
00926 {
00927 _cif_version = 2;
00928
00929 if (sub_version != CIF_SUB_VERSION_2)
00930 return(CIF_SUBVER);
00931
00932 return(Cif_Lines(filename, optype, rtypes,
00933 version, keep));
00934 }
00935
00936
00937
00938
00939
00940 int Cif_Lines_V3_1
00941 #ifdef __STDC__
00942 (char *filename, char *optype, int *rtypes, int version, int keep, int sub_version)
00943 #else
00944 (filename, optype, rtypes, version, keep, sub_version)
00945 char *filename;
00946 char *optype;
00947 int *rtypes;
00948 int version;
00949 int keep;
00950 int sub_version;
00951 #endif
00952 {
00953 _cif_version = 3;
00954
00955 if (sub_version != CIF_SUB_VERSION_3)
00956 return(CIF_SUBVER);
00957
00958 return(Cif_Lines(filename, optype, rtypes,
00959 version, keep));
00960 }
00961
00962
00963
00964
00965
00966 static void save_record
00967 (struct record *l,
00968 struct Cif_generic *cif_record,
00969 int recno,
00970 long filepos)
00971 {
00972 if (l->ul == (struct unit_list *) NULL) {
00973 l->ulmax = 10000;
00974 l->ul=
00975 (struct unit_list *)
00976 calloc (l->ulmax, sizeof(struct unit_list));
00977 }
00978 else
00979 if (l->ulcur >= l->ulmax) {
00980 l->ulmax += 1000;
00981 l->ul = (struct unit_list *)
00982 realloc (l->ul, sizeof(struct unit_list) * l->ulmax);
00983
00984 (void) memset((char *) (&(l->ul[l->ulmax - 1000])), '\0',
00985 (1000 * sizeof(struct unit_list)));
00986
00987 }
00988
00989 l->ul[l->ulcur].rptr = cif_record;
00990 l->ul[l->ulcur].recno = recno;
00991 l->ul[l->ulcur++].filepos = filepos;
00992 }
00993
00994
00995
00996
00997
00998 static int comp_id (
00999 struct Cif_generic **r1,
01000 struct Cif_generic **r2)
01001 {
01002 int ret;
01003
01004 if (((ret = (get_fid(*r1) - get_fid(*r2)))) != 0)
01005 return (ret);
01006 else
01007 if (((ret = (get_line(*r1) - get_line(*r2)))) != 0)
01008 return (ret);
01009 else
01010 if (((ret = ( get_cpos(*r1) - get_cpos(*r2)))) != 0)
01011 return(ret);
01012 else {
01013 if (((ret = ((*r1)->rectype - (*r2)->rectype ))) != 0)
01014 return (ret);
01015 else
01016 if ((*r1)->rectype == CIF_F90_END_SCOPE)
01017
01018
01019
01020
01021
01022
01023
01024
01025 return ( get_scope(*r2) - get_scope(*r1) );
01026 else
01027 return ( get_scope(*r1) - get_scope(*r2) );
01028 }
01029 }
01030
01031
01032
01033
01034
01035 static int comp_scope (
01036 struct Cif_generic **r1,
01037 struct Cif_generic **r2)
01038 {
01039 int ret;
01040 if ((ret = (get_adjusted_scope(*r1) - get_adjusted_scope(*r2))) != 0)
01041 return(ret);
01042 else
01043 if ((ret = (get_type(*r1) - get_type(*r2))) != 0)
01044 return(ret);
01045 else
01046 return ( get_id(*r1) - get_id(*r2) );
01047 }
01048
01049
01050
01051
01052 static int comp_rtype (
01053 struct Cif_generic **r1,
01054 struct Cif_generic **r2)
01055 {
01056 int rtype_1, rtype_2;
01057
01058 rtype_1 = (*r1)->rectype;
01059 rtype_2 = (*r2)->rectype;
01060 if (rtype_1 == rtype_2 &&
01061 rtype_2 == CIF_FILE)
01062 return(CIFFILE(*r1)->fid - CIFFILE(*r2)->fid);
01063 else
01064 if (rtype_1 == CIF_SRCFILE)
01065 rtype_1 = CIF_FILE - 1;
01066 else
01067 if (rtype_2 == CIF_SRCFILE)
01068 rtype_2 = CIF_FILE - 1;
01069
01070 return ( rtype_1 - rtype_2 );
01071 }
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092 static int last_inc = 0;
01093
01094 static void print_include_records(struct record *w, struct record *n, int start, int current, int *pscope_index)
01095 {
01096 int inner_index;
01097 int inc_fid;
01098 int scope_index = *pscope_index;
01099 int save_scope_index;
01100 int ret;
01101
01102
01103
01104
01105 if (current == -1) inc_fid = last_inc;
01106 else
01107 inc_fid = CIFINC(w->ul[current].rptr)->incid;
01108
01109
01110
01111
01112 last_inc = inc_fid;
01113
01114
01115 for (inner_index = start + 1;
01116 w->ul[inner_index].rptr != NULL &&
01117 get_fid(w->ul[inner_index].rptr) != inc_fid;
01118 inner_index++) {
01119 }
01120
01121 for (;
01122 w->ul[inner_index].rptr != NULL &&
01123 get_fid(w->ul[inner_index].rptr) == inc_fid;
01124 inner_index++) {
01125
01126 if ((ret =
01127 Cif_Putrecord(outfd,
01128 w->ul[inner_index].rptr)) < 0) {
01129 (void) fprintf (stderr,
01130 "cif_lines: error writing output file %s - %s\n",
01131 outfile, Cif_Errstring(ret));
01132 exit (ret);
01133 }
01134
01135 if (CIFGEN(w->ul[inner_index].rptr)->rectype == CIF_INCLUDE) {
01136 print_include_records(w, n, start, inner_index, &scope_index);
01137 }
01138 else {
01139 if (CIFGEN(w->ul[inner_index].rptr)->rectype ==CIF_F90_BEGIN_SCOPE ||
01140 global_scope_found == 0 ) {
01141
01142
01143
01144
01145 save_scope_index = scope_index;
01146 for (; scope_index < n->ulcur; scope_index++) {
01147
01148 if (CIFGEN(n->ul[scope_index].rptr)->rectype !=
01149 CIF_F90_ENTRY)
01150 break;
01151
01152 if (CIFF90ENTRY(n->ul[scope_index].rptr)->symid ==
01153 CIFF90BS(w->ul[inner_index].rptr)->symid) {
01154
01155 if ((ret =
01156 Cif_Putrecord(outfd,
01157 n->ul[scope_index].rptr)) < 0) {
01158 (void) fprintf (stderr,
01159 "cif_lines: error writing output file %s - %s\n",
01160 outfile, Cif_Errstring(ret));
01161 exit (ret);
01162 }
01163 CIFGEN(n->ul[scope_index].rptr)->rectype = 0;
01164 break;
01165 }
01166 }
01167 scope_index = save_scope_index;
01168
01169 for (; scope_index < n->ulcur; scope_index++) {
01170
01171 if (CIFGEN(n->ul[scope_index].rptr)->rectype == 0)
01172 continue;
01173
01174 if (get_scope(n->ul[scope_index].rptr) ==
01175 CIFF90BS(w->ul[inner_index].rptr)->scopeid ||
01176 global_scope_found == 0) {
01177
01178 if (get_scope(n->ul[scope_index].rptr) == 0)
01179 continue;
01180
01181
01182
01183
01184
01185 if (CIFGEN(n->ul[scope_index].rptr)->rectype == CIF_F90_ENTRY &&
01186 CIFF90ENTRY(n->ul[scope_index].rptr)->etype == CIF_F90_ET_MODULE) {
01187 int mod;
01188
01189 for (mod = 0; mod < modid_current; mod++) {
01190
01191 if (modids[mod].modid ==
01192 CIFF90ENTRY(n->ul[scope_index].rptr)->symid) {
01193 CIFF90ENTRY(n->ul[scope_index].rptr)->direct = modids[mod].direct;
01194 break;
01195 }
01196 }
01197 }
01198
01199 if ((ret =
01200 Cif_Putrecord(outfd,
01201 n->ul[scope_index].rptr)) < 0) {
01202 (void) fprintf (stderr,
01203 "cif_lines: error writing output file %s - %s\n",
01204 outfile, Cif_Errstring(ret));
01205 exit (ret);
01206 }
01207 }
01208 else
01209 break;
01210 }
01211 }
01212 }
01213
01214 CIFGEN(w->ul[inner_index].rptr)->rectype = 0;
01215
01216 }
01217
01218 *pscope_index = scope_index;
01219
01220 }
01221
01222
01223
01224
01225
01226 static void print_records (struct record *w, struct record *n)
01227 {
01228 int i, ret, scope_index;
01229 int scope_count = 0;
01230 int save_scope_index = 0;
01231
01232 (void) qsort ((char *)w->ul, w->ulcur, sizeof(struct unit_list), (int(*)()) comp_id);
01233 (void) qsort ((char *)n->ul, n->ulcur, sizeof(struct unit_list), (int(*)()) comp_scope);
01234
01235
01236 for (i=0, scope_index = 0; i < w->ulcur; i++) {
01237 if ((w->ul[i].rptr)->rectype == CIF_UNIT) {
01238
01239 if (get_fid(w->ul[i].rptr) > global_srcfid) {
01240
01241
01242 if ((ret = Cif_Putrecord(outfd, w->ul[i].rptr)) < 0) {
01243 (void) fprintf (stderr,
01244 "cif_lines: error writing output file %s - %s\n",
01245 outfile, Cif_Errstring(ret));
01246 exit (ret);
01247 }
01248
01249 (w->ul[i].rptr)->rectype = 0;
01250
01251
01252
01253 print_include_records(w, n, i, -1, &scope_index);
01254 }
01255 break;
01256 }
01257 }
01258
01259 for (i=0, scope_index = 0; i < w->ulcur; i++) {
01260
01261
01262
01263
01264
01265 #ifdef notdef
01266 if (get_fid(w->ul[i].rptr) > global_srcfid) {
01267 if ((w->ul[i].rptr)->rectype == CIF_UNIT) {
01268
01269
01270 if ((ret = Cif_Putrecord(outfd, w->ul[i].rptr)) < 0) {
01271 (void) fprintf (stderr,
01272 "cif_lines: error writing output file %s - %s\n",
01273 outfile, Cif_Errstring(ret));
01274 exit (ret);
01275 }
01276
01277
01278 print_include_records(w, n, i, -1, &scope_index);
01279 }
01280 break;
01281 }
01282 #endif
01283
01284
01285
01286
01287 if ((w->ul[i].rptr)->rectype == 0)
01288 continue;
01289
01290
01291
01292
01293
01294
01295 if (CIFGEN(w->ul[i].rptr)->rectype == CIF_USAGE &&
01296 i < w->ulcur - 1 &&
01297 CIFGEN(w->ul[i+1].rptr)->rectype == CIF_USAGE) {
01298
01299 if (CIFUSAGE(w->ul[i].rptr)->use->line == CIFUSAGE(w->ul[i+1].rptr)->use->line &&
01300 CIFUSAGE(w->ul[i].rptr)->use->cpos == CIFUSAGE(w->ul[i+1].rptr)->use->cpos &&
01301 CIFUSAGE(w->ul[i].rptr)->symid == CIFUSAGE(w->ul[i+1].rptr)->symid) {
01302
01303 if (CIFUSAGE(w->ul[i].rptr)->use->utype == CIF_F90_OB_MODIFIED &&
01304 CIFUSAGE(w->ul[i+1].rptr)->use->utype == CIF_F90_OB_OPER_ARG
01305
01306 )
01307 CIFUSAGE(w->ul[i+1].rptr)->use->utype = CIF_F90_OB_MODIFIED_ASN;
01308 continue;
01309 }
01310 }
01311
01312 if ((ret = Cif_Putrecord(outfd, w->ul[i].rptr)) < 0) {
01313 (void) fprintf (stderr,
01314 "cif_lines: error writing output file %s - %s\n",
01315 outfile, Cif_Errstring(ret));
01316 exit (ret);
01317 }
01318 else
01319
01320 if (CIFGEN(w->ul[i].rptr)->rectype == CIF_INCLUDE) {
01321 print_include_records(w, n, i, i, &scope_index);
01322 }
01323 else {
01324 if (CIFGEN(w->ul[i].rptr)->rectype ==CIF_F90_BEGIN_SCOPE ||
01325 global_scope_found == 0 ) {
01326
01327
01328
01329
01330
01331 save_scope_index = scope_index;
01332 for (; scope_index < n->ulcur; scope_index++) {
01333 if (get_scope(n->ul[scope_index].rptr) !=
01334 CIFF90BS(w->ul[i].rptr)->scopeid ||
01335 global_scope_found == 0) {
01336 continue;
01337 }
01338
01339 if (CIFGEN(n->ul[scope_index].rptr)->rectype !=
01340 CIF_F90_ENTRY)
01341 break;
01342
01343 if (CIFF90ENTRY(n->ul[scope_index].rptr)->symid ==
01344 CIFF90BS(w->ul[i].rptr)->symid) {
01345
01346
01347 if ((ret =
01348 Cif_Putrecord(outfd,
01349 n->ul[scope_index].rptr)) < 0) {
01350 (void) fprintf (stderr,
01351 "cif_lines: error writing output file %s - %s\n",
01352 outfile, Cif_Errstring(ret));
01353 exit (ret);
01354 }
01355 CIFGEN(n->ul[scope_index].rptr)->rectype = 0;
01356 break;
01357 }
01358 }
01359 scope_index = save_scope_index;
01360
01361 for (; scope_index < n->ulcur; scope_index++) {
01362
01363 if (CIFGEN(n->ul[scope_index].rptr)->rectype == 0)
01364 continue;
01365
01366 if (get_scope(n->ul[scope_index].rptr) < CIFF90BS(w->ul[i].rptr)->scopeid)
01367 continue;
01368
01369 if (get_scope(n->ul[scope_index].rptr) ==
01370 CIFF90BS(w->ul[i].rptr)->scopeid ||
01371 global_scope_found == 0) {
01372
01373 if (get_scope(n->ul[scope_index].rptr) == 0)
01374 continue;
01375
01376
01377
01378
01379
01380 if (CIFGEN(n->ul[scope_index].rptr)->rectype == CIF_F90_ENTRY &&
01381 CIFF90ENTRY(n->ul[scope_index].rptr)->etype == CIF_F90_ET_MODULE) {
01382 int mod;
01383
01384
01385 for (mod = 0; mod < modid_current; mod++) {
01386
01387 if (modids[mod].modid ==
01388 CIFF90ENTRY(n->ul[scope_index].rptr)->symid) {
01389 CIFF90ENTRY(n->ul[scope_index].rptr)->direct = modids[mod].direct;
01390 break;
01391 }
01392 }
01393 }
01394
01395 if ((ret =
01396 Cif_Putrecord(outfd,
01397 n->ul[scope_index].rptr)) < 0) {
01398 (void) fprintf (stderr,
01399 "cif_lines: error writing output file %s - %s\n",
01400 outfile, Cif_Errstring(ret));
01401 exit (ret);
01402 }
01403 }
01404 else {
01405 break;
01406 }
01407 }
01408 }
01409 }
01410 }
01411 }
01412
01413
01414
01415
01416
01417 static void print_header_records (struct record *l)
01418 {
01419 int i, ret;
01420
01421 (void) qsort ((char *)l->ul, l->ulcur, sizeof(struct unit_list), (int(*)()) comp_rtype);
01422 for (i=0; i < l->ulcur; i++) {
01423
01424
01425
01426
01427
01428
01429 if (l->ul[i].rptr->rectype == CIF_CIFHDR) {
01430 CIFHDR(l->ul[i].rptr)->bintype = CIF_FORM_LINES;
01431 }
01432
01433 if ((ret = Cif_Putrecord(outfd, l->ul[i].rptr)) < 0) {
01434 (void) fprintf (stderr,
01435 "cif_lines: error writing output file %s - %s\n",
01436 outfile, Cif_Errstring(ret));
01437 exit (ret);
01438 }
01439 }
01440 }
01441
01442
01443
01444
01445
01446 static int get_id (
01447 struct Cif_generic *rptr)
01448 {
01449
01450 int id;
01451
01452 switch (rptr->rectype) {
01453 case CIF_CALLSITE:
01454 id = CIFCS(rptr)->entryid;
01455 break;
01456 case CIF_COMBLK:
01457 id = CIFCB(rptr)->symid;
01458 break;
01459 case CIF_CONST:
01460 id = CIFCON(rptr)->symid;
01461 break;
01462 case CIF_ENTRY:
01463 id = CIFENTRY(rptr)->symid;
01464 break;
01465 case CIF_LABEL:
01466 id = CIFLABEL(rptr)->symid;
01467 break;
01468 case CIF_NAMELIST:
01469 id = CIFNL(rptr)->symid;
01470 break;
01471 case CIF_OBJECT:
01472 id = CIFOBJ(rptr)->symid;
01473 break;
01474 case CIF_USAGE:
01475 id = CIFUSAGE(rptr)->symid;
01476 break;
01477
01478 #if CIF_VERSION != 1
01479 case CIF_F90_CALLSITE:
01480 id = CIFF90CS(rptr)->entryid;
01481 break;
01482 case CIF_F90_COMBLK:
01483 id = CIFF90CB(rptr)->symid;
01484 break;
01485 case CIF_F90_CONST:
01486 id = CIFF90CON(rptr)->symid;
01487 break;
01488 case CIF_F90_ENTRY:
01489 id = CIFF90ENTRY(rptr)->symid;
01490 break;
01491 case CIF_F90_LABEL:
01492 id = CIFF90LABEL(rptr)->symid;
01493 break;
01494 case CIF_F90_NAMELIST:
01495 id = CIFF90NL(rptr)->symid;
01496 break;
01497 case CIF_F90_OBJECT:
01498 id = CIFF90OBJ(rptr)->symid;
01499 break;
01500 case CIF_F90_DERIVED_TYPE:
01501 id = CIFF90DTYPE(rptr)->symid;
01502 break;
01503 case CIF_F90_BEGIN_SCOPE:
01504 id = CIFF90BS(rptr)->symid;
01505 global_scope_found = 1;
01506 break;
01507 case CIF_F90_USE_MODULE:
01508 id = CIFF90USE(rptr)->modid;
01509 break;
01510 case CIF_F90_RENAME:
01511 id = CIFF90RN(rptr)->modid;
01512 break;
01513 case CIF_F90_INT_BLOCK:
01514 id = CIFF90IB(rptr)->intid;
01515 break;
01516
01517 case CIF_GEOMETRY:
01518 id = CIFGEOM(rptr)->geomid;
01519 break;
01520
01521
01522 case CIF_C_LINT_DIRECTIVE:
01523 id = CIFCLDIR(rptr)->objid;
01524 break;
01525 case CIF_C_MACRO_DEF:
01526 id = CIFCMDEF(rptr)->symid;
01527 break;
01528 case CIF_C_MACRO_UNDEF:
01529 id = CIFCMUDEF(rptr)->symid;
01530 break;
01531 case CIF_C_MACRO_USAGE:
01532 id = CIFCMUSE(rptr)->symid;
01533 break;
01534 case CIF_C_ENTRY_END:
01535 id = CIFCEEND(rptr)->symid;
01536 break;
01537
01538 #endif
01539
01540
01541 #if CIF_VERSION == 3
01542
01543 case CIF_SRC_POS:
01544 id = CIFSPOS(rptr)->symid;
01545 break;
01546
01547 #endif
01548
01549 case CIF_C_TAG:
01550 id = CIFCTAG(rptr)->tagid;
01551 break;
01552 case CIF_C_CONST:
01553 id = CIFCCON(rptr)->symid;
01554 break;
01555 case CIF_C_ENTRY:
01556 id = CIFCENTRY(rptr)->symid;
01557 break;
01558 case CIF_C_OBJECT:
01559 id = CIFCOBJ(rptr)->symid;
01560 break;
01561 default:
01562 id = 0;
01563 }
01564 return (id);
01565
01566 }
01567
01568
01569
01570
01571
01572
01573 static int get_line (
01574 struct Cif_generic *rptr)
01575 {
01576 int id;
01577
01578 switch (rptr->rectype) {
01579 case CIF_UNIT:
01580 id = CIFUNIT(rptr)->line;
01581 break;
01582 case CIF_ENDUNIT:
01583 id = CIFENDU(rptr)->line;
01584 break;
01585 case CIF_CALLSITE:
01586 id = CIFCS(rptr)->line;
01587 break;
01588 case CIF_LOOP:
01589 id = CIFLOOP(rptr)->strline;
01590 break;
01591 case CIF_COMBLK:
01592 id = -1;
01593 break;
01594 case CIF_CONST:
01595 id = -2;
01596 break;
01597 case CIF_ENTRY:
01598 id = -3;
01599 break;
01600 case CIF_LABEL:
01601 id = -4;
01602 break;
01603 case CIF_MESSAGE:
01604 id = CIFMSG(rptr)->fline;;
01605 break;
01606 case CIF_ND_MSG:
01607 id = CIFNMSG(rptr)->fline;;
01608 break;
01609 case CIF_NAMELIST:
01610 id = -5;
01611 break;
01612 case CIF_OBJECT:
01613 id = -6;
01614 break;
01615 case CIF_USAGE:
01616 id = CIFUSAGE(rptr)->use->line;
01617 break;
01618 case CIF_STMT_TYPE:
01619 id = CIFSTMT(rptr)->line;
01620 break;
01621 case CIF_INCLUDE:
01622 id = CIFINC(rptr)->line;
01623 break;
01624
01625 #if CIF_VERSION != 1
01626 case CIF_CDIR:
01627 id = CIFCDIR(rptr)->line;
01628 break;
01629 case CIF_CDIR_DOSHARED:
01630 id = CIFCDIRDO(rptr)->line;
01631 break;
01632 case CIF_CONTINUATION:
01633 id = CIFCONT(rptr)->line;
01634 break;
01635
01636
01637 case CIF_F90_CALLSITE:
01638 id = CIFF90CS(rptr)->line;
01639 break;
01640 case CIF_F90_COMBLK:
01641 id = -7;
01642 break;
01643 case CIF_F90_LOOP:
01644 id = CIFF90LOOP(rptr)->strline;
01645 break;
01646 case CIF_F90_ENTRY:
01647 id = -8;
01648 break;
01649 case CIF_F90_CONST:
01650 id = CIFF90CON(rptr)->strline;
01651 break;
01652 case CIF_F90_LABEL:
01653 id = -10;
01654 break;
01655 case CIF_F90_NAMELIST:
01656 id = -11;
01657 break;
01658 case CIF_F90_OBJECT:
01659 id = -12;
01660 break;
01661 case CIF_F90_DERIVED_TYPE:
01662 id = -13;
01663 break;
01664 case CIF_F90_BEGIN_SCOPE:
01665 id = CIFF90BS(rptr)->line;
01666 global_scope_found = 1;
01667 break;
01668 case CIF_F90_END_SCOPE:
01669 id = CIFF90ES(rptr)->line;
01670 break;
01671 case CIF_F90_SCOPE_INFO:
01672 id = -14;
01673 break;
01674 case CIF_F90_USE_MODULE:
01675 id = -15;
01676 break;
01677 case CIF_F90_RENAME:
01678 id = -16;
01679 break;
01680 case CIF_F90_INT_BLOCK:
01681 id = -17;
01682 break;
01683
01684 case CIF_GEOMETRY:
01685 id = -18;
01686 break;
01687
01688
01689 case CIF_C_LINT_DIRECTIVE:
01690 id = CIFCLDIR(rptr)->strline;
01691 break;
01692 case CIF_C_MACRO_DEF:
01693 id = CIFCMDEF(rptr)->strline;
01694 break;
01695 case CIF_C_MACRO_UNDEF:
01696 id = CIFCMUDEF(rptr)->line;
01697 break;
01698 case CIF_C_MACRO_USAGE:
01699 id = CIFCMUSE(rptr)->strline;
01700 break;
01701 case CIF_C_ENTRY_END:
01702 id = CIFCEEND(rptr)->strline;
01703 break;
01704
01705 case CIF_BE_NODE:
01706 id = -19;
01707 break;
01708
01709 case CIF_BE_FID:
01710 id = -19;
01711 break;
01712
01713 #endif
01714
01715 #if CIF_VERSION >= 3
01716
01717 case CIF_CC_TYPE:
01718 id = -24;
01719 break;
01720
01721 case CIF_CC_ENTRY:
01722 id = CIFCCENT(rptr)->sline;
01723 break;
01724
01725 case CIF_CC_OBJ:
01726 id = -24;
01727 break;
01728
01729 case CIF_CC_SUBTYPE:
01730 id = -24;
01731 break;
01732
01733 case CIF_CC_ENUM:
01734 id = -24;
01735 break;
01736
01737 case CIF_CC_EXPR:
01738 id = CIFCCEXPR(rptr)->line;
01739 break;
01740
01741 case CIF_SRC_POS:
01742 id = CIFSPOS(rptr)->sline;
01743 break;
01744
01745 #endif
01746
01747 case CIF_C_TAG:
01748 id = -20;
01749 break;
01750 case CIF_C_CONST:
01751 id = -21;
01752 break;
01753 case CIF_C_MESSAGE:
01754 id = CIFCMSG(rptr)->fline;
01755 break;
01756 case CIF_C_ENTRY:
01757 id = -22;
01758 break;
01759 case CIF_C_OBJECT:
01760 id = -23;
01761 break;
01762 default:
01763 id = 0;
01764 }
01765 return (id);
01766 }
01767
01768
01769
01770
01771
01772
01773 static int get_fid (
01774 struct Cif_generic *rptr)
01775 {
01776 int id;
01777
01778 switch (rptr->rectype) {
01779 case CIF_UNIT:
01780 id = CIFUNIT(rptr)->fid;
01781 break;
01782 case CIF_ENDUNIT:
01783 id = CIFENDU(rptr)->fid;
01784 break;
01785 case CIF_CALLSITE:
01786 id = CIFCS(rptr)->fid;
01787 break;
01788 case CIF_COMBLK:
01789 id = -1;
01790 break;
01791 case CIF_CONST:
01792 id = -2;
01793 break;
01794 case CIF_ENTRY:
01795 id = -3;
01796 break;
01797 case CIF_LOOP:
01798 id = CIFLOOP(rptr)->sfid;
01799 break;
01800 case CIF_LABEL:
01801 id = -4;
01802 break;
01803 case CIF_MESSAGE:
01804 id = CIFMSG(rptr)->fid;
01805 break;
01806 case CIF_ND_MSG:
01807 id = CIFNMSG(rptr)->fid;
01808 break;
01809 case CIF_NAMELIST:
01810 id = -5;
01811 break;
01812 case CIF_OBJECT:
01813 id = -6;
01814 break;
01815 case CIF_USAGE:
01816 id = CIFUSAGE(rptr)->use->fid;
01817 break;
01818 case CIF_STMT_TYPE:
01819 id = CIFSTMT(rptr)->fid;
01820 break;
01821 case CIF_INCLUDE:
01822 id = CIFINC(rptr)->srcid;
01823 break;
01824
01825 #if CIF_VERSION != 1
01826 case CIF_CDIR:
01827 id = CIFCDIR(rptr)->fid;
01828 break;
01829 case CIF_CDIR_DOSHARED:
01830 id = CIFCDIRDO(rptr)->fid;
01831 break;
01832 case CIF_CONTINUATION:
01833 id = CIFCONT(rptr)->fid;
01834 break;
01835
01836
01837 case CIF_F90_CALLSITE:
01838 id = CIFF90CS(rptr)->fid;
01839 break;
01840 case CIF_F90_COMBLK:
01841 id = -7;
01842 break;
01843 case CIF_F90_LOOP:
01844 id = CIFF90LOOP(rptr)->sfid;
01845 break;
01846 case CIF_F90_ENTRY:
01847 id = -8;
01848 break;
01849 case CIF_F90_CONST:
01850 id = CIFF90CON(rptr)->fid;
01851 break;
01852 case CIF_F90_LABEL:
01853 id = -10;
01854 break;
01855 case CIF_F90_NAMELIST:
01856 id = -11;
01857 break;
01858 case CIF_F90_OBJECT:
01859 id = -12;
01860 break;
01861 case CIF_F90_DERIVED_TYPE:
01862 id = -13;
01863 break;
01864 case CIF_F90_BEGIN_SCOPE:
01865 id = CIFF90BS(rptr)->fid;
01866 global_scope_found = 1;
01867 break;
01868 case CIF_F90_END_SCOPE:
01869 id = CIFF90ES(rptr)->fid;
01870 break;
01871 case CIF_F90_SCOPE_INFO:
01872 id = -14;
01873 break;
01874 case CIF_F90_USE_MODULE:
01875 id = -15;
01876 break;
01877 case CIF_F90_RENAME:
01878 id = -16;
01879 break;
01880 case CIF_F90_INT_BLOCK:
01881 id = -17;
01882 break;
01883
01884 case CIF_GEOMETRY:
01885 id = -18;
01886 break;
01887
01888
01889 case CIF_C_LINT_DIRECTIVE:
01890 id = CIFCLDIR(rptr)->fid;
01891 break;
01892 case CIF_C_MACRO_DEF:
01893 id = CIFCMDEF(rptr)->fid;
01894 break;
01895 case CIF_C_MACRO_UNDEF:
01896 id = CIFCMUDEF(rptr)->fid;
01897 break;
01898 case CIF_C_MACRO_USAGE:
01899 id = CIFCMUSE(rptr)->fid;
01900 break;
01901 case CIF_C_ENTRY_END:
01902 id = CIFCEEND(rptr)->fid;
01903 break;
01904
01905 case CIF_BE_NODE:
01906 id = -19;
01907 break;
01908
01909 case CIF_BE_FID:
01910 id = -19;
01911 break;
01912
01913 #endif
01914
01915 #if CIF_VERSION == 3
01916
01917 case CIF_CC_TYPE:
01918 id = -24;
01919 break;
01920
01921 case CIF_CC_ENTRY:
01922 id = CIFCCENT(rptr)->sfid;
01923 break;
01924
01925 case CIF_CC_OBJ:
01926 id = -24;
01927 break;
01928
01929 case CIF_CC_SUBTYPE:
01930 id = -24;
01931 break;
01932
01933 case CIF_CC_ENUM:
01934 id = -24;
01935 break;
01936
01937 case CIF_CC_EXPR:
01938 id = CIFCCEXPR(rptr)->fid;
01939 break;
01940
01941 case CIF_SRC_POS:
01942 id = CIFSPOS(rptr)->fid;
01943 break;
01944
01945 #endif
01946
01947 case CIF_C_TAG:
01948 id = -20;
01949 break;
01950 case CIF_C_CONST:
01951 id = -21;
01952 break;
01953 case CIF_C_MESSAGE:
01954 id = CIFCMSG(rptr)->fid;
01955 break;
01956 case CIF_C_ENTRY:
01957 id = -22;
01958 break;
01959 case CIF_C_OBJECT:
01960 id = -23;
01961 break;
01962 default:
01963 id = 0;
01964 }
01965 return (id);
01966 }
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976 static int get_scope (
01977 struct Cif_generic *rptr)
01978 {
01979 int id;
01980
01981 switch (rptr->rectype) {
01982
01983 #if CIF_VERSION != 1
01984
01985 case CIF_F90_COMBLK:
01986 id = CIFF90CB(rptr)->scopeid;
01987 break;
01988 case CIF_F90_LOOP:
01989 id = CIFF90LOOP(rptr)->scopeid;
01990 break;
01991 case CIF_F90_ENTRY:
01992 id = CIFF90ENTRY(rptr)->scopeid;
01993 break;
01994 case CIF_F90_LABEL:
01995 id = CIFF90LABEL(rptr)->scopeid;
01996 break;
01997 case CIF_F90_NAMELIST:
01998 id = CIFF90NL(rptr)->scopeid;
01999 break;
02000 case CIF_F90_OBJECT:
02001 id = CIFF90OBJ(rptr)->scopeid;
02002 break;
02003 case CIF_F90_DERIVED_TYPE:
02004 id = CIFF90DTYPE(rptr)->scopeid;
02005 break;
02006 case CIF_F90_BEGIN_SCOPE:
02007 id = CIFF90BS(rptr)->scopeid;
02008 global_scope_found = 1;
02009 break;
02010 case CIF_F90_END_SCOPE:
02011 id = CIFF90ES(rptr)->scopeid;
02012 break;
02013 case CIF_F90_SCOPE_INFO:
02014 id = CIFF90SI(rptr)->scopeid;
02015 break;
02016 case CIF_F90_INT_BLOCK:
02017 id = CIFF90IB(rptr)->scopeid;
02018 break;
02019 case CIF_F90_RENAME:
02020 id = CIFF90RN(rptr)->scopeid;
02021 break;
02022 case CIF_F90_CONST:
02023 id = CIFF90CON(rptr)->scopeid;
02024 break;
02025 case CIF_F90_USE_MODULE:
02026 id = global_last_scope;
02027
02028
02029
02030
02031 break;
02032
02033 #endif
02034
02035 case CIF_C_ENTRY:
02036 id = CIFCENTRY(rptr)->scope;
02037 break;
02038 default:
02039 id = -1;
02040 }
02041 return (id);
02042 }
02043
02044
02045
02046
02047
02048
02049 static int get_type (
02050 struct Cif_generic *rptr)
02051 {
02052 int id;
02053
02054 switch (rptr->rectype) {
02055
02056 #if CIF_VERSION != 1
02057 case CIF_F90_ENTRY:
02058 id = -10;
02059 break;
02060 #endif
02061
02062 case CIF_ENTRY:
02063 id = -10;
02064 break;
02065
02066 default:
02067 id = rptr->rectype;
02068 break;
02069 }
02070
02071 return(id);
02072 }
02073
02074
02075
02076
02077
02078
02079 static int get_adjusted_scope (
02080 struct Cif_generic *rptr)
02081 {
02082 int id;
02083
02084 switch (rptr->rectype) {
02085
02086 #if CIF_VERSION != 1
02087
02088 case CIF_F90_COMBLK:
02089 id = CIFF90CB(rptr)->scopeid;
02090 break;
02091 case CIF_F90_LOOP:
02092 id = CIFF90LOOP(rptr)->scopeid;
02093 break;
02094 case CIF_F90_ENTRY:
02095 id = CIFF90ENTRY(rptr)->scopeid;
02096 break;
02097 case CIF_F90_LABEL:
02098 id = CIFF90LABEL(rptr)->scopeid;
02099 break;
02100 case CIF_F90_NAMELIST:
02101 id = CIFF90NL(rptr)->scopeid;
02102 break;
02103 case CIF_F90_OBJECT:
02104 id = CIFF90OBJ(rptr)->scopeid;
02105 break;
02106 case CIF_F90_DERIVED_TYPE:
02107 id = CIFF90DTYPE(rptr)->scopeid;
02108 break;
02109 case CIF_F90_BEGIN_SCOPE:
02110 id = CIFF90BS(rptr)->scopeid;
02111 global_scope_found = 1;
02112 break;
02113 case CIF_F90_END_SCOPE:
02114 id = CIFF90ES(rptr)->scopeid;
02115 break;
02116 case CIF_F90_SCOPE_INFO:
02117 id = CIFF90SI(rptr)->scopeid;
02118 break;
02119 case CIF_F90_INT_BLOCK:
02120 id = CIFF90IB(rptr)->scopeid;
02121 break;
02122 case CIF_F90_RENAME:
02123 id = CIFF90RN(rptr)->scopeid;
02124 break;
02125 case CIF_F90_CONST:
02126 id = CIFF90CON(rptr)->scopeid;
02127 break;
02128 case CIF_F90_USE_MODULE:
02129 id = global_last_scope;
02130
02131
02132
02133
02134 break;
02135
02136 #endif
02137
02138 case CIF_C_ENTRY:
02139 id = CIFCENTRY(rptr)->scope;
02140 break;
02141 default:
02142 id = 99999;
02143 }
02144 return (id);
02145 }
02146
02147
02148
02149
02150
02151
02152
02153 static int get_cpos (
02154 struct Cif_generic *rptr)
02155 {
02156 int id;
02157
02158 switch (rptr->rectype) {
02159 case CIF_UNIT:
02160 id = CIFUNIT(rptr)->cpos - 2;
02161
02162
02163 break;
02164 case CIF_ENDUNIT:
02165 id = CIFENDU(rptr)->cpos + 2;
02166
02167
02168 break;
02169 case CIF_CALLSITE:
02170 id = CIFCS(rptr)->cpos;
02171 break;
02172 case CIF_MESSAGE:
02173 id = CIFMSG(rptr)->cpos;;
02174 break;
02175 case CIF_ND_MSG:
02176 id = CIFNMSG(rptr)->cpos;;
02177 break;
02178 case CIF_USAGE:
02179 id = CIFUSAGE(rptr)->use->cpos;
02180 break;
02181 case CIF_STMT_TYPE:
02182 id = CIFSTMT(rptr)->cpos;
02183 break;
02184 case CIF_INCLUDE:
02185 id = CIFINC(rptr)->cpos;
02186 break;
02187
02188 #if CIF_VERSION != 1
02189 case CIF_CDIR:
02190 id = CIFCDIR(rptr)->cpos;
02191 break;
02192 case CIF_CDIR_DOSHARED:
02193 id = CIFCDIRDO(rptr)->cpos;
02194 break;
02195 case CIF_CONTINUATION:
02196 id = CIFCONT(rptr)->cpos;
02197 break;
02198
02199
02200 case CIF_F90_CALLSITE:
02201 id = CIFF90CS(rptr)->cpos;
02202 break;
02203 case CIF_F90_BEGIN_SCOPE:
02204 id = CIFF90BS(rptr)->cpos - 1;
02205
02206
02207 global_scope_found = 1;
02208 break;
02209 case CIF_F90_END_SCOPE:
02210 id = CIFF90ES(rptr)->cpos + 1;
02211 break;
02212
02213 case CIF_C_LINT_DIRECTIVE:
02214 id = CIFCLDIR(rptr)->strpos;
02215 break;
02216 case CIF_C_MACRO_DEF:
02217 id = CIFCMDEF(rptr)->strpos;
02218 break;
02219 case CIF_C_MACRO_UNDEF:
02220 id = CIFCMUDEF(rptr)->cpos;
02221 break;
02222 case CIF_C_MACRO_USAGE:
02223 id = CIFCMUSE(rptr)->strpos;
02224 break;
02225
02226 #endif
02227
02228
02229 #if CIF_VERSION == 3
02230
02231 case CIF_SRC_POS:
02232 id = CIFSPOS(rptr)->scol;
02233 break;
02234
02235 #endif
02236
02237 default:
02238 id = 0;
02239 }
02240 return (id);
02241
02242 }
02243