aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nls
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2011-11-21 10:15:13 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-26 22:58:47 -0500
commit045ddc8991698a8e9c5668c6190faa8b5d516dc0 (patch)
tree096014b4e552bd8d3701c0fd7c8b57a61827e448 /fs/nls
parent568987116ed5fce7e9e9c731ffe5f5af193ab2e3 (diff)
NLS: raname "maxlen" to "maxout" in UTF conversion routines
As requested by NamJae Jeon, this patch (as1503) changes the name of the "maxlen" parameters to "maxout" in the various UTF conversion routines. This should make the role of that parameter more clear. The patch also renames the "len" parameters to "inlen", for the same reason. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reviewed-by: NamJae Jeon <linkinjeon@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/nls')
-rw-r--r--fs/nls/nls_base.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
index 0eb059ec6f28..fea6bd5831dc 100644
--- a/fs/nls/nls_base.c
+++ b/fs/nls/nls_base.c
@@ -52,7 +52,7 @@ static const struct utf8_table utf8_table[] =
52#define SURROGATE_LOW 0x00000400 52#define SURROGATE_LOW 0x00000400
53#define SURROGATE_BITS 0x000003ff 53#define SURROGATE_BITS 0x000003ff
54 54
55int utf8_to_utf32(const u8 *s, int len, unicode_t *pu) 55int utf8_to_utf32(const u8 *s, int inlen, unicode_t *pu)
56{ 56{
57 unsigned long l; 57 unsigned long l;
58 int c0, c, nc; 58 int c0, c, nc;
@@ -71,7 +71,7 @@ int utf8_to_utf32(const u8 *s, int len, unicode_t *pu)
71 *pu = (unicode_t) l; 71 *pu = (unicode_t) l;
72 return nc; 72 return nc;
73 } 73 }
74 if (len <= nc) 74 if (inlen <= nc)
75 return -1; 75 return -1;
76 s++; 76 s++;
77 c = (*s ^ 0x80) & 0xFF; 77 c = (*s ^ 0x80) & 0xFF;
@@ -83,7 +83,7 @@ int utf8_to_utf32(const u8 *s, int len, unicode_t *pu)
83} 83}
84EXPORT_SYMBOL(utf8_to_utf32); 84EXPORT_SYMBOL(utf8_to_utf32);
85 85
86int utf32_to_utf8(unicode_t u, u8 *s, int maxlen) 86int utf32_to_utf8(unicode_t u, u8 *s, int maxout)
87{ 87{
88 unsigned long l; 88 unsigned long l;
89 int c, nc; 89 int c, nc;
@@ -97,7 +97,7 @@ int utf32_to_utf8(unicode_t u, u8 *s, int maxlen)
97 return -1; 97 return -1;
98 98
99 nc = 0; 99 nc = 0;
100 for (t = utf8_table; t->cmask && maxlen; t++, maxlen--) { 100 for (t = utf8_table; t->cmask && maxout; t++, maxout--) {
101 nc++; 101 nc++;
102 if (l <= t->lmask) { 102 if (l <= t->lmask) {
103 c = t->shift; 103 c = t->shift;
@@ -129,24 +129,24 @@ static inline void put_utf16(wchar_t *s, unsigned c, enum utf16_endian endian)
129 } 129 }
130} 130}
131 131
132int utf8s_to_utf16s(const u8 *s, int len, enum utf16_endian endian, 132int utf8s_to_utf16s(const u8 *s, int inlen, enum utf16_endian endian,
133 wchar_t *pwcs, int maxlen) 133 wchar_t *pwcs, int maxout)
134{ 134{
135 u16 *op; 135 u16 *op;
136 int size; 136 int size;
137 unicode_t u; 137 unicode_t u;
138 138
139 op = pwcs; 139 op = pwcs;
140 while (len > 0 && maxlen > 0 && *s) { 140 while (inlen > 0 && maxout > 0 && *s) {
141 if (*s & 0x80) { 141 if (*s & 0x80) {
142 size = utf8_to_utf32(s, len, &u); 142 size = utf8_to_utf32(s, inlen, &u);
143 if (size < 0) 143 if (size < 0)
144 return -EINVAL; 144 return -EINVAL;
145 s += size; 145 s += size;
146 len -= size; 146 inlen -= size;
147 147
148 if (u >= PLANE_SIZE) { 148 if (u >= PLANE_SIZE) {
149 if (maxlen < 2) 149 if (maxout < 2)
150 break; 150 break;
151 u -= PLANE_SIZE; 151 u -= PLANE_SIZE;
152 put_utf16(op++, SURROGATE_PAIR | 152 put_utf16(op++, SURROGATE_PAIR |
@@ -156,15 +156,15 @@ int utf8s_to_utf16s(const u8 *s, int len, enum utf16_endian endian,
156 SURROGATE_LOW | 156 SURROGATE_LOW |
157 (u & SURROGATE_BITS), 157 (u & SURROGATE_BITS),
158 endian); 158 endian);
159 maxlen -= 2; 159 maxout -= 2;
160 } else { 160 } else {
161 put_utf16(op++, u, endian); 161 put_utf16(op++, u, endian);
162 maxlen--; 162 maxout--;
163 } 163 }
164 } else { 164 } else {
165 put_utf16(op++, *s++, endian); 165 put_utf16(op++, *s++, endian);
166 len--; 166 inlen--;
167 maxlen--; 167 maxout--;
168 } 168 }
169 } 169 }
170 return op - pwcs; 170 return op - pwcs;
@@ -183,27 +183,27 @@ static inline unsigned long get_utf16(unsigned c, enum utf16_endian endian)
183 } 183 }
184} 184}
185 185
186int utf16s_to_utf8s(const wchar_t *pwcs, int len, enum utf16_endian endian, 186int utf16s_to_utf8s(const wchar_t *pwcs, int inlen, enum utf16_endian endian,
187 u8 *s, int maxlen) 187 u8 *s, int maxout)
188{ 188{
189 u8 *op; 189 u8 *op;
190 int size; 190 int size;
191 unsigned long u, v; 191 unsigned long u, v;
192 192
193 op = s; 193 op = s;
194 while (len > 0 && maxlen > 0) { 194 while (inlen > 0 && maxout > 0) {
195 u = get_utf16(*pwcs, endian); 195 u = get_utf16(*pwcs, endian);
196 if (!u) 196 if (!u)
197 break; 197 break;
198 pwcs++; 198 pwcs++;
199 len--; 199 inlen--;
200 if (u > 0x7f) { 200 if (u > 0x7f) {
201 if ((u & SURROGATE_MASK) == SURROGATE_PAIR) { 201 if ((u & SURROGATE_MASK) == SURROGATE_PAIR) {
202 if (u & SURROGATE_LOW) { 202 if (u & SURROGATE_LOW) {
203 /* Ignore character and move on */ 203 /* Ignore character and move on */
204 continue; 204 continue;
205 } 205 }
206 if (len <= 0) 206 if (inlen <= 0)
207 break; 207 break;
208 v = get_utf16(*pwcs, endian); 208 v = get_utf16(*pwcs, endian);
209 if ((v & SURROGATE_MASK) != SURROGATE_PAIR || 209 if ((v & SURROGATE_MASK) != SURROGATE_PAIR ||
@@ -214,18 +214,18 @@ int utf16s_to_utf8s(const wchar_t *pwcs, int len, enum utf16_endian endian,
214 u = PLANE_SIZE + ((u & SURROGATE_BITS) << 10) 214 u = PLANE_SIZE + ((u & SURROGATE_BITS) << 10)
215 + (v & SURROGATE_BITS); 215 + (v & SURROGATE_BITS);
216 pwcs++; 216 pwcs++;
217 len--; 217 inlen--;
218 } 218 }
219 size = utf32_to_utf8(u, op, maxlen); 219 size = utf32_to_utf8(u, op, maxout);
220 if (size == -1) { 220 if (size == -1) {
221 /* Ignore character and move on */ 221 /* Ignore character and move on */
222 } else { 222 } else {
223 op += size; 223 op += size;
224 maxlen -= size; 224 maxout -= size;
225 } 225 }
226 } else { 226 } else {
227 *op++ = (u8) u; 227 *op++ = (u8) u;
228 maxlen--; 228 maxout--;
229 } 229 }
230 } 230 }
231 return op - s; 231 return op - s;