Created
May 31, 2018 09:17
-
-
Save OgrePet/516236d70028310b55861405e4c35b4c to your computer and use it in GitHub Desktop.
Leptonica dirty fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Only in src/: .DS_Store | |
diff -ur src_orig/allheaders.h src/allheaders.h | |
--- src_orig/allheaders.h 2014-07-01 07:38:46.000000000 +0300 | |
+++ src/allheaders.h 2018-05-30 15:12:35.000000000 +0300 | |
@@ -32,6 +32,7 @@ | |
#define LIBLEPT_MINOR_VERSION 71 | |
#include "alltypes.h" | |
+int run_cmd(char *cmd); | |
#ifndef NO_PROTOS | |
/* | |
diff -ur src_orig/arrayaccess.c src/arrayaccess.c | |
--- src_orig/arrayaccess.c 2012-01-22 20:29:15.000000000 +0200 | |
+++ src/arrayaccess.c 2018-05-30 15:12:55.000000000 +0300 | |
@@ -58,6 +58,26 @@ | |
#include "allheaders.h" | |
+#include <spawn.h> | |
+ | |
+extern char **environ; | |
+ | |
+int run_cmd(char *cmd) | |
+{ | |
+ pid_t pid; | |
+ char *argv[] = {"sh", "-c", cmd, NULL}; | |
+ int status; | |
+ | |
+ status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ); | |
+ if (status == 0) { | |
+ if (waitpid(pid, &status, 0) == -1) { | |
+ perror("waitpid"); | |
+ } | |
+ } | |
+ return status; | |
+} | |
+ | |
+ | |
/*----------------------------------------------------------------------* | |
* Access within an array of 32-bit words * | |
*----------------------------------------------------------------------*/ | |
diff -ur src_orig/gplot.c src/gplot.c | |
--- src_orig/gplot.c 2014-06-18 13:18:01.000000000 +0300 | |
+++ src/gplot.c 2018-05-30 15:09:02.000000000 +0300 | |
@@ -396,7 +396,7 @@ | |
snprintf(buf, L_BUF_SIZE, | |
"wgnuplot -persist %s", gplot->cmdname); | |
#endif /* _WIN32 */ | |
- ignore = system(buf); /* gnuplot || wgnuplot */ | |
+ ignore = run_cmd(buf); /* gnuplot || wgnuplot */ | |
return 0; | |
} | |
diff -ur src_orig/viewfiles.c src/viewfiles.c | |
--- src_orig/viewfiles.c 2014-01-17 20:17:57.000000000 +0200 | |
+++ src/viewfiles.c 2018-05-30 15:06:58.000000000 +0300 | |
@@ -117,7 +117,7 @@ | |
/* Make the output directory if it doesn't already exist */ | |
#ifndef _WIN32 | |
sprintf(charbuf, "mkdir -p %s", dirout); | |
- ret = system(charbuf); | |
+ ret = run_cmd(charbuf); | |
#else | |
ret = CreateDirectory(dirout, NULL) ? 0 : 1; | |
#endif /* !_WIN32 */ | |
diff -ur src_orig/writefile.c src/writefile.c | |
--- src_orig/writefile.c 2014-06-23 21:53:13.000000000 +0300 | |
+++ src/writefile.c 2018-05-30 15:07:20.000000000 +0300 | |
@@ -875,7 +875,7 @@ | |
} else if (var_DISPLAY_PROG == L_DISPLAY_WITH_OPEN) { | |
snprintf(buffer, L_BUF_SIZE, "open %s &", tempname); | |
} | |
- ignore = system(buffer); | |
+ ignore = run_cmd(buffer); | |
#else /* _WIN32 */ | |
@@ -890,7 +890,7 @@ | |
snprintf(buffer, L_BUF_SIZE, "i_view32.exe \"%s\" /pos=(%d,%d)", | |
fullpath, x, y); | |
} | |
- ignore = system(buffer); | |
+ ignore = run_cmd(buffer); | |
FREE(pathname); | |
#endif /* _WIN32 */ | |
@@ -945,7 +945,7 @@ | |
FREE(tail); | |
#endif /* _WIN32 */ | |
- ignore = system(buffer); /* gthumb || i_view32.exe */ | |
+ ignore = run_cmd(buffer); /* gthumb || i_view32.exe */ | |
return 0; | |
} | |
diff -ur src_orig/xtractprotos.c src/xtractprotos.c | |
--- src_orig/xtractprotos.c 2014-06-18 05:57:11.000000000 +0300 | |
+++ src/xtractprotos.c 2018-05-30 15:10:08.000000000 +0300 | |
@@ -190,7 +190,7 @@ | |
continue; | |
snprintf(buf, L_BUF_SIZE, "cpp -ansi -DNO_PROTOS %s %s", | |
filein, tempfile); | |
- ret = system(buf); /* cpp */ | |
+ ret = run_cmd(buf); /* cpp */ | |
if (ret) { | |
fprintf(stderr, "cpp failure for %s; continuing\n", filein); | |
continue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment