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
00042
00043 static char USMID[] = "\n@(#)5.0_pl/sources/messages.c 5.9 10/14/99 14:08:59\n";
00044
00045 # include <stdarg.h>
00046
00047 # include "defines.h"
00048
00049
00050 # define __NLS_INTERNALS 1
00051
00052 # if defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN)
00053
00054 # include <nl_types.h>
00055 # include <nlcatmsg.h>
00056
00057 # else
00058 # include "nl_types.h"
00059 # endif
00060
00061
00062
00063 # include "host.m"
00064 # include "host.h"
00065 # include "target.m"
00066 # include "target.h"
00067
00068 # include "globals.m"
00069 # include "tokens.m"
00070 # include "sytb.m"
00071 # include "debug.m"
00072 # include "messages.m"
00073
00074 # include "globals.h"
00075 # include "tokens.h"
00076 # include "sytb.h"
00077 # include "pathscale_defs.h"
00078 # include "messages.h"
00079 #ifdef KEY
00080 # include "src_input.m"
00081 #endif
00082 #ifdef KEY
00083 #include "../liberrno.h"
00084
00085
00086 #pragma weak verbose_message
00087 #endif
00088
00089 # define CIF_VERSION 3
00090
00091
00092 # include "cif.h"
00093
00094
00095
00096
00097
00098
00099 static int compare_message_recs(const void *, const void *);
00100 static void flush_msg_file(void);
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 #ifdef KEY
00123 char *init_msg_processing (char *argv[])
00124 #else
00125 void init_msg_processing (char *argv[])
00126 #endif
00127
00128 {
00129 static char *allocstr;
00130 #ifdef KEY
00131 char *result = getenv("NLSPATH");
00132 #endif
00133
00134
00135 TRACE (Func_Entry, "init_msg_processing", NULL);
00136
00137
00138
00139 #if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(TARGET_OS_DARWIN))
00140 #ifdef KEY
00141 if (result == NULL)
00142 #else
00143 if (getenv("NLSPATH") == NULL)
00144 #endif
00145 {
00146
00147 const char * const toolroot = getenv("TOOLROOT");
00148 const char * const env_name = "NLSPATH=";
00149 const char * const env_val = "/usr/lib/locale/C/LC_MESSAGES/%N.cat";
00150 int len = strlen(env_name) + strlen(env_val) + 1;
00151 char * new_env;
00152 if (toolroot != NULL) len += strlen(toolroot);
00153 new_env = malloc(len);
00154 if (toolroot == NULL)
00155 sprintf(new_env, "%s%s", env_name, env_val);
00156 else
00157 sprintf(new_env, "%s%s%s", env_name, toolroot, env_val);
00158 putenv(new_env);
00159 #ifdef KEY
00160 result = new_env;
00161 #else
00162 free(new_env);
00163 #endif
00164 }
00165 #endif
00166
00167 msg_sys = catopen (group_code, 0);
00168
00169 if (msg_sys == (nl_catd) -1) {
00170
00171 # if defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN)
00172 #ifdef PSC_TO_OPEN64
00173 fprintf (stderr, OPEN64_NAME_PREFIX "f95 INTERNAL: Unable to open message system.\n");
00174 #endif
00175 # else
00176 fprintf (stderr, "cf90 INTERNAL: Unable to open message system.\n");
00177 # endif
00178 exit_compiler(RC_USER_ERROR);
00179
00180 }
00181
00182 save_glb_line_num = 0;
00183 save_column_num = 0;
00184
00185
00186
00187
00188
00189
00190
00191 command_name = getenv ("ORIG_CMD_NAME");
00192
00193 if (command_name == NULL) {
00194 command_name = argv[0];
00195 command_name = strrchr (argv[0], SLASH);
00196 command_name = (command_name == NULL) ? argv[0] : command_name+1;
00197 }
00198 else {
00199
00200
00201
00202
00203 MEM_ALLOC (allocstr, char, strlen(command_name)+1);
00204
00205 if (allocstr != NULL) {
00206 strcpy (allocstr, command_name);
00207
00208
00209 command_name = allocstr;
00210 }
00211 }
00212
00213 TRACE (Func_Exit, "init_msg_processing", NULL);
00214
00215 #ifdef KEY
00216 return result;
00217 #else
00218 return;
00219 #endif
00220
00221 }
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 void PRINTMSG (int glb_line_num,
00264 int msg_num,
00265 msg_severities_type msg_severity,
00266 int column_num,
00267 ... )
00268
00269 {
00270 long arg1;
00271 long arg2;
00272 long arg3;
00273 long arg4;
00274 va_list arg_ptr;
00275 boolean error;
00276 boolean exit_now;
00277 boolean warning;
00278
00279 # if defined(_DEBUG)
00280 boolean issue_line_out_of_range_msg = FALSE;
00281 # endif
00282
00283
00284
00285
00286
00287 # define END_UNIT 18
00288
00289
00290 TRACE (Func_Entry, "PRINTMSG", NULL);
00291
00292 # ifdef _DEBUG
00293
00294
00295 if (msg_num > MAX_MSG || msg_num < 0) {
00296 PRINTMSG (glb_line_num, 1, Internal, 0, msg_num);
00297 }
00298
00299 # endif
00300
00301 exit_now = TRUE;
00302
00303 error = GET_MESSAGE_TBL(message_error_tbl, msg_num);
00304 warning = GET_MESSAGE_TBL(message_warning_tbl, msg_num);
00305
00306 if ((error && (msg_severity != Error)) ||
00307 (warning && msg_severity != Warning)) {
00308
00309 switch (msg_severity) {
00310 case Ansi:
00311 case Comment:
00312 case Note:
00313 case Caution:
00314 case Warning:
00315 msg_severity = (error) ? Error : Warning;
00316 break;
00317
00318 case Error:
00319
00320 if (warning) {
00321 PRINTMSG (glb_line_num, 1653, Warning, 0, msg_num, "warning");
00322 }
00323 error = FALSE;
00324 break;
00325
00326 case Vector:
00327 case Scalar:
00328 case Table:
00329 case Inline:
00330 case Info:
00331 case Tasking:
00332 case Optimization:
00333 case Stream:
00334
00335 case Internal:
00336 case Limit:
00337 case Log_Error:
00338 case Log_Warning:
00339 case Log_Summary:
00340 PRINTMSG (glb_line_num, 1653, Warning, 0, msg_num,
00341 (error) ? "error" : "warning");
00342 break;
00343 }
00344 }
00345
00346 if (msg_severity != Log_Warning &&
00347 msg_severity != Log_Error &&
00348 msg_severity != Log_Summary) {
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 if (glb_line_num == 0) {
00362
00363 if (msg_num <= MAX_FE_MSG ||
00364 (msg_severity != Limit && msg_severity != Internal)) {
00365
00366 glb_line_num = (stmt_start_line > 0) ? stmt_start_line : 1;
00367
00368
00369
00370
00371
00372 exit_now = FALSE;
00373 }
00374 # if defined(_DEBUG)
00375
00376 if (dump_flags.msg_checking) {
00377
00378
00379
00380
00381 exit_now = FALSE;
00382 }
00383 # endif
00384 }
00385 else if (glb_line_num < pgm_unit_start_line && msg_num > MAX_FE_MSG) {
00386
00387
00388
00389
00390
00391
00392
00393 glb_line_num = pgm_unit_start_line;
00394
00395 # if defined(_DEBUG)
00396
00397
00398
00399
00400 issue_line_out_of_range_msg = (dump_flags.msg_checking) ? TRUE : FALSE;
00401 # endif
00402 }
00403 }
00404
00405 switch (msg_severity) {
00406
00407 case Ansi:
00408
00409 if (on_off_flags.issue_ansi_messages) {
00410
00411 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00412 break;
00413 }
00414
00415 if (cif_tmp_so_no_msg) {
00416 break;
00417 }
00418
00419 num_ansi++;
00420 va_start (arg_ptr, column_num);
00421 arg1 = va_arg (arg_ptr, long);
00422 arg2 = va_arg (arg_ptr, long);
00423 arg3 = va_arg (arg_ptr, long);
00424 arg4 = va_arg (arg_ptr, long);
00425 va_end (arg_ptr);
00426 output_msg (glb_line_num, msg_num, msg_severity,
00427 column_num, arg1, arg2, arg3, arg4);
00428
00429 # ifdef _DEBUG
00430 if (dump_flags.abort_on_ansi) {
00431
00432 output_msg (glb_line_num, 597, Limit, 0, 0, 0, 0, 0);
00433
00434 exit_compiler(RC_USER_ERROR);
00435 }
00436 # endif
00437
00438 }
00439
00440 break;
00441
00442
00443 case Comment:
00444
00445 if (cmd_line_flags.msg_lvl_suppressed <= Comment_Lvl) {
00446
00447 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00448 break;
00449 }
00450
00451 if (cif_tmp_so_no_msg) {
00452 break;
00453 }
00454
00455 num_comments++;
00456 va_start (arg_ptr, column_num);
00457 arg1 = va_arg (arg_ptr, long);
00458 arg2 = va_arg (arg_ptr, long);
00459 arg3 = va_arg (arg_ptr, long);
00460 arg4 = va_arg (arg_ptr, long);
00461 va_end (arg_ptr);
00462 output_msg (glb_line_num, msg_num, msg_severity,
00463 column_num, arg1, arg2, arg3, arg4);
00464 }
00465
00466 break;
00467
00468
00469 case Note:
00470
00471 if (cmd_line_flags.msg_lvl_suppressed <= Note_Lvl) {
00472
00473 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00474 break;
00475 }
00476
00477 if (cif_tmp_so_no_msg) {
00478 break;
00479 }
00480
00481 num_notes++;
00482 va_start (arg_ptr, column_num);
00483 arg1 = va_arg (arg_ptr, long);
00484 arg2 = va_arg (arg_ptr, long);
00485 arg3 = va_arg (arg_ptr, long);
00486 arg4 = va_arg (arg_ptr, long);
00487 va_end (arg_ptr);
00488 output_msg (glb_line_num, msg_num, msg_severity,
00489 column_num, arg1, arg2, arg3, arg4);
00490 }
00491
00492 break;
00493
00494
00495 case Caution:
00496
00497 if (cmd_line_flags.msg_lvl_suppressed <= Caution_Lvl) {
00498
00499 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00500 break;
00501 }
00502
00503 if (cif_tmp_so_no_msg) {
00504 break;
00505 }
00506
00507 num_cautions++;
00508 va_start (arg_ptr, column_num);
00509 arg1 = va_arg (arg_ptr, long);
00510 arg2 = va_arg (arg_ptr, long);
00511 arg3 = va_arg (arg_ptr, long);
00512 arg4 = va_arg (arg_ptr, long);
00513 va_end (arg_ptr);
00514 output_msg (glb_line_num, msg_num, msg_severity,
00515 column_num, arg1, arg2, arg3, arg4);
00516 }
00517
00518 break;
00519
00520
00521 case Warning:
00522
00523 if (cmd_line_flags.msg_lvl_suppressed <= Warning_Lvl) {
00524
00525 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00526 break;
00527 }
00528
00529 if (cif_tmp_so_no_msg) {
00530 break;
00531 }
00532
00533 num_warnings++;
00534 va_start (arg_ptr, column_num);
00535 arg1 = va_arg (arg_ptr, long);
00536 arg2 = va_arg (arg_ptr, long);
00537 arg3 = va_arg (arg_ptr, long);
00538 arg4 = va_arg (arg_ptr, long);
00539 va_end (arg_ptr);
00540 output_msg (glb_line_num, msg_num, msg_severity,
00541 column_num, arg1, arg2, arg3, arg4);
00542 }
00543
00544 break;
00545
00546
00547 case Error:
00548
00549 if (cif_tmp_so_no_msg) {
00550 break;
00551 }
00552
00553 num_errors++;
00554 num_prog_unit_errors++;
00555
00556 va_start (arg_ptr, column_num);
00557 arg1 = va_arg (arg_ptr, long);
00558 arg2 = va_arg (arg_ptr, long);
00559 arg3 = va_arg (arg_ptr, long);
00560 arg4 = va_arg (arg_ptr, long);
00561 va_end (arg_ptr);
00562 output_msg (glb_line_num, msg_num, msg_severity,
00563 column_num, arg1, arg2, arg3, arg4);
00564
00565 if (!error &&
00566 curr_stmt_sh_idx > NULL_IDX &&
00567 curr_stmt_sh_idx <= sh_tbl_idx &&
00568 glb_line_num >= SH_GLB_LINE(curr_stmt_sh_idx)) {
00569
00570
00571
00572
00573
00574
00575
00576
00577 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE;
00578 }
00579
00580 if (on_off_flags.abort_if_any_errors) {
00581
00582 if (c_i_f != NULL) {
00583 flush_msg_file();
00584 }
00585
00586
00587
00588
00589 output_msg (glb_line_num, 1226, Limit, 0, 0, 0, 0, 0);
00590
00591 PRINT_GL_TBL;
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602 c_i_f = fopen(cif_name, "a+");
00603
00604 cif_summary_rec("Ignore this",
00605 "Ignore this",
00606 "Ignore this",
00607 0,
00608 0,
00609 -1);
00610
00611 c_i_f = NULL;
00612
00613 exit_compiler(RC_USER_ERROR);
00614 }
00615
00616 if (on_off_flags.abort_on_100_errors &&
00617 num_errors >= MAX_ERR_LIMIT) {
00618
00619 if (c_i_f != NULL) {
00620 flush_msg_file();
00621 }
00622
00623 output_msg(glb_line_num, 214, Limit, 0, MAX_ERR_LIMIT, 0, 0, 0);
00624
00625 PRINT_GL_TBL;
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636 c_i_f = fopen(cif_name, "a+");
00637
00638 cif_summary_rec("Ignore this",
00639 "Ignore this",
00640 "Ignore this",
00641 0,
00642 0,
00643 -1);
00644
00645 c_i_f = NULL;
00646
00647 exit_compiler(RC_USER_ERROR);
00648 }
00649
00650 break;
00651
00652
00653 case Log_Error:
00654
00655
00656
00657
00658 num_errors++;
00659 num_prog_unit_errors++;
00660
00661 va_start (arg_ptr, column_num);
00662 arg1 = va_arg (arg_ptr, long);
00663 arg2 = va_arg (arg_ptr, long);
00664 arg3 = va_arg (arg_ptr, long);
00665 arg4 = va_arg (arg_ptr, long);
00666 va_end (arg_ptr);
00667 output_msg (glb_line_num, msg_num, msg_severity,
00668 column_num, arg1, arg2, arg3, arg4);
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679 if (msg_num == 49) {
00680 fclose(cif_actual_file);
00681 remove(cif_name);
00682 c_i_f = NULL;
00683 cif_actual_file = NULL;
00684 fclose(cif_tmp_file);
00685 remove(cif_tmp_file_name);
00686 cif_tmp_file = NULL;
00687 }
00688
00689 break;
00690
00691
00692 case Internal:
00693 case Limit:
00694
00695 if (c_i_f != NULL) {
00696 flush_msg_file();
00697 }
00698
00699 va_start (arg_ptr, column_num);
00700 arg1 = va_arg (arg_ptr, long);
00701 arg2 = va_arg (arg_ptr, long);
00702 arg3 = va_arg (arg_ptr, long);
00703 arg4 = va_arg (arg_ptr, long);
00704 va_end (arg_ptr);
00705 output_msg (glb_line_num, msg_num, msg_severity,
00706 column_num, arg1, arg2, arg3, arg4);
00707
00708
00709 if (comp_phase == Cmdline_Parsing) {
00710
00711
00712
00713
00714 exit_compiler(RC_INTERNAL_ERROR);
00715 break;
00716 }
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726 c_i_f = fopen(cif_name, "a+");
00727
00728 cif_summary_rec("Ignore this",
00729 "Ignore this",
00730 "Ignore this",
00731 0,
00732 0,
00733 -2);
00734
00735 c_i_f = NULL;
00736
00737
00738 # ifdef _DEBUG
00739
00740
00741
00742
00743 if (comp_phase < Pdg_Conversion) {
00744 PRINT_ALL_SYM_TBLS;
00745 PRINT_BLK_STK;
00746 PRINT_CMD_LINE_TBLS;
00747 PRINT_GL_TBL;
00748 PRINT_GN_TBL;
00749
00750 while (curr_scp_idx != NULL_IDX) {
00751 PRINT_DBG_SYTB;
00752 PRINT_DBG_STMT;
00753 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
00754 }
00755
00756 if (dump_flags.mem_report) {
00757 free_tables();
00758 }
00759 }
00760 # endif
00761
00762 # ifdef _DEBUG
00763 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
00764 if (msg_severity == Internal) {
00765 TRBK ();
00766 }
00767 # endif
00768 # endif
00769
00770
00771
00772
00773 if (exit_now) {
00774 exit_compiler(RC_INTERNAL_ERROR);
00775 }
00776
00777 break;
00778
00779
00780 case Log_Warning:
00781
00782 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00783 break;
00784 }
00785
00786 num_warnings++;
00787
00788 va_start (arg_ptr, column_num);
00789 arg1 = va_arg (arg_ptr, long);
00790 arg2 = va_arg (arg_ptr, long);
00791 arg3 = va_arg (arg_ptr, long);
00792 arg4 = va_arg (arg_ptr, long);
00793 va_end (arg_ptr);
00794 output_msg (glb_line_num, msg_num, msg_severity,
00795 column_num, arg1, arg2, arg3, arg4);
00796 break;
00797
00798
00799 case Log_Summary:
00800
00801 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00802 break;
00803 }
00804
00805 va_start (arg_ptr, column_num);
00806 arg1 = va_arg (arg_ptr, long);
00807 arg2 = va_arg (arg_ptr, long);
00808 arg3 = va_arg (arg_ptr, long);
00809 arg4 = va_arg (arg_ptr, long);
00810 va_end (arg_ptr);
00811 output_msg (glb_line_num, msg_num, msg_severity,
00812 column_num, arg1, arg2, arg3, arg4);
00813 break;
00814
00815
00816 case Vector:
00817 case Scalar:
00818 case Table:
00819 case Inline:
00820 case Info:
00821 case Tasking:
00822 case Optimization:
00823 case Stream:
00824
00825 if (GET_MESSAGE_TBL(message_suppress_tbl, msg_num)) {
00826 break;
00827 }
00828
00829 num_optz_msgs++;
00830
00831 if ((cif_flags & MESSAGE_RECS) || opt_flags.msgs) {
00832 va_start (arg_ptr, column_num);
00833 arg1 = va_arg (arg_ptr, long);
00834 arg2 = va_arg (arg_ptr, long);
00835 arg3 = va_arg (arg_ptr, long);
00836 arg4 = va_arg (arg_ptr, long);
00837 va_end (arg_ptr);
00838 output_msg (glb_line_num,
00839 msg_num,
00840 msg_severity,
00841 column_num,
00842 arg1,
00843 arg2,
00844 arg3,
00845 arg4);
00846 }
00847
00848 break;
00849
00850
00851 default:
00852 PRINTMSG (glb_line_num, 2, Internal, 0, msg_severity);
00853 break;
00854 }
00855
00856
00857
00858
00859
00860 if (! exit_now) {
00861 exit_now = TRUE;
00862 PRINTMSG (glb_line_num, 296, Internal, 0, msg_num, 0);
00863 }
00864
00865 # if defined(_DEBUG)
00866 if (issue_line_out_of_range_msg) {
00867 PRINTMSG (glb_line_num, 626, Internal, 0, "valid line number","PRINTMSG");
00868 }
00869 # endif
00870
00871 TRACE (Func_Exit, "PRINTMSG", NULL);
00872
00873 return;
00874
00875 }
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914 #define ERROR_ECHOING_SOURCE 995
00915
00916 void output_msg (int glb_line_num,
00917 int msg_num,
00918 msg_severities_type msg_severity,
00919 int column_num,
00920 long arg1,
00921 long arg2,
00922 long arg3,
00923 long arg4)
00924
00925 {
00926 int act_file_line;
00927 char *act_file_name;
00928 char expanded_text[EXPANDED_MSG_SIZE];
00929 char final_text[FINAL_MSG_SIZE];
00930 int glb_idx;
00931 static int last_msg_idx = NULL_IDX;
00932 int msg_idx;
00933 char orig_text[ORIG_MSG_SIZE];
00934 char position_buff[MAX_HDR_SIZE];
00935 boolean print_directly_to_stderr;
00936 #ifdef KEY
00937 char *scoping_unit_name = 0;
00938 #else
00939 char *scoping_unit_name;
00940 #endif
00941 char *text_ptr;
00942
00943
00944
00945
00946
00947 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
00948 last_msg_queue_type msg_desc;
00949 # endif
00950
00951
00952 TRACE (Func_Entry, "output_msg", NULL);
00953
00954 if (comp_phase == Lex_Parsing) {
00955
00956
00957
00958 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
00959 msg_desc.msg_num = msg_num;
00960 msg_desc.line_num = glb_line_num;
00961 msg_desc.col_num = column_num;
00962 # endif
00963
00964 for (msg_idx = 0; msg_idx < LAST_MSG_QUEUE_SIZE; msg_idx++) {
00965
00966 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
00967 if (*((long *) (&msg_desc)) ==
00968 *((long *) (&last_msg_queue[msg_idx]))){
00969 TRACE (Func_Exit, "output_msg", NULL);
00970 return;
00971 }
00972 # else
00973 if (last_msg_queue[msg_idx].msg_num == msg_num &&
00974 last_msg_queue[msg_idx].line_num == glb_line_num &&
00975 last_msg_queue[msg_idx].col_num == column_num) {
00976 TRACE (Func_Exit, "output_msg", NULL);
00977 return;
00978 }
00979 # endif
00980 }
00981
00982 last_msg_queue[last_msg_idx].msg_num = msg_num;
00983 last_msg_queue[last_msg_idx].line_num = glb_line_num;
00984 last_msg_queue[last_msg_idx].col_num = column_num;
00985
00986 if (++last_msg_idx == LAST_MSG_QUEUE_SIZE) {
00987 last_msg_idx = NULL_IDX;
00988 }
00989 }
00990
00991
00992
00993
00994
00995
00996
00997
00998 if (comp_phase == Pass1_Parsing) {
00999
01000 if (save_glb_line_num == glb_line_num &&
01001 save_column_num == column_num) {
01002 ++relative_order;
01003 }
01004 else {
01005 save_glb_line_num = glb_line_num;
01006 save_column_num = column_num;
01007 relative_order = 1;
01008 }
01009 }
01010 else {
01011 relative_order = 0;
01012 }
01013
01014
01015 switch (msg_severity) {
01016
01017 case Log_Warning:
01018 case Log_Error:
01019 print_directly_to_stderr = TRUE;
01020 sprintf (position_buff, "in command line");
01021 break;
01022
01023 case Log_Summary:
01024 print_directly_to_stderr = TRUE;
01025 break;
01026
01027 default:
01028
01029 if (comp_phase == Cmdline_Parsing) {
01030 print_directly_to_stderr = TRUE;
01031 sprintf (position_buff, "in command line");
01032 break;
01033 }
01034
01035 print_directly_to_stderr =
01036
01037 # ifdef _DEBUG
01038 dump_flags.std_err ||
01039 # endif
01040 (msg_severity == Internal || msg_severity == Limit);
01041
01042 if (print_directly_to_stderr) {
01043
01044
01045
01046 print_err_line(glb_line_num, column_num);
01047 }
01048
01049 #ifdef KEY
01050
01051
01052 if (ERROR_ECHOING_SOURCE == msg_num) {
01053 print_directly_to_stderr = TRUE;
01054 }
01055 #endif
01056
01057 GLOBAL_LINE_TO_FILE_LINE(glb_line_num, glb_idx, act_file_line);
01058 act_file_name = GL_FILE_NAME_PTR(glb_idx);
01059
01060 if (scp_tbl == NULL_IDX) {
01061 scoping_unit_name = program_unit_name;
01062
01063
01064
01065
01066 if (print_directly_to_stderr) {
01067 sprintf (position_buff, "%s, File = %s, Line = %d ",
01068 program_unit_name,
01069 act_file_name,
01070 act_file_line);
01071 }
01072 }
01073 else {
01074 scoping_unit_name = AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx));
01075
01076 if (print_directly_to_stderr) {
01077
01078 if (column_num == 0) {
01079 sprintf (position_buff, "%s, File = %s, Line = %d ",
01080 AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
01081 act_file_name,
01082 act_file_line);
01083 }
01084 else {
01085 sprintf (position_buff,
01086 "%s, File = %s, Line = %d, Column = %d ",
01087 AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
01088 act_file_name,
01089 act_file_line,
01090 column_num);
01091 }
01092 }
01093 }
01094
01095 }
01096
01097
01098 text_ptr = (char *) catgetmsg(msg_sys,
01099 NL_MSGSET,
01100 msg_num,
01101 orig_text,
01102 ORIG_MSG_SIZE);
01103
01104 if (!*text_ptr) {
01105
01106 if (msg_num == 3) {
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121 # if defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN)
01122 #ifdef PSC_TO_OPEN64
01123 fprintf(stderr, OPEN64_NAME_PREFIX "f95 INTERNAL: "
01124 #endif
01125 #else
01126 fprintf(stderr, "cft90 INTERNAL: "
01127 #endif
01128 "Message system failed trying to issue message %ld\n",
01129 arg1);
01130 fprintf(stderr, " Possible reasons include:\n");
01131 fprintf(stderr, " * The message catalog has been corrupted.\n");
01132 fprintf(stderr, " * The message catalog is out of date or "
01133 "does not match the compiler release.\n");
01134
01135 if (c_i_f != NULL && (cif_C_opts & CMD_PROVIDED_CIF)) {
01136 fclose(cif_actual_file);
01137 cif_actual_file = NULL;
01138 remove(cif_name);
01139 }
01140
01141 exit_compiler(RC_USER_ERROR);
01142 }
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158 # if !(defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN))
01159
01160 if (__catgetmsg_error_code() == NL_ERR_MALLOC) {
01161 fprintf(stderr, "cft90 INTERNAL: "
01162 "Message system failed trying to issue message %d\n",
01163 msg_num);
01164 fprintf(stderr, " User memory space has been exhausted - the "
01165 "message system has no space in which to work.\n");
01166
01167 if (c_i_f != NULL && (cif_C_opts & CMD_PROVIDED_CIF)) {
01168 fclose(cif_actual_file);
01169 cif_actual_file = NULL;
01170 remove(cif_name);
01171 }
01172
01173 exit_compiler(RC_USER_ERROR);
01174 }
01175 else {
01176 PRINTMSG (glb_line_num, 3, Internal, 0, msg_num);
01177 }
01178 # else
01179 PRINTMSG (glb_line_num, 3, Internal, 0, msg_num);
01180 # endif
01181 }
01182
01183 if (print_directly_to_stderr) {
01184
01185
01186
01187 #ifdef KEY
01188 snprintf (expanded_text, sizeof expanded_text, orig_text, arg1, arg2,
01189 arg3, arg4);
01190 #else
01191 sprintf (expanded_text, orig_text, arg1, arg2, arg3, arg4);
01192 #endif
01193 }
01194
01195
01196
01197
01198
01199 if (msg_severity != Log_Summary) {
01200
01201 if (print_directly_to_stderr) {
01202 text_ptr = expanded_text;
01203 catmsgfmt (command_name,
01204 message_prefix,
01205 msg_num,
01206 msg_severity_name[msg_severity],
01207 text_ptr,
01208 final_text,
01209 FINAL_MSG_SIZE,
01210 position_buff,
01211 (char *) NULL);
01212 fputs (final_text, stderr);
01213 #ifdef KEY
01214 if (verbose_message) {
01215 verbose_message(group_code, msg_num);
01216 }
01217 #endif
01218 }
01219 }
01220 else {
01221 fputs (expanded_text, stderr);
01222 fputc (NEWLINE, stderr);
01223 }
01224
01225 if (msg_severity != Log_Warning &&
01226 msg_severity != Log_Error &&
01227 msg_severity != Log_Summary &&
01228 msg_severity != Internal &&
01229 #ifdef KEY
01230
01231 msg_num != ERROR_ECHOING_SOURCE &&
01232 #endif
01233 msg_severity != Limit) {
01234 cif_message_rec(msg_num,
01235 glb_line_num,
01236 column_num,
01237 msg_severity,
01238 orig_text,
01239 arg1,
01240 arg2,
01241 arg3,
01242 arg4,
01243 scoping_unit_name,
01244 relative_order);
01245 }
01246
01247 TRACE (Func_Exit, "output_msg", NULL);
01248
01249 return;
01250
01251 }
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270 void exit_compiler (int code)
01271
01272 {
01273
01274 TRACE (Func_Entry, "exit_compiler", NULL);
01275
01276 if (cif_tmp_file != NULL && c_i_f == cif_tmp_file) {
01277 flush_msg_file();
01278 }
01279
01280 if (c_i_f != NULL) {
01281 print_buffered_messages();
01282 }
01283
01284 if (cif_actual_file) {
01285 fclose(cif_actual_file);
01286 }
01287
01288 if (cif_flags == 0) {
01289 remove(cif_name);
01290 }
01291
01292 catclose (msg_sys);
01293
01294 clean_up_module_files();
01295
01296 if (cif_flags != 0) {
01297 close_cif();
01298 }
01299
01300
01301 # ifdef _DEBUG
01302
01303 # if defined(_HOST_OS_SOLARIS) || (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN))
01304
01305
01306
01307 if (code == RC_INTERNAL_ERROR) {
01308 abort();
01309 }
01310
01311 # endif
01312
01313 # endif
01314
01315 exit (code);
01316
01317 TRACE (Func_Exit, "exit_compiler", NULL);
01318
01319 }
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339 char *global_to_local_file (int search_line)
01340 {
01341 int idx;
01342 int line;
01343 char *act_file_name;
01344
01345
01346 TRACE (Func_Entry, "global_to_local_file", NULL);
01347
01348 GLOBAL_LINE_TO_FILE_LINE(search_line, idx, line);
01349 act_file_name = GL_FILE_NAME_PTR(idx);
01350
01351 TRACE (Func_Exit, "global_to_local_file", NULL);
01352
01353 return(act_file_name);
01354
01355 }
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375 char *global_to_local_path (int search_line)
01376 {
01377 int idx;
01378 int line;
01379 char *act_path_name;
01380
01381
01382 TRACE (Func_Entry, "global_to_local_path", NULL);
01383
01384 GLOBAL_LINE_TO_FILE_LINE(search_line, idx, line);
01385 act_path_name = GL_PATH_NAME_PTR(idx);
01386
01387 TRACE (Func_Exit, "global_to_local_path", NULL);
01388
01389 return(act_path_name);
01390
01391 }
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416 int global_to_file_id (int search_line)
01417 {
01418 int idx;
01419 int line;
01420
01421
01422 TRACE (Func_Entry, "global_to_file_id", NULL);
01423
01424 GLOBAL_LINE_TO_FILE_LINE(search_line, idx, line);
01425
01426 TRACE (Func_Exit, "global_to_file_id", NULL);
01427
01428 return(GL_CIF_FILE_ID(idx));
01429
01430 }
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454 int global_to_file_line_number (int search_line)
01455 {
01456 int idx;
01457 int line;
01458
01459
01460 TRACE (Func_Entry, "global_to_file_line_number", NULL);
01461
01462 GLOBAL_LINE_TO_FILE_LINE(search_line, idx, line);
01463
01464 TRACE (Func_Exit, "global_to_file_line_number", NULL);
01465
01466 return(line);
01467
01468 }
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493 int global_to_local_line_number (int search_line)
01494 {
01495 int idx;
01496 int line;
01497
01498
01499 TRACE (Func_Entry, "global_to_local_line_number", NULL);
01500
01501 GLOBAL_LINE_TO_FILE_LINE(search_line, idx, line);
01502
01503 TRACE (Func_Exit, "global_to_local_line_number", NULL);
01504
01505 return(line);
01506
01507 }
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528 static void flush_msg_file(void)
01529 {
01530 int scp_idx;
01531
01532
01533 TRACE (Func_Entry, "flush_msg_file", NULL);
01534
01535 if (c_i_f == cif_tmp_file) {
01536 cif_fake_a_unit();
01537 }
01538
01539 if (last_msg_file_rec != END_UNIT) {
01540
01541 if (curr_scp_idx == 0) {
01542 cif_end_unit_rec(program_unit_name);
01543 }
01544 else {
01545 scp_idx = curr_scp_idx;
01546
01547 while (SCP_PARENT_IDX(scp_idx) != 0) {
01548 scp_idx = SCP_PARENT_IDX(scp_idx);
01549 }
01550
01551 cif_end_unit_rec(AT_OBJ_NAME_PTR(SCP_ATTR_IDX(scp_idx)));
01552 }
01553 }
01554
01555 print_buffered_messages();
01556
01557 TRACE (Func_Exit, "flush_msg_file", NULL);
01558
01559 return;
01560
01561 }
01562
01563 #ifdef KEY
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574 static void
01575 cannot_open_include_file(int line_num)
01576 {
01577 PRINTMSG(line_num, ERROR_ECHOING_SOURCE, Warning, 0,
01578 "cannot open INCLUDE file");
01579 }
01580
01581 static void
01582 files_too_deeply_nested(int line_num)
01583 {
01584 PRINTMSG(line_num, ERROR_ECHOING_SOURCE, Warning, 0,
01585 "source files too deeply nested");
01586 }
01587
01588 static void
01589 cannot_read_source_file(int line_num)
01590 {
01591 PRINTMSG(line_num, ERROR_ECHOING_SOURCE, Warning, 0,
01592 "cannot read source file");
01593 }
01594 #endif
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613 void print_buffered_messages(void)
01614 {
01615
01616
01617 # define FILE_STK_MAX 500
01618 #ifdef KEY
01619 #else
01620 # define MAX_SRC_LINE_SIZE 256
01621 #endif
01622
01623 char carat[MAX_SRC_LINE_SIZE];
01624 char expanded_text[EXPANDED_MSG_SIZE];
01625 int fd;
01626 int file_line;
01627 char final_text[FINAL_MSG_SIZE];
01628 int global_idx;
01629 int i;
01630 int line_num;
01631 nl_catd message_catalog;
01632 char message_hdr[MAX_HDR_SIZE];
01633 int msg_idx;
01634 char *msg_insert;
01635 int my_file_id;
01636 int num_msgs;
01637 int num_recs;
01638 char orig_text[ORIG_MSG_SIZE];
01639 int rec_type;
01640 int search_idx;
01641 char source_line[MAX_SRC_LINE_SIZE];
01642 int stk_idx;
01643 int unit_idx;
01644
01645 struct file_stk_frame {int file_id;
01646 int file_line;
01647 FILE *file_ptr;
01648 };
01649
01650 typedef struct file_stk_frame file_stk_type;
01651
01652 file_stk_type file_stk[FILE_STK_MAX];
01653
01654
01655 struct Cif_filedir *filedir;
01656 struct Cif_unitdir *unitdir;
01657
01658 struct Cif_cifhdr *header_rec;
01659 struct Cif_file *file_rec;
01660 struct Cif_message *message_rec;
01661
01662
01663 # ifdef _DEBUG
01664
01665 int dbg_global_line;
01666 struct Cif_message dbg_message_rec;
01667
01668 # endif
01669
01670
01671 TRACE (Func_Entry, "print_buffered_messages", NULL);
01672
01673 if (c_i_f == cif_actual_file) {
01674
01675 cif_actual_file = NULL;
01676 }
01677
01678 fclose(c_i_f);
01679
01680 stk_idx = 0;
01681
01682
01683 num_msgs = num_ansi + num_cautions + num_comments + num_errors +
01684 num_notes + num_warnings;
01685
01686 if (opt_flags.msgs) {
01687 num_msgs += num_optz_msgs;
01688 }
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700 if (global_line_tbl_idx == 0) {
01701 goto EXIT;
01702 }
01703
01704
01705 # ifdef _DEBUG
01706
01707 if (dump_flags.std_err) {
01708 TRACE (Func_Exit, "print_buffered_messages", NULL);
01709 return;
01710 }
01711
01712 if (num_msgs == 0) {
01713
01714 if (dump_flags.stmt_dmp) {
01715 dbg_global_line = 1;
01716 message_rec = &dbg_message_rec;
01717 message_rec->uline = GL_GLOBAL_LINE(global_line_tbl_idx) + 1;
01718 goto INIT_FILE_STK;
01719 }
01720 else {
01721 goto EXIT;
01722 }
01723 }
01724
01725 # else
01726
01727 if (num_msgs == 0) {
01728 goto EXIT;
01729 }
01730
01731 # endif
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746 #ifdef _DEBUG
01747
01748 fd = Cif_Cifconv(cif_name,
01749 "r",
01750 NULL,
01751 CIF_VERSION,
01752 0x100);
01753
01754 #else
01755
01756 fd = Cif_Cifconv(cif_name,
01757 "r",
01758 NULL,
01759 CIF_VERSION,
01760 FALSE);
01761
01762 #endif
01763
01764
01765 if (fd < 0) {
01766 if (c_i_f == cif_actual_file) {
01767
01768 cif_actual_file = NULL;
01769 }
01770 fclose(c_i_f);
01771 c_i_f = NULL;
01772 remove(cif_name);
01773 fclose(cif_tmp_file);
01774 remove(cif_tmp_file_name);
01775 PRINTMSG(1, 1060, Internal, 0, Cif_Errstring(fd));
01776 }
01777
01778
01779
01780
01781 Cif_Memmode(fd, CIF_MEM_MANAGED);
01782
01783 rec_type = Cif_Getrecord(fd, (struct Cif_generic **) &header_rec);
01784
01785 if (rec_type != CIF_CIFHDR) {
01786 line_num = 1;
01787 msg_insert = "first rec is not hdr rec.";
01788 goto EMERGENCY_EXIT;
01789 }
01790
01791 #if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
01792 if (getenv("NLSPATH") == NULL) {
01793
01794 const char * const toolroot = getenv("TOOLROOT");
01795 const char * const env_name = "NLSPATH=";
01796 const char * const env_val = "/usr/lib/locale/C/LC_MESSAGES/%N.cat";
01797 int len = strlen(env_name) + strlen(env_val) + 1;
01798 char * new_env;
01799 if (toolroot != NULL) len += strlen(toolroot);
01800 new_env = malloc(len);
01801 if (toolroot == NULL)
01802 sprintf(new_env, "%s%s", env_name, env_val);
01803 else
01804 sprintf(new_env, "%s%s%s", env_name, toolroot, env_val);
01805 putenv(new_env);
01806 free(new_env);
01807 }
01808 #endif
01809
01810 message_catalog = catopen(header_rec->group, 0);
01811
01812 Cif_Getfiledir(fd, &filedir);
01813
01814
01815
01816
01817 Cif_Recgroup(fd,
01818 NULL,
01819 CIF_FILE,
01820 (struct Cif_generic **) &file_rec);
01821
01822
01823
01824
01825
01826 INIT_FILE_STK:
01827
01828 global_idx = 1;
01829
01830 file_stk[0].file_id = GL_CIF_FILE_ID(1);
01831 file_stk[0].file_line = 0;
01832
01833 if ((file_stk[0].file_ptr = fopen(GL_FILE_NAME_PTR(1), "r")) == NULL) {
01834 line_num = 1;
01835 #ifdef KEY
01836 cannot_read_source_file(line_num);
01837 #else
01838 msg_insert = "can not open source file.";
01839 goto EMERGENCY_EXIT;
01840 #endif
01841 }
01842
01843
01844 # ifdef _DEBUG
01845
01846 if (dump_flags.stmt_dmp && num_msgs == 0) {
01847 goto NO_MSGS_STMT_DUMP;
01848 }
01849
01850 # endif
01851
01852
01853
01854
01855
01856 for (unit_idx = 0; unit_idx < filedir->nunits; ++unit_idx) {
01857
01858 Cif_Getunitdir(fd, &filedir->ut[unit_idx], &unitdir);
01859
01860 num_recs = Cif_Recgroup(fd,
01861 unitdir,
01862 CIF_MESSAGE,
01863 (struct Cif_generic **) &message_rec);
01864
01865
01866
01867
01868
01869 if (num_recs > 1) {
01870 (void) qsort ( (char *) message_rec,
01871 num_recs,
01872 sizeof(struct Cif_message),
01873 &compare_message_recs);
01874 }
01875
01876
01877
01878
01879
01880 for (msg_idx = 0; msg_idx < num_recs; ++msg_idx) {
01881
01882 if ((message_rec->severity == Vector ||
01883 message_rec->severity == Scalar ||
01884 message_rec->severity == Table ||
01885 message_rec->severity == Inline ||
01886 message_rec->severity == Info ||
01887 message_rec->severity == Tasking ||
01888 message_rec->severity == Stream ||
01889 message_rec->severity == Optimization) &&
01890 ! opt_flags.msgs) {
01891 ++message_rec;
01892 continue;
01893 }
01894
01895 # ifdef _DEBUG
01896
01897 if (dump_flags.stmt_dmp) {
01898 goto CHECK_GL_IDX;
01899 }
01900
01901 # endif
01902
01903
01904 GLOBAL_LINE_TO_FILE_LINE(message_rec->uline,
01905 global_idx,
01906 file_line);
01907 my_file_id = GL_CIF_FILE_ID(global_idx);
01908
01909 if (my_file_id != file_stk[stk_idx].file_id) {
01910
01911 for (search_idx = stk_idx - 1; search_idx >= 0; --search_idx) {
01912
01913 if (my_file_id == file_stk[search_idx].file_id) {
01914
01915 #ifdef KEY
01916 for (; stk_idx != search_idx; stk_idx -= 1) {
01917 if (NULL != file_stk[stk_idx].file_ptr) {
01918 fclose(file_stk[stk_idx].file_ptr);
01919 }
01920 }
01921 #else
01922 while (stk_idx != search_idx) {
01923 fclose(file_stk[stk_idx--].file_ptr);
01924 }
01925 #endif
01926
01927 goto HAVE_FILE;
01928 }
01929 }
01930
01931 ++stk_idx;
01932
01933 if (stk_idx < FILE_STK_MAX) {
01934 file_stk[stk_idx].file_id = my_file_id;
01935
01936 for (i = 2; i < filedir->nfiles; ++i) {
01937
01938 if (file_rec[i].fid == my_file_id) {
01939 break;
01940 }
01941 }
01942
01943 if ((file_stk[stk_idx].file_ptr =
01944 fopen(file_rec[i].name, "r")) != NULL) {
01945 file_stk[stk_idx].file_line = 0;
01946 }
01947 else {
01948 line_num = message_rec->uline;
01949 #ifdef KEY
01950 cannot_open_include_file(line_num);
01951 goto JUST_PRINT_MESSAGE;
01952 #else
01953 msg_insert = "can not open INCLUDE file.";
01954 goto EMERGENCY_EXIT;
01955 #endif
01956 }
01957 }
01958 else {
01959 line_num = message_rec->uline;
01960 #ifdef KEY
01961 files_too_deeply_nested(line_num);
01962 goto JUST_PRINT_MESSAGE;
01963 #else
01964 msg_insert = "file_stk size exceeded.";
01965 goto EMERGENCY_EXIT;
01966 #endif
01967 }
01968 }
01969
01970 # ifdef _DEBUG
01971
01972 CHECK_GL_IDX:
01973
01974 if (global_idx < global_line_tbl_idx) {
01975
01976 if (message_rec->uline >= GL_GLOBAL_LINE(global_idx + 1)) {
01977
01978 while (dbg_global_line < GL_GLOBAL_LINE(global_idx + 1)) {
01979
01980 #ifdef KEY
01981 if (NULL == file_stk[stk_idx].file_ptr) {
01982 goto JUST_PRINT_MESSAGE;
01983 }
01984 #endif
01985 if (fgets(source_line,
01986 MAX_SRC_LINE_SIZE,
01987 file_stk[stk_idx].file_ptr) != NULL) {
01988 ++dbg_global_line;
01989 ++file_stk[stk_idx].file_line;
01990 fprintf(stderr, "%s", source_line);
01991 }
01992 else {
01993 line_num = dbg_global_line;
01994 #ifdef KEY
01995 cannot_read_source_file(line_num);
01996 goto JUST_PRINT_MESSAGE;
01997 #else
01998 msg_insert = "can not read source file.";
01999 goto EMERGENCY_EXIT;
02000 #endif
02001 }
02002 }
02003
02004 ++global_idx;
02005
02006 for (search_idx = stk_idx - 1; search_idx >=0; --search_idx) {
02007
02008 if (GL_CIF_FILE_ID(global_idx) ==
02009 file_stk[search_idx].file_id) {
02010
02011 while (stk_idx != search_idx) {
02012 fclose(file_stk[stk_idx--].file_ptr);
02013 }
02014
02015 goto CHECK_GL_IDX;
02016 }
02017 }
02018
02019 ++stk_idx;
02020
02021 if (stk_idx < FILE_STK_MAX) {
02022 file_stk[stk_idx].file_id = GL_CIF_FILE_ID(global_idx);
02023
02024 for (i = 2; i < filedir->nfiles; ++i) {
02025
02026 if (file_rec[i].fid == file_stk[stk_idx].file_id) {
02027 break;
02028 }
02029 }
02030
02031 if ((file_stk[stk_idx].file_ptr =
02032 fopen(file_rec[i].name, "r")) != NULL) {
02033 file_stk[stk_idx].file_line = 0;
02034 }
02035 else {
02036 line_num = message_rec->uline;
02037 #ifdef KEY
02038 cannot_open_include_file(line_num);
02039 goto JUST_PRINT_MESSAGE;
02040 #else
02041 msg_insert = "can not open INCLUDE file.";
02042 goto EMERGENCY_EXIT;
02043 #endif
02044 }
02045 }
02046 else {
02047 line_num = message_rec->uline;
02048 #ifdef KEY
02049 files_too_deeply_nested(line_num);
02050 goto JUST_PRINT_MESSAGE;
02051 #else
02052 msg_insert = "file_stk size exceeded.";
02053 goto EMERGENCY_EXIT;
02054 #endif
02055 }
02056
02057 goto CHECK_GL_IDX;
02058 }
02059 }
02060
02061 # endif
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071 HAVE_FILE:
02072
02073 #ifdef KEY
02074 if (NULL == file_stk[stk_idx].file_ptr) {
02075 goto JUST_PRINT_MESSAGE;
02076 }
02077 #endif
02078
02079 if (file_stk[stk_idx].file_line != message_rec->fline) {
02080
02081 if (file_stk[stk_idx].file_line > message_rec->fline &&
02082 stk_idx > 0) {
02083 rewind(file_stk[stk_idx].file_ptr);
02084 file_stk[stk_idx].file_line = 0;
02085 }
02086
02087 while (file_stk[stk_idx].file_line != message_rec->fline) {
02088
02089 if (fgets(source_line,
02090 MAX_SRC_LINE_SIZE,
02091 file_stk[stk_idx].file_ptr) != NULL) {
02092 ++file_stk[stk_idx].file_line;
02093
02094 # ifdef _DEBUG
02095 if (dump_flags.stmt_dmp) {
02096 fprintf(stderr, "%s", source_line);
02097 ++dbg_global_line;
02098 }
02099 # endif
02100
02101 }
02102 else {
02103 line_num = message_rec->uline;
02104 #ifdef KEY
02105 cannot_read_source_file(line_num);
02106 goto JUST_PRINT_MESSAGE;
02107 #else
02108 sprintf(final_text,
02109 "hit EOF while trying to issue message %d at line %d.",
02110 message_rec->msgno,
02111 line_num);
02112 msg_insert = final_text;
02113 goto EMERGENCY_EXIT;
02114 #endif
02115 }
02116 }
02117
02118 fprintf(stderr, "\n%s", source_line);
02119 }
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135 if (message_rec->cpos != 0) {
02136
02137 for (i = 0; source_line[i] != '\0'; ++i) {
02138 carat[i] = (source_line[i] == '\t') ? '\t' : ' ';
02139 }
02140
02141 for ( ; i < message_rec->cpos; ++i) {
02142 carat[i] = ' ';
02143 }
02144
02145 carat[i] = '\0';
02146 carat[message_rec->cpos - 1] = '^';
02147 fprintf(stderr, "%s\n", carat);
02148 }
02149
02150 #ifdef KEY
02151
02152
02153 JUST_PRINT_MESSAGE:
02154 #endif
02155
02156 catgetmsg(message_catalog,
02157 NL_MSGSET,
02158 message_rec->msgno,
02159 orig_text,
02160 ORIG_MSG_SIZE);
02161
02162 Cif_Msginsert(orig_text,
02163 (struct Cif_generic *) message_rec,
02164 expanded_text,
02165 EXPANDED_MSG_SIZE);
02166
02167 if (message_rec->cpos == 0) {
02168 sprintf(message_hdr, "%s, File = %s, Line = %d ",
02169 message_rec->name,
02170 GL_FILE_NAME_PTR(global_idx),
02171 message_rec->fline);
02172 }
02173 else {
02174 sprintf(message_hdr, "%s, File = %s, Line = %d, Column = %d ",
02175 message_rec->name,
02176 GL_FILE_NAME_PTR(global_idx),
02177 message_rec->fline,
02178 message_rec->cpos);
02179 }
02180
02181 catmsgfmt(command_name,
02182 message_prefix,
02183 message_rec->msgno,
02184 msg_severity_name[message_rec->severity],
02185 expanded_text,
02186 final_text,
02187 FINAL_MSG_SIZE,
02188 message_hdr,
02189 (char *) NULL);
02190
02191 fputs(final_text, stderr);
02192 #ifdef KEY
02193 if (verbose_message) {
02194 verbose_message(group_code, message_rec->msgno);
02195 }
02196 #endif
02197
02198 # ifdef _DEBUG
02199 if (dump_flags.stmt_dmp) {
02200 fprintf(stderr, "\n");
02201 }
02202 # endif
02203
02204 ++message_rec;
02205
02206 }
02207
02208 }
02209
02210
02211 # ifdef _DEBUG
02212
02213 NO_MSGS_STMT_DUMP:
02214
02215 #ifdef KEY
02216 if (NULL == file_stk[stk_idx].file_ptr) {
02217 goto CLEANUP;
02218 }
02219 #endif
02220 if (dump_flags.stmt_dmp) {
02221
02222 CHECK_GL_IDX_AGAIN:
02223
02224 if (global_idx < global_line_tbl_idx) {
02225
02226 while (dbg_global_line < GL_GLOBAL_LINE(global_idx + 1)) {
02227
02228 if (fgets(source_line,
02229 MAX_SRC_LINE_SIZE,
02230 file_stk[stk_idx].file_ptr) != NULL) {
02231 ++dbg_global_line;
02232 fprintf(stderr, "%s", source_line);
02233 }
02234 else {
02235 line_num = dbg_global_line;
02236 #ifdef KEY
02237 cannot_read_source_file(line_num);
02238 goto CLEANUP;
02239 #else
02240 msg_insert = "can not read source file.";
02241 goto EMERGENCY_EXIT;
02242 #endif
02243 }
02244 }
02245
02246 ++global_idx;
02247
02248 for (search_idx = stk_idx - 1; search_idx >=0; --search_idx) {
02249
02250 if (GL_CIF_FILE_ID(global_idx) == file_stk[search_idx].file_id) {
02251
02252 while (stk_idx != search_idx) {
02253 fclose(file_stk[stk_idx--].file_ptr);
02254 }
02255
02256 goto CHECK_GL_IDX_AGAIN;
02257 }
02258 }
02259
02260 ++stk_idx;
02261
02262 if (stk_idx < FILE_STK_MAX) {
02263 file_stk[stk_idx].file_id = GL_CIF_FILE_ID(global_idx);
02264
02265 for (i = 2; i < filedir->nfiles; ++i) {
02266
02267 if (file_rec[i].fid == file_stk[stk_idx].file_id) {
02268 break;
02269 }
02270 }
02271
02272 if ((file_stk[stk_idx].file_ptr =
02273 fopen(file_rec[i].name, "r")) != NULL) {
02274 file_stk[stk_idx].file_line = 0;
02275 }
02276 else {
02277 #ifdef KEY
02278 cannot_open_include_file(message_rec->uline);
02279 goto CLEANUP;
02280 #else
02281 line_num = message_rec->uline;
02282 msg_insert = "can not open INCLUDE file.";
02283 goto EMERGENCY_EXIT;
02284 #endif
02285 }
02286 }
02287 else {
02288 #ifdef KEY
02289 files_too_deeply_nested(message_rec->uline);
02290 goto CLEANUP;
02291 #else
02292 line_num = message_rec->uline;
02293 msg_insert = "file_stk size exceeded.";
02294 goto EMERGENCY_EXIT;
02295 #endif
02296 }
02297
02298 goto CHECK_GL_IDX_AGAIN;
02299 }
02300
02301 while (feof(file_stk[0].file_ptr) == 0) {
02302
02303 if (fgets(source_line,
02304 MAX_SRC_LINE_SIZE,
02305 file_stk[0].file_ptr) != NULL &&
02306 feof(file_stk[0].file_ptr) == 0) {
02307 fprintf(stderr, "%s", source_line);
02308 }
02309 }
02310 }
02311
02312 # endif
02313
02314 #ifdef KEY
02315
02316
02317 CLEANUP:
02318 #endif
02319
02320 fprintf(stderr, "\n");
02321
02322
02323 # ifdef _DEBUG
02324
02325 if (num_msgs != 0) {
02326 Cif_Close(fd, CIF_MEM_FREE);
02327 }
02328
02329 # else
02330
02331 Cif_Close(fd, CIF_MEM_FREE);
02332
02333 # endif
02334
02335
02336 #ifdef KEY
02337 for (; stk_idx >= 0; stk_idx -= 1) {
02338 if (NULL != file_stk[stk_idx].file_ptr) {
02339 fclose(file_stk[stk_idx].file_ptr);
02340 }
02341 }
02342 #else
02343 while (stk_idx >= 0) {
02344 fclose(file_stk[stk_idx--].file_ptr);
02345 }
02346 #endif
02347
02348 EXIT:
02349
02350
02351
02352
02353
02354
02355 c_i_f = NULL;
02356
02357
02358 fclose(cif_tmp_file);
02359 remove(cif_tmp_file_name);
02360
02361 TRACE (Func_Exit, "print_buffered_messages", NULL);
02362
02363 return;
02364
02365
02366 EMERGENCY_EXIT:
02367
02368 if (c_i_f == cif_actual_file) {
02369
02370 cif_actual_file = NULL;
02371 }
02372 fclose(c_i_f);
02373 c_i_f = NULL;
02374 remove(cif_name);
02375 remove(cif_tmp_file_name);
02376 Cif_Close(fd, CIF_MEM_FREE);
02377 PRINTMSG(line_num, 995, Internal, 0, msg_insert);
02378
02379 }
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399 static int compare_message_recs(const void *p1,
02400 const void *p2)
02401 {
02402 register int result;
02403 register int order1;
02404 register int order2;
02405
02406
02407 TRACE (Func_Entry, "compare_message_recs", NULL);
02408
02409 result = ((struct Cif_message *) p1)->uline -
02410 ((struct Cif_message *) p2)->uline;
02411
02412 if (result == 0) {
02413 result = ((struct Cif_message *) p1)->cpos -
02414 ((struct Cif_message *) p2)->cpos;
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425 if (result == 0) {
02426 order1 = ((struct Cif_message *) p1)->order;
02427 order2 = ((struct Cif_message *) p2)->order;
02428
02429 if ( (order1 == order2) || (order1 == 0) || (order2 == 0) ) {
02430 result = ((struct Cif_message *) p1)->msgno -
02431 ((struct Cif_message *) p2)->msgno;
02432 }
02433 else {
02434 result = ((struct Cif_message *) p1)->order -
02435 ((struct Cif_message *) p2)->order;
02436 }
02437 }
02438 }
02439
02440 TRACE (Func_Exit, "compare_message_recs", NULL);
02441
02442 return (result);
02443
02444 }
02445 # if defined(_USE_FOLD_DOT_f)
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463 #define FOLD_ABORT fold_f_abort__
02464
02465 void FOLD_ABORT(int *oper)
02466
02467 {
02468
02469
02470 TRACE (Func_Entry, "fold_f_abort_", NULL);
02471
02472 #ifdef KEY
02473
02474
02475
02476
02477 PRINTMSG(stmt_start_line, 626, Internal, stmt_start_col,
02478 "supported operator or type", "FOLD_OPERATION");
02479 #else
02480 PRINTMSG(stmt_start_line, 626, Internal, *oper,
02481 "supported operator or type", "FOLD_OPERATION");
02482 #endif
02483
02484 TRACE (Func_Exit, "fold_f_abort_", NULL);
02485
02486 return;
02487
02488 }
02489 # endif
02490 #ifdef KEY
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507 msg_severities_type
02508 ansi_or_warning(void) {
02509 return on_off_flags.issue_ansi_messages ? Ansi : Warning ;
02510 }
02511 #endif