enum format_arg_type *format_args;
};
-static void format_free (void *descr);
-
static void *
format_parse (const char *format, bool translated, char *fdi,
char **invalid_reason)
const char *format_start = format;
const char *fatstr = format;
- struct spec *result = NULL;
+ struct spec spec;
+ struct spec *result;
unsigned int format_args_allocated;
- result = XMALLOC (struct spec);
- result->directives = 0;
- result->format_args_count = 0;
- result->format_args = NULL;
+ spec.directives = 0;
+ spec.format_args_count = 0;
+ spec.format_args = NULL;
format_args_allocated = 0;
for (; *fatstr != '\0';)
if (*fatstr++ == '%')
{
FDI_SET (fatstr - 1, FMTDIR_START);
- result->directives++;
+ spec.directives++;
if (*fatstr != '%')
{
else
{
*invalid_reason =
- INVALID_CONVERSION_SPECIFIER (result->
- format_args_count + 1,
+ INVALID_CONVERSION_SPECIFIER (spec.format_args_count + 1,
*fatstr);
FDI_SET (fatstr, FMTDIR_ERROR);
}
- goto fmt_error;
+ goto bad_format;
}
- if (result->format_args_count == format_args_allocated)
+ if (spec.format_args_count == format_args_allocated)
{
format_args_allocated = 2 * format_args_allocated + 10;
- result->format_args =
- xrealloc (result->format_args,
+ spec.format_args =
+ xrealloc (spec.format_args,
format_args_allocated *
sizeof (enum format_arg_type));
}
- result->format_args[result->format_args_count++] = type;
+ spec.format_args[spec.format_args_count++] = type;
}
FDI_SET (fatstr, FMTDIR_END);
fatstr++;
}
}
+ result = XMALLOC (struct spec);
+ *result = spec;
return result;
-fmt_error:
- format_free (result);
+ bad_format:
+ if (spec.format_args != NULL)
+ free (spec.format_args);
return NULL;
}
format_check
};
+
#ifdef TEST
/* Test program: Print the argument list specification returned by