Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Clean up C extension
Browse files Browse the repository at this point in the history
This commit fixes a few warnings in the C extension. It also fixes a bug
by calling `global_parse` instead of `_parse`.

Fixes #124
  • Loading branch information
4e554c4c committed Nov 30, 2023
1 parent 0f31464 commit ec94ba8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ mkmf.log
Makefile
ext/mathematical/build
ext/mathematical/lasem/build
# clangd files
*compile_commands.json
*.cache
12 changes: 4 additions & 8 deletions ext/mathematical/lasem_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lsm_itex_free_mathml_buffer (char *mathml)
}

char *
lsm_itex_to_mathml (const char *itex, gssize size) { }
lsm_itex_to_mathml (const char *itex, gssize size) { return NULL; }


char *
Expand All @@ -27,7 +27,7 @@ lsm_mtex_to_mathml (const char *mtex, gssize size, int delimiter, int render_typ
char *mathml;
int status = 0;

if (mtex == NULL) {
if (!mtex) {
return NULL;
}

Expand All @@ -42,7 +42,7 @@ lsm_mtex_to_mathml (const char *mtex, gssize size, int delimiter, int render_typ

switch (render_type) {
case PARSE:
mathml = mtex2MML_parse(mtex, usize, delimiter);
mathml = mtex2MML_global_parse(mtex, usize, delimiter, 1);
if (mathml == NULL) {
status = 1;
}
Expand All @@ -60,7 +60,7 @@ lsm_mtex_to_mathml (const char *mtex, gssize size, int delimiter, int render_typ
mathml = mtex2MML_output();
break;
default:
mathml = mtex2MML_parse(mtex, usize, delimiter);
mathml = mtex2MML_global_parse(mtex, usize, delimiter, 1);
if (mathml == NULL) {
status = 1;
}
Expand All @@ -82,9 +82,5 @@ lsm_mtex_to_mathml (const char *mtex, gssize size, int delimiter, int render_typ
void
lsm_mtex_free_mathml_buffer (char *mathml)
{
if (mathml == NULL) {
return;
}

mtex2MML_free_string (mathml);
}
6 changes: 2 additions & 4 deletions ext/mathematical/mathematical.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,12 @@ VALUE process(VALUE self, unsigned long maxsize, const char *latex_code, unsigne
lsm_dom_view_render (view, cairo, 0, 0);

switch (format) {
case FORMAT_PNG: {
case FORMAT_PNG:
cairo_surface_write_to_png_stream (cairo_get_target (cairo), cairoPngSurfaceCallback, self);
break;
}
default: {
default:
break;
}
}

cairo_destroy (cairo);
cairo_surface_destroy (surface);
Expand Down

0 comments on commit ec94ba8

Please sign in to comment.