27 const char *prev_start;
28 const char *percent_loc;
29 char *sub_start, *current_substring;
37 f =
string = (
char *)
alloca (strlen (s) + 1);
39 while (*s !=
'"' && *s !=
'\0')
79 error (
_(
"Unrecognized escape character \\%c in format string."),
98 current_substring = (
char *)
xmalloc (strlen (
string) * 2 + 1000);
110 int seen_hash = 0, seen_zero = 0, lcount = 0, seen_prec = 0;
111 int seen_space = 0, seen_plus = 0;
112 int seen_big_l = 0, seen_h = 0, seen_big_h = 0;
113 int seen_big_d = 0, seen_double_big_d = 0;
123 sub_start = current_substring;
125 strncpy (current_substring, prev_start, f - 1 - prev_start);
126 current_substring += f - 1 - prev_start;
127 *current_substring++ =
'\0';
140 while (*f !=
'\0' && strchr (
"0-+ #", *f))
154 while (*f !=
'\0' && strchr (
"0123456789", *f))
162 while (*f !=
'\0' && strchr (
"0123456789", *f))
202 seen_double_big_d = 1;
218 if (seen_space || seen_plus)
226 else if (lcount == 1)
237 if (lcount > 1 || seen_h || seen_big_l)
239 if (seen_prec || seen_zero || seen_space || seen_plus)
245 if (lcount || seen_h || seen_big_l)
249 if (seen_hash || seen_zero || seen_space || seen_plus)
255 if (lcount > 1 || seen_h || seen_big_l)
257 if (seen_zero || seen_space || seen_plus)
266 if (seen_double_big_d)
277 if (lcount || seen_h)
282 error (
_(
"`*' not supported for precision or width in printf"));
285 error (
_(
"Format specifier `n' not supported in printf"));
288 error (
_(
"Incomplete format specifier at end of format string"));
291 error (
_(
"Unrecognized format specifier '%c' in printf"), *f);
295 error (
_(
"Inappropriate modifiers to " 296 "format specifier '%c' in printf"),
301 sub_start = current_substring;
307 int length_before_ll = f - percent_loc - 1 - lcount;
309 strncpy (current_substring, percent_loc, length_before_ll);
310 strcpy (current_substring + length_before_ll,
"I64");
311 current_substring[length_before_ll + 3] =
312 percent_loc[length_before_ll + lcount];
313 current_substring += length_before_ll + 4;
319 int length_before_ls = f - percent_loc - 2;
321 strncpy (current_substring, percent_loc, length_before_ls);
322 strcpy (current_substring + length_before_ls,
"s");
323 current_substring += length_before_ls + 2;
327 strncpy (current_substring, percent_loc, f - percent_loc);
328 current_substring += f - percent_loc;
331 *current_substring++ =
'\0';
335 m_pieces.emplace_back (sub_start, this_argclass);
340 sub_start = current_substring;
342 strncpy (current_substring, prev_start, f - prev_start);
343 current_substring += f - prev_start;
344 *current_substring++ =
'\0';
void error(const char *fmt,...)