Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1135)

Side by Side Diff: gcc/libgfortran/io/open.c

Issue 3050029: [gcc] GCC 4.5.0=>4.5.1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gcc/libgfortran/io/io.h ('k') | gcc/libgfortran/io/unit.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 1 /* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 Contributed by Andy Vaught 3 Contributed by Andy Vaught
4 F2003 I/O support contributed by Jerry DeLisle 4 F2003 I/O support contributed by Jerry DeLisle
5 5
6 This file is part of the GNU Fortran 95 runtime library (libgfortran). 6 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7 7
8 Libgfortran is free software; you can redistribute it and/or modify 8 Libgfortran is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option) 10 the Free Software Foundation; either version 3, or (at your option)
11 any later version. 11 any later version.
12 12
13 Libgfortran is distributed in the hope that it will be useful, 13 Libgfortran is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 Under Section 7 of GPL version 3, you are granted additional 18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version 19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation. 20 3.1, as published by the Free Software Foundation.
21 21
22 You should have received a copy of the GNU General Public License and 22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program; 23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */ 25 <http://www.gnu.org/licenses/>. */
26 26
27 #include "io.h" 27 #include "io.h"
28 #include "fbuf.h"
29 #include "unix.h"
28 #include <unistd.h> 30 #include <unistd.h>
29 #include <string.h> 31 #include <string.h>
30 #include <errno.h> 32 #include <errno.h>
31 33
32 34
33 static const st_option access_opt[] = { 35 static const st_option access_opt[] = {
34 {"sequential", ACCESS_SEQUENTIAL}, 36 {"sequential", ACCESS_SEQUENTIAL},
35 {"direct", ACCESS_DIRECT}, 37 {"direct", ACCESS_DIRECT},
36 {"append", ACCESS_APPEND}, 38 {"append", ACCESS_APPEND},
37 {"stream", ACCESS_STREAM}, 39 {"stream", ACCESS_STREAM},
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 form_opt, "Bad FORM parameter in OPEN statement"); 770 form_opt, "Bad FORM parameter in OPEN statement");
769 771
770 flags.position = !(cf & IOPARM_OPEN_HAS_POSITION) ? POSITION_UNSPECIFIED : 772 flags.position = !(cf & IOPARM_OPEN_HAS_POSITION) ? POSITION_UNSPECIFIED :
771 find_option (&opp->common, opp->position, opp->position_len, 773 find_option (&opp->common, opp->position, opp->position_len,
772 position_opt, "Bad POSITION parameter in OPEN statement"); 774 position_opt, "Bad POSITION parameter in OPEN statement");
773 775
774 flags.status = !(cf & IOPARM_OPEN_HAS_STATUS) ? STATUS_UNSPECIFIED : 776 flags.status = !(cf & IOPARM_OPEN_HAS_STATUS) ? STATUS_UNSPECIFIED :
775 find_option (&opp->common, opp->status, opp->status_len, 777 find_option (&opp->common, opp->status, opp->status_len,
776 status_opt, "Bad STATUS parameter in OPEN statement"); 778 status_opt, "Bad STATUS parameter in OPEN statement");
777 779
778 /* First, we check whether the convert flag has been set via environment 780 /* First, we check wether the convert flag has been set via environment
779 variable. This overrides the convert tag in the open statement. */ 781 variable. This overrides the convert tag in the open statement. */
780 782
781 conv = get_unformatted_convert (opp->common.unit); 783 conv = get_unformatted_convert (opp->common.unit);
782 784
783 if (conv == GFC_CONVERT_NONE) 785 if (conv == GFC_CONVERT_NONE)
784 { 786 {
785 /* Nothing has been set by environment variable, check the convert tag. * / 787 /* Nothing has been set by environment variable, check the convert tag. * /
786 if (cf & IOPARM_OPEN_HAS_CONVERT) 788 if (cf & IOPARM_OPEN_HAS_CONVERT)
787 conv = find_option (&opp->common, opp->convert, opp->convert_len, 789 conv = find_option (&opp->common, opp->convert, opp->convert_len,
788 convert_opt, 790 convert_opt,
(...skipping 18 matching lines...) Expand all
807 conv = big_endian ? GFC_CONVERT_SWAP : GFC_CONVERT_NATIVE; 809 conv = big_endian ? GFC_CONVERT_SWAP : GFC_CONVERT_NATIVE;
808 break; 810 break;
809 811
810 default: 812 default:
811 internal_error (&opp->common, "Illegal value for CONVERT"); 813 internal_error (&opp->common, "Illegal value for CONVERT");
812 break; 814 break;
813 } 815 }
814 816
815 flags.convert = conv; 817 flags.convert = conv;
816 818
817 if (opp->common.unit < 0) 819 if (!(opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT) && opp->common.unit < 0)
818 generate_error (&opp->common, LIBERROR_BAD_OPTION, 820 generate_error (&opp->common, LIBERROR_BAD_OPTION,
819 "Bad unit number in OPEN statement"); 821 "Bad unit number in OPEN statement");
820 822
821 if (flags.position != POSITION_UNSPECIFIED 823 if (flags.position != POSITION_UNSPECIFIED
822 && flags.access == ACCESS_DIRECT) 824 && flags.access == ACCESS_DIRECT)
823 generate_error (&opp->common, LIBERROR_BAD_OPTION, 825 generate_error (&opp->common, LIBERROR_BAD_OPTION,
824 "Cannot use POSITION with direct access files"); 826 "Cannot use POSITION with direct access files");
825 827
826 if (flags.access == ACCESS_APPEND) 828 if (flags.access == ACCESS_APPEND)
827 { 829 {
828 if (flags.position != POSITION_UNSPECIFIED 830 if (flags.position != POSITION_UNSPECIFIED
829 && flags.position != POSITION_APPEND) 831 && flags.position != POSITION_APPEND)
830 generate_error (&opp->common, LIBERROR_BAD_OPTION, 832 generate_error (&opp->common, LIBERROR_BAD_OPTION,
831 "Conflicting ACCESS and POSITION flags in" 833 "Conflicting ACCESS and POSITION flags in"
832 " OPEN statement"); 834 " OPEN statement");
833 835
834 notify_std (&opp->common, GFC_STD_GNU, 836 notify_std (&opp->common, GFC_STD_GNU,
835 "Extension: APPEND as a value for ACCESS in OPEN statement"); 837 "Extension: APPEND as a value for ACCESS in OPEN statement");
836 flags.access = ACCESS_SEQUENTIAL; 838 flags.access = ACCESS_SEQUENTIAL;
837 flags.position = POSITION_APPEND; 839 flags.position = POSITION_APPEND;
838 } 840 }
839 841
840 if (flags.position == POSITION_UNSPECIFIED) 842 if (flags.position == POSITION_UNSPECIFIED)
841 flags.position = POSITION_ASIS; 843 flags.position = POSITION_ASIS;
842 844
843 if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK) 845 if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK)
844 { 846 {
847 if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT))
848 {
849 *opp->newunit = get_unique_unit_number(opp);
850 opp->common.unit = *opp->newunit;
851 }
852
845 u = find_or_create_unit (opp->common.unit); 853 u = find_or_create_unit (opp->common.unit);
846
847 if (u->s == NULL) 854 if (u->s == NULL)
848 { 855 {
849 u = new_unit (opp, u, &flags); 856 u = new_unit (opp, u, &flags);
850 if (u != NULL) 857 if (u != NULL)
851 unlock_unit (u); 858 unlock_unit (u);
852 } 859 }
853 else 860 else
854 already_open (opp, u, &flags); 861 already_open (opp, u, &flags);
855 } 862 }
856 863
857 library_end (); 864 library_end ();
858 } 865 }
OLDNEW
« no previous file with comments | « gcc/libgfortran/io/io.h ('k') | gcc/libgfortran/io/unit.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698