comparison src/os_vms.c @ 31804:50555279168b

patch 9.0.1234: the code style has to be checked manually Commit: https://github.com/vim/vim/commit/ebfec1c531f32d424bb2aca6e7391ef3bfcbfe20 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 22 21:14:53 2023 +0000 patch 9.0.1234: the code style has to be checked manually Problem: The code style has to be checked manually. Solution: Add basic code style checks in a test. Fix or avoid uncovered problems.
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 Jan 2023 22:15:04 +0100
parents c0403cd5ca06
children
comparison
equal deleted inserted replaced
31803:7a9569aecc51 31804:50555279168b
116 { 116 {
117 int status; 117 int status;
118 118
119 if ( tmode == TMODE_RAW ) 119 if ( tmode == TMODE_RAW )
120 set_tty(0, 0); 120 set_tty(0, 0);
121 else{ 121 else
122 {
122 switch (orgmode.width) 123 switch (orgmode.width)
123 { 124 {
124 case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break; 125 case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break;
125 case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break; 126 case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break;
126 default: break; 127 default: break;
377 378
378 if (val == DECC$K_FOREIGN ) // foreign non VMS files are not counting 379 if (val == DECC$K_FOREIGN ) // foreign non VMS files are not counting
379 return 1; 380 return 1;
380 381
381 // accept all DECC$K_FILE and DECC$K_DIRECTORY 382 // accept all DECC$K_FILE and DECC$K_DIRECTORY
382 if (vms_match_num == 0) { 383 if (vms_match_num == 0)
384 {
383 // first time through, setup some things 385 // first time through, setup some things
384 if (NULL == vms_fmatch) { 386 if (NULL == vms_fmatch)
387 {
385 vms_fmatch = ALLOC_MULT(char_u *, EXPL_ALLOC_INC); 388 vms_fmatch = ALLOC_MULT(char_u *, EXPL_ALLOC_INC);
386 if (!vms_fmatch) 389 if (!vms_fmatch)
387 return 0; 390 return 0;
388 vms_match_alloced = EXPL_ALLOC_INC; 391 vms_match_alloced = EXPL_ALLOC_INC;
389 vms_match_free = EXPL_ALLOC_INC; 392 vms_match_free = EXPL_ALLOC_INC;
390 } 393 }
391 else { 394 else
395 {
392 // re-use existing space 396 // re-use existing space
393 vms_match_free = vms_match_alloced; 397 vms_match_free = vms_match_alloced;
394 } 398 }
395 } 399 }
396 400
397 // make matches look uniform 401 // make matches look uniform
398 vms_remove_version(name); 402 vms_remove_version(name);
399 name=vms_tolower(name); 403 name=vms_tolower(name);
400 404
401 // if name already exists, don't add it 405 // if name already exists, don't add it
402 for (i = 0; i<vms_match_num; i++) { 406 for (i = 0; i<vms_match_num; i++)
407 {
403 if (0 == STRCMP((char_u *)name,vms_fmatch[i])) 408 if (0 == STRCMP((char_u *)name,vms_fmatch[i]))
404 return 1; 409 return 1;
405 } 410 }
406 if (--vms_match_free == 0) { 411 if (--vms_match_free == 0)
412 {
407 char_u **old_vms_fmatch = vms_fmatch; 413 char_u **old_vms_fmatch = vms_fmatch;
408 414
409 // add more space to store matches 415 // add more space to store matches
410 vms_match_alloced += EXPL_ALLOC_INC; 416 vms_match_alloced += EXPL_ALLOC_INC;
411 vms_fmatch = vim_realloc(old_vms_fmatch, 417 vms_fmatch = vim_realloc(old_vms_fmatch,
462 else 468 else
463 STRCPY(buf,pat[i]); 469 STRCPY(buf,pat[i]);
464 470
465 vms_match_num = 0; // reset collection counter 471 vms_match_num = 0; // reset collection counter
466 result = decc$translate_vms(vms_fixfilename(buf)); 472 result = decc$translate_vms(vms_fixfilename(buf));
467 if ( (int) result == 0 || (int) result == -1 ) { 473 if ( (int) result == 0 || (int) result == -1 )
474 {
468 cnt = 0; 475 cnt = 0;
469 } else { 476 }
477 else
478 {
470 cnt = decc$to_vms(result, vms_wproc, 1 /*allow wild*/ , (flags & EW_DIR ? 0:1 ) /*allow directory*/) ; 479 cnt = decc$to_vms(result, vms_wproc, 1 /*allow wild*/ , (flags & EW_DIR ? 0:1 ) /*allow directory*/) ;
471 } 480 }
472 if (cnt > 0) 481 if (cnt > 0)
473 cnt = vms_match_num; 482 cnt = vms_match_num;
474 483
522 531
523 vms_match_num = 0; 532 vms_match_num = 0;
524 // the result from the decc$translate_vms needs to be handled 533 // the result from the decc$translate_vms needs to be handled
525 // otherwise it might create ACCVIO error in decc$to_vms 534 // otherwise it might create ACCVIO error in decc$to_vms
526 result = decc$translate_vms(vms_fixfilename(path)); 535 result = decc$translate_vms(vms_fixfilename(path));
527 if ( (int) result == 0 || (int) result == -1 ) { 536 if ( (int) result == 0 || (int) result == -1 )
537 {
528 cnt = 0; 538 cnt = 0;
529 } else { 539 }
540 else
541 {
530 cnt = decc$to_vms(result, vms_wproc, 1 /*allow_wild*/, (flags & EW_DIR ? 0:1 ) /*allow directory*/); 542 cnt = decc$to_vms(result, vms_wproc, 1 /*allow_wild*/, (flags & EW_DIR ? 0:1 ) /*allow directory*/);
531 } 543 }
532 if (cnt > 0) 544 if (cnt > 0)
533 cnt = vms_match_num; 545 cnt = vms_match_num;
534 for (i = 0; i < cnt; i++) 546 for (i = 0; i < cnt; i++)
552 char *out_str=out; 564 char *out_str=out;
553 565
554 // copy vms filename portion up to last colon 566 // copy vms filename portion up to last colon
555 // (node and/or disk) 567 // (node and/or disk)
556 lastcolon = strrchr(in, ':'); // find last colon 568 lastcolon = strrchr(in, ':'); // find last colon
557 if (lastcolon != NULL) { 569 if (lastcolon != NULL)
570 {
558 len = lastcolon - in + 1; 571 len = lastcolon - in + 1;
559 strncpy(out, in, len); 572 strncpy(out, in, len);
560 out += len; 573 out += len;
561 in += len; 574 in += len;
562 } 575 }
563 576
564 end_of_dir = NULL; // default: no directory 577 end_of_dir = NULL; // default: no directory
565 578
566 // start of directory portion 579 // start of directory portion
567 ch = *in; 580 ch = *in;
568 if ((ch == '[') || (ch == '/') || (ch == '<')) { // start of directory(s) ? 581 if ((ch == '[') || (ch == '/') || (ch == '<')) // start of directory(s) ?
582 {
569 ch = '['; 583 ch = '[';
570 SKIP_FOLLOWING_SLASHES(in); 584 SKIP_FOLLOWING_SLASHES(in);
571 } else if (EQN(in, "../", 3)) { // Unix parent directory? 585 }
586 else if (EQN(in, "../", 3)) // Unix parent directory?
587 {
572 *out++ = '['; 588 *out++ = '[';
573 *out++ = '-'; 589 *out++ = '-';
574 end_of_dir = out; 590 end_of_dir = out;
575 ch = '.'; 591 ch = '.';
576 in += 2; 592 in += 2;
577 SKIP_FOLLOWING_SLASHES(in); 593 SKIP_FOLLOWING_SLASHES(in);
578 } else { // not a special character 594 }
579 while (EQN(in, "./", 2)) { // Ignore Unix "current dir" 595 else
596 { // not a special character
597 while (EQN(in, "./", 2)) // Ignore Unix "current dir"
598 {
580 in += 2; 599 in += 2;
581 SKIP_FOLLOWING_SLASHES(in); 600 SKIP_FOLLOWING_SLASHES(in);
582 } 601 }
583 if (strchr(in, '/') == NULL) { // any more Unix directories ? 602 if (strchr(in, '/') == NULL) // any more Unix directories ?
603 {
584 strcpy(out, in); // No - get rest of the spec 604 strcpy(out, in); // No - get rest of the spec
585 return; 605 return;
586 } else { 606 }
607 else
608 {
587 *out++ = '['; // Yes, denote a Vms subdirectory 609 *out++ = '['; // Yes, denote a Vms subdirectory
588 ch = '.'; 610 ch = '.';
589 --in; 611 --in;
590 } 612 }
591 } 613 }
594 616
595 // initialize output file spec 617 // initialize output file spec
596 *out++ = ch; 618 *out++ = ch;
597 ++in; 619 ++in;
598 620
599 while (*in != '\0') { 621 while (*in != '\0')
622 {
600 ch = *in; 623 ch = *in;
601 if ((ch == ']') || (ch == '/') || (ch == '>') ) { // end of (sub)directory ? 624 if ((ch == ']') || (ch == '/') || (ch == '>') ) // end of (sub)directory ?
625 {
602 end_of_dir = out; 626 end_of_dir = out;
603 ch = '.'; 627 ch = '.';
604 SKIP_FOLLOWING_SLASHES(in); 628 SKIP_FOLLOWING_SLASHES(in);
605 } 629 }
606 else if (EQN(in, "../", 3)) { // Unix parent directory? 630 else if (EQN(in, "../", 3)) // Unix parent directory?
631 {
607 *out++ = '-'; 632 *out++ = '-';
608 end_of_dir = out; 633 end_of_dir = out;
609 ch = '.'; 634 ch = '.';
610 in += 2; 635 in += 2;
611 SKIP_FOLLOWING_SLASHES(in); 636 SKIP_FOLLOWING_SLASHES(in);
612 } 637 }
613 else { 638 else
614 while (EQN(in, "./", 2)) { // Ignore Unix "current dir" 639 {
615 end_of_dir = out; 640 while (EQN(in, "./", 2)) // Ignore Unix "current dir"
616 in += 2; 641 {
617 SKIP_FOLLOWING_SLASHES(in); 642 end_of_dir = out;
618 ch = *in; 643 in += 2;
644 SKIP_FOLLOWING_SLASHES(in);
645 ch = *in;
619 } 646 }
620 } 647 }
621 648
622 // Place next character into output file spec 649 // Place next character into output file spec
623 *out++ = ch; 650 *out++ = ch;
707 734
708 if ((cp = vim_strchr( fname, ';')) != NULL) // remove version 735 if ((cp = vim_strchr( fname, ';')) != NULL) // remove version
709 *cp = '\0'; 736 *cp = '\0';
710 else if ((cp = vim_strrchr( fname, '.')) != NULL ) 737 else if ((cp = vim_strrchr( fname, '.')) != NULL )
711 { 738 {
712 if ((fp = vim_strrchr( fname, ']')) != NULL ) {;} 739 if ((fp = vim_strrchr( fname, ']')) != NULL )
713 else if ((fp = vim_strrchr( fname, '>')) != NULL ) {;} 740 {;}
714 else fp = fname; 741 else if ((fp = vim_strrchr( fname, '>')) != NULL )
742 {;}
743 else
744 fp = fname;
715 745
716 while ( *fp != '\0' && fp < cp ) 746 while ( *fp != '\0' && fp < cp )
717 if ( *fp++ == '.' ) 747 if ( *fp++ == '.' )
718 *cp = '\0'; 748 *cp = '\0';
719 } 749 }
748 778
749 // make sure the iochan is set 779 // make sure the iochan is set
750 if (!iochan) 780 if (!iochan)
751 get_tty(); 781 get_tty();
752 782
753 if (sec > 0) { 783 if (sec > 0)
784 {
754 // time-out specified; convert it to absolute time 785 // time-out specified; convert it to absolute time
755 // sec>0 requirement of lib$cvtf_to_internal_time() 786 // sec>0 requirement of lib$cvtf_to_internal_time()
756 787
757 // get current time (number of 100ns ticks since the VMS Epoch) 788 // get current time (number of 100ns ticks since the VMS Epoch)
758 status = sys$gettim(&time_curr); 789 status = sys$gettim(&time_curr);
778 &time_out); 809 &time_out);
779 if (status != LIB$_NORMAL) 810 if (status != LIB$_NORMAL)
780 return 0; // error 811 return 0; // error
781 } 812 }
782 813
783 while (TRUE) { 814 while (TRUE)
815 {
784 // select() 816 // select()
785 status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb, 817 status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb,
786 0, 0, &typeahead, 8, 0, 0, 0, 0); 818 0, 0, &typeahead, 8, 0, 0, 0, 0);
787 if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) 819 if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
788 return 0; // error 820 return 0; // error
789 821
790 if (typeahead.numchars) 822 if (typeahead.numchars)
791 return 1; // ready to read 823 return 1; // ready to read
792 824
793 // there's nothing to read; what now? 825 // there's nothing to read; what now?
794 if (msec == 0) { 826 if (msec == 0)
827 {
795 // immediate time-out; return impatiently 828 // immediate time-out; return impatiently
796 return 0; 829 return 0;
797 } else if (msec < 0) { 830 }
831 else if (msec < 0)
832 {
798 // no time-out; wait on indefinitely 833 // no time-out; wait on indefinitely
799 return 1; // fakeout to force a wait in vms_read() 834 return 1; // fakeout to force a wait in vms_read()
800 } else { 835 }
836 else
837 {
801 // time-out needs to be checked 838 // time-out needs to be checked
802 status = sys$gettim(&time_curr); 839 status = sys$gettim(&time_curr);
803 if (status != SS$_NORMAL) 840 if (status != SS$_NORMAL)
804 return 0; // error 841 return 0; // error
805 842