Mercurial > hg > octave-nkf
comparison src/file-io.cc @ 218:d981cdce52d9
[project @ 1993-11-13 09:35:19 by jwe]
author | jwe |
---|---|
date | Sat, 13 Nov 1993 09:35:19 +0000 |
parents | e2c950dd96d2 |
children | a99f28f5e351 |
comparison
equal
deleted
inserted
replaced
217:cd2e49fb4f6b | 218:d981cdce52d9 |
---|---|
598 | 598 |
599 if (*s == '*') | 599 if (*s == '*') |
600 { | 600 { |
601 if (fmt_arg_count >= nargin) | 601 if (fmt_arg_count >= nargin) |
602 { | 602 { |
603 message (type, "not enough arguments"); | 603 error ("%s: not enough arguments", type); |
604 return -1; | 604 return -1; |
605 } | 605 } |
606 | 606 |
607 if (args[fmt_arg_count].const_type () | 607 if (args[fmt_arg_count].const_type () |
608 != tree_constant_rep::scalar_constant) | 608 != tree_constant_rep::scalar_constant) |
609 { | 609 { |
610 message (type, "`*' must be replaced by an integer"); | 610 error ("%s: `*' must be replaced by an integer", type); |
611 return -1; | 611 return -1; |
612 } | 612 } |
613 | 613 |
614 fmt << NINT (args[fmt_arg_count++].double_value ()); | 614 fmt << NINT (args[fmt_arg_count++].double_value ()); |
615 s++; | 615 s++; |
638 if (*(s-1) == '*') | 638 if (*(s-1) == '*') |
639 goto invalid_format; | 639 goto invalid_format; |
640 | 640 |
641 if (fmt_arg_count >= nargin) | 641 if (fmt_arg_count >= nargin) |
642 { | 642 { |
643 message (type, "not enough arguments"); | 643 error ("%s: not enough arguments", type); |
644 return -1; | 644 return -1; |
645 } | 645 } |
646 | 646 |
647 if (args[fmt_arg_count].const_type () | 647 if (args[fmt_arg_count].const_type () |
648 != tree_constant_rep::scalar_constant) | 648 != tree_constant_rep::scalar_constant) |
649 { | 649 { |
650 message (type, "`*' must be replaced by an integer"); | 650 error ("%s: `*' must be replaced by an integer", type); |
651 return -1; | 651 return -1; |
652 } | 652 } |
653 | 653 |
654 fmt << NINT (args[fmt_arg_count++].double_value ()); | 654 fmt << NINT (args[fmt_arg_count++].double_value ()); |
655 s++; | 655 s++; |
676 if (*s == '\0') | 676 if (*s == '\0') |
677 goto invalid_format; | 677 goto invalid_format; |
678 | 678 |
679 if (fmt_arg_count >= nargin) | 679 if (fmt_arg_count >= nargin) |
680 { | 680 { |
681 message (type, "not enough arguments"); | 681 error ("%s: not enough arguments", type); |
682 return -1; | 682 return -1; |
683 } | 683 } |
684 | 684 |
685 arg_type = args[fmt_arg_count].const_type (); | 685 arg_type = args[fmt_arg_count].const_type (); |
686 | 686 |
757 default: | 757 default: |
758 goto invalid_format; | 758 goto invalid_format; |
759 } | 759 } |
760 | 760 |
761 invalid_conversion: | 761 invalid_conversion: |
762 message (type, "invalid conversion"); | 762 error ("%s: invalid conversion", type); |
763 return -1; | 763 return -1; |
764 | 764 |
765 invalid_format: | 765 invalid_format: |
766 message (type, "invalid format"); | 766 error ("%s: invalid format", type); |
767 return -1; | 767 return -1; |
768 } | 768 } |
769 | 769 |
770 | 770 |
771 tree_constant * | 771 tree_constant * |
873 else if (strcmp (type, "fprintf") == 0) | 873 else if (strcmp (type, "fprintf") == 0) |
874 { | 874 { |
875 char *msg = output_buf.str (); | 875 char *msg = output_buf.str (); |
876 int success = fputs (msg, file.fptr ()); | 876 int success = fputs (msg, file.fptr ()); |
877 if (success == EOF) | 877 if (success == EOF) |
878 error ("%s: writing to file", type); | 878 warning ("%s: unknown failure writing to file", type); |
879 delete [] msg; | 879 delete [] msg; |
880 } | 880 } |
881 else if (strcmp (type, "sprintf") == 0) | 881 else if (strcmp (type, "sprintf") == 0) |
882 { | 882 { |
883 retval = new tree_constant [2]; | 883 retval = new tree_constant [2]; |
937 if (*s == '\0') | 937 if (*s == '\0') |
938 goto invalid_format; | 938 goto invalid_format; |
939 | 939 |
940 if (fmt_arg_count >= nargout && store_value) | 940 if (fmt_arg_count >= nargout && store_value) |
941 { | 941 { |
942 message (type, "not enough arguments"); | 942 error ("%s: not enough arguments", type); |
943 return -1; | 943 return -1; |
944 } | 944 } |
945 | 945 |
946 arg_type = args[fmt_arg_count].const_type (); | 946 arg_type = args[fmt_arg_count].const_type (); |
947 | 947 |
1029 | 1029 |
1030 if (success > 0 || (success == 0 && store_value == 0)) | 1030 if (success > 0 || (success == 0 && store_value == 0)) |
1031 return chars_from_fmt_str; | 1031 return chars_from_fmt_str; |
1032 | 1032 |
1033 if (success == 0) | 1033 if (success == 0) |
1034 message (type, "invalid conversion"); | 1034 warning ("%s: invalid conversion", type); |
1035 else if (success == EOF) | 1035 else if (success == EOF) |
1036 { | 1036 { |
1037 if (strcmp (type, "fscanf") == 0) | 1037 if (strcmp (type, "fscanf") == 0) |
1038 message (type, "end of file reached before final conversion"); | 1038 warning ("%s: end of file reached before final conversion", type); |
1039 else if (strcmp (type, "sscanf") == 0) | 1039 else if (strcmp (type, "sscanf") == 0) |
1040 message (type, "end of string reached before final conversion"); | 1040 warning ("%s: end of string reached before final conversion", type); |
1041 else if (strcmp (type, "scanf") == 0) | 1041 else if (strcmp (type, "scanf") == 0) |
1042 message (type, "end of input reached before final conversion"); | 1042 warning ("%s: end of input reached before final conversion", type); |
1043 } | 1043 } |
1044 else | 1044 else |
1045 { | 1045 { |
1046 invalid_format: | 1046 invalid_format: |
1047 message (type, "invalid format"); | 1047 warning ("%s: invalid format", type); |
1048 } | 1048 } |
1049 | 1049 |
1050 return -1; | 1050 return -1; |
1051 } | 1051 } |
1052 | 1052 |