Print this page
make: translate using gettext, rather than the unmaintainable catgets
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/lib/mksh/read.cc
+++ new/usr/src/cmd/make/lib/mksh/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.
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 25
26 26
27 27 /*
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
28 28 * read.c
29 29 *
30 30 * This file contains the makefile reader.
31 31 */
32 32
33 33 /*
34 34 * Included files
35 35 */
36 36 #include <mksh/misc.h> /* retmem() */
37 37 #include <mksh/read.h>
38 -#include <mksdmsi18n/mksdmsi18n.h>
39 38 #include <sys/uio.h> /* read() */
40 39 #include <unistd.h> /* close(), unlink(), read() */
40 +#include <libintl.h>
41 41
42 42 #define STRING_LEN_TO_CONVERT (8*1024)
43 43
44 44 /*
45 45 * get_next_block_fn(source)
46 46 *
47 47 * Will get the next block of text to read either
48 48 * by popping one source bVSIZEOFlock of the stack of Sources
49 49 * or by reading some more from the makefile.
50 50 *
51 51 * Return value:
52 52 * The new source block to read from
53 53 *
54 54 * Parameters:
55 55 * source The old source block
56 56 *
57 57 * Global variables used:
58 58 * file_being_read The name of the current file, error msg
59 59 */
60 60 Boolean make_state_locked;
61 61 Source
62 62 get_next_block_fn(register Source source)
63 63 {
64 64 register off_t to_read;
65 65 register int length;
66 66 register size_t num_wc_chars;
67 67 char ch_save;
68 68 char *ptr;
69 69
70 70 if (source == NULL) {
71 71 return NULL;
72 72 }
73 73 if ((source->fd < 0) ||
74 74 ((source->bytes_left_in_file <= 0) &&
75 75 (source->inp_buf_ptr >= source->inp_buf_end))) {
76 76 /* We can't read from the makefile, so pop the source block */
77 77 if (source->fd > 2) {
78 78 (void) close(source->fd);
79 79 if (make_state_lockfile != NULL) {
80 80 (void) unlink(make_state_lockfile);
81 81 retmem_mb(make_state_lockfile);
82 82 make_state_lockfile = NULL;
83 83 make_state_locked = false;
84 84 }
85 85 }
86 86 if (source->string.free_after_use &&
87 87 (source->string.buffer.start != NULL)) {
88 88 retmem(source->string.buffer.start);
89 89 source->string.buffer.start = NULL;
90 90 }
91 91 if (source->inp_buf != NULL) {
92 92 retmem_mb(source->inp_buf);
93 93 source->inp_buf = NULL;
94 94 }
95 95 source = source->previous;
96 96 if (source != NULL) {
97 97 source->error_converting = false;
98 98 }
99 99 return source;
100 100 }
101 101 if (source->bytes_left_in_file > 0) {
102 102 /*
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
103 103 * Read the whole makefile.
104 104 * Hopefully the kernel managed to prefetch the stuff.
105 105 */
106 106 to_read = source->bytes_left_in_file;
107 107 source->inp_buf_ptr = source->inp_buf = getmem(to_read + 1);
108 108 source->inp_buf_end = source->inp_buf + to_read;
109 109 length = read(source->fd, source->inp_buf, (unsigned int) to_read);
110 110 if (length != to_read) {
111 111 WCSTOMBS(mbs_buffer, file_being_read);
112 112 if (length == 0) {
113 - fatal_mksh(catgets(libmksdmsi18n_catd, 1, 140, "Error reading `%s': Premature EOF"),
113 + fatal_mksh(gettext("Error reading `%s': Premature EOF"),
114 114 mbs_buffer);
115 115 } else {
116 - fatal_mksh(catgets(libmksdmsi18n_catd, 1, 141, "Error reading `%s': %s"),
116 + fatal_mksh(gettext("Error reading `%s': %s"),
117 117 mbs_buffer,
118 118 errmsg(errno));
119 119 }
120 120 }
121 121 *source->inp_buf_end = nul_char;
122 122 source->bytes_left_in_file = 0;
123 123 }
124 124 /*
125 125 * Try to convert the next piece.
126 126 */
127 127 ptr = source->inp_buf_ptr + STRING_LEN_TO_CONVERT;
128 128 if (ptr > source->inp_buf_end) {
129 129 ptr = source->inp_buf_end;
130 130 }
131 131 for (num_wc_chars = 0; ptr > source->inp_buf_ptr; ptr--) {
132 132 ch_save = *ptr;
133 133 *ptr = nul_char;
134 134 num_wc_chars = mbstowcs(source->string.text.end,
135 135 source->inp_buf_ptr,
136 136 STRING_LEN_TO_CONVERT);
137 137 *ptr = ch_save;
138 138 if (num_wc_chars != (size_t)-1) {
139 139 break;
140 140 }
141 141 }
142 142
143 143 if ((int) num_wc_chars == (size_t)-1) {
144 144 source->error_converting = true;
145 145 return source;
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
146 146 }
147 147
148 148 source->error_converting = false;
149 149 source->inp_buf_ptr = ptr;
150 150 source->string.text.end += num_wc_chars;
151 151 *source->string.text.end = 0;
152 152
153 153 if (source->inp_buf_ptr >= source->inp_buf_end) {
154 154 if (*(source->string.text.end - 1) != (int) newline_char) {
155 155 WCSTOMBS(mbs_buffer, file_being_read);
156 - warning_mksh(catgets(libmksdmsi18n_catd, 1, 142, "newline is not last character in file %s"),
156 + warning_mksh(gettext("newline is not last character in file %s"),
157 157 mbs_buffer);
158 158 *source->string.text.end++ = (int) newline_char;
159 159 *source->string.text.end = (int) nul_char;
160 160 *source->string.buffer.end++;
161 161 }
162 162 if (source->inp_buf != NULL) {
163 163 retmem_mb(source->inp_buf);
164 164 source->inp_buf = NULL;
165 165 }
166 166 }
167 167 return source;
168 168 }
169 169
170 170
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX