85#define INF_DEBUG_FOUND FALSE
86#define INF_DEBUG_NOT_FOUND FALSE
88#define INF_MAGIC (0xabdc0132)
116typedef const char *(*get_token_fn_t)(
struct inputfile *inf);
143#define inf_log(inf, level, message, ...) \
144 if (log_do_output_for_level(level)) { \
145 do_log(__FILE__, __FUNCTION__, __FC_LINE__, FALSE, level, "%s", \
146 inf_log_str(inf, message, ## __VA_ARGS__)); \
148#define inf_warn(inf, message) \
149 inf_log(inf, LOG_NORMAL, "%s", message);
156 return (c ==
'#' || c ==
';');
211 return "(anonymous)";
289 inf->
magic = ~INF_MAGIC;
365 const char *include_prefix =
"*include";
366 static size_t len = 0;
367 size_t bare_name_len;
369 const char *c, *bare_name_start, *full_name;
373 len = strlen(include_prefix);
401 "Did not find opening doublequote for '*include' line");
408 while (*c !=
'\0' && *c !=
'\"') c++;
411 "Did not find closing doublequote for '*include' line");
415 bare_name_len = c - bare_name_start;
417 strncpy(bare_name, bare_name_start, bare_name_len - 1);
418 bare_name[bare_name_len - 1] =
'\0';
431 full_name = inf->
datafn(bare_name);
433 log_error(
"Could not find included file \"%s\"", bare_name);
445 log_error(
"Recursion trap on '*include' for \"%s\"", full_name);
533 *((
char *)
astr_str(line) + end) =
'\0';
570 static char str[512];
584 (inf->
at_eof ?
", EOF" :
""));
592 "\n processing string starting at line %d",
663 const char *c, *start;
672 while (*c !=
'\0' && *c !=
']') {
678 *((
char *) c) =
'\0';
691 const char *c, *start, *end;
707 if (!(*c !=
'\0' && (
fc_isspace(*c) || *c ==
'='))) {
711 while (*c !=
'\0' && *c !=
'=' && !
is_comment(*c)) {
718 *((
char *) end) =
'\0';
720 *((
char *) end) = trailing;
806 const char *c, *start;
808 bool has_i18n_marking =
FALSE;
809 char border_character =
'\"';
821 if (*c ==
'-' || *c ==
'+' ||
fc_isdigit(*c)) {
841 *((
char *) c) =
'\0';
846 *((
char *) c) = trailing;
851 if (*c ==
'_' && *(c + 1) ==
'(') {
852 has_i18n_marking =
TRUE;
862 border_character = *c;
864 if (border_character ==
'*') {
874 if (*c ==
'\0' || *c ==
'\n') {
887 *((
char *) (c - 1)) =
'\0';
890 if (rfname == NULL) {
892 _(
"Cannot find stringfile \"%s\"."), start);
893 *((
char *) c) = trailing;
896 *((
char *) c) = trailing;
900 _(
"Cannot open stringfile \"%s\"."), rfname);
903 log_debug(
"Stringfile \"%s\" opened ok", start);
904 *((
char *) (c - 1)) = trailing;
927 }
else if (border_character !=
'\"'
928 && border_character !=
'\''
929 && border_character !=
'$') {
942 *((
char *) c) =
'\0';
947 *((
char *) c) = trailing;
974 while (*c !=
'\0' && *c != border_character) {
977 if (*c ==
'\\' && *(c + 1) !=
'\0') {
983 if (*c == border_character) {
993 "Bad return for multi-line string from read_a_line");
1001 *((
char *) c) =
'\0';
1006 *((
char *) c) = trailing;
1009 if (has_i18n_marking) {
1013 inf_warn(inf,
"Missing end of i18n string marking");
void astr_free(struct astring *astr)
void astr_set(struct astring *astr, const char *format,...)
void astr_reserve(struct astring *astr, size_t n)
void astr_clear(struct astring *astr)
void astr_init(struct astring *astr)
void astr_add(struct astring *astr, const char *format,...)
static size_t astr_capacity(const struct astring *astr) fc__attribute((nonnull(1)))
static size_t astr_len(const struct astring *astr) fc__attribute((nonnull(1)))
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
static bool astr_empty(const struct astring *astr) fc__attribute((nonnull(1)))
char * fz_fgets(char *buffer, int size, fz_FILE *fp)
fz_FILE * fz_from_file(const char *filename, const char *in_mode, enum fz_method method, int compress_level)
const char * fz_strerror(fz_FILE *fp)
int fz_fclose(fz_FILE *fp)
int fz_ferror(fz_FILE *fp)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define log_error(message,...)
const char * fileinfoname(const struct strvec *dirs, const char *filename)
const struct strvec * get_data_dirs(void)
int cat_snprintf(char *str, size_t n, const char *format,...)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
#define sz_strlcat(dest, src)