28 const char *prev_start;
29 const char *percent_loc;
30 char *sub_start, *current_substring;
41 f =
string = (
char *)
alloca (strlen (s) + 1);
43 while (*s !=
'"' && *s !=
'\0')
83 error (
_(
"Unrecognized escape character \\%c in format string."),
102 current_substring =
xmalloc (strlen (
string) * 2 + 1000);
104 max_pieces = strlen (
string) + 2;
120 int seen_hash = 0, seen_zero = 0, lcount = 0, seen_prec = 0;
121 int seen_space = 0, seen_plus = 0;
122 int seen_big_l = 0, seen_h = 0, seen_big_h = 0;
123 int seen_big_d = 0, seen_double_big_d = 0;
133 sub_start = current_substring;
135 strncpy (current_substring, prev_start, f - 1 - prev_start);
136 current_substring += f - 1 - prev_start;
137 *current_substring++ =
'\0';
139 pieces[next_frag].
string = sub_start;
152 while (*f !=
'\0' && strchr (
"0-+ #", *f))
166 while (*f !=
'\0' && strchr (
"0123456789", *f))
174 while (*f !=
'\0' && strchr (
"0123456789", *f))
214 seen_double_big_d = 1;
230 if (seen_space || seen_plus)
238 else if (lcount == 1)
249 if (lcount > 1 || seen_h || seen_big_l)
251 if (seen_prec || seen_zero || seen_space || seen_plus)
257 if (lcount || seen_h || seen_big_l)
261 if (seen_hash || seen_zero || seen_space || seen_plus)
267 if (lcount > 1 || seen_h || seen_big_l)
269 if (seen_zero || seen_space || seen_plus)
278 if (seen_big_h || seen_big_d || seen_double_big_d)
285 if (lcount || seen_h)
290 error (
_(
"`*' not supported for precision or width in printf"));
293 error (
_(
"Format specifier `n' not supported in printf"));
296 error (
_(
"Incomplete format specifier at end of format string"));
299 error (
_(
"Unrecognized format specifier '%c' in printf"), *f);
303 error (
_(
"Inappropriate modifiers to "
304 "format specifier '%c' in printf"),
309 sub_start = current_substring;
315 int length_before_ll = f - percent_loc - 1 - lcount;
317 strncpy (current_substring, percent_loc, length_before_ll);
318 strcpy (current_substring + length_before_ll,
"I64");
319 current_substring[length_before_ll + 3] =
320 percent_loc[length_before_ll + lcount];
321 current_substring += length_before_ll + 4;
327 int length_before_ls = f - percent_loc - 2;
329 strncpy (current_substring, percent_loc, length_before_ls);
330 strcpy (current_substring + length_before_ls,
"s");
331 current_substring += length_before_ls + 2;
335 strncpy (current_substring, percent_loc, f - percent_loc);
336 current_substring += f - percent_loc;
339 *current_substring++ =
'\0';
343 pieces[next_frag].
string = sub_start;
344 pieces[next_frag].
argclass = this_argclass;
350 sub_start = current_substring;
352 strncpy (current_substring, prev_start, f - prev_start);
353 current_substring += f - prev_start;
354 *current_substring++ =
'\0';
356 pieces[next_frag].
string = sub_start;
362 pieces[next_frag].
string = NULL;
376 if (pieces[0].
string)
377 xfree (pieces[0].
string);
385 void **location = ptr;
387 if (location == NULL)
390 if (*location != NULL)
void error(const char *fmt,...)