Print this page
make: remove SCCS ident stuff
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/lib/mksh/src/read.cc
+++ new/usr/src/cmd/make/lib/mksh/src/read.cc
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 -/*
26 - * @(#)read.cc 1.11 06/12/12
27 - */
28 25
29 -#pragma ident "@(#)read.cc 1.11 06/12/12"
30 26
31 27 /*
32 28 * read.c
33 29 *
34 30 * This file contains the makefile reader.
35 31 */
36 32
37 33 /*
38 34 * Included files
39 35 */
40 36 #include <mksh/misc.h> /* retmem() */
41 37 #include <mksh/read.h>
42 38 #include <mksdmsi18n/mksdmsi18n.h>
43 39 #include <sys/uio.h> /* read() */
44 40 #include <unistd.h> /* close(), unlink(), read() */
45 41
46 42 #define STRING_LEN_TO_CONVERT (8*1024)
47 43
48 44 /*
49 45 * get_next_block_fn(source)
50 46 *
51 47 * Will get the next block of text to read either
52 48 * by popping one source bVSIZEOFlock of the stack of Sources
53 49 * or by reading some more from the makefile.
54 50 *
55 51 * Return value:
56 52 * The new source block to read from
57 53 *
58 54 * Parameters:
59 55 * source The old source block
60 56 *
61 57 * Global variables used:
62 58 * file_being_read The name of the current file, error msg
63 59 */
64 60 Boolean make_state_locked;
65 61 Source
66 62 get_next_block_fn(register Source source)
67 63 {
68 64 register off_t to_read;
69 65 register int length;
70 66 register size_t num_wc_chars;
71 67 char ch_save;
72 68 char *ptr;
73 69
74 70 if (source == NULL) {
75 71 return NULL;
76 72 }
77 73 if ((source->fd < 0) ||
78 74 ((source->bytes_left_in_file <= 0) &&
79 75 (source->inp_buf_ptr >= source->inp_buf_end))) {
80 76 /* We can't read from the makefile, so pop the source block */
81 77 if (source->fd > 2) {
82 78 (void) close(source->fd);
83 79 if (make_state_lockfile != NULL) {
84 80 (void) unlink(make_state_lockfile);
85 81 retmem_mb(make_state_lockfile);
86 82 make_state_lockfile = NULL;
87 83 make_state_locked = false;
88 84 }
89 85 }
90 86 if (source->string.free_after_use &&
91 87 (source->string.buffer.start != NULL)) {
92 88 retmem(source->string.buffer.start);
93 89 source->string.buffer.start = NULL;
94 90 }
95 91 if (source->inp_buf != NULL) {
96 92 retmem_mb(source->inp_buf);
97 93 source->inp_buf = NULL;
98 94 }
99 95 source = source->previous;
100 96 if (source != NULL) {
101 97 source->error_converting = false;
102 98 }
103 99 return source;
104 100 }
105 101 if (source->bytes_left_in_file > 0) {
106 102 /*
107 103 * Read the whole makefile.
108 104 * Hopefully the kernel managed to prefetch the stuff.
109 105 */
110 106 to_read = source->bytes_left_in_file;
111 107 source->inp_buf_ptr = source->inp_buf = getmem(to_read + 1);
112 108 source->inp_buf_end = source->inp_buf + to_read;
113 109 length = read(source->fd, source->inp_buf, (unsigned int) to_read);
114 110 if (length != to_read) {
115 111 WCSTOMBS(mbs_buffer, file_being_read);
116 112 if (length == 0) {
117 113 fatal_mksh(catgets(libmksdmsi18n_catd, 1, 140, "Error reading `%s': Premature EOF"),
118 114 mbs_buffer);
119 115 } else {
120 116 fatal_mksh(catgets(libmksdmsi18n_catd, 1, 141, "Error reading `%s': %s"),
121 117 mbs_buffer,
122 118 errmsg(errno));
123 119 }
124 120 }
125 121 *source->inp_buf_end = nul_char;
126 122 source->bytes_left_in_file = 0;
127 123 }
128 124 /*
129 125 * Try to convert the next piece.
130 126 */
131 127 ptr = source->inp_buf_ptr + STRING_LEN_TO_CONVERT;
132 128 if (ptr > source->inp_buf_end) {
133 129 ptr = source->inp_buf_end;
134 130 }
135 131 for (num_wc_chars = 0; ptr > source->inp_buf_ptr; ptr--) {
136 132 ch_save = *ptr;
137 133 *ptr = nul_char;
138 134 num_wc_chars = mbstowcs(source->string.text.end,
139 135 source->inp_buf_ptr,
140 136 STRING_LEN_TO_CONVERT);
141 137 *ptr = ch_save;
142 138 if (num_wc_chars != (size_t)-1) {
143 139 break;
144 140 }
145 141 }
146 142
147 143 if ((int) num_wc_chars == (size_t)-1) {
148 144 source->error_converting = true;
149 145 return source;
150 146 }
151 147
152 148 source->error_converting = false;
153 149 source->inp_buf_ptr = ptr;
154 150 source->string.text.end += num_wc_chars;
155 151 *source->string.text.end = 0;
156 152
157 153 if (source->inp_buf_ptr >= source->inp_buf_end) {
158 154 if (*(source->string.text.end - 1) != (int) newline_char) {
159 155 WCSTOMBS(mbs_buffer, file_being_read);
160 156 warning_mksh(catgets(libmksdmsi18n_catd, 1, 142, "newline is not last character in file %s"),
161 157 mbs_buffer);
162 158 *source->string.text.end++ = (int) newline_char;
163 159 *source->string.text.end = (int) nul_char;
164 160 *source->string.buffer.end++;
165 161 }
166 162 if (source->inp_buf != NULL) {
167 163 retmem_mb(source->inp_buf);
168 164 source->inp_buf = NULL;
169 165 }
170 166 }
171 167 return source;
172 168 }
173 169
174 170
↓ open down ↓ |
135 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX