Browse Source

= bugfixes

master
Alex 'AdUser' Z 13 years ago
parent
commit
f64f350623
  1. 12
      src/torrent2json.c

12
src/torrent2json.c

@ -70,7 +70,7 @@ get_string(int chr)
} }
memset(buf, '\0', len + 1); memset(buf, '\0', len + 1);
for (i = 0; i <= len; i++) for (i = 0; i < len; i++)
*(buf + i * sizeof(char)) = fgetc(in); *(buf + i * sizeof(char)) = fgetc(in);
yajl_gen_string(gen, buf, len); yajl_gen_string(gen, buf, len);
@ -142,7 +142,7 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
void (*handler)(int) = NULL; void (*handler)(int) = NULL;
int chr = '\0'; int c = '\0';
const unsigned char *buf = NULL; const unsigned char *buf = NULL;
size_t len = 0; size_t len = 0;
@ -153,14 +153,14 @@ main(int argc, char **argv)
yajl_gen_config(gen, yajl_gen_beautify, 1); yajl_gen_config(gen, yajl_gen_beautify, 1);
yajl_gen_config(gen, yajl_gen_indent_string, " "); yajl_gen_config(gen, yajl_gen_indent_string, " ");
while ((chr = fgetc(in)) != EOF); while ((c = fgetc(in)) != EOF)
{ {
handler = select_handler(chr); handler = select_handler(c);
handler(chr); if (handler) handler(c);
} }
yajl_gen_get_buf(gen, &buf, &len); yajl_gen_get_buf(gen, &buf, &len);
fprintf(out, "%s", buf); if (len > 0) fprintf(out, "%s", buf);
yajl_gen_free(gen); yajl_gen_free(gen);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);

Loading…
Cancel
Save