Skip to content

Commit b1bf328

Browse files
authored
Merge pull request #56 from rekka/feat-synctex
Fix SyncTeX
2 parents 328213e + 8c2a2a2 commit b1bf328

File tree

9 files changed

+176
-190
lines changed

9 files changed

+176
-190
lines changed

tectonic/core-bridge.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,27 @@ ttstub_issue_error(const_string format, ...)
137137
TGB->issue_error(TGB->context, error_buf);
138138
}
139139

140+
PRINTF_FUNC(2,3) int
141+
ttstub_fprintf(rust_output_handle_t handle, const_string format, ...)
142+
{
143+
static char fprintf_buf[BUF_SIZE] = "";
144+
va_list ap;
145+
146+
va_start(ap, format);
147+
int len = vsnprintf(fprintf_buf, BUF_SIZE, format, ap);
148+
va_end(ap);
149+
150+
if (len >= BUF_SIZE) {
151+
len = BUF_SIZE - 1;
152+
fprintf_buf[len] = '\0';
153+
}
154+
155+
if (len >= 0) {
156+
ttstub_output_write(handle, (unsigned char*) fprintf_buf, len);
157+
}
158+
return len;
159+
}
160+
140161
int
141162
ttstub_get_file_md5(char const *path, unsigned char *digest)
142163
{

tectonic/core-bridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extern char *kpse_find_file (char const *name, kpse_file_format_type format, int
138138

139139
extern PRINTF_FUNC(1,2) void ttstub_issue_warning(const_string format, ...);
140140
extern PRINTF_FUNC(1,2) void ttstub_issue_error(const_string format, ...);
141+
extern PRINTF_FUNC(2,3) int ttstub_fprintf(rust_output_handle_t handle, const_string format, ...);
141142

142143
extern int ttstub_get_file_md5 (char const *path, unsigned char *digest);
143144
extern int ttstub_get_data_md5 (unsigned char const *data, size_t len, unsigned char *digest);

0 commit comments

Comments
 (0)