diff -Nura leptonica-1.83.1/configure.ac leptonica-1.83.1-patch/configure.ac
--- leptonica-1.83.1/configure.ac	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/configure.ac	2024-09-05 14:26:42.598983984 +0800
@@ -252,7 +252,7 @@
 )
 
 # Checks for library functions.
-AC_CHECK_FUNCS([fmemopen])
+#AC_CHECK_FUNCS([fmemopen])
 AC_CHECK_FUNC([fstatat])
 AC_CHECK_FUNC([dirfd])
 
diff -Nura leptonica-1.83.1/prog/adaptmap_dark.c leptonica-1.83.1-patch/prog/adaptmap_dark.c
--- leptonica-1.83.1/prog/adaptmap_dark.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/adaptmap_dark.c	2024-09-05 14:26:11.003618453 +0800
@@ -84,14 +84,14 @@
     GenCleans("cavalerie.11.jpg", &index, 40, bmf);
 
         /* Read the images and convert to a 4-up pixa */
-    pixa1 = convertToNUpPixa("/tmp/lept/adapt", "adapt_", 2, 2, 500,
+    pixa1 = convertToNUpPixa("/data/local/tmp/lept/adapt", "adapt_", 2, 2, 500,
                              6, 2, 0);
 
         /* Convert to pdf */
-    L_INFO("Writing to /tmp/lept/adapt/cleaning.pdf\n", __func__);
+    L_INFO("Writing to /data/local/tmp/lept/adapt/cleaning.pdf\n", __func__);
     pixaConvertToPdf(pixa1, 100, 1.0, L_JPEG_ENCODE,
                      75, "Adaptive cleaning",
-                     "/tmp/lept/adapt/cleaning.pdf");
+                     "/data/local/tmp/lept/adapt/cleaning.pdf");
     pixaDestroy(&pixa1);
 
         /* Test the pixac interleaving.  Make two copies,
@@ -102,7 +102,7 @@
          *   (4) convert back to pixa
          *   (5) convert NUp 1 x 2   (result now is 2 x 2)
          *   (6) output as pdf   */
-    pixa1 = convertToNUpPixa("/tmp/lept/adapt", "adapt_", 2, 1, 500,
+    pixa1 = convertToNUpPixa("/data/local/tmp/lept/adapt", "adapt_", 2, 1, 500,
                              6, 2, 0);
     startTimer();
     pixac1 = pixacompCreateFromPixa(pixa1, IFF_DEFAULT, L_CLONE);
@@ -111,9 +111,9 @@
     pixa2 = pixaCreateFromPixacomp(pixac3, L_CLONE);
     pixa3 = pixaConvertToNUpPixa(pixa2, NULL, 1, 2, 1000, 6, 2, 0);
     lept_stderr("Time with pixac interleaving = %7.3f sec\n", stopTimer());
-    L_INFO("Writing to /tmp/lept/adapt/cleaning2.pdf\n", __func__);
+    L_INFO("Writing to /data/local/tmp/lept/adapt/cleaning2.pdf\n", __func__);
     pixaConvertToPdf(pixa3, 100, 1.0, L_JPEG_ENCODE,
-                     75, "Adaptive cleaning", "/tmp/lept/adapt/cleaning2.pdf");
+                     75, "Adaptive cleaning", "/data/local/tmp/lept/adapt/cleaning2.pdf");
     pixaDestroy(&pixa1);
     pixaDestroy(&pixa2);
     pixaDestroy(&pixa3);
@@ -127,16 +127,16 @@
          *   (2) copy and interleave
          *   (3) convert NUp 1 x 2   (result now is 2 x 2)
          *   (4) output as pdf   */
-    pixa1 = convertToNUpPixa("/tmp/lept/adapt", "adapt_", 2, 1, 500,
+    pixa1 = convertToNUpPixa("/data/local/tmp/lept/adapt", "adapt_", 2, 1, 500,
                              6, 2, 0);
     startTimer();
     pixa2 = pixaCopy(pixa1, L_COPY_CLONE);
     pixa3 = pixaInterleave(pixa1, pixa2, L_CLONE);
     pixa4 = pixaConvertToNUpPixa(pixa3, NULL, 1, 2, 1000, 6, 2, 0);
     lept_stderr("Time with pixa interleaving = %7.3f sec\n", stopTimer());
-    L_INFO("Writing to /tmp/lept/adapt/cleaning3.pdf\n", __func__);
+    L_INFO("Writing to /data/local/tmp/lept/adapt/cleaning3.pdf\n", __func__);
     pixaConvertToPdf(pixa4, 100, 1.0, L_JPEG_ENCODE,
-                     75, "Adaptive cleaning", "/tmp/lept/adapt/cleaning3.pdf");
+                     75, "Adaptive cleaning", "/data/local/tmp/lept/adapt/cleaning3.pdf");
     pixaDestroy(&pixa1);
     pixaDestroy(&pixa2);
     pixaDestroy(&pixa3);
@@ -159,20 +159,20 @@
     whiteval = 180;
     index = *pindex;
     pix1 = pixRead(fname);
-    snprintf(buf, sizeof(buf), "/tmp/lept/adapt/adapt_%03d.jpg", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/adapt/adapt_%03d.jpg", index++);
     pixWrite(buf, pix1, IFF_JFIF_JPEG);
 
     pix2 = pixBackgroundNorm(pix1, NULL, NULL, 10, 15, thresh, 25, 200, 2, 1);
     snprintf(buf, sizeof(buf), "Norm color: fg thresh = %d", thresh);
     lept_stderr("%s\n", buf);
     pix3 = pixAddTextlines(pix2, bmf, buf, 0x00ff0000, L_ADD_BELOW);
-    snprintf(buf, sizeof(buf), "/tmp/lept/adapt/adapt_%03d.jpg", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/adapt/adapt_%03d.jpg", index++);
     pixWrite(buf, pix3, IFF_JFIF_JPEG);
     pixDestroy(&pix3);
     pix3 = pixGammaTRC(NULL, pix2, 1.0, blackval, whiteval);
     snprintf(buf, sizeof(buf), "Clean color: fg thresh = %d", thresh);
     pix4 = pixAddSingleTextblock(pix3, bmf, buf, 0x00ff0000, L_ADD_BELOW, NULL);
-    snprintf(buf, sizeof(buf), "/tmp/lept/adapt/adapt_%03d.jpg", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/adapt/adapt_%03d.jpg", index++);
     pixWrite(buf, pix4, IFF_JFIF_JPEG);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
@@ -183,7 +183,7 @@
     pix4 = pixGammaTRC(NULL, pix3, 1.0, blackval, whiteval);
     snprintf(buf, sizeof(buf), "Clean gray: fg thresh = %d", thresh);
     pix5 = pixAddSingleTextblock(pix4, bmf, buf, 0x00ff0000, L_ADD_BELOW, NULL);
-    snprintf(buf, sizeof(buf), "/tmp/lept/adapt/adapt_%03d.jpg", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/adapt/adapt_%03d.jpg", index++);
     pixWrite(buf, pix5, IFF_JFIF_JPEG);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
diff -Nura leptonica-1.83.1/prog/adaptmap_reg.c leptonica-1.83.1-patch/prog/adaptmap_reg.c
--- leptonica-1.83.1/prog/adaptmap_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/adaptmap_reg.c	2024-09-05 14:26:11.003618453 +0800
@@ -161,7 +161,7 @@
 
         /* Display results */
     pix1 = pixaDisplayTiledAndScaled(pixa, 32, 400, 4, 0, 20, 2);
-    pixWrite("/tmp/lept/adapt/results.jpg", pix1, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/adapt/results.jpg", pix1, IFF_JFIF_JPEG);
     pixDisplayWithTitle(pix1, 50, 0, NULL, rp->display);
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/alltests_reg.c leptonica-1.83.1-patch/prog/alltests_reg.c
--- leptonica-1.83.1/prog/alltests_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/alltests_reg.c	2024-09-05 14:26:11.003618453 +0800
@@ -32,7 +32,7 @@
  *        alltests_reg command
  *
  *    where
- *        <command> == "generate" to make the golden files in /tmp/golden
+ *        <command> == "generate" to make the golden files in /data/local/tmp/golden
  *        <command> == "compare" to make local files and compare with
  *                     the golden files
  *        <command> == "display" to make local files and display
@@ -232,14 +232,14 @@
         /* Clear the output file if we're doing the set of reg tests */
     dotest = strcmp(argv[1], "compare") ? 0 : 1;
     if (dotest) {
-        results_file = genPathname("/tmp/lept", "reg_results.txt");
+        results_file = genPathname("/data/local/tmp/lept", "reg_results.txt");
         sa = sarrayCreate(3);
         sarrayAddString(sa, header, L_COPY);
         sarrayAddString(sa, getLeptonicaVersion(), L_INSERT);
         sarrayAddString(sa, getImagelibVersions(), L_INSERT);
         str = sarrayToString(sa, 1);
         sarrayDestroy(&sa);
-        l_binaryWrite("/tmp/lept/reg_results.txt", "w", str, strlen(str));
+        l_binaryWrite("/data/local/tmp/lept/reg_results.txt", "w", str, strlen(str));
         lept_free(str);
     }
 
@@ -254,7 +254,7 @@
         if (ret) {
             snprintf(buf, sizeof(buf), "Failed to complete %s\n", tests[i]);
             if (dotest) {
-                l_binaryWrite("/tmp/lept/reg_results.txt", "a",
+                l_binaryWrite("/data/local/tmp/lept/reg_results.txt", "a",
                               buf, strlen(buf));
                 nfail++;
             }
diff -Nura leptonica-1.83.1/prog/alphaops_reg.c leptonica-1.83.1-patch/prog/alphaops_reg.c
--- leptonica-1.83.1/prog/alphaops_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/alphaops_reg.c	2024-09-05 14:26:11.003618453 +0800
@@ -90,8 +90,8 @@
     pix3 = pixSetAlphaOverWhite(pix2);
     pixSetSpp(pix3, 3);
             /* without alpha */
-    pixWrite("/tmp/lept/regout/alphaops.2.png", pix3, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/alphaops.2.png");   /* 2 */
+    pixWrite("/data/local/tmp/lept/regout/alphaops.2.png", pix3, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/alphaops.2.png");   /* 2 */
     pixSetSpp(pix3, 4);
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 3, with alpha */
     pixDisplayWithTitle(pix3, 100, 300, NULL, rp->display);
@@ -139,9 +139,9 @@
          * transparent part of the alpha layer, and write that result
          * out as well. */
     pixSetRGBComponent(pixcs1, pixg2, L_ALPHA_CHANNEL);
-    pixWrite("/tmp/lept/alpha/cs1.png", pixcs1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/alpha/cs1.png", pixcs1, IFF_PNG);
     pixcs2 = pixSetUnderTransparency(pixcs1, 0, 0);
-    pixWrite("/tmp/lept/alpha/cs2.png", pixcs2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/alpha/cs2.png", pixcs2, IFF_PNG);
 
         /* What will this look like over a black background?
          * Do the blending explicitly and display.  It should
@@ -156,10 +156,10 @@
          * the alpha layer was fully transparent.  It will
          * look the same when viewed through the alpha layer,
          * but have much better compression. */
-    pix1 = pixRead("/tmp/lept/alpha/cs1.png");  /* just pixcs1 */
-    pix2 = pixRead("/tmp/lept/alpha/cs2.png");  /* cleaned under transparent */
-    n1 = nbytesInFile("/tmp/lept/alpha/cs1.png");
-    n2 = nbytesInFile("/tmp/lept/alpha/cs2.png");
+    pix1 = pixRead("/data/local/tmp/lept/alpha/cs1.png");  /* just pixcs1 */
+    pix2 = pixRead("/data/local/tmp/lept/alpha/cs2.png");  /* cleaned under transparent */
+    n1 = nbytesInFile("/data/local/tmp/lept/alpha/cs1.png");
+    n2 = nbytesInFile("/data/local/tmp/lept/alpha/cs2.png");
     lept_stderr(" Original: %d bytes\n Cleaned: %d bytes\n", n1, n2);
     regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG);  /* 9 */
     regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG);  /* 10 */
@@ -177,7 +177,7 @@
     pixd = pixaDisplayTiledInColumns(pixa, 1, 1.0, 20, 2);
     regTestWritePixAndCheck(rp, pixd, IFF_JFIF_JPEG);  /* 11 */
     pixDisplayWithTitle(pixd, 200, 200, "composite", rp->display);
-    pixWrite("/tmp/lept/alpha/composite.png", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/alpha/composite.png", pixd, IFF_JFIF_JPEG);
     pixDestroy(&pixd);
     pixaDestroy(&pixa);
     pixDestroy(&pixs);
@@ -223,9 +223,9 @@
     }
     if (rp->display) {
         pixaConvertToPdf(pixa2, 0, 0.75, L_FLATE_ENCODE, 0, "blend 1 test",
-                         "/tmp/lept/alpha/blend1.pdf");
+                         "/data/local/tmp/lept/alpha/blend1.pdf");
         pixaConvertToPdf(pixa3, 0, 0.75, L_FLATE_ENCODE, 0, "blend 2 test",
-                         "/tmp/lept/alpha/blend2.pdf");
+                         "/data/local/tmp/lept/alpha/blend2.pdf");
     }
     pixaDestroy(&pixa);
     pixaDestroy(&pixa2);
@@ -262,11 +262,11 @@
     lept_free(data);
 
         /* Test ascii serialization/deserialization of colormap with alpha */
-    if ((fp = fopenWriteStream("/tmp/lept/alpha/cmap.4", "w")) != NULL) {
+    if ((fp = fopenWriteStream("/data/local/tmp/lept/alpha/cmap.4", "w")) != NULL) {
         pixcmapWriteStream(fp, cmap);
         fclose(fp);
     }
-    if ((fp = fopenReadStream("/tmp/lept/alpha/cmap.4")) != NULL) {
+    if ((fp = fopenReadStream("/data/local/tmp/lept/alpha/cmap.4")) != NULL) {
         cmap2 = pixcmapReadStream(fp);
         fclose(fp);
     }
@@ -277,8 +277,8 @@
         /* Test r/w for cmapped pix with non-opaque alpha */
     pixDisplayWithTitle(pix5, 900, 0, NULL, rp->display);
     regTestWritePixAndCheck(rp, pix5, IFF_PNG);  /* 27 */
-    pixWrite("/tmp/lept/alpha/fourcomp.png", pix5, IFF_PNG);
-    pix6 = pixRead("/tmp/lept/alpha/fourcomp.png");
+    pixWrite("/data/local/tmp/lept/alpha/fourcomp.png", pix5, IFF_PNG);
+    pix6 = pixRead("/data/local/tmp/lept/alpha/fourcomp.png");
     regTestComparePix(rp, pix5, pix6);  /* 28 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
diff -Nura leptonica-1.83.1/prog/arabic_lines.c leptonica-1.83.1-patch/prog/arabic_lines.c
--- leptonica-1.83.1/prog/arabic_lines.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/arabic_lines.c	2024-09-05 14:26:11.003618453 +0800
@@ -28,7 +28,7 @@
  * arabic_lines.c
  *
  *   Demonstrates some segmentation techniques and display options.
- *   To see the results in one image: /tmp/lept/lineseg/result.png.
+ *   To see the results in one image: /data/local/tmp/lept/lineseg/result.png.
  *
  *   This demonstration shows many different operations.  However,
  *   better results may be obtained from pixExtractLines()
@@ -138,17 +138,17 @@
     pix2 = selDisplayInPix(selsplit, 31, 2);
     pixaAddPix(pixa, pix2, L_INSERT);
     pix3 = pixaDisplayTiledAndScaled(pixa, 32, 400, 3, 0, 35, 3);
-    pixWrite("/tmp/lept/lineseg/result.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/lineseg/result.png", pix3, IFF_PNG);
     pixDisplay(pix3, 100, 100);
     pixaDestroy(&pixa);
     pixDestroy(&pix3);
     selDestroy(&selsplit);
 
         /* Test pixaa I/O */
-    pixaaWrite("/tmp/lept/lineseg/pixaa", pixaa);
-    pixaa2 = pixaaRead("/tmp/lept/lineseg/pixaa");
-    pixaaWrite("/tmp/lept/lineseg/pixaa2", pixaa2);
-    filesAreIdentical("/tmp/lept/lineseg/pixaa", "/tmp/lept/lineseg/pixaa2",
+    pixaaWrite("/data/local/tmp/lept/lineseg/pixaa", pixaa);
+    pixaa2 = pixaaRead("/data/local/tmp/lept/lineseg/pixaa");
+    pixaaWrite("/data/local/tmp/lept/lineseg/pixaa2", pixaa2);
+    filesAreIdentical("/data/local/tmp/lept/lineseg/pixaa", "/data/local/tmp/lept/lineseg/pixaa2",
                       &same);
     if (!same)
        L_ERROR("pixaa I/O failure\n", __func__);
@@ -156,7 +156,7 @@
 
         /* Test pixaa display */
     pix2 = pixaaDisplay(pixaa, w2, h2);
-    pixWrite("/tmp/lept/lineseg/textlines.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/lineseg/textlines.png", pix2, IFF_PNG);
     pixaaDestroy(&pixaa);
     pixDestroy(&pix2);
 
diff -Nura leptonica-1.83.1/prog/arithtest.c leptonica-1.83.1-patch/prog/arithtest.c
--- leptonica-1.83.1/prog/arithtest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/arithtest.c	2024-09-05 14:26:11.007618374 +0800
@@ -61,16 +61,16 @@
     pixMultConstAccumulate(pix1, 255., 0);
     pix2 = pixFinalAccumulate(pix1, 0, 16);
     l_pngSetReadStrip16To8(0);
-    pixWrite("/tmp/lept/arith/pix1.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/arith/pix1.png", pix2, IFF_PNG);
 
         /* Convert it back to 8 bpp, linear mapped */
     pix3 = pixMaxDynamicRange(pix2, L_LINEAR_SCALE);
-    pixWrite("/tmp/lept/arith/pix2.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/arith/pix2.png", pix3, IFF_PNG);
 
         /* Convert it back to 8 bpp using the MSB */
-    pix4 = pixRead("/tmp/pix1.png");
+    pix4 = pixRead("/data/local/tmp/pix1.png");
     pix5 = pixConvert16To8(pix4, 1);
-    pixWrite("/tmp/lept/arith/pix3.png", pix5, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/arith/pix3.png", pix5, IFF_PNG);
 
     pixDestroy(&pixs);
     pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/autogentest1.c leptonica-1.83.1-patch/prog/autogentest1.c
--- leptonica-1.83.1/prog/autogentest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/autogentest1.c	2024-09-05 14:26:11.007618374 +0800
@@ -27,7 +27,7 @@
 /*
  *  autogentest1.c
  *
- *  This makes /tmp/lept/auto/autogen.137.c and /tmp/lept/auto/autogen.137.h.
+ *  This makes /data/local/tmp/lept/auto/autogen.137.c and /data/local/tmp/lept/auto/autogen.137.h.
  *  It shows how to use the stringcode facility.
  *
  *  In general use, you compile and run the code generator before
@@ -36,10 +36,10 @@
  *  But here, because we compile both autogentest1.c and autogentest2.c
  *  at the same time, it is necessary to put the generated code
  *  in this directory.  Running autogentest1 will simply regenerate
- *  this code, but in the /tmp/lept/auto/ directory.
+ *  this code, but in the /data/local/tmp/lept/auto/ directory.
  *
- *  As part of the test, this makes /tmp/lept/auto/autogen.138.c and
- *  /tmp/lept/auto/autogen.138.h, which contain the same data, using
+ *  As part of the test, this makes /data/local/tmp/lept/auto/autogen.138.c and
+ *  /data/local/tmp/lept/auto/autogen.138.h, which contain the same data, using
  *  the function strcodeCreateFromFile().  With this method, you do not
  *  need to specify the file type (e.g., "PIXA")
  */
@@ -72,9 +72,9 @@
     strcodeFinalize(&strc, NULL);
 
         /* Method 2: generate autogen.138.c and autogen.138.c  */
-    l_binaryWrite("/tmp/lept/auto/fontnames.txt", "w", filetext,
+    l_binaryWrite("/data/local/tmp/lept/auto/fontnames.txt", "w", filetext,
                   strlen(filetext));
-    strcodeCreateFromFile("/tmp/lept/auto/fontnames.txt", 138, NULL);
+    strcodeCreateFromFile("/data/local/tmp/lept/auto/fontnames.txt", 138, NULL);
     return 0;
 }
 
diff -Nura leptonica-1.83.1/prog/autogentest2.c leptonica-1.83.1-patch/prog/autogentest2.c
--- leptonica-1.83.1/prog/autogentest2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/autogentest2.c	2024-09-05 14:26:11.007618374 +0800
@@ -55,8 +55,8 @@
 
     for (i = 0; i < 2; i++) {
        pixa = (PIXA *)l_autodecode_137(i);  /* this is the dispatcher */
-       pixaWrite("/tmp/lept/auto/junkpa.pa", pixa);
-       filesAreIdentical("/tmp/lept/auto/junkpa.pa", files[i], &same);
+       pixaWrite("/data/local/tmp/lept/auto/junkpa.pa", pixa);
+       filesAreIdentical("/data/local/tmp/lept/auto/junkpa.pa", files[i], &same);
        if (same)
            lept_stderr("Files are the same for %s\n", files[i]);
        else
diff -Nura leptonica-1.83.1/prog/barcodetest.c leptonica-1.83.1-patch/prog/barcodetest.c
--- leptonica-1.83.1/prog/barcodetest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/barcodetest.c	2024-09-05 14:26:11.007618374 +0800
@@ -60,15 +60,15 @@
         return ERROR_INT("pixs not made", __func__, 1);
 
     sad1 = pixProcessBarcodes(pixs, L_BF_ANY, L_USE_WIDTHS, &saw1, 0);
-    sarrayWrite("/tmp/lept/barc/saw1.sa", saw1);
-    sarrayWrite("/tmp/lept/barc/sad1.sa", sad1);
+    sarrayWrite("/data/local/tmp/lept/barc/saw1.sa", saw1);
+    sarrayWrite("/data/local/tmp/lept/barc/sad1.sa", sad1);
     sarrayDestroy(&saw1);
     sarrayDestroy(&sad1);
 
     pixRotate180(pixs, pixs);
     sad2 = pixProcessBarcodes(pixs, L_BF_ANY, L_USE_WIDTHS, &saw2, 0);
-    sarrayWrite("/tmp/lept/barc/saw2.sa", saw2);
-    sarrayWrite("/tmp/lept/barc/sad2.sa", sad2);
+    sarrayWrite("/data/local/tmp/lept/barc/saw2.sa", saw2);
+    sarrayWrite("/data/local/tmp/lept/barc/sad2.sa", sad2);
     sarrayDestroy(&saw2);
     sarrayDestroy(&sad2);
 
@@ -76,8 +76,8 @@
 {
     SARRAY  *saw3, *sad3;
     sad3 = pixProcessBarcodes(pixs, L_BF_ANY, L_USE_WINDOW, &saw3, 1);
-    sarrayWrite("/tmp/lept/barc/saw3.sa", saw3);
-    sarrayWrite("/tmp/lept/barc/sad3.sa", sad3);
+    sarrayWrite("/data/local/tmp/lept/barc/saw3.sa", saw3);
+    sarrayWrite("/data/local/tmp/lept/barc/sad3.sa", sad3);
     sarrayDestroy(&saw3);
     sarrayDestroy(&sad3);
 }
diff -Nura leptonica-1.83.1/prog/baseline_reg.c leptonica-1.83.1-patch/prog/baseline_reg.c
--- leptonica-1.83.1/prog/baseline_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/baseline_reg.c	2024-09-05 14:26:11.007618374 +0800
@@ -67,9 +67,9 @@
 
         /* Test function for finding local skew angles */
     na = pixGetLocalSkewAngles(pixs, 10, 0, 0, 0.0, 0.0, 0.0, NULL, NULL, 1);
-    gplotSimple1(na, GPLOT_PNG, "/tmp/lept/baseline/ang", "Angles in degrees");
-    pix2 = pixRead("/tmp/lept/baseline/ang.png");
-    pix3 = pixRead("/tmp/lept/baseline/skew.png");
+    gplotSimple1(na, GPLOT_PNG, "/data/local/tmp/lept/baseline/ang", "Angles in degrees");
+    pix2 = pixRead("/data/local/tmp/lept/baseline/ang.png");
+    pix3 = pixRead("/data/local/tmp/lept/baseline/skew.png");
     regTestWritePixAndCheck(rp, pix2, IFF_PNG);  /* 1 */
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 2 */
     pixDisplayWithTitle(pix2, 0, 550, NULL, rp->display);
@@ -82,9 +82,9 @@
         /* Test baseline finder */
     pixadb = pixaCreate(6);
     na = pixFindBaselines(pix1, &pta, pixadb);
-    pix2 = pixRead("/tmp/lept/baseline/diff.png");
-    pix3 = pixRead("/tmp/lept/baseline/loc.png");
-    pix4 = pixRead("/tmp/lept/baseline/baselines.png");
+    pix2 = pixRead("/data/local/tmp/lept/baseline/diff.png");
+    pix3 = pixRead("/data/local/tmp/lept/baseline/loc.png");
+    pix4 = pixRead("/data/local/tmp/lept/baseline/baselines.png");
     regTestWritePixAndCheck(rp, pix2, IFF_PNG);  /* 3 */
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 4 */
     regTestWritePixAndCheck(rp, pix4, IFF_PNG);  /* 5 */
diff -Nura leptonica-1.83.1/prog/binarizefiles.c leptonica-1.83.1-patch/prog/binarizefiles.c
--- leptonica-1.83.1/prog/binarizefiles.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/binarizefiles.c	2024-09-05 14:26:11.007618374 +0800
@@ -59,7 +59,7 @@
             "               in the directory\n"
             "      thresh: 0 for adaptive; > 0 for global thresh (e.g., 128)\n"
             "      scalefactor: in (0.0 ... 4.0]; use 1.0 to prevent scaling\n"
-            "      subdirout: subdirectory of /tmp for output files\n");
+            "      subdirout: subdirectory of /data/local/tmp for output files\n");
         return 1;
     }
     dirin = argv[1];
diff -Nura leptonica-1.83.1/prog/binarize_set.c leptonica-1.83.1-patch/prog/binarize_set.c
--- leptonica-1.83.1/prog/binarize_set.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/binarize_set.c	2024-09-05 14:26:11.007618374 +0800
@@ -85,7 +85,7 @@
     pixg = pixConvertTo8(pixs, 0);
     pix1 = pixBackgroundNorm(pixg, NULL, NULL, 10, 15, 100, 50, 255, 2, 2);
     pix2 = pixThresholdToBinary(pix1, 160);
-    pixWrite("/tmp/lept/binar/binar1.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/binar/binar1.png", pix2, IFF_PNG);
     pixDisplay(pix2, 100, 0);
     pixaAddPix(pixa, pix2, L_INSERT);
     pixDestroy(&pixg);
@@ -105,7 +105,7 @@
                                     50, 255, 2, 2, 0.10, &threshval);
     lept_stderr("thresh val = %d\n", threshval);
     pixaAddPix(pixa, pix1, L_INSERT);
-    pixWrite("/tmp/lept/binar/binar2.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/binar/binar2.png", pix1, IFF_PNG);
     pixDisplay(pix1, 100, 200);
     pixDestroy(&pixg);
 #endif
@@ -118,7 +118,7 @@
                                            50, 2, 2, 0.10, &threshval);
     lept_stderr("thresh val = %d\n", threshval);
     pixaAddPix(pixa, pix1, L_INSERT);
-    pixWrite("/tmp/lept/binar/binar3.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/binar/binar3.png", pix1, IFF_PNG);
     pixDisplay(pix1, 100, 400);
     pixDestroy(&pixg);
 #endif
@@ -127,7 +127,7 @@
     /* 4. Contrast normalization followed by Sauvola binarization */
     pix1 = pixSauvolaOnContrastNorm(pixs, 130, NULL, NULL);
     pixaAddPix(pixa, pix1, L_INSERT);
-    pixWrite("/tmp/lept/binar/binar4.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/binar/binar4.png", pix1, IFF_PNG);
     pixDisplay(pix1, 100, 600);
 #endif
 
@@ -136,12 +136,12 @@
      * thresholding. */
     pix1 = pixThreshOnDoubleNorm(pixs, 130);
     pixaAddPix(pixa, pix1, L_INSERT);
-    pixWrite("/tmp/lept/binar/binar5.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/binar/binar5.png", pix1, IFF_PNG);
     pixDisplay(pix1, 100, 800);
 #endif
 
     pix1 = pixaDisplayTiledInColumns(pixa, 2, 1.0, 30, 2);
-    pixWrite("/tmp/lept/binar/binar6.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/binar/binar6.png", pix1, IFF_PNG);
     pixDisplay(pix1, 1000, 0);
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/binmorph2_reg.c leptonica-1.83.1-patch/prog/binmorph2_reg.c
--- leptonica-1.83.1/prog/binmorph2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/binmorph2_reg.c	2024-09-05 14:26:11.007618374 +0800
@@ -219,7 +219,7 @@
 
     { SELA *sela;
     sela = selaAddBasic(NULL);
-    selaWrite("/tmp/junksela.sela", sela);
+    selaWrite("/data/local/tmp/junksela.sela", sela);
     selaDestroy(&sela);
     }
 #endif
diff -Nura leptonica-1.83.1/prog/blend2_reg.c leptonica-1.83.1-patch/prog/blend2_reg.c
--- leptonica-1.83.1/prog/blend2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/blend2_reg.c	2024-09-05 14:26:11.007618374 +0800
@@ -38,8 +38,8 @@
 #include "allheaders.h"
 
     /* In case libpng is not enabled */
-static const char fname_png[64] = "/tmp/lept/regout/blend2.14.png";
-static const char fname_bmp[64] = "/tmp/lept/regout/blend2.14.bmp";
+static const char fname_png[64] = "/data/local/tmp/lept/regout/blend2.14.png";
+static const char fname_bmp[64] = "/data/local/tmp/lept/regout/blend2.14.bmp";
 
 
 int main(int    argc,
diff -Nura leptonica-1.83.1/prog/blend3_reg.c leptonica-1.83.1-patch/prog/blend3_reg.c
--- leptonica-1.83.1/prog/blend3_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/blend3_reg.c	2024-09-05 14:26:11.007618374 +0800
@@ -82,7 +82,7 @@
     pixDisplayWithTitle(pixt, 0, 1000, NULL, rp->display);
 
     pixd = pixaDisplayTiledInRows(pixa, 32, 1800, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/regout/blendall.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/blendall.jpg", pixd, IFF_JFIF_JPEG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 
diff -Nura leptonica-1.83.1/prog/blend4_reg.c leptonica-1.83.1-patch/prog/blend4_reg.c
--- leptonica-1.83.1/prog/blend4_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/blend4_reg.c	2024-09-05 14:26:11.007618374 +0800
@@ -91,8 +91,8 @@
     }
 
     pixaConvertToPdf(pixa, 100, 1.0, L_JPEG_ENCODE, 0,
-                     "Blendings: blend4_reg", "/tmp/lept/regout/blend.pdf");
-    L_INFO("Output pdf: /tmp/lept/regout/blend.pdf\n", rp->testname);
+                     "Blendings: blend4_reg", "/data/local/tmp/lept/regout/blend.pdf");
+    L_INFO("Output pdf: /data/local/tmp/lept/regout/blend.pdf\n", rp->testname);
     pixDestroy(&pix0);
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/blendcmaptest.c leptonica-1.83.1-patch/prog/blendcmaptest.c
--- leptonica-1.83.1/prog/blendcmaptest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/blendcmaptest.c	2024-09-05 14:26:11.007618374 +0800
@@ -98,9 +98,9 @@
     pixaAddPix(pixa, pix2, L_COPY);
     cmap = pixGetColormap(pix2);
     pixcmapWriteStream(stderr, cmap);
-    lept_stderr("Writing to: /tmp/lept/blend/blendcmap.pdf\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/blend/blendcmap.pdf\n");
     pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, "cmap-blendtest",
-                     "/tmp/lept/blend/blendcmap.pdf");
+                     "/data/local/tmp/lept/blend/blendcmap.pdf");
 
     pixDestroy(&pixs);
     pixDestroy(&pixb);
diff -Nura leptonica-1.83.1/prog/boxa1_reg.c leptonica-1.83.1-patch/prog/boxa1_reg.c
--- leptonica-1.83.1/prog/boxa1_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/boxa1_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -106,9 +106,9 @@
     boxa1 = boxaReadMem(data1, size1);
     boxaWriteMem(&data2, &size2, boxa1);
     boxa2 = boxaReadMem(data2, size2);
-    boxaWrite("/tmp/lept/boxa/boxa1.ba", boxa1);
-    boxaWrite("/tmp/lept/boxa/boxa2.ba", boxa2);
-    filesAreIdentical("/tmp/lept/boxa/boxa1.ba", "/tmp/lept/boxa/boxa2.ba",
+    boxaWrite("/data/local/tmp/lept/boxa/boxa1.ba", boxa1);
+    boxaWrite("/data/local/tmp/lept/boxa/boxa2.ba", boxa2);
+    filesAreIdentical("/data/local/tmp/lept/boxa/boxa1.ba", "/data/local/tmp/lept/boxa/boxa2.ba",
                       &same);
     regTestCompareValues(rp, 1, same, 0.0);  /* 8 */
     boxaDestroy(&boxa1);
diff -Nura leptonica-1.83.1/prog/boxa4_reg.c leptonica-1.83.1-patch/prog/boxa4_reg.c
--- leptonica-1.83.1/prog/boxa4_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/boxa4_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -117,7 +117,7 @@
                                      L_ADJUST_TOP_AND_BOT, 50, 0, pixa1);
     boxaWriteMem(&data, &size, boxa2);
     regTestWriteDataAndCheck(rp, data, size, "ba");  /* 5 */
-    pix1 = pixRead("/tmp/lept/boxa/recon_sides.png");
+    pix1 = pixRead("/data/local/tmp/lept/boxa/recon_sides.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 6 */
     pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
     lept_free(data);
@@ -131,7 +131,7 @@
                                      L_ADJUST_TOP_AND_BOT, 50, 0, pixa1);
     boxaWriteMem(&data, &size, boxa2);
     regTestWriteDataAndCheck(rp, data, size, "ba");  /* 7 */
-    pix1 = pixRead("/tmp/lept/boxa/recon_sides.png");
+    pix1 = pixRead("/data/local/tmp/lept/boxa/recon_sides.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 8 */
     pixDisplayWithTitle(pix1, 0, 300, NULL, rp->display);
     lept_free(data);
@@ -208,10 +208,10 @@
     pix1 = pixaDisplayTiledInRows(pixa2, 32, 1400, 1.0, 0, 10, 0);
     regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG);  /* 12 */
     pixDisplayWithTitle(pix1, 0, 600, NULL, rp->display);
-    lept_stderr("Writing to: /tmp/lept/boxa/show.pdf\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/boxa/show.pdf\n");
     l_pdfSetDateAndVersion(FALSE);
-    pixaConvertToPdf(pixa2, 75, 0.6, 0, 0, NULL, "/tmp/lept/boxa/show.pdf");
-    regTestCheckFile(rp, "/tmp/lept/boxa/show.pdf");  /* 13 */
+    pixaConvertToPdf(pixa2, 75, 0.6, 0, 0, NULL, "/data/local/tmp/lept/boxa/show.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/boxa/show.pdf");  /* 13 */
     pixDestroy(&pix1);
     pixaDestroy(&pixa1);
     pixaDestroy(&pixa2);
diff -Nura leptonica-1.83.1/prog/buffertest.c leptonica-1.83.1-patch/prog/buffertest.c
--- leptonica-1.83.1/prog/buffertest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/buffertest.c	2024-09-05 14:26:11.011618296 +0800
@@ -64,9 +64,9 @@
     l_binaryWrite(fileout, "w", dataout, nout);
 
     dataout2 = zlibUncompress(dataout, nout, &nout2);
-    l_binaryWrite("/tmp/dataout2", "w", dataout2, nout2);
+    l_binaryWrite("/data/local/tmp/dataout2", "w", dataout2, nout2);
 
-    filesAreIdentical(filein, "/tmp/dataout2", &same);
+    filesAreIdentical(filein, "/data/local/tmp/dataout2", &same);
     if (same)
         lept_stderr("Correct: data is the same\n");
     else
diff -Nura leptonica-1.83.1/prog/bytea_reg.c leptonica-1.83.1-patch/prog/bytea_reg.c
--- leptonica-1.83.1/prog/bytea_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/bytea_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -68,8 +68,8 @@
     size1 = l_byteaGetSize(lba1);
     size2 = l_byteaGetSize(lba2);
     l_byteaJoin(lba1, &lba3);  /* destroys lba3 */
-    l_byteaWrite("/tmp/lept/bytea/lba2.bya", lba2, 0, 0);
-    regTestCheckFile(rp, "/tmp/lept/bytea/lba2.bya");  /* 0 */
+    l_byteaWrite("/data/local/tmp/lept/bytea/lba2.bya", lba2, 0, 0);
+    regTestCheckFile(rp, "/data/local/tmp/lept/bytea/lba2.bya");  /* 0 */
 
         /* Test split, using init from memory */
     lba3 = l_byteaInitFromMem(lba1->data, size1);
@@ -154,9 +154,9 @@
     lept_free(data2);
 
         /* Test search */
-    convertToPdf("test24.jpg", L_JPEG_ENCODE, 0, "/tmp/lept/bytea/test24.pdf",
+    convertToPdf("test24.jpg", L_JPEG_ENCODE, 0, "/data/local/tmp/lept/bytea/test24.pdf",
                  0, 0, 100, NULL, NULL, 0);
-    lba1 = l_byteaInitFromFile("/tmp/lept/bytea/test24.pdf");
+    lba1 = l_byteaInitFromFile("/data/local/tmp/lept/bytea/test24.pdf");
     l_byteaFindEachSequence(lba1, (l_uint8 *)" 0 obj\n", 7, &da);
     n = l_dnaGetCount(da);
     regTestCompareValues(rp, 6, n, 0.0);  /* 6 */
@@ -166,12 +166,12 @@
         /* Test write to file */
     lba1 = l_byteaInitFromFile("feyn.tif");
     size1 = l_byteaGetSize(lba1);
-    fp = lept_fopen("/tmp/lept/bytea/feyn.dat", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/bytea/feyn.dat", "wb");
     for (start = 0; start < size1; start += 1000) {
          l_byteaWriteStream(fp, lba1, start, 1000);
     }
     lept_fclose(fp);
-    lba2 = l_byteaInitFromFile("/tmp/lept/bytea/feyn.dat");
+    lba2 = l_byteaInitFromFile("/data/local/tmp/lept/bytea/feyn.dat");
     regTestCompareStrings(rp, lba1->data, size1, lba2->data,
                           lba2->size);  /* 7 */
     l_byteaDestroy(&lba1);
diff -Nura leptonica-1.83.1/prog/ccbord_reg.c leptonica-1.83.1-patch/prog/ccbord_reg.c
--- leptonica-1.83.1/prog/ccbord_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/ccbord_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -127,7 +127,7 @@
                     lept_stderr("bad pixel at (%d, %d)\n", j, i);
             }
         }
-        pixWrite("/tmp/lept/ccbord/badpixels1.png", pixc, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/ccbord/badpixels1.png", pixc, IFF_PNG);
 #endif
     }
 
@@ -135,9 +135,9 @@
      *        Write to file (compressed) and read back          *
      *----------------------------------------------------------*/
     if (disp) lept_stderr("Write serialized step data...");
-    ccbaWrite("/tmp/lept/ccbord/stepdata.ccb", ccba);
+    ccbaWrite("/data/local/tmp/lept/ccbord/stepdata.ccb", ccba);
     if (disp) lept_stderr("read serialized step data...");
-    ccba2 = ccbaRead("/tmp/lept/ccbord/stepdata.ccb");
+    ccba2 = ccbaRead("/data/local/tmp/lept/ccbord/stepdata.ccb");
 
         /* Display the border pixels again */
     if (disp) lept_stderr("convert from step chain to global locs...");
@@ -184,7 +184,7 @@
                     lept_stderr("bad pixel at (%d, %d)\n", j, i);
             }
         }
-        pixWrite("/tmp/lept/ccbord/badpixels2.png", pixc, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/ccbord/badpixels2.png", pixc, IFF_PNG);
 #endif
     }
 
diff -Nura leptonica-1.83.1/prog/ccbordtest.c leptonica-1.83.1-patch/prog/ccbordtest.c
--- leptonica-1.83.1/prog/ccbordtest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/ccbordtest.c	2024-09-05 14:26:11.011618296 +0800
@@ -70,7 +70,7 @@
     startTimer();
     pixd = ccbaDisplayBorder(ccba);
     lept_stderr("%6.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/ccbord/junkborder1.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/ccbord/junkborder1.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
         /* Get step chain code, then global coords, and display borders */
@@ -86,7 +86,7 @@
     startTimer();
     pixd = ccbaDisplayBorder(ccba);
     lept_stderr("%6.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/ccbord/junkborder1.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/ccbord/junkborder1.png", pixd, IFF_PNG);
 
         /* Check if border pixels are in original set */
     lept_stderr("Check if border pixels are in original set ...\n");
@@ -104,7 +104,7 @@
 /*    pixc = ccbaDisplayImage1(ccba); */
     pixc = ccbaDisplayImage2(ccba);
     lept_stderr("%6.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/ccbord/junkrecon1.png", pixc, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/ccbord/junkrecon1.png", pixc, IFF_PNG);
 
         /* check with original to see if correct */
     lept_stderr("Check with original to see if correct ...\n");
@@ -126,7 +126,7 @@
                     lept_stderr("bad pixel at (%d, %d)\n", j, i);
             }
         }
-        pixWrite("/tmp/lept/ccbord/junkbadpixels.png", pixc, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/ccbord/junkbadpixels.png", pixc, IFF_PNG);
 #endif
     }
 
@@ -136,11 +136,11 @@
      *----------------------------------------------------------*/
     lept_stderr("Write serialized step data...");
     startTimer();
-    ccbaWrite("/tmp/junkstepout", ccba);
+    ccbaWrite("/data/local/tmp/junkstepout", ccba);
     lept_stderr("%6.3f sec\n", stopTimer());
     lept_stderr("Read serialized step data...");
     startTimer();
-    ccba2 = ccbaRead("/tmp/junkstepout");
+    ccba2 = ccbaRead("/data/local/tmp/junkstepout");
     lept_stderr("%6.3f sec\n", stopTimer());
 
         /* display the border pixels again */
@@ -152,7 +152,7 @@
     startTimer();
     pixd2 = ccbaDisplayBorder(ccba2);
     lept_stderr("%6.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/ccbord/junkborder2.png", pixd2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/ccbord/junkborder2.png", pixd2, IFF_PNG);
 
         /* check if border pixels are same as first time */
     pixXor(pixd2, pixd2, pixd);
@@ -173,7 +173,7 @@
 /*    pixc2 = ccbaDisplayImage1(ccba2); */
     pixc2 = ccbaDisplayImage2(ccba2);
     lept_stderr("%6.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/ccbord/junkrecon2.png", pixc2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/ccbord/junkrecon2.png", pixc2, IFF_PNG);
 
         /* check with original to see if correct */
     lept_stderr("Check with original to see if correct ...\n");
@@ -195,7 +195,7 @@
                     lept_stderr("bad pixel at (%d, %d)\n", j, i);
             }
         }
-        pixWrite("/tmp/lept/ccbord/junkbadpixels2.png", pixc2, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/ccbord/junkbadpixels2.png", pixc2, IFF_PNG);
 #endif
     }
 
@@ -217,7 +217,7 @@
     startTimer();
     pixd3 = ccbaDisplaySPBorder(ccba);
     lept_stderr("%6.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/ccbord/junkborder3.png", pixd3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/ccbord/junkborder3.png", pixd3, IFF_PNG);
         /* check if border pixels are in original set */
     lept_stderr("Check if border pixels are in original set ...\n");
     pixt = pixSubtract(NULL, pixd3, pixs);
@@ -232,7 +232,7 @@
         /*  output in svg file format */
     lept_stderr("Write output in svg file format ...\n");
     startTimer();
-    ccbaWriteSVG("/tmp/junksvg", ccba);
+    ccbaWriteSVG("/data/local/tmp/junksvg", ccba);
     lept_stderr("%6.3f sec\n", stopTimer());
 
     ccbaDestroy(&ccba2);
diff -Nura leptonica-1.83.1/prog/ccthin1_reg.c leptonica-1.83.1-patch/prog/ccthin1_reg.c
--- leptonica-1.83.1/prog/ccthin1_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/ccthin1_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -155,9 +155,9 @@
         /* Optional display */
     if (rp->display) {
         lept_mkdir("/lept/thin");
-        lept_stderr("Writing to: /tmp/lept/thin/ccthin1-1.pdf");
+        lept_stderr("Writing to: /data/local/tmp/lept/thin/ccthin1-1.pdf");
         pixaConvertToPdf(pixa, 0, 1.0, 0, 0, "Thin 1 Sels",
-                         "/tmp/lept/thin/ccthin1-1.pdf");
+                         "/data/local/tmp/lept/thin/ccthin1-1.pdf");
     }
     pixaDestroy(&pixa);
 
@@ -192,9 +192,9 @@
     pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
     pixDestroy(&pix1);
     if (rp->display) {
-        lept_stderr("Writing to: /tmp/lept/thin/ccthin1-2.pdf");
+        lept_stderr("Writing to: /data/local/tmp/lept/thin/ccthin1-2.pdf");
         pixaConvertToPdf(pixa, 0, 1.0, 0, 0, "Thin 1 Results",
-                         "/tmp/lept/thin/ccthin1-2.pdf");
+                         "/data/local/tmp/lept/thin/ccthin1-2.pdf");
     }
     pixaDestroy(&pixa);
 
diff -Nura leptonica-1.83.1/prog/ccthin2_reg.c leptonica-1.83.1-patch/prog/ccthin2_reg.c
--- leptonica-1.83.1/prog/ccthin2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/ccthin2_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -142,9 +142,9 @@
     if (rp->display) {
         lept_mkdir("lept/thin");
         pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
-        lept_stderr("Writing to: /tmp/lept/thin/ccthin2-1.pdf");
+        lept_stderr("Writing to: /data/local/tmp/lept/thin/ccthin2-1.pdf");
         pixaConvertToPdf(pixa1, 0, 1.0, 0, 0, "Thin 2 Results",
-                         "/tmp/lept/thin/ccthin2-1.pdf");
+                         "/data/local/tmp/lept/thin/ccthin2-1.pdf");
     }
     pixDestroy(&pix1);
     pixDestroy(&pixs);
@@ -177,9 +177,9 @@
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 18 */
     if (rp->display) {
         pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
-        lept_stderr("Writing to: /tmp/lept/thin/ccthin2-2.pdf");
+        lept_stderr("Writing to: /data/local/tmp/lept/thin/ccthin2-2.pdf");
         pixaConvertToPdf(pixa5, 0, 1.0, 0, 0, "Thin strokes",
-                         "/tmp/lept/thin/ccthin2-2.pdf");
+                         "/data/local/tmp/lept/thin/ccthin2-2.pdf");
     }
     pixaaDestroy(&paa);
     pixaDestroy(&pixa1);
diff -Nura leptonica-1.83.1/prog/colorcontent_reg.c leptonica-1.83.1-patch/prog/colorcontent_reg.c
--- leptonica-1.83.1/prog/colorcontent_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/colorcontent_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -42,7 +42,7 @@
              char **argv)
 {
 //char         *fname[64];
-char          fname[] = "/tmp/lept/colorcontent/maskgen.pdf";
+char          fname[] = "/data/local/tmp/lept/colorcontent/maskgen.pdf";
 l_uint32     *colors;
 l_int32       ncolors, w, h;
 l_float32     fcolor;
diff -Nura leptonica-1.83.1/prog/coloring_reg.c leptonica-1.83.1-patch/prog/coloring_reg.c
--- leptonica-1.83.1/prog/coloring_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/coloring_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -147,8 +147,8 @@
         /* If in testing mode, make a pdf */
     if (rp->display) {
         pixaConvertToPdf(pixa, 100, 1.0, L_FLATE_ENCODE, 0,
-                         "Colored background", "/tmp/lept/regout/coloring.pdf");
-        L_INFO("Output pdf: /tmp/lept/regout/coloring.pdf\n", rp->testname);
+                         "Colored background", "/data/local/tmp/lept/regout/coloring.pdf");
+        L_INFO("Output pdf: /data/local/tmp/lept/regout/coloring.pdf\n", rp->testname);
     }
 
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/colorize_reg.c leptonica-1.83.1-patch/prog/colorize_reg.c
--- leptonica-1.83.1/prog/colorize_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/colorize_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -209,9 +209,9 @@
 
         /* Generate a pdf of the intermediate results */
     lept_mkdir("lept/color");
-    L_INFO("Writing to /tmp/lept/color/colorize.pdf\n", rp->testname);
+    L_INFO("Writing to /data/local/tmp/lept/color/colorize.pdf\n", rp->testname);
     pixaConvertToPdf(pixa, 90, 1.0, 0, 0, "Colorizing highlighted text",
-                     "/tmp/lept/color/colorize.pdf");
+                     "/data/local/tmp/lept/color/colorize.pdf");
 
 
     pixaDestroy(&pixa);
@@ -254,9 +254,9 @@
     pixaAddPix(pixa, pix1, L_INSERT);
 
         /* Generate a pdf of the color detector results */
-    L_INFO("Writing to /tmp/lept/color/colordetect.pdf\n", rp->testname);
+    L_INFO("Writing to /data/local/tmp/lept/color/colordetect.pdf\n", rp->testname);
     pixaConvertToPdf(pixa, 45, 1.0, 0, 0, "Color detection",
-                     "/tmp/lept/color/colordetect.pdf");
+                     "/data/local/tmp/lept/color/colordetect.pdf");
     pixaDestroy(&pixa);
     bmfDestroy(&bmf);
 
diff -Nura leptonica-1.83.1/prog/colormask_reg.c leptonica-1.83.1-patch/prog/colormask_reg.c
--- leptonica-1.83.1/prog/colormask_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/colormask_reg.c	2024-09-05 14:26:11.011618296 +0800
@@ -91,15 +91,15 @@
     pixaAddPix(pixa, pixhsv, L_INSERT);
     pixaAddPix(pixa, pixg, L_INSERT);
     pixaAddPix(pixa, pixf, L_INSERT);
-    gplotSimple1(nahue, GPLOT_PNG, "/tmp/lept/regout/junkhue",
+    gplotSimple1(nahue, GPLOT_PNG, "/data/local/tmp/lept/regout/junkhue",
                  "Histogram of hue values");
-    pix3 = pixRead("/tmp/lept/regout/junkhue.png");
+    pix3 = pixRead("/data/local/tmp/lept/regout/junkhue.png");
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 1 */
     pixDisplayWithTitle(pix3, 100, 300, "Histo of hue", rp->display);
     pixaAddPix(pixa, pix3, L_INSERT);
-    gplotSimple1(nasat, GPLOT_PNG, "/tmp/lept/regout/junksat",
+    gplotSimple1(nasat, GPLOT_PNG, "/data/local/tmp/lept/regout/junksat",
                  "Histogram of saturation values");
-    pix3 = pixRead("/tmp/lept/regout/junksat.png");
+    pix3 = pixRead("/data/local/tmp/lept/regout/junksat.png");
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 2 */
     pixDisplayWithTitle(pix3, 100, 800, "Histo of saturation", rp->display);
     pixaAddPix(pixa, pix3, L_INSERT);
diff -Nura leptonica-1.83.1/prog/colormorph_reg.c leptonica-1.83.1-patch/prog/colormorph_reg.c
--- leptonica-1.83.1/prog/colormorph_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/colormorph_reg.c	2024-09-05 14:26:11.015618218 +0800
@@ -86,12 +86,12 @@
 
     if (rp->display) {
         lept_mkdir("lept/cmorph");
-        lept_stderr("Writing to: /tmp/lept/cmorph/colormorph.pdf\n");
+        lept_stderr("Writing to: /data/local/tmp/lept/cmorph/colormorph.pdf\n");
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, "colormorph-test",
-                         "/tmp/lept/cmorph/colormorph.pdf");
-        lept_stderr("Writing to: /tmp/lept/cmorph/colormorph.jpg\n");
+                         "/data/local/tmp/lept/cmorph/colormorph.pdf");
+        lept_stderr("Writing to: /data/local/tmp/lept/cmorph/colormorph.jpg\n");
         pix1 = pixaDisplayTiledInColumns(pixa, 2, 1.0, 30, 2);
-        pixWrite("/tmp/lept/cmorph/colormorph.jpg", pix1, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/cmorph/colormorph.jpg", pix1, IFF_JFIF_JPEG);
         pixDisplay(pix1, 100, 100);
         pixDestroy(&pix1);
     }
diff -Nura leptonica-1.83.1/prog/colorquant_reg.c leptonica-1.83.1-patch/prog/colorquant_reg.c
--- leptonica-1.83.1/prog/colorquant_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/colorquant_reg.c	2024-09-05 14:26:11.015618218 +0800
@@ -217,7 +217,7 @@
 
     pixd = pixaDisplayTiledInColumns(pixa, 4, 1.0, 25, 2);
     pixDisplayWithTitle(pixd, 100, 100, NULL, rp->display);
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/disp.%d.jpg", i);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/disp.%d.jpg", i);
     pixWrite(buf, pixd, IFF_JFIF_JPEG);
 
     pixDestroy(&pixs);
diff -Nura leptonica-1.83.1/prog/colorspace_reg.c leptonica-1.83.1-patch/prog/colorspace_reg.c
--- leptonica-1.83.1/prog/colorspace_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/colorspace_reg.c	2024-09-05 14:26:11.015618218 +0800
@@ -161,10 +161,10 @@
         }
         pixDestroy(&pix1);
     }
-    gplot1 = gplotCreate("/tmp/lept/regout/colorspace.10", GPLOT_PNG,
+    gplot1 = gplotCreate("/data/local/tmp/lept/regout/colorspace.10", GPLOT_PNG,
                          "Fraction with given color (diff from average)",
                          "white point space for red", "amount of color");
-    gplot2 = gplotCreate("/tmp/lept/regout/colorspace.11", GPLOT_PNG,
+    gplot2 = gplotCreate("/data/local/tmp/lept/regout/colorspace.11", GPLOT_PNG,
                          "Fraction with given color (min diff)",
                          "white point space for red", "amount of color");
     for (j = 0; j < 6; j++) {
@@ -190,17 +190,17 @@
     numaaDestroy(&naa2);
 
         /* Save as golden files, or check against them */
-    regTestCheckFile(rp, "/tmp/lept/regout/colorspace.10.png");  /* 10 */
-    regTestCheckFile(rp, "/tmp/lept/regout/colorspace.11.png");  /* 11 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/colorspace.10.png");  /* 10 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/colorspace.11.png");  /* 11 */
 
     if (rp->display) {
-        pix3 = pixRead("/tmp/lept/regout/colorspace.10.png");
+        pix3 = pixRead("/data/local/tmp/lept/regout/colorspace.10.png");
         pixaAddPix(pixa, pix3, L_INSERT);
-        pix3 = pixRead("/tmp/lept/regout/colorspace.11.png");
+        pix3 = pixRead("/data/local/tmp/lept/regout/colorspace.11.png");
         pixaAddPix(pixa, pix3, L_INSERT);
         pixaConvertToPdf(pixa, 0, 1.0, 0, 0, "colorspace tests",
-                         "/tmp/lept/regout/colorspace.pdf");
-        L_INFO("Output pdf: /tmp/lept/regout/colorspace.pdf\n", rp->testname);
+                         "/data/local/tmp/lept/regout/colorspace.pdf");
+        L_INFO("Output pdf: /data/local/tmp/lept/regout/colorspace.pdf\n", rp->testname);
     }
     pixaDestroy(&pixa);
 
diff -Nura leptonica-1.83.1/prog/comparepages.c leptonica-1.83.1-patch/prog/comparepages.c
--- leptonica-1.83.1/prog/comparepages.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/comparepages.c	2024-09-05 14:26:11.015618218 +0800
@@ -55,9 +55,9 @@
     pixGetWordBoxesInTextlines(pixb1, 10, 10, 500, 50, &boxa1, &nai1);
     pixt = pixDrawBoxaRandom(pixs, boxa1, 2);
     pixDisplay(pixt, 100, 100);
-    pixWrite("/tmp/lept/comp/pixt.png", pixt, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/comp/pixt.png", pixt, IFF_PNG);
     naa1 = boxaExtractSortedPattern(boxa1, nai1);
-    numaaWrite("/tmp/lept/comp/naa1.naa", naa1);
+    numaaWrite("/data/local/tmp/lept/comp/naa1.naa", naa1);
     n = numaaGetCount(naa1);
     lept_stderr("Number of textlines = %d\n", n);
     pixDisplay(pixb1, 300, 0);
diff -Nura leptonica-1.83.1/prog/compare_reg.c leptonica-1.83.1-patch/prog/compare_reg.c
--- leptonica-1.83.1/prog/compare_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/compare_reg.c	2024-09-05 14:26:11.015618218 +0800
@@ -86,8 +86,8 @@
     lept_stderr("delx = %d, dely = %d, score = %7.4f\n", delx, dely, score);
     regTestCompareValues(rp, 32, delx, 0);   /* 0 */
     regTestCompareValues(rp, 12, dely, 0);   /* 1 */
-    lept_mv("/tmp/lept/comp/correl_5.png", "lept/regout", NULL, NULL);
-    regTestCheckFile(rp, "/tmp/lept/regout/correl_5.png");   /* 2 */
+    lept_mv("/data/local/tmp/lept/comp/correl_5.png", "lept/regout", NULL, NULL);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/correl_5.png");   /* 2 */
     lept_free(stab);
     lept_free(ctab);
     pixDestroy(&pix0);
@@ -108,10 +108,10 @@
     lept_stderr("delx = %d, dely = %d\n", delx, dely);
     regTestCompareValues(rp, 45, delx, 0);   /* 3 */
     regTestCompareValues(rp, -25, dely, 0);   /* 4 */
-    lept_mv("/tmp/lept/comp/correl.pdf", "lept/regout", NULL, NULL);
-    lept_mv("/tmp/lept/comp/compare.pdf", "lept/regout", NULL, NULL);
-    regTestCheckFile(rp, "/tmp/lept/regout/compare.pdf");   /* 5 */
-    regTestCheckFile(rp, "/tmp/lept/regout/correl.pdf");  /* 6 */
+    lept_mv("/data/local/tmp/lept/comp/correl.pdf", "lept/regout", NULL, NULL);
+    lept_mv("/data/local/tmp/lept/comp/compare.pdf", "lept/regout", NULL, NULL);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/compare.pdf");   /* 5 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/correl.pdf");  /* 6 */
 
     /* ------------ Test of pixGetPerceptualDiff() --------------- */
     pix0 = pixRead("greencover.jpg");
diff -Nura leptonica-1.83.1/prog/comparetest.c leptonica-1.83.1-patch/prog/comparetest.c
--- leptonica-1.83.1/prog/comparetest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/comparetest.c	2024-09-05 14:26:11.015618218 +0800
@@ -138,13 +138,13 @@
                 lept_stderr("Nonzero diff range: first = %d, last = %d\n",
                              first, last);
                 na2 = numaClipToInterval(na1, first, last);
-                gplot = gplotCreate("/tmp/lept/comp/rank", GPLOT_PNG,
+                gplot = gplotCreate("/data/local/tmp/lept/comp/rank", GPLOT_PNG,
                                     "Pixel Rank Difference",
                                     "pixel val difference", "rank");
                 gplotAddPlot(gplot, NULL, na2, GPLOT_LINES, "rank");
                 gplotMakeOutput(gplot);
                 gplotDestroy(&gplot);
-                l_fileDisplay("/tmp/lept/comp/rank.png", 100, 100, 1.0);
+                l_fileDisplay("/data/local/tmp/lept/comp/rank.png", 100, 100, 1.0);
                 numaDestroy(&na1);
                 numaDestroy(&na2);
             }
diff -Nura leptonica-1.83.1/prog/compfilter_reg.c leptonica-1.83.1-patch/prog/compfilter_reg.c
--- leptonica-1.83.1/prog/compfilter_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/compfilter_reg.c	2024-09-05 14:26:11.015618218 +0800
@@ -285,7 +285,7 @@
     if (rp->display) {
         pix1 = pixaDisplayTiledInColumns(pixa3, 2, 0.25, 25, 2);
         pixDisplay(pix1, 100, 100);
-        pixWrite("/tmp/lept/filter/result.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/filter/result.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
     pixaDestroy(&pixa3);
diff -Nura leptonica-1.83.1/prog/conncomp_reg.c leptonica-1.83.1-patch/prog/conncomp_reg.c
--- leptonica-1.83.1/prog/conncomp_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/conncomp_reg.c	2024-09-05 14:26:11.015618218 +0800
@@ -105,17 +105,17 @@
      * --------------------------------------------------------------- */
     lept_mkdir("lept/conn");
     boxa1 = pixConnComp(pixs, NULL, 4);
-    fp = lept_fopen("/tmp/lept/conn/boxa1.ba", "wb+");
+    fp = lept_fopen("/data/local/tmp/lept/conn/boxa1.ba", "wb+");
     boxaWriteStream(fp, boxa1);
     lept_fclose(fp);
-    fp = lept_fopen("/tmp/lept/conn/boxa1.ba", "rb");
+    fp = lept_fopen("/data/local/tmp/lept/conn/boxa1.ba", "rb");
     boxa2 = boxaReadStream(fp);
     lept_fclose(fp);
-    fp = lept_fopen("/tmp/lept/conn/boxa2.ba", "wb+");
+    fp = lept_fopen("/data/local/tmp/lept/conn/boxa2.ba", "wb+");
     boxaWriteStream(fp, boxa2);
     lept_fclose(fp);
-    array1 = l_binaryRead("/tmp/lept/conn/boxa1.ba", &size1);
-    array2 = l_binaryRead("/tmp/lept/conn/boxa2.ba", &size2);
+    array1 = l_binaryRead("/data/local/tmp/lept/conn/boxa1.ba", &size1);
+    array2 = l_binaryRead("/data/local/tmp/lept/conn/boxa2.ba", &size2);
     regTestCompareStrings(rp, array1, size1, array2, size2);  /* 10 */
     lept_free(array1);
     lept_free(array2);
diff -Nura leptonica-1.83.1/prog/contrasttest.c leptonica-1.83.1-patch/prog/contrasttest.c
--- leptonica-1.83.1/prog/contrasttest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/contrasttest.c	2024-09-05 14:26:11.015618218 +0800
@@ -64,13 +64,13 @@
         return ERROR_INT("pixs not made", __func__, 1);
 
     na = numaContrastTRC(factor);
-    gplotSimple1(na, GPLOT_PNG, "/tmp/lept/contrast/trc1", "contrast trc");
-    l_fileDisplay("/tmp/lept/contrast/trc1.png", 0, 100, 1.0);
+    gplotSimple1(na, GPLOT_PNG, "/data/local/tmp/lept/contrast/trc1", "contrast trc");
+    l_fileDisplay("/data/local/tmp/lept/contrast/trc1.png", 0, 100, 1.0);
     numaDestroy(&na);
 
          /* Plot contrast TRC maps */
     nax = numaMakeSequence(0.0, 1.0, 256);
-    gplot = gplotCreate("/tmp/lept/contrast/trc2", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/contrast/trc2", GPLOT_PNG,
         "Atan mapping function for contrast enhancement",
         "value in", "value out");
     for (iplot = 0; fact[iplot] >= 0.0; iplot++) {
@@ -81,7 +81,7 @@
     }
     gplotMakeOutput(gplot);
     gplotDestroy(&gplot);
-    l_fileDisplay("/tmp/lept/contrast/trc2.png", 600, 100, 1.0);
+    l_fileDisplay("/data/local/tmp/lept/contrast/trc2.png", 600, 100, 1.0);
     numaDestroy(&nax);
 
         /* Apply the input contrast enhancement */
diff -Nura leptonica-1.83.1/prog/convertsegfilestopdf.c leptonica-1.83.1-patch/prog/convertsegfilestopdf.c
--- leptonica-1.83.1/prog/convertsegfilestopdf.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/convertsegfilestopdf.c	2024-09-05 14:26:11.015618218 +0800
@@ -37,14 +37,14 @@
  *    for its substring.
  *
  *    A typical invocation would be something like:
- *       convertsegfilestopdf /tmp/segpages allfiles /tmp/segmasks allfiles \
+ *       convertsegfilestopdf /data/local/tmp/segpages allfiles /data/local/tmp/segmasks allfiles \
  *       300 2 160 skip 0.5 [title] [output pdf]
  *    This upscales by 2x all non-image regions to 600 ppi, and downscales
  *    by 0.5 all image regions to 150 ppi.
  *
  *    If used on a set of images without segmentation data, a typical
  *    invocation would be:
- *       convertsegfilestopdf /tmp/pages allfiles skip skip \
+ *       convertsegfilestopdf /data/local/tmp/pages allfiles skip skip \
  *       300 2 160 skip 1.0 [title] [output pdf]
  *    If the page images have depth > 1 bpp, this will upscale all pages
  *    by 2x (to 600 ppi), and then convert the images to 1 bpp.
@@ -66,7 +66,7 @@
  *    maskdir.  Otherwise, this will generate the boxaa from the mask images.
  *
  *    A regression test that uses this is pdfseg_reg, which
- *    generates images and the boxaa file in /tmp/segtest/.
+ *    generates images and the boxaa file in /data/local/tmp/segtest/.
  */
 
 #ifdef HAVE_CONFIG_H
diff -Nura leptonica-1.83.1/prog/converttogray.c leptonica-1.83.1-patch/prog/converttogray.c
--- leptonica-1.83.1/prog/converttogray.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/converttogray.c	2024-09-05 14:26:11.015618218 +0800
@@ -72,8 +72,8 @@
             lept_stderr("images are the same\n");
         else
             lept_stderr("images are different!\n");
-        pixWrite("/tmp/lept/gray/pix1.png", pix1, IFF_PNG);
-        pixWrite("/tmp/lept/gray/pix2.png", pix2, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix2.png", pix2, IFF_PNG);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         pixSetColormap(pixs, NULL);
@@ -84,8 +84,8 @@
             lept_stderr("images are the same\n");
         else
             lept_stderr("images are different!\n");
-        pixWrite("/tmp/lept/gray/pix3.png", pix3, IFF_PNG);
-        pixWrite("/tmp/lept/gray/pix4.png", pix4, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix3.png", pix3, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix4.png", pix4, IFF_PNG);
         pixDestroy(&pix3);
         pixDestroy(&pix4);
     } else if (d == 4) {
@@ -96,8 +96,8 @@
             lept_stderr("images are the same\n");
         else
             lept_stderr("images are different!\n");
-        pixWrite("/tmp/lept/gray/pix1.png", pix1, IFF_PNG);
-        pixWrite("/tmp/lept/gray/pix2.png", pix2, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix2.png", pix2, IFF_PNG);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         pixSetColormap(pixs, NULL);
@@ -108,8 +108,8 @@
             lept_stderr("images are the same\n");
         else
             lept_stderr("images are different!\n");
-        pixWrite("/tmp/lept/gray/pix3.png", pix3, IFF_PNG);
-        pixWrite("/tmp/lept/gray/pix4.png", pix4, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix3.png", pix3, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gray/pix4.png", pix4, IFF_PNG);
         pixDestroy(&pix3);
         pixDestroy(&pix4);
     } else {
diff -Nura leptonica-1.83.1/prog/cornertest.c leptonica-1.83.1-patch/prog/cornertest.c
--- leptonica-1.83.1/prog/cornertest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/cornertest.c	2024-09-05 14:26:11.019618139 +0800
@@ -72,12 +72,12 @@
     ptaaAddPta(ptaa, pta, L_COPY);
     ptaaAddPta(ptaa, pta, L_COPY);
     ptaaWriteStream(stderr, ptaa, 1);
-    ptaaWrite("/tmp/junkptaa", ptaa, 1);
-    ptaa2 = ptaaRead("/tmp/junkptaa");
-    ptaaWrite("/tmp/junkptaa2", ptaa2, 1);
-    ptaaWrite("/tmp/junkptaa3", ptaa, 0);
-    ptaa3 = ptaaRead("/tmp/junkptaa3");
-    ptaaWrite("/tmp/junkptaa4", ptaa3, 0);
+    ptaaWrite("/data/local/tmp/junkptaa", ptaa, 1);
+    ptaa2 = ptaaRead("/data/local/tmp/junkptaa");
+    ptaaWrite("/data/local/tmp/junkptaa2", ptaa2, 1);
+    ptaaWrite("/data/local/tmp/junkptaa3", ptaa, 0);
+    ptaa3 = ptaaRead("/data/local/tmp/junkptaa3");
+    ptaaWrite("/data/local/tmp/junkptaa4", ptaa3, 0);
     ptaaDestroy(&ptaa);
     ptaaDestroy(&ptaa2);
     ptaaDestroy(&ptaa3);
diff -Nura leptonica-1.83.1/prog/corrupttest.c leptonica-1.83.1-patch/prog/corrupttest.c
--- leptonica-1.83.1/prog/corrupttest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/corrupttest.c	2024-09-05 14:26:11.019618139 +0800
@@ -60,7 +60,7 @@
 #include "string.h"
 #include "allheaders.h"
 
-static const char *corruptfile = "/tmp/lept/corrupt/badfile";
+static const char *corruptfile = "/data/local/tmp/lept/corrupt/badfile";
 
 int main(int     argc,
          char  **argv)
diff -Nura leptonica-1.83.1/prog/crop_reg.c leptonica-1.83.1-patch/prog/crop_reg.c
--- leptonica-1.83.1/prog/crop_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/crop_reg.c	2024-09-05 14:26:11.019618139 +0800
@@ -125,9 +125,9 @@
         numaDestroy(&nait);
     }
 
-    lept_stderr("Writing profiles to /tmp/lept/crop/croptest.pdf\n");
+    lept_stderr("Writing profiles to /data/local/tmp/lept/crop/croptest.pdf\n");
     pixaConvertToPdf(pixa1, 75, 1.0, L_JPEG_ENCODE, 0, "Profiles",
-                     "/tmp/lept/crop/croptest.pdf");
+                     "/data/local/tmp/lept/crop/croptest.pdf");
     pixaDestroy(&pixa1);
 
         /* Calculate projection profiles from text lines */
@@ -149,7 +149,7 @@
     pixaAddPix(pixa1, pix1, L_INSERT);
     pixaAddPix(pixa1, pix2, L_INSERT);
     pixd = pixaDisplayTiledInRows(pixa1, 32, 1000, 1.0, 0, 30, 2);
-    pixWrite("/tmp/lept/crop/profiles.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/crop/profiles.png", pixd, IFF_PNG);
     pixDisplayWithTitle(pixd, 0, 700, NULL, rp->display);
     pixDestroy(&pixs);
     pixDestroy(&pixd);
diff -Nura leptonica-1.83.1/prog/dewarp_reg.c leptonica-1.83.1-patch/prog/dewarp_reg.c
--- leptonica-1.83.1/prog/dewarp_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarp_reg.c	2024-09-05 14:26:11.019618139 +0800
@@ -130,11 +130,11 @@
 
         /* Write and read back minimized dewarp struct */
     dewarpMinimize(dew1);
-    dewarpWrite("/tmp/lept/regout/dewarp.6.dew", dew1);
-    regTestCheckFile(rp, "/tmp/lept/regout/dewarp.6.dew");  /* 6 */
-    dew2 = dewarpRead("/tmp/lept/regout/dewarp.6.dew");
-    dewarpWrite("/tmp/lept/regout/dewarp.7.dew", dew2);
-    regTestCheckFile(rp, "/tmp/lept/regout/dewarp.7.dew");  /* 7 */
+    dewarpWrite("/data/local/tmp/lept/regout/dewarp.6.dew", dew1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dewarp.6.dew");  /* 6 */
+    dew2 = dewarpRead("/data/local/tmp/lept/regout/dewarp.6.dew");
+    dewarpWrite("/data/local/tmp/lept/regout/dewarp.7.dew", dew2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dewarp.7.dew");  /* 7 */
     regTestCompareFiles(rp, 6, 7);  /* 8 */
 
         /* Apply this minimized dew to page 3 in a new dewa */
@@ -163,12 +163,12 @@
         return 1;
     }
     fpix1 = fpixClone(dew2->sampvdispar);
-    fpixWrite("/tmp/lept/regout/dewarp.12.fpix", fpix1);
-    regTestCheckFile(rp, "/tmp/lept/regout/dewarp.12.fpix");  /* 12 */
+    fpixWrite("/data/local/tmp/lept/regout/dewarp.12.fpix", fpix1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dewarp.12.fpix");  /* 12 */
 
-    fpix2 = fpixRead("/tmp/lept/regout/dewarp.12.fpix");
-    fpixWrite("/tmp/lept/regout/dewarp.13.fpix", fpix2);
-    regTestCheckFile(rp, "/tmp/lept/regout/dewarp.13.fpix");  /* 13 */
+    fpix2 = fpixRead("/data/local/tmp/lept/regout/dewarp.12.fpix");
+    fpixWrite("/data/local/tmp/lept/regout/dewarp.13.fpix", fpix2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dewarp.13.fpix");  /* 13 */
     regTestCompareFiles(rp, 12, 13);  /* 14 */
     fpix3 = fpixScaleByInteger(fpix2, 30);
     pix1 = fpixRenderContours(fpix3, 2.0, 0.2);
@@ -182,11 +182,11 @@
          * 15 with 19, because of a tiny difference due to float roundoff,
          * so we do an approximate comparison on the images. */
     dpix1 = fpixConvertToDPix(dew2->sampvdispar);
-    dpixWrite("/tmp/lept/regout/dewarp.16.dpix", dpix1);
-    regTestCheckFile(rp, "/tmp/lept/regout/dewarp.16.dpix");  /* 16 */
-    dpix2 = dpixRead("/tmp/lept/regout/dewarp.16.dpix");
-    dpixWrite("/tmp/lept/regout/dewarp.17.dpix", dpix2);
-    regTestCheckFile(rp, "/tmp/lept/regout/dewarp.17.dpix");  /* 17 */
+    dpixWrite("/data/local/tmp/lept/regout/dewarp.16.dpix", dpix1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dewarp.16.dpix");  /* 16 */
+    dpix2 = dpixRead("/data/local/tmp/lept/regout/dewarp.16.dpix");
+    dpixWrite("/data/local/tmp/lept/regout/dewarp.17.dpix", dpix2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dewarp.17.dpix");  /* 17 */
     regTestCompareFiles(rp, 16, 17);  /* 18 */
     dpix3 = dpixScaleByInteger(dpix2, 30);
     fpix3 = dpixConvertToFPix(dpix3);
diff -Nura leptonica-1.83.1/prog/dewarprules.c leptonica-1.83.1-patch/prog/dewarprules.c
--- leptonica-1.83.1/prog/dewarprules.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarprules.c	2024-09-05 14:26:11.019618139 +0800
@@ -113,7 +113,7 @@
         dewarpaUseBothArrays(dewa, 1);
         dew = dewarpCreate(pix2, 0);
         dewarpaInsertDewarp(dewa, dew);
-        dewarpBuildLineModel(dew, 10, "/tmp/dewarp/sud.pdf");
+        dewarpBuildLineModel(dew, 10, "/data/local/tmp/dewarp/sud.pdf");
         dewarpaApplyDisparity(dewa, 0, pix1, 255, 0, 0, &pix3, NULL);
         dewarpaApplyDisparity(dewa, 0, pix2, 255, 0, 0, &pix4, NULL);
         pixDisplay(pix3, 500, 100);
@@ -137,7 +137,7 @@
         dewarpaUseBothArrays(dewa, 0);
         dew = dewarpCreate(pix3, 0);
         dewarpaInsertDewarp(dewa, dew);
-        dewarpBuildPageModel(dew, "/tmp/dewarp/sud1.pdf");
+        dewarpBuildPageModel(dew, "/data/local/tmp/dewarp/sud1.pdf");
         dewarpaApplyDisparity(dewa, 0, pix1, 255, 0, 0, &pix4, NULL);
         dewarpaApplyDisparity(dewa, 0, pix2, 255, 0, 0, &pix5, NULL);
         pixDisplay(pix4, 500, 100);
@@ -158,7 +158,7 @@
         dewarpaUseBothArrays(dewa, 0);
         dew = dewarpCreate(pix8, 0);
         dewarpaInsertDewarp(dewa, dew);
-        dewarpBuildPageModel(dew, "/tmp/dewarp/sud2.pdf");
+        dewarpBuildPageModel(dew, "/data/local/tmp/dewarp/sud2.pdf");
         dewarpaApplyDisparity(dewa, 0, pix6, 255, 0, 0, &pix9, NULL);
         dewarpaApplyDisparity(dewa, 0, pix8, 255, 0, 0, &pix10, NULL);
         pixd = pixRotateOrth(pix9, 3);
diff -Nura leptonica-1.83.1/prog/dewarptest1.c leptonica-1.83.1-patch/prog/dewarptest1.c
--- leptonica-1.83.1/prog/dewarptest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarptest1.c	2024-09-05 14:26:11.019618139 +0800
@@ -75,50 +75,50 @@
     dewarpaUseBothArrays(dewa, 1);
     dew1 = dewarpCreate(pixb, 35);
     dewarpaInsertDewarp(dewa, dew1);
-    dewarpBuildPageModel(dew1, "/tmp/lept/model/dewarp_model1.pdf");
+    dewarpBuildPageModel(dew1, "/data/local/tmp/lept/model/dewarp_model1.pdf");
     dewarpaApplyDisparity(dewa, 35, pixg, 200, 0, 0, &pixd,
-                          "/tmp/lept/model/dewarp_apply1.pdf");
+                          "/data/local/tmp/lept/model/dewarp_apply1.pdf");
 
          /* Write out some of the files to be imaged */
     lept_rmdir("lept/dewtest");
     lept_mkdir("lept/dewtest");
-    pixWrite("/tmp/lept/dewtest/001.jpg", pixs, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/dewtest/002.jpg", pixn, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/dewtest/003.jpg", pixg, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/dewtest/004.png", pixb, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/dewtest/005.jpg", pixd, IFF_JFIF_JPEG);
-    pixt1 = pixRead("/tmp/lept/dewmod/0020.png");
-    pixWrite("/tmp/lept/dewtest/006.png", pixt1, IFF_PNG);
-    pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewmod/0030.png");
-    pixWrite("/tmp/lept/dewtest/007.png", pixt1, IFF_PNG);
-    pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewmod/0060.png");
-    pixWrite("/tmp/lept/dewtest/008.png", pixt1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/dewtest/001.jpg", pixs, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/dewtest/002.jpg", pixn, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/dewtest/003.jpg", pixg, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/dewtest/004.png", pixb, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/dewtest/005.jpg", pixd, IFF_JFIF_JPEG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0020.png");
+    pixWrite("/data/local/tmp/lept/dewtest/006.png", pixt1, IFF_PNG);
+    pixDestroy(&pixt1);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0030.png");
+    pixWrite("/data/local/tmp/lept/dewtest/007.png", pixt1, IFF_PNG);
+    pixDestroy(&pixt1);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0060.png");
+    pixWrite("/data/local/tmp/lept/dewtest/008.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewmod/0070.png");
-    pixWrite("/tmp/lept/dewtest/009.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0070.png");
+    pixWrite("/data/local/tmp/lept/dewtest/009.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewapply/002.png");
-    pixWrite("/tmp/lept/dewtest/010.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewapply/002.png");
+    pixWrite("/data/local/tmp/lept/dewtest/010.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewapply/003.png");
-    pixWrite("/tmp/lept/dewtest/011.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewapply/003.png");
+    pixWrite("/data/local/tmp/lept/dewtest/011.png", pixt1, IFF_PNG);
     pixt2 = pixThresholdToBinary(pixt1, 130);
-    pixWrite("/tmp/lept/dewtest/012.png", pixt2, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/dewtest/012.png", pixt2, IFF_TIFF_G4);
     pixDestroy(&pixt1);
     pixDestroy(&pixt2);
-    pixt1 = pixRead("/tmp/lept/dewmod/0041.png");
-    pixWrite("/tmp/lept/dewtest/013.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0041.png");
+    pixWrite("/data/local/tmp/lept/dewtest/013.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewmod/0042.png");
-    pixWrite("/tmp/lept/dewtest/014.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0042.png");
+    pixWrite("/data/local/tmp/lept/dewtest/014.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewmod/0051.png");
-    pixWrite("/tmp/lept/dewtest/015.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0051.png");
+    pixWrite("/data/local/tmp/lept/dewtest/015.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewmod/0052.png");
-    pixWrite("/tmp/lept/dewtest/016.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0052.png");
+    pixWrite("/data/local/tmp/lept/dewtest/016.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
 
         /* Normalize another image, that may not have enough textlines
@@ -136,37 +136,37 @@
     dewarpaInsertRefModels(dewa, 0, 1);
     dewarpaInfo(stderr, dewa);
     dewarpaApplyDisparity(dewa, 7, pixg2, 200, 0, 0, &pixd2,
-                          "/tmp/lept/model/dewarp_apply2.pdf");
+                          "/data/local/tmp/lept/model/dewarp_apply2.pdf");
     dewarpaDestroy(&dewa);
 
         /* Write out files for the second image */
-    pixWrite("/tmp/lept/dewtest/017.jpg", pixs2, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/dewtest/018.jpg", pixg2, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/dewtest/019.png", pixb2, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/dewtest/020.jpg", pixd2, IFF_JFIF_JPEG);
-    pixt1 = pixRead("/tmp/lept/dewmod/0060.png");
-    pixWrite("/tmp/lept/dewtest/021.png", pixt1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/dewtest/017.jpg", pixs2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/dewtest/018.jpg", pixg2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/dewtest/019.png", pixb2, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/dewtest/020.jpg", pixd2, IFF_JFIF_JPEG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0060.png");
+    pixWrite("/data/local/tmp/lept/dewtest/021.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewapply/002.png");
-    pixWrite("/tmp/lept/dewtest/022.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewapply/002.png");
+    pixWrite("/data/local/tmp/lept/dewtest/022.png", pixt1, IFF_PNG);
     pixt2 = pixThresholdToBinary(pixt1, 130);
-    pixWrite("/tmp/lept/dewtest/023.png", pixt2, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/dewtest/023.png", pixt2, IFF_TIFF_G4);
     pixDestroy(&pixt1);
     pixDestroy(&pixt2);
-    pixt1 = pixRead("/tmp/lept/dewmod/0070.png");
-    pixWrite("/tmp/lept/dewtest/024.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewmod/0070.png");
+    pixWrite("/data/local/tmp/lept/dewtest/024.png", pixt1, IFF_PNG);
     pixDestroy(&pixt1);
-    pixt1 = pixRead("/tmp/lept/dewapply/003.png");
-    pixWrite("/tmp/lept/dewtest/025.png", pixt1, IFF_PNG);
+    pixt1 = pixRead("/data/local/tmp/lept/dewapply/003.png");
+    pixWrite("/data/local/tmp/lept/dewtest/025.png", pixt1, IFF_PNG);
     pixt2 = pixThresholdToBinary(pixt1, 130);
-    pixWrite("/tmp/lept/dewtest/026.png", pixt2, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/dewtest/026.png", pixt2, IFF_TIFF_G4);
     pixDestroy(&pixt1);
     pixDestroy(&pixt2);
 
         /* Generate the big pdf file */
-    convertFilesToPdf("/tmp/lept/dewtest", NULL, 135, 1.0, 0, 0, "Dewarp Test",
-                      "/tmp/lept/dewarptest1.pdf");
-    lept_stderr("pdf file made: /tmp/lept/model/dewarptest1.pdf\n");
+    convertFilesToPdf("/data/local/tmp/lept/dewtest", NULL, 135, 1.0, 0, 0, "Dewarp Test",
+                      "/data/local/tmp/lept/dewarptest1.pdf");
+    lept_stderr("pdf file made: /data/local/tmp/lept/model/dewarptest1.pdf\n");
 
     pixDestroy(&pixs);
     pixDestroy(&pixn);
diff -Nura leptonica-1.83.1/prog/dewarptest2.c leptonica-1.83.1-patch/prog/dewarptest2.c
--- leptonica-1.83.1/prog/dewarptest2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarptest2.c	2024-09-05 14:26:11.019618139 +0800
@@ -107,9 +107,9 @@
             /* Run the basic functions */
         dew1 = dewarpCreate(pixb, pageno);
         dewarpaInsertDewarp(dewa, dew1);
-        dewarpBuildPageModel(dew1, "/tmp/lept/dewarp/test2_model.pdf");
+        dewarpBuildPageModel(dew1, "/data/local/tmp/lept/dewarp/test2_model.pdf");
         dewarpaApplyDisparity(dewa, pageno, pixb, -1, 0, 0, &pixd,
-                              "/tmp/lept/dewarp/test2_apply.pdf");
+                              "/data/local/tmp/lept/dewarp/test2_apply.pdf");
 
         dewarpaInfo(stderr, dewa);
         dewarpaDestroy(&dewa);
diff -Nura leptonica-1.83.1/prog/dewarptest3.c leptonica-1.83.1-patch/prog/dewarptest3.c
--- leptonica-1.83.1/prog/dewarptest3.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarptest3.c	2024-09-05 14:26:11.023618061 +0800
@@ -72,7 +72,7 @@
     pixt1 = pixCreateTemplate(pixs);
     pixSetAll(pixt1);
     pixt2 = pixDisplayPtaa(pixt1, ptaa1);
-    pixWrite("/tmp/lept/textline1.png", pixt2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/textline1.png", pixt2, IFF_PNG);
     pixDisplayWithTitle(pixt2, 0, 100, "textline centers 1", 1);
     pixaAddPix(pixa, pixt2, L_INSERT);
     pixDestroy(&pixt1);
@@ -83,7 +83,7 @@
     pixt1 = pixCreateTemplate(pixs);
     pixSetAll(pixt1);
     pixt2 = pixDisplayPtaa(pixt1, ptaa2);
-    pixWrite("/tmp/lept/textline2.png", pixt2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/textline2.png", pixt2, IFF_PNG);
     pixDisplayWithTitle(pixt2, 300, 100, "textline centers 2", 1);
     pixaAddPix(pixa, pixt2, L_INSERT);
     pixDestroy(&pixt1);
@@ -95,7 +95,7 @@
         /* Long lines over input image */
     pixt1 = pixCopy(NULL, pixs);
     pixt2 = pixDisplayPtaa(pixt1, ptaa2);
-    pixWrite("/tmp/lept/textline3.png", pixt2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/textline3.png", pixt2, IFF_PNG);
     pixDisplayWithTitle(pixt2, 600, 100, "textline centers 3", 1);
     pixaAddPix(pixa, pixt2, L_INSERT);
     pixDestroy(&pixt1);
@@ -114,7 +114,7 @@
         numaDestroy(&nax);
         numaDestroy(&nafit);
     }
-    pixWrite("/tmp/lept/textline4.png", pixt1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/textline4.png", pixt1, IFF_PNG);
     pixDisplayWithTitle(pixt1, 900, 100, "textline centers 4", 1);
     pixaAddPix(pixa, pixt1, L_INSERT);
 
@@ -133,7 +133,7 @@
         numaDestroy(&nax);
         numaDestroy(&nafit);
     }
-    pixWrite("/tmp/lept/textline5.png", pixt1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/textline5.png", pixt1, IFF_PNG);
     pixDisplayWithTitle(pixt1, 1200, 100, "textline centers 5", 1);
     pixaAddPix(pixa, pixt1, L_INSERT);
 
@@ -153,13 +153,13 @@
         numaDestroy(&nax);
         numaDestroy(&nafit);
     }
-    pixWrite("/tmp/lept/textline6.png", pixt1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/textline6.png", pixt1, IFF_PNG);
     pixDisplayWithTitle(pixt1, 1500, 100, "textline centers 6", 1);
     pixaAddPix(pixa, pixt1, L_INSERT);
 
     pixaConvertToPdf(pixa, 300, 0.5, L_JPEG_ENCODE, 75,
                      "LS fittings to textlines",
-                     "/tmp/lept/dewarp_fittings.pdf");
+                     "/data/local/tmp/lept/dewarp_fittings.pdf");
     pixaDestroy(&pixa);
     pixDestroy(&pixs);
     ptaaDestroy(&ptaa2);
diff -Nura leptonica-1.83.1/prog/dewarptest4.c leptonica-1.83.1-patch/prog/dewarptest4.c
--- leptonica-1.83.1/prog/dewarptest4.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarptest4.c	2024-09-05 14:26:11.023618061 +0800
@@ -62,10 +62,10 @@
         /* Run the basic functions */
     dew1 = dewarpCreate(pixb, 35);
     dewarpaInsertDewarp(dewa1, dew1);
-    dewarpBuildPageModel(dew1, "/tmp/lept/dewarp_junk35.pdf");
+    dewarpBuildPageModel(dew1, "/data/local/tmp/lept/dewarp_junk35.pdf");
     dewarpPopulateFullRes(dew1, pixg, 0, 0);
     dewarpaApplyDisparity(dewa1, 35, pixg, 200, 0, 0, &pixd,
-                          "/tmp/lept/dewarp_debug_35.pdf");
+                          "/data/local/tmp/lept/dewarp_debug_35.pdf");
 
         /* Normalize another image. */
 /*    pixs2 = pixRead("1555.003.jpg"); */
@@ -77,17 +77,17 @@
         /* Run the basic functions */
     dew2 = dewarpCreate(pixb2, 7);
     dewarpaInsertDewarp(dewa1, dew2);
-    dewarpBuildPageModel(dew2, "/tmp/lept/dewarp_junk7.pdf");
+    dewarpBuildPageModel(dew2, "/data/local/tmp/lept/dewarp_junk7.pdf");
     dewarpaApplyDisparity(dewa1, 7, pixg, 200, 0, 0, &pixd2,
-                          "/tmp/lept/dewarp_debug_7.pdf");
+                          "/data/local/tmp/lept/dewarp_debug_7.pdf");
 
         /* Serialize and deserialize dewarpa */
-    dewarpaWrite("/tmp/lept/dewarpa1.dewa", dewa1);
-    dewa2 = dewarpaRead("/tmp/lept/dewarpa1.dewa");
-    dewarpaWrite("/tmp/lept/dewarpa2.dewa", dewa2);
-    dewa3 = dewarpaRead("/tmp/lept/dewarpa2.dewa");
+    dewarpaWrite("/data/local/tmp/lept/dewarpa1.dewa", dewa1);
+    dewa2 = dewarpaRead("/data/local/tmp/lept/dewarpa1.dewa");
+    dewarpaWrite("/data/local/tmp/lept/dewarpa2.dewa", dewa2);
+    dewa3 = dewarpaRead("/data/local/tmp/lept/dewarpa2.dewa");
     dewarpDebug(dewa3->dewarp[7], "dew1", 7);
-    dewarpaWrite("/tmp/lept/dewarpa3.dewa", dewa3);
+    dewarpaWrite("/data/local/tmp/lept/dewarpa3.dewa", dewa3);
 
         /* Repopulate and show the vertical disparity arrays */
     dewarpPopulateFullRes(dew1, NULL, 0, 0);
@@ -98,7 +98,7 @@
     pixc2 = fpixRenderContours(dew3->fullvdispar, 2.0, 0.2);
     pixDisplay(pixc2, 1400, 900);
     dewarpaApplyDisparity(dewa2, 35, pixb, 200, 0, 0, &pixd3,
-                          "/tmp/lept/dewarp_debug_35b.pdf");
+                          "/data/local/tmp/lept/dewarp_debug_35b.pdf");
     pixDisplay(pixd, 0, 1000);
     pixDisplay(pixd2, 600, 1000);
     pixDisplay(pixd3, 1200, 1000);
diff -Nura leptonica-1.83.1/prog/dewarptest5.c leptonica-1.83.1-patch/prog/dewarptest5.c
--- leptonica-1.83.1/prog/dewarptest5.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dewarptest5.c	2024-09-05 14:26:11.023618061 +0800
@@ -68,7 +68,7 @@
     dew = dewarpCreate(pixb, pageno);
     dewarpaInsertDewarp(dewa, dew);
     if (build_output) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/dewarp_build_%d.pdf", pageno);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewarp_build_%d.pdf", pageno);
         dewarpBuildPageModel(dew, buf);
     } else {
         dewarpBuildPageModel(dew, NULL);
@@ -77,7 +77,7 @@
         /* Apply the model */
     dewarpPopulateFullRes(dew, pixg, 0, 0);
     if (apply_output) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/dewarp_apply_%d.pdf", pageno);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewarp_apply_%d.pdf", pageno);
         dewarpaApplyDisparity(dewa, pageno, pixb, 200, 0, 0, &pix2, buf);
     } else {
         dewarpaApplyDisparity(dewa, pageno, pixb, 200, 0, 0, &pix2, NULL);
@@ -92,7 +92,7 @@
 
         /* ... and map to the word boxes for the input image */
     if (map_output) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/dewarp_map1_%d.pdf", pageno);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewarp_map1_%d.pdf", pageno);
         dewarpaApplyDisparityBoxa(dewa, pageno, pix2, boxa1, 0, 0, 0, &boxa2,
                                   buf);
     } else {
@@ -111,7 +111,7 @@
 
         /* ... and map to the word boxes for the dewarped image */
     if (map_output) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/dewarp_map2_%d.pdf", pageno);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewarp_map2_%d.pdf", pageno);
         dewarpaApplyDisparityBoxa(dewa, pageno, pixb, boxa3, 1, 0, 0, &boxa4,
                                   buf);
     } else {
diff -Nura leptonica-1.83.1/prog/digitprep1.c leptonica-1.83.1-patch/prog/digitprep1.c
--- leptonica-1.83.1/prog/digitprep1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/digitprep1.c	2024-09-05 14:26:11.023618061 +0800
@@ -86,7 +86,7 @@
 
         /* Save in a pixaa, with 1 pix in each pixa */
     paa = pixaaCreateFromPixa(pixad, 1, L_CHOOSE_CONSECUTIVE, L_CLONE);
-    pixaaWrite("/tmp/lept/barcode_digits.paa", paa);
+    pixaaWrite("/data/local/tmp/lept/barcode_digits.paa", paa);
 
         /* Show result */
     pix1 = pixaaDisplayByPixa(paa, 50, 1.0, 20, 20, 0);
diff -Nura leptonica-1.83.1/prog/displayboxes_on_pixa.c leptonica-1.83.1-patch/prog/displayboxes_on_pixa.c
--- leptonica-1.83.1/prog/displayboxes_on_pixa.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/displayboxes_on_pixa.c	2024-09-05 14:26:11.023618061 +0800
@@ -48,7 +48,7 @@
  *   pix in the input pixa.  The number of boxes in each boxa is arbitrary.
  *
  *   For example, you can call this with:
- *     displayboxes_on_pixa showboxes.pac showboxes2.baa 4 2 /tmp/result.pa 1
+ *     displayboxes_on_pixa showboxes.pac showboxes2.baa 4 2 /data/local/tmp/result.pa 1
  */
 
 #ifdef HAVE_CONFIG_H
diff -Nura leptonica-1.83.1/prog/dna_reg.c leptonica-1.83.1-patch/prog/dna_reg.c
--- leptonica-1.83.1/prog/dna_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dna_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -67,13 +67,13 @@
         /* Conversion to Numa; I/O for Dna */
     na = l_dnaConvertToNuma(da1);
     da2 = numaConvertToDna(na);
-    l_dnaWrite("/tmp/lept/regout/dna1.da", da1);
-    l_dnaWrite("/tmp/lept/regout/dna2.da", da2);
-    da3 = l_dnaRead("/tmp/lept/regout/dna2.da");
-    l_dnaWrite("/tmp/lept/regout/dna3.da", da3);
-    regTestCheckFile(rp, "/tmp/lept/regout/dna1.da");  /* 0 */
-    regTestCheckFile(rp, "/tmp/lept/regout/dna2.da");  /* 1 */
-    regTestCheckFile(rp, "/tmp/lept/regout/dna3.da");  /* 2 */
+    l_dnaWrite("/data/local/tmp/lept/regout/dna1.da", da1);
+    l_dnaWrite("/data/local/tmp/lept/regout/dna2.da", da2);
+    da3 = l_dnaRead("/data/local/tmp/lept/regout/dna2.da");
+    l_dnaWrite("/data/local/tmp/lept/regout/dna3.da", da3);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dna1.da");  /* 0 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dna2.da");  /* 1 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dna3.da");  /* 2 */
     regTestCompareFiles(rp, 1, 2);  /* 3 */
 
         /* I/O for Dnaa */
@@ -81,11 +81,11 @@
     l_dnaaAddDna(daa1, da1, L_INSERT);
     l_dnaaAddDna(daa1, da2, L_INSERT);
     l_dnaaAddDna(daa1, da3, L_INSERT);
-    l_dnaaWrite("/tmp/lept/regout/dnaa1.daa", daa1);
-    daa2 = l_dnaaRead("/tmp/lept/regout/dnaa1.daa");
-    l_dnaaWrite("/tmp/lept/regout/dnaa2.daa", daa2);
-    regTestCheckFile(rp, "/tmp/lept/regout/dnaa1.daa");  /* 4 */
-    regTestCheckFile(rp, "/tmp/lept/regout/dnaa2.daa");  /* 5 */
+    l_dnaaWrite("/data/local/tmp/lept/regout/dnaa1.daa", daa1);
+    daa2 = l_dnaaRead("/data/local/tmp/lept/regout/dnaa1.daa");
+    l_dnaaWrite("/data/local/tmp/lept/regout/dnaa2.daa", daa2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dnaa1.daa");  /* 4 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dnaa2.daa");  /* 5 */
     regTestCompareFiles(rp, 4, 5);  /* 6 */
     l_dnaaDestroy(&daa1);
     l_dnaaDestroy(&daa2);
@@ -94,11 +94,11 @@
     nahisto = numaMakeHistogramClipped(na, 12, 2000);
     nbins = numaGetCount(nahisto);
     nax = numaMakeSequence(0, 1, nbins);
-    gplot = gplotCreate("/tmp/lept/regout/historoot", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/regout/historoot", GPLOT_PNG,
                         "Histo example", "i", "histo[i]");
     gplotAddPlot(gplot, nax, nahisto, GPLOT_LINES, "sine");
     gplotMakeOutput(gplot);
-    regTestCheckFile(rp, "/tmp/lept/regout/historoot.png");  /* 7 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/historoot.png");  /* 7 */
     gplotDestroy(&gplot);
     numaDestroy(&na);
     numaDestroy(&nax);
@@ -108,8 +108,8 @@
     da4 = l_dnaCreate(25);
     for (i = 0; i < 1000; i++)
         l_dnaAddNumber(da4, 1928374 * i);
-    l_dnaWrite("/tmp/lept/regout/dna4.da", da4);
-    da5 = l_dnaRead("/tmp/lept/regout/dna4.da");
+    l_dnaWrite("/data/local/tmp/lept/regout/dna4.da", da4);
+    da5 = l_dnaRead("/data/local/tmp/lept/regout/dna4.da");
     sum = 0;
     for (i = 0; i < 1000; i++) {
         l_dnaGetIValue(da5, i, &ival);
diff -Nura leptonica-1.83.1/prog/dwamorph2_reg.c leptonica-1.83.1-patch/prog/dwamorph2_reg.c
--- leptonica-1.83.1/prog/dwamorph2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/dwamorph2_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -112,7 +112,7 @@
     nac2 = numaWindowedMean(na2, HALFWIDTH);
     nac3 = numaWindowedMean(na3, HALFWIDTH);
     nac4 = numaWindowedMean(na4, HALFWIDTH);
-    gplot = gplotCreate("/tmp/lept/morph/dilate", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/morph/dilate", GPLOT_PNG,
                         "Dilation time vs sel size", "size", "time (ms)");
     gplotAddPlot(gplot, nax, nac1, GPLOT_LINES, "linear rasterop");
     gplotAddPlot(gplot, nax, nac2, GPLOT_LINES, "composite rasterop");
@@ -167,7 +167,7 @@
     nac2 = numaWindowedMean(na2, HALFWIDTH);
     nac3 = numaWindowedMean(na3, HALFWIDTH);
     nac4 = numaWindowedMean(na4, HALFWIDTH);
-    gplot = gplotCreate("/tmp/lept/morph/erode", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/morph/erode", GPLOT_PNG,
                         "Erosion time vs sel size", "size", "time (ms)");
     gplotAddPlot(gplot, nax, nac1, GPLOT_LINES, "linear rasterop");
     gplotAddPlot(gplot, nax, nac2, GPLOT_LINES, "composite rasterop");
@@ -222,7 +222,7 @@
     nac2 = numaWindowedMean(na2, HALFWIDTH);
     nac3 = numaWindowedMean(na3, HALFWIDTH);
     nac4 = numaWindowedMean(na4, HALFWIDTH);
-    gplot = gplotCreate("/tmp/lept/morph/open", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/morph/open", GPLOT_PNG,
                         "Opening time vs sel size", "size", "time (ms)");
     gplotAddPlot(gplot, nax, nac1, GPLOT_LINES, "linear rasterop");
     gplotAddPlot(gplot, nax, nac2, GPLOT_LINES, "composite rasterop");
@@ -277,7 +277,7 @@
     nac2 = numaWindowedMean(na2, HALFWIDTH);
     nac3 = numaWindowedMean(na3, HALFWIDTH);
     nac4 = numaWindowedMean(na4, HALFWIDTH);
-    gplot = gplotCreate("/tmp/lept/morph/close", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/morph/close", GPLOT_PNG,
                         "Closing time vs sel size", "size", "time (ms)");
     gplotAddPlot(gplot, nax, nac1, GPLOT_LINES, "linear rasterop");
     gplotAddPlot(gplot, nax, nac2, GPLOT_LINES, "composite rasterop");
@@ -302,16 +302,16 @@
 
         /* Display the results together */
     pixa = pixaCreate(0);
-    pixs = pixRead("/tmp/lept/morph/dilate.png");
+    pixs = pixRead("/data/local/tmp/lept/morph/dilate.png");
     pixaAddPix(pixa, pixs, L_INSERT);
-    pixs = pixRead("/tmp/lept/morph/erode.png");
+    pixs = pixRead("/data/local/tmp/lept/morph/erode.png");
     pixaAddPix(pixa, pixs, L_INSERT);
-    pixs = pixRead("/tmp/lept/morph/open.png");
+    pixs = pixRead("/data/local/tmp/lept/morph/open.png");
     pixaAddPix(pixa, pixs, L_INSERT);
-    pixs = pixRead("/tmp/lept/morph/close.png");
+    pixs = pixRead("/data/local/tmp/lept/morph/close.png");
     pixaAddPix(pixa, pixs, L_INSERT);
     pixt = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 40, 3);
-    pixWrite("/tmp/lept/morph/timings.png", pixt, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morph/timings.png", pixt, IFF_PNG);
     pixDisplay(pixt, 100, 100);
     pixDestroy(&pixt);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/encoding_reg.c leptonica-1.83.1-patch/prog/encoding_reg.c
--- leptonica-1.83.1/prog/encoding_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/encoding_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -63,8 +63,8 @@
         lept_stderr("file bytes = %zu, a85 bytes = %zu, bina2 bytes = %zu\n",
                     fbytes, nbytes1, nbytes2);
     }
-    l_binaryWrite("/tmp/lept/encode/ascii85", "w", a85a, nbytes1);
-    l_binaryWrite("/tmp/lept/encode/bina2", "w", bina2, nbytes2);
+    l_binaryWrite("/data/local/tmp/lept/encode/ascii85", "w", a85a, nbytes1);
+    l_binaryWrite("/data/local/tmp/lept/encode/bina2", "w", bina2, nbytes2);
 
         /* Test the reconstructed image */
     pix1 = pixReadMem(bina2, nbytes2);
diff -Nura leptonica-1.83.1/prog/enhance_reg.c leptonica-1.83.1-patch/prog/enhance_reg.c
--- leptonica-1.83.1/prog/enhance_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/enhance_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -122,7 +122,7 @@
     }
     pix1 = pixaDisplayTiledAndScaled(pixa1, 32, w, 5, 0, 10, 2);
     pixaAddPix(pixaf, pix1, L_INSERT);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/regout/enhance.7",
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/regout/enhance.7",
                  "Average Saturation");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 3 */
     pixDisplayWithTitle(pix1, 900, 100, "Saturation", rp->display);
@@ -182,7 +182,7 @@
     pixDestroy(&pixd);
 
         /* Delayed testing of saturation plot */
-    regTestCheckFile(rp, "/tmp/lept/regout/enhance.7.png");  /* 7 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/enhance.7.png");  /* 7 */
 
         /* Display results */
     pixd = pixaDisplayTiledInColumns(pixaf, 1, 1.0, 20, 2);
@@ -245,8 +245,8 @@
 
     na1 = numaGammaTRC(0.8, 0, 220);
     na2 = numaGammaTRC(1.0, 40, 220);
-    gplotSimple2(na1, na2, GPLOT_PNG, "/tmp/lept/enhance/junkp", NULL);
-    pix1 = pixRead("/tmp/lept/enhance/junkp.png");
+    gplotSimple2(na1, na2, GPLOT_PNG, "/data/local/tmp/lept/enhance/junkp", NULL);
+    pix1 = pixRead("/data/local/tmp/lept/enhance/junkp.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 13 */
     pixaAddPix(pixa1, pix1, L_COPY);
     numaDestroy(&na1);
diff -Nura leptonica-1.83.1/prog/equal_reg.c leptonica-1.83.1-patch/prog/equal_reg.c
--- leptonica-1.83.1/prog/equal_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/equal_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -60,8 +60,8 @@
     lept_mkdir("lept/equal");
 
     pixs = pixRead(FEYN1);
-    pixWrite("/tmp/lept/equal/junkfeyn.png", pixs, IFF_PNG);
-    pix1 = pixRead("/tmp/lept/equal/junkfeyn.png");
+    pixWrite("/data/local/tmp/lept/equal/junkfeyn.png", pixs, IFF_PNG);
+    pix1 = pixRead("/data/local/tmp/lept/equal/junkfeyn.png");
     regTestComparePix(rp, pixs, pix1);  /* 0 */
     pixDestroy(&pixs);
     pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/expand_reg.c leptonica-1.83.1-patch/prog/expand_reg.c
--- leptonica-1.83.1/prog/expand_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/expand_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -154,9 +154,9 @@
     pixDestroy(&pixs);
 
     if (rp->display) {
-        lept_stderr("Writing to: /tmp/lept/expand/test.pdf\n");
+        lept_stderr("Writing to: /data/local/tmp/lept/expand/test.pdf\n");
         pixaConvertToPdf(pixa, 0, 1.0, 0, 0, "Replicative expansion",
-                         "/tmp/lept/expand/test.pdf");
+                         "/data/local/tmp/lept/expand/test.pdf");
     }
     pixaDestroy(&pixa);
 
diff -Nura leptonica-1.83.1/prog/extrema_reg.c leptonica-1.83.1-patch/prog/extrema_reg.c
--- leptonica-1.83.1/prog/extrema_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/extrema_reg.c	2024-09-05 14:26:11.023618061 +0800
@@ -67,7 +67,7 @@
         f += 63.4 * cos(0.21 * (l_float32)i);
         numaAddNumber(na1, f);
     }
-    gplot = gplotCreate("/tmp/lept/extrema/plot", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/extrema/plot", GPLOT_PNG,
                         "Extrema test", "x", "y");
     gplotAddPlot(gplot, NULL, na1, GPLOT_LINES, "plot 1");
 
@@ -87,9 +87,9 @@
     regTestWriteDataAndCheck(rp, data, size, "na");  /* 0 */
     lept_free(data);
 
-    regTestCheckFile(rp, "/tmp/lept/extrema/plot.png");  /* 1 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/extrema/plot.png");  /* 1 */
     if (rp->display) {
-        pix1 = pixRead("/tmp/lept/extrema/plot.png");
+        pix1 = pixRead("/data/local/tmp/lept/extrema/plot.png");
         pixDisplay(pix1, 100, 100);
         pixDestroy(&pix1);
     }
diff -Nura leptonica-1.83.1/prog/files_reg.c leptonica-1.83.1-patch/prog/files_reg.c
--- leptonica-1.83.1/prog/files_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/files_reg.c	2024-09-05 14:26:11.027617983 +0800
@@ -30,7 +30,7 @@
  *    Regression test for lept_*() and other path utilities in utils.h
  *
  *    Some of these only work properly on unix because they explicitly
- *    use "/tmp" for string compares.
+ *    use "/data/local/tmp" for string compares.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -66,11 +66,11 @@
     lept_stderr(" =================== Test pathJoin() ===============\n");
     lept_stderr(" ===================================================\n");
     TestPathJoin(rp, "/a/b//c///d//", "//e//f//g//", "/a/b/c/d/e/f/g");  /* 0 */
-    TestPathJoin(rp, "/tmp/", "junk//", "/tmp/junk");  /* 1 */
-    TestPathJoin(rp, "//tmp/", "junk//", "/tmp/junk");  /* 2 */
+    TestPathJoin(rp, "/data/local/tmp/", "junk//", "/data/local/tmp/junk");  /* 1 */
+    TestPathJoin(rp, "//data/local/tmp/", "junk//", "/data/local/tmp/junk");  /* 2 */
     TestPathJoin(rp, "tmp/", "//junk//", "tmp/junk");  /* 3 */
     TestPathJoin(rp, "tmp/", "junk/////", "tmp/junk");  /* 4 */
-    TestPathJoin(rp, "/tmp/", "///", "/tmp");  /* 5 */
+    TestPathJoin(rp, "/data/local/tmp/", "///", "/data/local/tmp");  /* 5 */
     TestPathJoin(rp, "////", NULL, "/");  /* 6 */
     TestPathJoin(rp, "//", "/junk//", "/junk");  /* 7 */
     TestPathJoin(rp, NULL, "/junk//", "/junk");  /* 8 */
@@ -86,8 +86,8 @@
     lept_stderr("The next 3 joins properly give error messages:\n");
     lept_stderr("join: .. + a --> NULL\n");
     pathJoin("..", "a");  /* returns NULL */
-    lept_stderr("join: %s + .. --> NULL\n", "/tmp");
-    pathJoin("/tmp", "..");  /* returns NULL */
+    lept_stderr("join: %s + .. --> NULL\n", "/data/local/tmp");
+    pathJoin("/data/local/tmp", "..");  /* returns NULL */
     lept_stderr("join: ./ + .. --> NULL\n");
     pathJoin("./", "..");  /* returns NULL */
 
@@ -95,12 +95,12 @@
     lept_stderr(" ======= Test lept_rmdir() and lept_mkdir()) =======\n");
     lept_stderr(" ===================================================\n");
     lept_rmdir("junkfiles");
-    lept_direxists("/tmp/junkfiles", &exists);
+    lept_direxists("/data/local/tmp/junkfiles", &exists);
     if (rp->display) lept_stderr("directory removed?: %d\n", !exists);
     regTestCompareValues(rp, 0, exists, 0.0);  /* 17 */
 
     lept_mkdir("junkfiles");
-    lept_direxists("/tmp/junkfiles", &exists);
+    lept_direxists("/data/local/tmp/junkfiles", &exists);
     if (rp->display) lept_stderr("directory made?: %d\n", exists);
     regTestCompareValues(rp, 1, exists, 0.0);  /* 18 */
 
@@ -121,12 +121,12 @@
     TestGenPathname(rp, "", "abc/def", "abc/def");  /* 38 */
 #ifndef _WIN32   /* unix only */
     if (getenv("TMPDIR") == NULL) {
-        TestGenPathname(rp, "/tmp", NULL, "/tmp");  /* 39 */
-        TestGenPathname(rp, "/tmp/", NULL, "/tmp");  /* 40 */
-        TestGenPathname(rp, "/tmp/junk", NULL, "/tmp/junk");  /* 41 */
-        TestGenPathname(rp, "/tmp/junk/abc", NULL, "/tmp/junk/abc");  /* 42 */
-        TestGenPathname(rp, "/tmp/junk/", NULL, "/tmp/junk");  /* 43 */
-        TestGenPathname(rp, "/tmp/junk", "abc", "/tmp/junk/abc");  /* 44 */
+        TestGenPathname(rp, "/data/local/tmp", NULL, "/data/local/tmp");  /* 39 */
+        TestGenPathname(rp, "/data/local/tmp/", NULL, "/data/local/tmp");  /* 40 */
+        TestGenPathname(rp, "/data/local/tmp/junk", NULL, "/data/local/tmp/junk");  /* 41 */
+        TestGenPathname(rp, "/data/local/tmp/junk/abc", NULL, "/data/local/tmp/junk/abc");  /* 42 */
+        TestGenPathname(rp, "/data/local/tmp/junk/", NULL, "/data/local/tmp/junk");  /* 43 */
+        TestGenPathname(rp, "/data/local/tmp/junk", "abc", "/data/local/tmp/junk/abc");  /* 44 */
     }
 #endif  /* !_WIN32 */
 
diff -Nura leptonica-1.83.1/prog/findbinding.c leptonica-1.83.1-patch/prog/findbinding.c
--- leptonica-1.83.1/prog/findbinding.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/findbinding.c	2024-09-05 14:26:11.027617983 +0800
@@ -133,8 +133,8 @@
         /* Plot the windowed variance as a function of the y-value
          * of the window location */
     lept_stderr("maxvar = %f, ymax = %d\n", maxvar, ymax);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/binding/root", NULL);
-    pix7 = pixRead("/tmp/lept/binding/root.png");
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/binding/root", NULL);
+    pix7 = pixRead("/data/local/tmp/lept/binding/root.png");
     pixDisplay(pix7, 0, 800);
     pixaAddPix(pixa, pix7, L_COPY);
 
@@ -146,9 +146,9 @@
     pixaAddPix(pixa, pix5, L_COPY);
 
         /* Bundle the results up in a pdf */
-    lept_stderr("Writing pdf output file: /tmp/lept/binding/binding.pdf\n");
+    lept_stderr("Writing pdf output file: /data/local/tmp/lept/binding/binding.pdf\n");
     pixaConvertToPdf(pixa, 45, 1.0, 0, 0, "Binding locator",
-                     "/tmp/lept/binding/binding.pdf");
+                     "/data/local/tmp/lept/binding/binding.pdf");
 
     pixDestroy(&pix1);
     pixDestroy(&pix2);
diff -Nura leptonica-1.83.1/prog/find_colorregions.c leptonica-1.83.1-patch/prog/find_colorregions.c
--- leptonica-1.83.1/prog/find_colorregions.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/find_colorregions.c	2024-09-05 14:26:11.027617983 +0800
@@ -77,7 +77,7 @@
 
     pix2 = pixaDisplayTiledInColumns(pixadb, 5, 0.3, 20, 2);
     pixDisplay(pix2, 0, 0);
-    pixWrite("/tmp/lept/color/result1.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/color/result1.png", pix2, IFF_PNG);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
     pixDestroy(&pix4);
@@ -93,7 +93,7 @@
 
     pix2 = pixaDisplayTiledInColumns(pixadb, 5, 0.3, 20, 2);
     pixDisplay(pix2, 1100, 0);
-    pixWrite("/tmp/lept/color/result2.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/color/result2.png", pix2, IFF_PNG);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
     pixDestroy(&pix4);
@@ -242,8 +242,8 @@
     pixDestroy(&pix2);
     if (pixadb) {
         L_INFO("val at 0.95 rank = %5.1f\n", __func__, val95);
-        gplotSimple1(nah, GPLOT_PNG, "/tmp/lept/histo1", "gray histo");
-        pix3 = pixRead("/tmp/lept/histo1.png");
+        gplotSimple1(nah, GPLOT_PNG, "/data/local/tmp/lept/histo1", "gray histo");
+        pix3 = pixRead("/data/local/tmp/lept/histo1.png");
         pix4 = pixExpandReplicate(pix3, 2);
         pixaAddPix(pixadb, pix4, L_INSERT);
         pixDestroy(&pix3);
diff -Nura leptonica-1.83.1/prog/findcorners_reg.c leptonica-1.83.1-patch/prog/findcorners_reg.c
--- leptonica-1.83.1/prog/findcorners_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/findcorners_reg.c	2024-09-05 14:26:11.027617983 +0800
@@ -42,9 +42,9 @@
  *   When this function is called with the display argument
  *        findcorners_reg display
  *   we display some results and additionally generate the following pdfs:
- *        /tmp/lept/regout/seq_output_1.pdf  (morphological operations of
+ *        /data/local/tmp/lept/regout/seq_output_1.pdf  (morphological operations of
  *                                       first call to locate barcodes)
- *        /tmp/lept/regout/tickets.pdf  (deskewed result for the set of tickets)
+ *        /data/local/tmp/lept/regout/tickets.pdf  (deskewed result for the set of tickets)
  */
 
 #ifdef HAVE_CONFIG_H
@@ -124,8 +124,8 @@
     }
     if (rp->display) {
         pixaConvertToPdf(pixa, 0, 1.0, 0, 0, "tickets",
-                         "/tmp/lept/regout/tickets.pdf");
-        L_INFO("Output pdf: /tmp/lept/regout/tickets.pdf\n", rp->testname);
+                         "/data/local/tmp/lept/regout/tickets.pdf");
+        L_INFO("Output pdf: /data/local/tmp/lept/regout/tickets.pdf\n", rp->testname);
     }
     pixaDestroy(&pixa);
 
diff -Nura leptonica-1.83.1/prog/findpattern1.c leptonica-1.83.1-patch/prog/findpattern1.c
--- leptonica-1.83.1/prog/findpattern1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/findpattern1.c	2024-09-05 14:26:11.027617983 +0800
@@ -34,7 +34,7 @@
  *    For example, use char.tif of a "c" bitmap, taken from the
  *    the page image feyn.tif:
  *
- *       findpattern1 feyn.tif char.tif /tmp/result.tif
+ *       findpattern1 feyn.tif char.tif /data/local/tmp/result.tif
  *
  *    This shows a number of different outputs, including a magnified
  *    image of the Sel superimposed on the "c" bitmap.
@@ -92,7 +92,7 @@
     selWriteStream(stderr, sel);
     pix1 = pixDisplayHitMissSel(pixpe, sel, 9, HitColor, MissColor);
     pixDisplay(pix1, 200, 200);
-    pixWrite("/tmp/lept/hmt/pix1.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pix1.png", pix1, IFF_PNG);
 
         /* Use the Sel to find all instances in the page */
     startTimer();
@@ -125,7 +125,7 @@
         pixRenderBoxArb(pix4, boxe, 2, 255, 0, 0);
         boxDestroy(&box);
     }
-    pixWrite("/tmp/lept/hmt/outline.png", pix4, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/outline.png", pix4, IFF_PNG);
     boxaWriteStderr(boxa2);
 
     pixDestroy(&pixs);
diff -Nura leptonica-1.83.1/prog/findpattern2.c leptonica-1.83.1-patch/prog/findpattern2.c
--- leptonica-1.83.1/prog/findpattern2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/findpattern2.c	2024-09-05 14:26:11.027617983 +0800
@@ -76,7 +76,7 @@
         /* Display the sel */
     pixsel = pixDisplayHitMissSel(pixp, selhm, 7, HitColor, MissColor);
     pixDisplay(pixsel, 200, 200);
-    pixWrite("/tmp/lept/hmt/pixsel1.png", pixsel, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixsel1.png", pixsel, IFF_PNG);
 
         /* Use the Sel to find all instances in the page */
     startTimer();
@@ -86,18 +86,18 @@
         /* Color each instance at full res */
     pixd1 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 1.0, 5);
-    pixWrite("/tmp/lept/hmt/pixd11.png", pixd1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd11.png", pixd1, IFF_PNG);
 
         /* Color each instance at 0.3 scale */
     pixd2 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 0.5, 5);
-    pixWrite("/tmp/lept/hmt/junkpixd12.png", pixd2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/junkpixd12.png", pixd2, IFF_PNG);
 
         /* Remove each instance from the input image */
     pixd3 = pixCopy(NULL, pixs);
     pixRemoveMatchedPattern(pixd3, pixp, pixhmt, selhm->cx,
                                     selhm->cy, 1);
-    pixWrite("/tmp/lept/hmt/pixr1.png", pixd3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixr1.png", pixd3, IFF_PNG);
 
     boxDestroy(&box);
     selDestroy(&selhm);
@@ -122,7 +122,7 @@
         /* Display the sel */
     pixsel = pixDisplayHitMissSel(pixp, selhm, 7, HitColor, MissColor);
     pixDisplay(pixsel, 200, 200);
-    pixWrite("/tmp/lept/hmt/pixsel2.png", pixsel, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixsel2.png", pixsel, IFF_PNG);
 
         /* Use the Sel to find all instances in the page */
     startTimer();
@@ -132,18 +132,18 @@
         /* Color each instance at full res */
     pixd1 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 1.0, 5);
-    pixWrite("/tmp/lept/hmt/pixd21.png", pixd1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd21.png", pixd1, IFF_PNG);
 
         /* Color each instance at 0.3 scale */
     pixd2 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 0.5, 5);
-    pixWrite("/tmp/lept/hmt/pixd22.png", pixd2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd22.png", pixd2, IFF_PNG);
 
         /* Remove each instance from the input image */
     pixd3 = pixCopy(NULL, pixs);
     pixRemoveMatchedPattern(pixd3, pixp, pixhmt, selhm->cx,
                                     selhm->cy, 1);
-    pixWrite("/tmp/lept/hmt/pixr2.png", pixd3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixr2.png", pixd3, IFF_PNG);
 
     selDestroy(&selhm);
     boxDestroy(&box);
diff -Nura leptonica-1.83.1/prog/findpattern3.c leptonica-1.83.1-patch/prog/findpattern3.c
--- leptonica-1.83.1/prog/findpattern3.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/findpattern3.c	2024-09-05 14:26:11.027617983 +0800
@@ -75,7 +75,7 @@
         /* Display the sel */
     pixsel = pixDisplayHitMissSel(pixp, selhm, 7, HitColor, MissColor);
     pixDisplay(pixsel, 200, 200);
-    pixWrite("/tmp/lept/hmt/pixsel1.png", pixsel, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixsel1.png", pixsel, IFF_PNG);
 
         /* Use the Sel to find all instances in the page */
     startTimer();
@@ -85,18 +85,18 @@
         /* Color each instance at full res */
     pixd1 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 1.0, 5);
-    pixWrite("/tmp/lept/hmt/pixd11.png", pixd1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd11.png", pixd1, IFF_PNG);
 
         /* Color each instance at 0.3 scale */
     pixd2 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 0.5, 5);
-    pixWrite("/tmp/lept/hmt/pixd12.png", pixd2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd12.png", pixd2, IFF_PNG);
 
         /* Remove each instance from the input image */
     pixd3 = pixCopy(NULL, pixs);
     pixRemoveMatchedPattern(pixd3, pixp, pixhmt, selhm->cx,
                                     selhm->cy, 1);
-    pixWrite("/tmp/lept/hmt/pixr1.png", pixd3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixr1.png", pixd3, IFF_PNG);
 
     boxDestroy(&box);
     selDestroy(&selhm);
@@ -121,7 +121,7 @@
         /* Display the sel */
     pixsel = pixDisplayHitMissSel(pixp, selhm, 7, HitColor, MissColor);
     pixDisplay(pixsel, 200, 200);
-    pixWrite("/tmp/lept/hmt/pixsel2.png", pixsel, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixsel2.png", pixsel, IFF_PNG);
 
         /* Use the Sel to find all instances in the page */
     startTimer();
@@ -131,18 +131,18 @@
         /* Color each instance at full res */
     pixd1 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 1.0, 5);
-    pixWrite("/tmp/lept/hmt/pixd21.png", pixd1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd21.png", pixd1, IFF_PNG);
 
         /* Color each instance at 0.3 scale */
     pixd2 = pixDisplayMatchedPattern(pixs, pixp, pixhmt, selhm->cx,
                                      selhm->cy, 0x0000ff00, 0.5, 5);
-    pixWrite("/tmp/lept/hmt/pixd22.png", pixd2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixd22.png", pixd2, IFF_PNG);
 
         /* Remove each instance from the input image */
     pixd3 = pixCopy(NULL, pixs);
     pixRemoveMatchedPattern(pixd3, pixp, pixhmt, selhm->cx,
                                     selhm->cy, 1);
-    pixWrite("/tmp/lept/hmt/pixr2.png", pixd3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/hmt/pixr2.png", pixd3, IFF_PNG);
 
     selDestroy(&selhm);
     boxDestroy(&box);
diff -Nura leptonica-1.83.1/prog/fpix1_reg.c leptonica-1.83.1-patch/prog/fpix1_reg.c
--- leptonica-1.83.1/prog/fpix1_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/fpix1_reg.c	2024-09-05 14:26:11.027617983 +0800
@@ -161,7 +161,7 @@
     pixCompareGray(pix2, pix4, L_COMPARE_ABS_DIFF, GPLOT_PNG, NULL,
                    &diff, NULL, NULL);
     lept_stderr("Ave diff of pixConvolveSep and fpixConvolveSep: %f\n", diff);
-    pix5 = pixRead("/tmp/lept/comp/compare_gray0.png");
+    pix5 = pixRead("/data/local/tmp/lept/comp/compare_gray0.png");
     regTestWritePixAndCheck(rp, pix5, IFF_PNG);  /* 9 */
     pixaAddPix(pixa, pix5, L_INSERT);
     pix1 = pixaDisplayTiledInColumns(pixa, 2, 1.0, 20, 2);
@@ -287,8 +287,8 @@
     dpixDestroy(&dpix2);
 
         /* Test affine and projective transforms on fpix */
-    fpixWrite("/tmp/lept/regout/fpix1.fp", dew->fullvdispar);
-    fpix1 = fpixRead("/tmp/lept/regout/fpix1.fp");
+    fpixWrite("/data/local/tmp/lept/regout/fpix1.fp", dew->fullvdispar);
+    fpix1 = fpixRead("/data/local/tmp/lept/regout/fpix1.fp");
     pix1 = fpixAutoRenderContours(fpix1, 40);
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 28 */
     pixDisplayWithTitle(pix1, 0, 500, NULL, rp->display);
diff -Nura leptonica-1.83.1/prog/fpixcontours.c leptonica-1.83.1-patch/prog/fpixcontours.c
--- leptonica-1.83.1/prog/fpixcontours.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/fpixcontours.c	2024-09-05 14:26:11.027617983 +0800
@@ -40,7 +40,7 @@
 #include <string.h>
 #include "allheaders.h"
 
-static const char *fileout = "/tmp/lept/fpix/fpixcontours.png";
+static const char *fileout = "/data/local/tmp/lept/fpix/fpixcontours.png";
 
 int main(int    argc,
          char **argv)
diff -Nura leptonica-1.83.1/prog/fuzzing/colorquant_fuzzer.cc leptonica-1.83.1-patch/prog/fuzzing/colorquant_fuzzer.cc
--- leptonica-1.83.1/prog/fuzzing/colorquant_fuzzer.cc	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/fuzzing/colorquant_fuzzer.cc	2024-09-05 14:26:11.027617983 +0800
@@ -35,7 +35,7 @@
     pix6 = pixFewColorsMedianCutQuantMixed(pix4, 30, 30, 100, 0, 0, 0);
 
     pix7 = pixDeskew(pixs, 0);
-    pixWriteImpliedFormat("/tmp/fuzzfile1", pix7, 0, 0);
+    pixWriteImpliedFormat("/data/local/tmp/fuzzfile1", pix7, 0, 0);
 
     pix8 = pixOctreeQuantByPopulation(pixs, 0, 0);
     pix9 = pixFewColorsOctcubeQuantMixed(pix4, 3, 20, 244, 20, 0.05, 15);
diff -Nura leptonica-1.83.1/prog/fuzzing/dewarp_fuzzer.cc leptonica-1.83.1-patch/prog/fuzzing/dewarp_fuzzer.cc
--- leptonica-1.83.1/prog/fuzzing/dewarp_fuzzer.cc	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/fuzzing/dewarp_fuzzer.cc	2024-09-05 14:26:11.027617983 +0800
@@ -15,7 +15,7 @@
     pixs = pixReadMemSpix(data, size);
     if(pixs==NULL) return 0;
     
-    // Don't use debug, because it requires writing to /tmp
+    // Don't use debug, because it requires writing to /data/local/tmp
     dewarpSinglePage(pixs, 0, 1, 1, 0, &pixd, NULL, 0);
 	
     pixac = pixacompReadMem(data, size);
diff -Nura leptonica-1.83.1/prog/fuzzing/pixa_recog_fuzzer.cc leptonica-1.83.1-patch/prog/fuzzing/pixa_recog_fuzzer.cc
--- leptonica-1.83.1/prog/fuzzing/pixa_recog_fuzzer.cc	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/fuzzing/pixa_recog_fuzzer.cc	2024-09-05 14:26:11.027617983 +0800
@@ -11,7 +11,7 @@
         leptSetStdNullHandler();
 
         char filename[256];
-        sprintf(filename, "/tmp/libfuzzer.pa");
+        sprintf(filename, "/data/local/tmp/libfuzzer.pa");
         FILE *fp = fopen(filename, "wb");
         if (!fp) return 0;
         fwrite(data, size, 1, fp);
diff -Nura leptonica-1.83.1/prog/fuzzing/recog_basic_fuzzer.cc leptonica-1.83.1-patch/prog/fuzzing/recog_basic_fuzzer.cc
--- leptonica-1.83.1/prog/fuzzing/recog_basic_fuzzer.cc	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/fuzzing/recog_basic_fuzzer.cc	2024-09-05 14:26:11.027617983 +0800
@@ -9,7 +9,7 @@
 
     L_RECOG  *recog;
     char filename[256];
-    sprintf(filename, "/tmp/libfuzzer.%d", getppid());
+    sprintf(filename, "/data/local/tmp/libfuzzer.%d", getppid());
 
     FILE *fp = fopen(filename, "wb");
     if (!fp)
diff -Nura leptonica-1.83.1/prog/gammatest.c leptonica-1.83.1-patch/prog/gammatest.c
--- leptonica-1.83.1/prog/gammatest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/gammatest.c	2024-09-05 14:26:11.031617904 +0800
@@ -73,12 +73,12 @@
     pixDestroy(&pixs);
 
     na = numaGammaTRC(gam, MINVAL, MAXVAL);
-    gplotSimple1(na, GPLOT_PNG, "/tmp/lept/gamma/trc", "gamma trc");
-    l_fileDisplay("/tmp/lept/gamma/trc.png", 100, 100, 1.0);
+    gplotSimple1(na, GPLOT_PNG, "/data/local/tmp/lept/gamma/trc", "gamma trc");
+    l_fileDisplay("/data/local/tmp/lept/gamma/trc.png", 100, 100, 1.0);
     numaDestroy(&na);
 
         /* Plot gamma TRC maps */
-    gplot = gplotCreate("/tmp/lept/gamma/corr", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/gamma/corr", GPLOT_PNG,
                         "Mapping function for gamma correction",
                         "value in", "value out");
     nax = numaMakeSequence(0.0, 1.0, 256);
@@ -90,7 +90,7 @@
     }
     gplotMakeOutput(gplot);
     gplotDestroy(&gplot);
-    l_fileDisplay("/tmp/lept/gamma/corr.png", 100, 100, 1.0);
+    l_fileDisplay("/data/local/tmp/lept/gamma/corr.png", 100, 100, 1.0);
     numaDestroy(&nax);
     return 0;
 }
diff -Nura leptonica-1.83.1/prog/genfonts_reg.c leptonica-1.83.1-patch/prog/genfonts_reg.c
--- leptonica-1.83.1/prog/genfonts_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/genfonts_reg.c	2024-09-05 14:26:11.031617904 +0800
@@ -80,8 +80,8 @@
     lept_rmdir("lept/filefonts");
     lept_mkdir("lept/filefonts");
     for (i = 0; i < 9; i++) {
-        pixaSaveFont("fonts", "/tmp/lept/filefonts", sizes[i]);
-        pathname = pathJoin("/tmp/lept/filefonts", outputfonts[i]);
+        pixaSaveFont("fonts", "/data/local/tmp/lept/filefonts", sizes[i]);
+        pathname = pathJoin("/data/local/tmp/lept/filefonts", outputfonts[i]);
         pixa = pixaRead(pathname);
         if (rp->display) {
             lept_stderr("Found %d chars in font size %d\n",
@@ -100,8 +100,8 @@
     lept_rmdir("lept/strfonts");
     lept_mkdir("lept/strfonts");
     for (i = 0; i < 9; i++) {
-        pixaSaveFont(NULL, "/tmp/lept/strfonts", sizes[i]);
-        pathname = pathJoin("/tmp/lept/strfonts", outputfonts[i]);
+        pixaSaveFont(NULL, "/data/local/tmp/lept/strfonts", sizes[i]);
+        pathname = pathJoin("/data/local/tmp/lept/strfonts", outputfonts[i]);
         pixa = pixaRead(pathname);
         if (rp->display) {
             lept_stderr("Found %d chars in font size %d\n",
@@ -119,9 +119,9 @@
     lept_rmdir("lept/pafonts");
     lept_mkdir("lept/pafonts");
     for (i = 0; i < 9; i++) {
-        pixa = pixaGetFont("/tmp/lept/strfonts", sizes[i], &bl1, &bl2, &bl3);
+        pixa = pixaGetFont("/data/local/tmp/lept/strfonts", sizes[i], &bl1, &bl2, &bl3);
         lept_stderr("Baselines are at: %d, %d, %d\n", bl1, bl2, bl3);
-        snprintf(buf, sizeof(buf), "/tmp/lept/pafonts/chars-%d.pa", sizes[i]);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/pafonts/chars-%d.pa", sizes[i]);
         pixaWrite(buf, pixa);
         if (i == 2) {
             pixd = pixaDisplayTiled(pixa, 1500, 0, 15);
@@ -144,7 +144,7 @@
             lept_stderr("nbytes = %lu, sbytes = %d\n",
                         (unsigned long)nbytes, sbytes);
         formstr = reformatPacked64(datastr, sbytes, 4, 72, 1, &formbytes);
-        snprintf(buf, sizeof(buf), "/tmp/lept/encfonts/formstr_%d.txt",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/encfonts/formstr_%d.txt",
                  fontsize);
         l_binaryWrite(buf, "w", formstr, formbytes);
         regTestCheckFile(rp, buf);  /* 18-26 */
@@ -153,7 +153,7 @@
         lept_free(data1);
 
         data2 = decodeBase64(datastr, sbytes, &rbytes);
-        snprintf(buf, sizeof(buf), "/tmp/lept/encfonts/image_%d.tif", fontsize);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/encfonts/image_%d.tif", fontsize);
         l_binaryWrite(buf, "w", data2, rbytes);
         if (i == 8) {
             pix2 = pixReadMem(data2, rbytes);  /* encode/decode */
diff -Nura leptonica-1.83.1/prog/gifio_reg.c leptonica-1.83.1-patch/prog/gifio_reg.c
--- leptonica-1.83.1/prog/gifio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/gifio_reg.c	2024-09-05 14:26:11.031617904 +0800
@@ -131,7 +131,7 @@
 
     if (rp->display) {
         pix = pixaDisplayTiledAndScaled(pixa, 32, 450, 3, 0, 20, 2);
-        pixWrite("/tmp/lept/gif/giftest.jpg", pix, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/gif/giftest.jpg", pix, IFF_JFIF_JPEG);
         pixDisplay(pix, 100, 100);
         pixDestroy(&pix);
         pixaDestroy(&pixa);
@@ -169,10 +169,10 @@
 PIX     *pixs, *pix1, *pix2;
 
     pixs = pixRead(fname);
-    snprintf(buf, sizeof(buf), "/tmp/lept/gif/gifio-a.%d.gif", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/gif/gifio-a.%d.gif", rp->index + 1);
     pixWrite(buf, pixs, IFF_GIF);
     pix1 = pixRead(buf);
-    snprintf(buf, sizeof(buf), "/tmp/lept/gif/gifio-b.%d.gif", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/gif/gifio-b.%d.gif", rp->index + 1);
     pixWrite(buf, pix1, IFF_GIF);
     pix2 = pixRead(buf);
     regTestWritePixAndCheck(rp, pix2, IFF_GIF);
diff -Nura leptonica-1.83.1/prog/grayquant_reg.c leptonica-1.83.1-patch/prog/grayquant_reg.c
--- leptonica-1.83.1/prog/grayquant_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/grayquant_reg.c	2024-09-05 14:26:11.031617904 +0800
@@ -129,7 +129,7 @@
         lept_mkdir("lept/gquant");
         pix1 = pixaDisplayTiled(pixa, 2000, 0, 20);
         pixDisplay(pix1, 100, 100);
-        pixWrite("/tmp/lept/gquant/mosaic1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gquant/mosaic1.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
     pixaDestroy(&pixa);
@@ -211,7 +211,7 @@
     if (rp->display) {
         pix1 = pixaDisplayTiled(pixa, 2000, 0, 20);
         pixDisplay(pix1, 200, 100);
-        pixWrite("/tmp/lept/gquant/mosaic2.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gquant/mosaic2.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
     pixaDestroy(&pixa);
@@ -309,7 +309,7 @@
     if (rp->display) {
         pix1 = pixaDisplayTiled(pixa, 2000, 0, 20);
         pixDisplay(pix1, 300, 100);
-        pixWrite("/tmp/lept/gquant/mosaic3.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gquant/mosaic3.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
     pixaDestroy(&pixa);
@@ -368,7 +368,7 @@
     if (rp->display) {
         pix1 = pixaDisplayTiled(pixa, 2000, 0, 20);
         pixDisplay(pix1, 400, 100);
-        pixWrite("/tmp/lept/gquant/mosaic4.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gquant/mosaic4.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
     pixaDestroy(&pixa);
@@ -379,7 +379,7 @@
         startTimer();
         pix1 = pixScaleGray2xLIThresh(pixs, THRESHOLD);
         lept_stderr(" time for scale/dither = %7.3f sec\n", stopTimer());
-        pixWrite("/tmp/lept/gquant/upscale1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gquant/upscale1.png", pix1, IFF_PNG);
         pixDisplay(pix1, 0, 500);
         pixDestroy(&pix1);
 
@@ -387,7 +387,7 @@
         startTimer();
         pix1 = pixScaleGray4xLIThresh(pixs, THRESHOLD);
         lept_stderr(" time for scale/dither = %7.3f sec\n", stopTimer());
-        pixWrite("/tmp/lept/gquant/upscale2.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/gquant/upscale2.png", pix1, IFF_PNG);
         pixDisplay(pix1, 700, 500);
         pixDestroy(&pix1);
         pixDestroy(&pixs);
diff -Nura leptonica-1.83.1/prog/histoduptest.c leptonica-1.83.1-patch/prog/histoduptest.c
--- leptonica-1.83.1/prog/histoduptest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/histoduptest.c	2024-09-05 14:26:11.031617904 +0800
@@ -99,13 +99,13 @@
 
         /* Show the similarity classes. */
     numaWriteStderr(nai);
-    pixWrite("/tmp/lept/comp/photoclass1.jpg", pix1, IFF_JFIF_JPEG);
-    lept_stderr("Writing photo classes: /tmp/lept/comp/photoclass1.jpg\n");
+    pixWrite("/data/local/tmp/lept/comp/photoclass1.jpg", pix1, IFF_JFIF_JPEG);
+    lept_stderr("Writing photo classes: /data/local/tmp/lept/comp/photoclass1.jpg\n");
     numaDestroy(&nai);
     pixDestroy(&pix1);
 
         /* Show the scores between images as a 2d array */
-    pix2 = pixRead("/tmp/lept/comp/scorearray.png");
+    pix2 = pixRead("/data/local/tmp/lept/comp/scorearray.png");
     pixDisplay(pix2, 100, 100);
     pixDestroy(&pix2);
     pixaDestroy(&pixa1);
@@ -129,13 +129,13 @@
 
         /* Show the similarity classes. */
     numaWriteStderr(nai);
-    pixWrite("/tmp/lept/comp/photoclass2.jpg", pix1, IFF_JFIF_JPEG);
-    lept_stderr("Writing photo classes: /tmp/lept/comp/photoclass2.jpg\n");
+    pixWrite("/data/local/tmp/lept/comp/photoclass2.jpg", pix1, IFF_JFIF_JPEG);
+    lept_stderr("Writing photo classes: /data/local/tmp/lept/comp/photoclass2.jpg\n");
     numaDestroy(&nai);
     pixDestroy(&pix1);
 
         /* Show the scores between images as a 2d array */
-    pix2 = pixRead("/tmp/lept/comp/scorearray.png");
+    pix2 = pixRead("/data/local/tmp/lept/comp/scorearray.png");
     pixDisplay(pix2, 100, 100);
     pixDestroy(&pix2);
     pixaDestroy(&pixa1);
@@ -226,7 +226,7 @@
      * -------------------------------------------------------------- */
         /* Are the images photo or text?  This is the morphological
          * method, which is more accurate than the variance of gray
-         * histo method.  Output to /tmp/lept/comp/isphoto1.pdf.  */
+         * histo method.  Output to /data/local/tmp/lept/comp/isphoto1.pdf.  */
     pixa1 = pixaCreateFromPixacomp(pac, L_COPY);
     n = pixaGetCount(pixa1);
     pixa2 = pixaCreate(n);
@@ -254,9 +254,9 @@
         pixDestroy(&pix1);
         boxDestroy(&box1);
     }
-    lept_stderr("Writing to: /tmp/lept/comp/isphoto1.pdf\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/comp/isphoto1.pdf\n");
     pixaConvertToPdf(pixa2, 300, 1.0, L_FLATE_ENCODE, 0, NULL,
-                         "/tmp/lept/comp/isphoto1.pdf");
+                         "/data/local/tmp/lept/comp/isphoto1.pdf");
     pixaDestroy(&pixa1);
     pixaDestroy(&pixa2);
 #endif
diff -Nura leptonica-1.83.1/prog/histotest.c leptonica-1.83.1-patch/prog/histotest.c
--- leptonica-1.83.1/prog/histotest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/histotest.c	2024-09-05 14:26:11.031617904 +0800
@@ -78,26 +78,26 @@
         if ((na1 = pixOctcubeHistogram(pixs, sigbits, NULL)) == NULL)
             return ERROR_INT("na1 not made", __func__, 1);
         lept_stderr("histo time = %7.3f sec\n", stopTimer());
-        gplot = gplotCreate("/tmp/lept/histo/color", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/histo/color", GPLOT_PNG,
                             "color histogram with octcube indexing",
                             "octcube index", "number of pixels in cube");
         gplotAddPlot(gplot, NULL, na1, GPLOT_LINES, "input pix");
         gplotMakeOutput(gplot);
         gplotDestroy(&gplot);
-        l_fileDisplay("/tmp/lept/histo/color.png", 100, 100, 1.0);
+        l_fileDisplay("/data/local/tmp/lept/histo/color.png", 100, 100, 1.0);
     }
     else {
         if ((na1 = pixGetGrayHistogram(pixs, 1)) == NULL)
             return ERROR_INT("na1 not made", __func__, 1);
-        numaWrite("/tmp/junk.na", na1);
-        gplot = gplotCreate("/tmp/lept/histo/gray", GPLOT_PNG,
+        numaWrite("/data/local/tmp/junk.na", na1);
+        gplot = gplotCreate("/data/local/tmp/lept/histo/gray", GPLOT_PNG,
                             "grayscale histogram", "gray value",
                             "number of pixels");
         gplotSetScaling(gplot, GPLOT_LOG_SCALE_Y);
         gplotAddPlot(gplot, NULL, na1, GPLOT_LINES, "input pix");
         gplotMakeOutput(gplot);
         gplotDestroy(&gplot);
-        l_fileDisplay("/tmp/lept/histo/gray.png", 100, 100, 1.0);
+        l_fileDisplay("/data/local/tmp/lept/histo/gray.png", 100, 100, 1.0);
     }
 
     pixDestroy(&pixs);
@@ -106,9 +106,9 @@
         /* Test behavior of pixThresholdByHisto() */
 #if 0  /* for valgrind, use pnm instead of jpg */
     pix1 = pixRead("lyra.005.jpg");
-    pixWrite("/tmp/lyra.005.pnm", pix1, IFF_PNM);
+    pixWrite("/data/local/tmp/lyra.005.pnm", pix1, IFF_PNM);
 #endif
-/*    pix1 = pixRead("/tmp/lyra.005.pnm"); */
+/*    pix1 = pixRead("/data/local/tmp/lyra.005.pnm"); */
     pixs = pixRead("lyra.005.jpg");
     box1 = boxCreate(0, 173, 350, 580);
     pix1 = pixClipRectangle(pixs, box1, 0);
diff -Nura leptonica-1.83.1/prog/htmlviewer.c leptonica-1.83.1-patch/prog/htmlviewer.c
--- leptonica-1.83.1/prog/htmlviewer.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/htmlviewer.c	2024-09-05 14:26:11.031617904 +0800
@@ -37,13 +37,13 @@
  *            viewwidth: max width of view images, in pixels; use 0 for default
  *
  *    Example:
- *         mkdir /tmp/lept/lion-in
- *         mkdir /tmp/lept/lion-out
- *         cp lion-page* /tmp/lept/lion-in
- *         htmlviewer /tmp/lept/lion-in /tmp/lept/lion-out lion 200 600
+ *         mkdir /data/local/tmp/lept/lion-in
+ *         mkdir /data/local/tmp/lept/lion-out
+ *         cp lion-page* /data/local/tmp/lept/lion-in
+ *         htmlviewer /data/local/tmp/lept/lion-in /data/local/tmp/lept/lion-out lion 200 600
  *        ==> output:
- *            /tmp/lept/lion-out/lion.html         (main html file)
- *            /tmp/lept/lion-out/lion-links.html   (html file of links)
+ *            /data/local/tmp/lept/lion-out/lion.html         (main html file)
+ *            /data/local/tmp/lept/lion-out/lion-links.html   (html file of links)
  */
 
 #ifdef HAVE_CONFIG_H
diff -Nura leptonica-1.83.1/prog/insert_reg.c leptonica-1.83.1-patch/prog/insert_reg.c
--- leptonica-1.83.1/prog/insert_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/insert_reg.c	2024-09-05 14:26:11.031617904 +0800
@@ -57,12 +57,12 @@
     if (regTestSetup(argc, argv, &rp))
         return 1;
 
-    lept_rmfile("/tmp/lept/regout/insert3.ba");
-    lept_rmfile("/tmp/lept/regout/insert4.ba");
-    lept_rmfile("/tmp/lept/regout/insert6.pa");
-    lept_rmfile("/tmp/lept/regout/insert7.pa");
-    lept_rmfile("/tmp/lept/regout/insert9.pa");
-    lept_rmfile("/tmp/lept/regout/insert10.pa");
+    lept_rmfile("/data/local/tmp/lept/regout/insert3.ba");
+    lept_rmfile("/data/local/tmp/lept/regout/insert4.ba");
+    lept_rmfile("/data/local/tmp/lept/regout/insert6.pa");
+    lept_rmfile("/data/local/tmp/lept/regout/insert7.pa");
+    lept_rmfile("/data/local/tmp/lept/regout/insert9.pa");
+    lept_rmfile("/data/local/tmp/lept/regout/insert10.pa");
 
     /* ----------------- Test numa operations -------------------- */
     pi = 3.1415926535;
@@ -72,7 +72,7 @@
         val = (l_float32)sin(angle);
         numaAddNumber(na1, val);
     }
-    numaWrite("/tmp/lept/regout/insert0.na", na1);
+    numaWrite("/data/local/tmp/lept/regout/insert0.na", na1);
     na2 = numaCopy(na1);
     n = numaGetCount(na2);
     for (i = 0; i < n; i++) {
@@ -80,9 +80,9 @@
         numaRemoveNumber(na2, i);
         numaInsertNumber(na2, i, val);
     }
-    numaWrite("/tmp/lept/regout/insert1.na", na2);
-    regTestCheckFile(rp, "/tmp/lept/regout/insert0.na");  /* 0 */
-    regTestCheckFile(rp, "/tmp/lept/regout/insert1.na");  /* 1 */
+    numaWrite("/data/local/tmp/lept/regout/insert1.na", na2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert0.na");  /* 0 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert1.na");  /* 1 */
     regTestCompareFiles(rp, 0, 1);  /* 2 */
     numaDestroy(&na1);
     numaDestroy(&na2);
@@ -93,16 +93,16 @@
     pix2 = pixClipRectangle(pix1, box, NULL);
     boxDestroy(&box);
     boxa1 = pixConnComp(pix2, NULL, 8);
-    boxaWrite("/tmp/lept/regout/insert3.ba", boxa1);
+    boxaWrite("/data/local/tmp/lept/regout/insert3.ba", boxa1);
     boxa2 = boxaCopy(boxa1, L_COPY);
     n = boxaGetCount(boxa2);
     for (i = 0; i < n; i++) {
         boxaRemoveBoxAndSave(boxa2, i, &box);
         boxaInsertBox(boxa2, i, box);
     }
-    boxaWrite("/tmp/lept/regout/insert4.ba", boxa2);
-    regTestCheckFile(rp, "/tmp/lept/regout/insert3.ba");  /* 3 */
-    regTestCheckFile(rp, "/tmp/lept/regout/insert4.ba");  /* 4 */
+    boxaWrite("/data/local/tmp/lept/regout/insert4.ba", boxa2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert3.ba");  /* 3 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert4.ba");  /* 4 */
     regTestCompareFiles(rp, 3, 4);  /* 5 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -116,8 +116,8 @@
     boxDestroy(&box);
     boxa = pixConnComp(pix2, &pixa1, 8);
     boxaDestroy(&boxa);
-    pixaWrite("/tmp/lept/regout/insert6.pa", pixa1);
-    regTestCheckFile(rp, "/tmp/lept/regout/insert6.pa");  /* 6 */
+    pixaWrite("/data/local/tmp/lept/regout/insert6.pa", pixa1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert6.pa");  /* 6 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
 
@@ -128,8 +128,8 @@
         pixaRemovePixAndSave(pixa2, i, &pix, &box);
         pixaInsertPix(pixa2, i, pix, box);
     }
-    pixaWrite("/tmp/lept/regout/insert7.pa", pixa2);
-    regTestCheckFile(rp, "/tmp/lept/regout/insert7.pa");  /* 7 */
+    pixaWrite("/data/local/tmp/lept/regout/insert7.pa", pixa2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert7.pa");  /* 7 */
     regTestCompareFiles(rp, 6, 7);  /* 8 */
 
         /* Move the last to the beginning; do it n times */
@@ -140,8 +140,8 @@
         pixaInsertPix(pixa3, 0, pix, box);
         pixaRemovePix(pixa3, n);
     }
-    pixaWrite("/tmp/lept/regout/insert9.pa", pixa3);
-    regTestCheckFile(rp, "/tmp/lept/regout/insert9.pa");  /* 9 */
+    pixaWrite("/data/local/tmp/lept/regout/insert9.pa", pixa3);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert9.pa");  /* 9 */
 
         /* Move the first one to the end; do it n times */
     pixa4 = pixaCopy(pixa3, L_COPY);
@@ -151,8 +151,8 @@
         pixaInsertPix(pixa4, n, pix, box);  /* make sure insert works at end */
         pixaRemovePix(pixa4, 0);
     }
-    pixaWrite("/tmp/lept/regout/insert10.pa", pixa4);
-    regTestCheckFile(rp, "/tmp/lept/regout/insert10.pa");  /* 10 */
+    pixaWrite("/data/local/tmp/lept/regout/insert10.pa", pixa4);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/insert10.pa");  /* 10 */
     regTestCompareFiles(rp, 9, 10);  /* 11 */
     pixaDestroy(&pixa1);
     pixaDestroy(&pixa2);
diff -Nura leptonica-1.83.1/prog/ioformats_reg.c leptonica-1.83.1-patch/prog/ioformats_reg.c
--- leptonica-1.83.1/prog/ioformats_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/ioformats_reg.c	2024-09-05 14:26:11.031617904 +0800
@@ -235,27 +235,27 @@
         d = pixGetDepth(pix);
         lept_stderr("%d bpp\n", d);
         if (i == 0) {   /* 1 bpp */
-            pixWrite("/tmp/lept/regout/junkg3.tif", pix, IFF_TIFF_G3);
-            pixWrite("/tmp/lept/regout/junkg4.tif", pix, IFF_TIFF_G4);
-            pixWrite("/tmp/lept/regout/junkrle.tif", pix, IFF_TIFF_RLE);
-            pixWrite("/tmp/lept/regout/junkpb.tif", pix, IFF_TIFF_PACKBITS);
-            if (testcomp("/tmp/lept/regout/junkg3.tif", pix, IFF_TIFF_G3))
+            pixWrite("/data/local/tmp/lept/regout/junkg3.tif", pix, IFF_TIFF_G3);
+            pixWrite("/data/local/tmp/lept/regout/junkg4.tif", pix, IFF_TIFF_G4);
+            pixWrite("/data/local/tmp/lept/regout/junkrle.tif", pix, IFF_TIFF_RLE);
+            pixWrite("/data/local/tmp/lept/regout/junkpb.tif", pix, IFF_TIFF_PACKBITS);
+            if (testcomp("/data/local/tmp/lept/regout/junkg3.tif", pix, IFF_TIFF_G3))
                 success = FALSE;
-            if (testcomp("/tmp/lept/regout/junkg4.tif", pix, IFF_TIFF_G4))
+            if (testcomp("/data/local/tmp/lept/regout/junkg4.tif", pix, IFF_TIFF_G4))
                 success = FALSE;
-            if (testcomp("/tmp/lept/regout/junkrle.tif", pix, IFF_TIFF_RLE))
+            if (testcomp("/data/local/tmp/lept/regout/junkrle.tif", pix, IFF_TIFF_RLE))
                 success = FALSE;
-            if (testcomp("/tmp/lept/regout/junkpb.tif", pix, IFF_TIFF_PACKBITS))
+            if (testcomp("/data/local/tmp/lept/regout/junkpb.tif", pix, IFF_TIFF_PACKBITS))
                 success = FALSE;
         }
-        pixWrite("/tmp/lept/regout/junklzw.tif", pix, IFF_TIFF_LZW);
-        pixWrite("/tmp/lept/regout/junkzip.tif", pix, IFF_TIFF_ZIP);
-        pixWrite("/tmp/lept/regout/junknon.tif", pix, IFF_TIFF);
-        if (testcomp("/tmp/lept/regout/junklzw.tif", pix, IFF_TIFF_LZW))
+        pixWrite("/data/local/tmp/lept/regout/junklzw.tif", pix, IFF_TIFF_LZW);
+        pixWrite("/data/local/tmp/lept/regout/junkzip.tif", pix, IFF_TIFF_ZIP);
+        pixWrite("/data/local/tmp/lept/regout/junknon.tif", pix, IFF_TIFF);
+        if (testcomp("/data/local/tmp/lept/regout/junklzw.tif", pix, IFF_TIFF_LZW))
             success = FALSE;
-        if (testcomp("/tmp/lept/regout/junkzip.tif", pix, IFF_TIFF_ZIP))
+        if (testcomp("/data/local/tmp/lept/regout/junkzip.tif", pix, IFF_TIFF_ZIP))
             success = FALSE;
-        if (testcomp("/tmp/lept/regout/junknon.tif", pix, IFF_TIFF))
+        if (testcomp("/data/local/tmp/lept/regout/junknon.tif", pix, IFF_TIFF))
             success = FALSE;
         pixDestroy(&pix);
     }
@@ -263,16 +263,16 @@
         /* Test writing and reading tiff colormaps */
     lept_stderr("Tiff read/write 8 bpp with cmap\n");
     pix1 = pixRead(FILE_8BPP_2);
-    pixWrite("/tmp/lept/regout/weas8.tif", pix1, IFF_TIFF);
-    readHeaderTiff("/tmp/lept/regout/weas8.tif", 0, &w, &h, &bps, &spp,
+    pixWrite("/data/local/tmp/lept/regout/weas8.tif", pix1, IFF_TIFF);
+    readHeaderTiff("/data/local/tmp/lept/regout/weas8.tif", 0, &w, &h, &bps, &spp,
                    NULL, &iscmap, NULL);
     if (w != 82 || h != 73 || bps != 8 || spp != 1 || iscmap != 1) {
         lept_stderr("Header error testing tiff cmaps\n");
         success = FALSE;
     }
-    pix2 = pixRead("/tmp/lept/regout/weas8.tif");
-    pixWrite("/tmp/lept/regout/weas8a.tif", pix2, IFF_TIFF);
-    pix3 = pixRead("/tmp/lept/regout/weas8a.tif");
+    pix2 = pixRead("/data/local/tmp/lept/regout/weas8.tif");
+    pixWrite("/data/local/tmp/lept/regout/weas8a.tif", pix2, IFF_TIFF);
+    pix3 = pixRead("/data/local/tmp/lept/regout/weas8a.tif");
     pixEqual(pix1, pix3, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for cmaps\n");
@@ -289,8 +289,8 @@
     pixcmapAddColor(cmap, 0, 0, 0);  /* inverted b/w */
     pixcmapAddColor(cmap, 255, 255, 255);
     pixSetColormap(pix1, cmap);
-    pixWrite("/tmp/lept/regout/fract1.tif", pix1, IFF_TIFF_ZIP);
-    pix2 = pixRead("/tmp/lept/regout/fract1.tif");
+    pixWrite("/data/local/tmp/lept/regout/fract1.tif", pix1, IFF_TIFF_ZIP);
+    pix2 = pixRead("/data/local/tmp/lept/regout/fract1.tif");
     pixEqual(pix1, pix2, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for 1 bpp cmap\n");
@@ -300,8 +300,8 @@
     pixcmapAddColor(cmap, 255, 255, 255);
     pixcmapAddColor(cmap, 100, 200, 50);  /* with color */
     pixSetColormap(pix1, cmap);  /* replace the colormap */
-    pixWrite("/tmp/lept/regout/fract2.tif", pix1, IFF_TIFF_ZIP);
-    pix3 = pixRead("/tmp/lept/regout/fract2.tif");
+    pixWrite("/data/local/tmp/lept/regout/fract2.tif", pix1, IFF_TIFF_ZIP);
+    pix3 = pixRead("/data/local/tmp/lept/regout/fract2.tif");
     pixEqual(pix1, pix3, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for 1 bpp color cmap\n");
@@ -314,14 +314,14 @@
         /* Test writing and reading tiff with alpha */
     lept_stderr("Tiff read/write gray plus alpha\n");
     pix1 = pixRead(FILE_GRAY_ALPHA_TIF);  /* converts to RGBA */
-    pixWrite("/tmp/lept/regout/graya.tif", pix1, IFF_TIFF);
-    readHeaderTiff("/tmp/lept/regout/graya.tif", 0, &w, &h, &bps, &spp,
+    pixWrite("/data/local/tmp/lept/regout/graya.tif", pix1, IFF_TIFF);
+    readHeaderTiff("/data/local/tmp/lept/regout/graya.tif", 0, &w, &h, &bps, &spp,
                    NULL, &iscmap, NULL);
     if (w != 100 || h != 100 || bps != 8 || spp != 4 || iscmap != 0) {
         lept_stderr("Header error testing tiff with alpha\n");
         success = FALSE;
     }
-    pix2 = pixRead("/tmp/lept/regout/graya.tif");
+    pix2 = pixRead("/data/local/tmp/lept/regout/graya.tif");
     pixEqual(pix1, pix2, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for graya.tif\n");
@@ -330,8 +330,8 @@
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pix1 = pixRead(FILE_GRAY_ALPHA);  /* converts to RGBA */
-    pixWriteTiff("/tmp/lept/regout/graya2.tif", pix1, IFF_TIFF_ZIP, "w");
-    pix2 = pixRead("/tmp/lept/regout/graya2.tif");
+    pixWriteTiff("/data/local/tmp/lept/regout/graya2.tif", pix1, IFF_TIFF_ZIP, "w");
+    pix2 = pixRead("/data/local/tmp/lept/regout/graya2.tif");
     pixEqual(pix1, pix2, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for graya2.tif\n");
@@ -343,14 +343,14 @@
         /* Test reading 16 bit sampled rgb tiff */
     lept_stderr("Tiff read/write 16 bit sampled rgb\n");
     pix1 = pixRead(FILE_RGB16_TIF);  /* converts 16 to 8 bits RGB */
-    pixWrite("/tmp/lept/regout/rgb16.tif", pix1, IFF_TIFF_ZIP);
-    readHeaderTiff("/tmp/lept/regout/rgb16.tif", 0, &w, &h, &bps, &spp,
+    pixWrite("/data/local/tmp/lept/regout/rgb16.tif", pix1, IFF_TIFF_ZIP);
+    readHeaderTiff("/data/local/tmp/lept/regout/rgb16.tif", 0, &w, &h, &bps, &spp,
                    NULL, &iscmap, NULL);
     if (w != 129 || h != 90 || bps != 8 || spp != 3 || iscmap != 0) {
         lept_stderr("Header error testing tiff with alpha\n");
         success = FALSE;
     }
-    pix2 = pixRead("/tmp/lept/regout/rgb16.tif");
+    pix2 = pixRead("/data/local/tmp/lept/regout/rgb16.tif");
     pixEqual(pix1, pix2, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for rgb16.tif\n");
@@ -362,14 +362,14 @@
         /* Test reading 32 bit rgb with approx half-sized tiff buffer */
     lept_stderr("Tiff read/write rgb with half-sized tiff buffer\n");
     pix1 = pixRead("testbuffer.tif");
-    pixWrite("/tmp/lept/regout/testbuffer.tif", pix1, IFF_TIFF_ZIP);
-    readHeaderTiff("/tmp/lept/regout/testbuffer.tif", 0, &w, &h, &bps, &spp,
+    pixWrite("/data/local/tmp/lept/regout/testbuffer.tif", pix1, IFF_TIFF_ZIP);
+    readHeaderTiff("/data/local/tmp/lept/regout/testbuffer.tif", 0, &w, &h, &bps, &spp,
                    &res, &iscmap, NULL);
     if (w != 659 || h != 799 || bps != 8 || spp != 3 || res != 96) {
         lept_stderr("Header error testing rgb tiff with small tif buffer\n");
         success = FALSE;
     }
-    pix2 = pixRead("/tmp/lept/regout/testbuffer.tif");
+    pix2 = pixRead("/data/local/tmp/lept/regout/testbuffer.tif");
     pixEqual(pix1, pix2, &same);
     if (!same) {
         lept_stderr("Tiff read/write failed for testbuffer.tif\n");
@@ -398,14 +398,14 @@
         lept_stderr("%d bpp\n", d);
         if (i == 0) {   /* 1 bpp */
             pixWriteMemTiff(&data, &size, pix, IFF_TIFF_G3);
-            nbytes = nbytesInFile("/tmp/lept/regout/junkg3.tif");
+            nbytes = nbytesInFile("/data/local/tmp/lept/regout/junkg3.tif");
             lept_stderr("nbytes = %lu, size = %lu\n",
                         (unsigned long)nbytes, (unsigned long)size);
             pixt = pixReadMemTiff(data, size, 0);
             if (testcomp_mem(pix, &pixt, i, IFF_TIFF_G3)) success = FALSE;
             lept_free(data);
             pixWriteMemTiff(&data, &size, pix, IFF_TIFF_G4);
-            nbytes = nbytesInFile("/tmp/lept/regout/junkg4.tif");
+            nbytes = nbytesInFile("/data/local/tmp/lept/regout/junkg4.tif");
             lept_stderr("nbytes = %lu, size = %lu\n",
                         (unsigned long)nbytes, (unsigned long)size);
             pixt = pixReadMemTiff(data, size, 0);
@@ -415,14 +415,14 @@
             lept_stderr("(w,h,bps,spp) = (%d,%d,%d,%d)\n", w, h, bps, spp);
             lept_free(data);
             pixWriteMemTiff(&data, &size, pix, IFF_TIFF_RLE);
-            nbytes = nbytesInFile("/tmp/lept/regout/junkrle.tif");
+            nbytes = nbytesInFile("/data/local/tmp/lept/regout/junkrle.tif");
             lept_stderr("nbytes = %lu, size = %lu\n",
                         (unsigned long)nbytes, (unsigned long)size);
             pixt = pixReadMemTiff(data, size, 0);
             if (testcomp_mem(pix, &pixt, i, IFF_TIFF_RLE)) success = FALSE;
             lept_free(data);
             pixWriteMemTiff(&data, &size, pix, IFF_TIFF_PACKBITS);
-            nbytes = nbytesInFile("/tmp/lept/regout/junkpb.tif");
+            nbytes = nbytesInFile("/data/local/tmp/lept/regout/junkpb.tif");
             lept_stderr("nbytes = %lu, size = %lu\n",
                         (unsigned long)nbytes, (unsigned long)size);
             pixt = pixReadMemTiff(data, size, 0);
@@ -462,7 +462,7 @@
             continue;
         }
         d = pixGetDepth(pix);
-        snprintf(psname, sizeof(psname), "/tmp/lept/regout/junkps.%d", d);
+        snprintf(psname, sizeof(psname), "/data/local/tmp/lept/regout/junkps.%d", d);
         lept_stderr("%d bpp\n", d);
         if (test_writemem(pix, IFF_PNM, NULL)) success = FALSE;
         if (test_writemem(pix, IFF_PS, psname)) success = FALSE;
@@ -499,14 +499,14 @@
         if ((pixt = pixaGetPix(pixa, i, L_CLONE)) == NULL)
             continue;
         if (i == 0)
-            pixWriteTiff("/tmp/lept/regout/junktiffmpage.tif", pixt,
+            pixWriteTiff("/data/local/tmp/lept/regout/junktiffmpage.tif", pixt,
                          IFF_TIFF_G4, "w");
         else
-            pixWriteTiff("/tmp/lept/regout/junktiffmpage.tif", pixt,
+            pixWriteTiff("/data/local/tmp/lept/regout/junktiffmpage.tif", pixt,
                          IFF_TIFF_G4, "a");
         pixDestroy(&pixt);
     }
-    data = l_binaryRead("/tmp/lept/regout/junktiffmpage.tif", &nbytes);
+    data = l_binaryRead("/data/local/tmp/lept/regout/junktiffmpage.tif", &nbytes);
     pixaDestroy(&pixa);
 
         /* Read the individual pages from memory to a pix */
@@ -555,10 +555,10 @@
     if ((pix = pixRead("marge.jpg")) == NULL)
         success = FALSE;
     pixt = make_24_bpp_pix(pix);
-    pixWrite("/tmp/lept/regout/junk24.png", pixt, IFF_PNG);
-    pixWrite("/tmp/lept/regout/junk24.jpg", pixt, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/regout/junk24.tif", pixt, IFF_TIFF);
-    pixd = pixRead("/tmp/lept/regout/junk24.png");
+    pixWrite("/data/local/tmp/lept/regout/junk24.png", pixt, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/regout/junk24.jpg", pixt, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/junk24.tif", pixt, IFF_TIFF);
+    pixd = pixRead("/data/local/tmp/lept/regout/junk24.png");
     pixEqual(pix, pixd, &same);
     if (same) {
         lept_stderr("    **** success writing 24 bpp png ****\n");
@@ -567,10 +567,10 @@
         success = FALSE;
     }
     pixDestroy(&pixd);
-    pixd = pixRead("/tmp/lept/regout/junk24.jpg");
+    pixd = pixRead("/data/local/tmp/lept/regout/junk24.jpg");
     regTestCompareSimilarPix(rp, pix, pixd, 10, 0.0002, 0);
     pixDestroy(&pixd);
-    pixd = pixRead("/tmp/lept/regout/junk24.tif");
+    pixd = pixRead("/data/local/tmp/lept/regout/junk24.tif");
     pixEqual(pix, pixd, &same);
     if (same) {
         lept_stderr("    **** success writing 24 bpp tif ****\n");
diff -Nura leptonica-1.83.1/prog/iomisc_reg.c leptonica-1.83.1-patch/prog/iomisc_reg.c
--- leptonica-1.83.1/prog/iomisc_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/iomisc_reg.c	2024-09-05 14:26:11.035617826 +0800
@@ -77,14 +77,14 @@
 
         /* Test 16 to 8 stripping */
     pixs = pixRead("test16.tif");
-    pixWrite("/tmp/lept/io/test16.png", pixs, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/io/test16.png");  /* 0 */
-    pix1 = pixRead("/tmp/lept/io/test16.png");
+    pixWrite("/data/local/tmp/lept/io/test16.png", pixs, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/test16.png");  /* 0 */
+    pix1 = pixRead("/data/local/tmp/lept/io/test16.png");
     d = pixGetDepth(pix1);
     regTestCompareValues(rp, 8, d, 0.0);  /* 1 */
     pixDestroy(&pix1);
     l_pngSetReadStrip16To8(0);
-    pix1 = pixRead("/tmp/lept/io/test16.png");
+    pix1 = pixRead("/data/local/tmp/lept/io/test16.png");
     d = pixGetDepth(pix1);
     regTestCompareValues(rp, 16, d, 0.0);  /* 2 */
     pixDestroy(&pix1);
@@ -92,24 +92,24 @@
 
         /* Test chroma sampling options in jpeg */
     pixs = pixRead("marge.jpg");
-    pixWrite("/tmp/lept/io/chromatest1.jpg", pixs, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/io/chromatest1.jpg");  /* 3 */
+    pixWrite("/data/local/tmp/lept/io/chromatest1.jpg", pixs, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/chromatest1.jpg");  /* 3 */
     if (rp->display) {
-        size = nbytesInFile("/tmp/lept/io/chromatest1.jpg");
+        size = nbytesInFile("/data/local/tmp/lept/io/chromatest1.jpg");
         lept_stderr("chroma default: file size = %ld\n", (unsigned long)size);
     }
     pixSetChromaSampling(pixs, 0);
-    pixWrite("/tmp/lept/io/chromatest2.jpg", pixs, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/io/chromatest2.jpg");  /* 4 */
+    pixWrite("/data/local/tmp/lept/io/chromatest2.jpg", pixs, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/chromatest2.jpg");  /* 4 */
     if (rp->display) {
-        size = nbytesInFile("/tmp/lept/io/chromatest2.jpg");
+        size = nbytesInFile("/data/local/tmp/lept/io/chromatest2.jpg");
         lept_stderr("no ch. sampling: file size = %ld\n", (unsigned long)size);
     }
     pixSetChromaSampling(pixs, 1);
-    pixWrite("/tmp/lept/io/chromatest3.jpg", pixs, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/io/chromatest3.jpg");  /* 5 */
+    pixWrite("/data/local/tmp/lept/io/chromatest3.jpg", pixs, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/chromatest3.jpg");  /* 5 */
     if (rp->display) {
-        size = nbytesInFile("/tmp/lept/io/chromatest3.jpg");
+        size = nbytesInFile("/data/local/tmp/lept/io/chromatest3.jpg");
         lept_stderr("chroma default: file size = %ld\n", (unsigned long)size);
     }
     pixDestroy(&pixs);
@@ -125,14 +125,14 @@
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 7 */
     pixDisplayWithTitle(pix1, 0, 250, NULL, rp->display);
     pix2 = pixSetAlphaOverWhite(pix1);  /* regenerate alpha from white */
-    pixWrite("/tmp/lept/io/logo2.png", pix2, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/io/logo2.png");  /* 8 */
+    pixWrite("/data/local/tmp/lept/io/logo2.png", pix2, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/logo2.png");  /* 8 */
     pixDisplayWithTitle(pix2, 0, 400, NULL, rp->display);
     pixg = pixGetRGBComponent(pix2, L_ALPHA_CHANNEL);
     regTestWritePixAndCheck(rp, pixg, IFF_PNG);  /* 9 */
     pixDisplayWithTitle(pixg, 300, 400, NULL, rp->display);
     pixDestroy(&pixg);
-    pix3 = pixRead("/tmp/lept/io/logo2.png");
+    pix3 = pixRead("/data/local/tmp/lept/io/logo2.png");
     pix4 = pixAlphaBlendUniform(pix3, 0x00ffff00);  /* render rgb over cyan */
     regTestWritePixAndCheck(rp, pix4, IFF_PNG);  /* 10 */
     pixDisplayWithTitle(pix3, 0, 550, NULL, rp->display);
@@ -156,17 +156,17 @@
     cmap = pixGetColormap(pixs);
         /* Write and read back the colormap */
     if (rp->display) pixcmapWriteStream(stderr, pixGetColormap(pixs));
-    fp = lept_fopen("/tmp/lept/io/cmap1", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/io/cmap1", "wb");
     pixcmapWriteStream(fp, pixGetColormap(pixs));
     lept_fclose(fp);
-    regTestCheckFile(rp, "/tmp/lept/io/cmap1");  /* 11 */
-    fp = lept_fopen("/tmp/lept/io/cmap1", "rb");
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/cmap1");  /* 11 */
+    fp = lept_fopen("/data/local/tmp/lept/io/cmap1", "rb");
     cmap = pixcmapReadStream(fp);
     lept_fclose(fp);
-    fp = lept_fopen("/tmp/lept/io/cmap2", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/io/cmap2", "wb");
     pixcmapWriteStream(fp, cmap);
     lept_fclose(fp);
-    regTestCheckFile(rp, "/tmp/lept/io/cmap2");  /* 12 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/cmap2");  /* 12 */
     pixcmapDestroy(&cmap);
 
         /* Remove and regenerate colormap */
@@ -218,39 +218,39 @@
                     ImageFileFormatExtensions[format]);
     }
     pixs = pixRead("feyn-fract.tif");
-    pixWrite("/tmp/lept/io/fract1.tif", pixs, IFF_TIFF);
-    regTestCheckFile(rp, "/tmp/lept/io/fract1.tif");  /* 18 */
-    size = nbytesInFile("/tmp/lept/io/fract1.tif");
+    pixWrite("/data/local/tmp/lept/io/fract1.tif", pixs, IFF_TIFF);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/fract1.tif");  /* 18 */
+    size = nbytesInFile("/data/local/tmp/lept/io/fract1.tif");
     regTestCompareValues(rp, tiffsize[0], size, 0.0);  /* 19 */
     if (rp->display)
         lept_stderr("uncompressed: %ld\n", (unsigned long)size);
-    pixWrite("/tmp/lept/io/fract2.tif", pixs, IFF_TIFF_PACKBITS);
-    regTestCheckFile(rp, "/tmp/lept/io/fract2.tif");  /* 20 */
-    size = nbytesInFile("/tmp/lept/io/fract2.tif");
+    pixWrite("/data/local/tmp/lept/io/fract2.tif", pixs, IFF_TIFF_PACKBITS);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/fract2.tif");  /* 20 */
+    size = nbytesInFile("/data/local/tmp/lept/io/fract2.tif");
     regTestCompareValues(rp, tiffsize[1], size, 0.0);  /* 21 */
     if (rp->display)
         lept_stderr("packbits: %ld\n", (unsigned long)size);
-    pixWrite("/tmp/lept/io/fract3.tif", pixs, IFF_TIFF_RLE);
-    regTestCheckFile(rp, "/tmp/lept/io/fract3.tif");  /* 22 */
-    size = nbytesInFile("/tmp/lept/io/fract3.tif");
+    pixWrite("/data/local/tmp/lept/io/fract3.tif", pixs, IFF_TIFF_RLE);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/fract3.tif");  /* 22 */
+    size = nbytesInFile("/data/local/tmp/lept/io/fract3.tif");
     regTestCompareValues(rp, tiffsize[2], size, 0.0);  /* 23 */
     if (rp->display)
         lept_stderr("rle: %ld\n", (unsigned long)size);
-    pixWrite("/tmp/lept/io/fract4.tif", pixs, IFF_TIFF_G3);
-    regTestCheckFile(rp, "/tmp/lept/io/fract4.tif");  /* 24 */
-    size = nbytesInFile("/tmp/lept/io/fract4.tif");
+    pixWrite("/data/local/tmp/lept/io/fract4.tif", pixs, IFF_TIFF_G3);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/fract4.tif");  /* 24 */
+    size = nbytesInFile("/data/local/tmp/lept/io/fract4.tif");
     regTestCompareValues(rp, tiffsize[3], size, 0.0);  /* 25 */
     if (rp->display)
         lept_stderr("g3: %ld\n", (unsigned long)size);
-    pixWrite("/tmp/lept/io/fract5.tif", pixs, IFF_TIFF_G4);
-    regTestCheckFile(rp, "/tmp/lept/io/fract5.tif");  /* 26 */
-    size = nbytesInFile("/tmp/lept/io/fract5.tif");
+    pixWrite("/data/local/tmp/lept/io/fract5.tif", pixs, IFF_TIFF_G4);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/fract5.tif");  /* 26 */
+    size = nbytesInFile("/data/local/tmp/lept/io/fract5.tif");
     regTestCompareValues(rp, tiffsize[4], size, 0.0);  /* 27 */
     if (rp->display)
         lept_stderr("g4: %ld\n", (unsigned long)size);
-    pixWrite("/tmp/lept/io/fract6.tif", pixs, IFF_TIFF_LZW);
-    regTestCheckFile(rp, "/tmp/lept/io/fract6.tif");  /* 28 */
-    size = nbytesInFile("/tmp/lept/io/fract6.tif");
+    pixWrite("/data/local/tmp/lept/io/fract6.tif", pixs, IFF_TIFF_LZW);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/fract6.tif");  /* 28 */
+    size = nbytesInFile("/data/local/tmp/lept/io/fract6.tif");
     regTestCompareValues(rp, tiffsize[5], size, 0.0);  /* 29 */
     if (rp->display)
         lept_stderr("lzw: %ld\n", (unsigned long)size);
@@ -258,9 +258,9 @@
 
         /* Test read/write of alpha with pnm */
     pixs = pixRead("books_logo.png");
-    pixWrite("/tmp/lept/io/alpha1.pnm", pixs, IFF_PNM);
-    regTestCheckFile(rp, "/tmp/lept/io/alpha1.pnm");  /* 30 */
-    pix1 = pixRead("/tmp/lept/io/alpha1.pnm");
+    pixWrite("/data/local/tmp/lept/io/alpha1.pnm", pixs, IFF_PNM);
+    regTestCheckFile(rp, "/data/local/tmp/lept/io/alpha1.pnm");  /* 30 */
+    pix1 = pixRead("/data/local/tmp/lept/io/alpha1.pnm");
     regTestComparePix(rp, pixs, pix1);  /* 31 */
     pixDisplayWithTitle(pix1, 600, 100, NULL, rp->display);
     pixDestroy(&pixs);
diff -Nura leptonica-1.83.1/prog/italic_reg.c leptonica-1.83.1-patch/prog/italic_reg.c
--- leptonica-1.83.1/prog/italic_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/italic_reg.c	2024-09-05 14:26:11.035617826 +0800
@@ -61,14 +61,14 @@
 
         /* Basic functionality with debug flag */
     pixItalicWords(pixs, NULL, NULL, &boxa1, 1);
-    boxaWrite("/tmp/lept/ital/ital1.ba", boxa1);
-    regTestCheckFile(rp, "/tmp/lept/ital/ital1.ba");  /* 0 */
-    regTestCheckFile(rp, "/tmp/lept/ital/ital.3.pdf");  /* 1 */
-    pix1 = pixRead("/tmp/lept/ital/ital.3.png");
+    boxaWrite("/data/local/tmp/lept/ital/ital1.ba", boxa1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/ital/ital1.ba");  /* 0 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/ital/ital.3.pdf");  /* 1 */
+    pix1 = pixRead("/data/local/tmp/lept/ital/ital.3.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 2 */
     pixDisplayWithTitle(pix1, 0, 0, "Intermediate steps", rp->display);
     pixDestroy(&pix1);
-    pix1 = pixRead("/tmp/lept/ital/runhisto.png");
+    pix1 = pixRead("/data/local/tmp/lept/ital/runhisto.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 3 */
     pixDisplayWithTitle(pix1, 400, 0, "Histogram of white runs", rp->display);
     pixDestroy(&pix1);
@@ -78,8 +78,8 @@
     pixWordMaskByDilation(pixs, NULL, &size, pixadb);
     l_pdfSetDateAndVersion(0);
     pixaConvertToPdf(pixadb, 100, 1.0, L_FLATE_ENCODE, 0, "Word Mask",
-                     "/tmp/lept/ital/wordmask.pdf");
-    regTestCheckFile(rp, "/tmp/lept/ital/wordmask.pdf");  /* 4 */
+                     "/data/local/tmp/lept/ital/wordmask.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/ital/wordmask.pdf");  /* 4 */
     pix1 = pixaDisplayTiledInColumns(pixadb, 1, 1.0, 25, 2);
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 5 */
     pixDisplayWithTitle(pix1, 1400, 0, "Intermediate mask step", rp->display);
@@ -93,16 +93,16 @@
 
         /* Re-run italic finder using the word mask */
     pixItalicWords(pixs, NULL, pixm, &boxa2, 1);
-    boxaWrite("/tmp/lept/ital/ital2.ba", boxa2);
-    regTestCheckFile(rp, "/tmp/lept/ital/ital2.ba");  /* 7 */
+    boxaWrite("/data/local/tmp/lept/ital/ital2.ba", boxa2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/ital/ital2.ba");  /* 7 */
 
         /* Re-run italic finder using word mask bounding boxes */
     boxa3 = pixConnComp(pixm, NULL, 8);
     pixItalicWords(pixs, boxa3, NULL, &boxa4, 1);
-    boxaWrite("/tmp/lept/ital/ital3.ba", boxa3);
-    regTestCheckFile(rp, "/tmp/lept/ital/ital3.ba");  /* 8 */
-    boxaWrite("/tmp/lept/ital/ital4.ba", boxa4);
-    regTestCheckFile(rp, "/tmp/lept/ital/ital4.ba");  /* 9 */
+    boxaWrite("/data/local/tmp/lept/ital/ital3.ba", boxa3);
+    regTestCheckFile(rp, "/data/local/tmp/lept/ital/ital3.ba");  /* 8 */
+    boxaWrite("/data/local/tmp/lept/ital/ital4.ba", boxa4);
+    regTestCheckFile(rp, "/data/local/tmp/lept/ital/ital4.ba");  /* 9 */
     regTestCompareFiles(rp, 7, 9);  /* 10 */
 
     boxaDestroy(&boxa1);
diff -Nura leptonica-1.83.1/prog/jbclass_reg.c leptonica-1.83.1-patch/prog/jbclass_reg.c
--- leptonica-1.83.1/prog/jbclass_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/jbclass_reg.c	2024-09-05 14:26:11.035617826 +0800
@@ -69,18 +69,18 @@
     pixGetDimensions(pix1, &w, &h, NULL);
     box = boxCreate(0, 0, w, h / 2);
     pix2 = pixClipRectangle(pix1, box, NULL);
-    pixWrite("/tmp/lept/class/pix1.tif", pix2, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/class/pix1.tif", pix2, IFF_TIFF_G4);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pix1 = pixRead("pageseg4.tif");
     pix2 = pixClipRectangle(pix1, box, NULL);
-    pixWrite("/tmp/lept/class/pix2.tif", pix2, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/class/pix2.tif", pix2, IFF_TIFF_G4);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     boxDestroy(&box);
     sa = sarrayCreate(2);
-    sarrayAddString(sa, "/tmp/lept/class/pix1.tif", L_COPY);
-    sarrayAddString(sa, "/tmp/lept/class/pix2.tif", L_COPY);
+    sarrayAddString(sa, "/data/local/tmp/lept/class/pix1.tif", L_COPY);
+    sarrayAddString(sa, "/data/local/tmp/lept/class/pix2.tif", L_COPY);
 
     /*--------------------------------------------------------------*/
 
@@ -90,10 +90,10 @@
 
         /* Save and write out the result */
     data = jbDataSave(classer);
-    jbDataWrite("/tmp/lept/class/corr", data);
+    jbDataWrite("/data/local/tmp/lept/class/corr", data);
     lept_stderr("Number of classes: %d\n", classer->nclass);
 
-    pix1 = pixRead("/tmp/lept/class/corr.templates.png");
+    pix1 = pixRead("/data/local/tmp/lept/class/corr.templates.png");
     regTestWritePixAndCheck(rp, pix1, IFF_TIFF_G4);  /* 0 */
     pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
     pixDestroy(&pix1);
@@ -130,10 +130,10 @@
 
         /* Save and write out the result */
     data = jbDataSave(classer);
-    jbDataWrite("/tmp/lept/class2/haus", data);
+    jbDataWrite("/data/local/tmp/lept/class2/haus", data);
     lept_stderr("Number of classes: %d\n", classer->nclass);
 
-    pix1 = pixRead("/tmp/lept/class2/haus.templates.png");
+    pix1 = pixRead("/data/local/tmp/lept/class2/haus.templates.png");
     regTestWritePixAndCheck(rp, pix1, IFF_TIFF_G4);  /* 4 */
     pixDisplayWithTitle(pix1, 200, 0, NULL, rp->display);
     pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/jbcorrelation.c leptonica-1.83.1-patch/prog/jbcorrelation.c
--- leptonica-1.83.1/prog/jbcorrelation.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/jbcorrelation.c	2024-09-05 14:26:11.035617826 +0800
@@ -39,7 +39,7 @@
  *             The default size is given in jbclass.c.
  *         (2) The two output files (for templates and c.c. data)
  *             are written with the rootname
- *               /tmp/lept/jb/result
+ *               /data/local/tmp/lept/jb/result
  */
 
 #ifdef HAVE_CONFIG_H
@@ -61,7 +61,7 @@
 #define   DISPLAY_DIFFERENCE        1
 #define   DISPLAY_ALL_INSTANCES     0
 
-static const char  rootname[] = "/tmp/lept/jb/result";
+static const char  rootname[] = "/data/local/tmp/lept/jb/result";
 
 int main(int    argc,
          char **argv)
@@ -149,7 +149,7 @@
     pix1 = pixRead(fname);
     pix2 = pixaGetPix(pixa, 0, L_CLONE);
     pixXor(pix1, pix1, pix2);
-    pixWrite("/tmp/lept/jb/output_diff.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/jb/output_diff.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     }
@@ -206,7 +206,7 @@
         /* Display all instances, organized by template.
          * The display programs have a lot of trouble with these. */
     pix = pixaaDisplayByPixa(classer->pixaa, 5, 1.0, 10, 0, 0);
-    pixWrite("/tmp/lept/jb/output_instances", pix, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/jb/output_instances", pix, IFF_PNG);
     pixDestroy(&pix);
 #endif  /* DISPLAY_ALL_INSTANCES */
 
diff -Nura leptonica-1.83.1/prog/jbrankhaus.c leptonica-1.83.1-patch/prog/jbrankhaus.c
--- leptonica-1.83.1/prog/jbrankhaus.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/jbrankhaus.c	2024-09-05 14:26:11.035617826 +0800
@@ -42,7 +42,7 @@
  *               rank = 0.97
  *     (3) The two output files (for templates and c.c. data)
  *         are written with the rootname
- *               /tmp/lept/jb/result
+ *               /data/local/tmp/lept/jb/result
  */
 
 #ifdef HAVE_CONFIG_H
@@ -64,7 +64,7 @@
 #define   DISPLAY_DIFFERENCE        1
 #define   DISPLAY_ALL_INSTANCES     0
 
-static const char  rootname[] = "/tmp/lept/jb/result";
+static const char  rootname[] = "/data/local/tmp/lept/jb/result";
 
 int main(int    argc,
          char **argv)
@@ -149,7 +149,7 @@
     pix1 = pixRead(fname);
     pix2 = pixaGetPix(pixa, 0, L_CLONE);
     pixXor(pix1, pix1, pix2);
-    pixWrite("/tmp/lept/jb/output_diff.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/jb/output_diff.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     }
@@ -206,7 +206,7 @@
         /* Display all instances, organized by template
          * The display programs have a lot of trouble with these. */
     pix = pixaaDisplayByPixa(classer->pixaa, 5, 1.0, 10, 0, 0);
-    pixWrite("/tmp/lept/jb/output_instances", pix, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/jb/output_instances", pix, IFF_PNG);
     pixDestroy(&pix);
 #endif  /* DISPLAY_ALL_INSTANCES */
 
diff -Nura leptonica-1.83.1/prog/jp2kio_reg.c leptonica-1.83.1-patch/prog/jp2kio_reg.c
--- leptonica-1.83.1/prog/jp2kio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/jp2kio_reg.c	2024-09-05 14:26:11.035617826 +0800
@@ -114,7 +114,7 @@
         /* Test cropping and scaling in the jp2 interface */
     box = boxCreate(w / 4, h / 4, w / 2, h / 2);
     pix1 = pixReadJp2k(name, 1, box, 0, 0);  /* read cropped to the box */
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jp2kio.%02d.jp2",
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jp2kio.%02d.jp2",
              rp->index + 1);
     pixWriteJp2k(buf, pix1, 38, 0, 0, 0);  /* write cropped to the box */
     regTestCheckFile(rp, buf);  /* 2, 7 */
@@ -164,7 +164,7 @@
         /* Test scaling on read with the memory interface */
     box = boxCreate(w / 3, h / 3, w / 3, h / 3);
     pix1 = pixReadJp2k(name, 1, box, 0, 0);  /* just read the box region */
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jp2kio.%02d.jp2",
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jp2kio.%02d.jp2",
              rp->index + 1);
     pixWriteJp2k(buf, pix1, 38, 0, 0, 0);  /* write cropped to the box */
     regTestCheckFile(rp, buf);  /* 13 */
@@ -194,11 +194,11 @@
         /* Test write and read using J2K codec */
     lept_mkdir("lept/jp2k");
     pix0 = pixRead(fname);
-    if ((fp = fopenWriteStream("/tmp/lept/jp2k/wyom.j2k", "wb+")) != NULL) {
+    if ((fp = fopenWriteStream("/data/local/tmp/lept/jp2k/wyom.j2k", "wb+")) != NULL) {
         pixWriteStreamJp2k(fp, pix0, 34, 4, L_J2K_CODEC, 0, 0);
         fclose(fp);
     }
-    pix1 = pixRead("/tmp/lept/jp2k/wyom.j2k");
+    pix1 = pixRead("/data/local/tmp/lept/jp2k/wyom.j2k");
     regTestCompareSimilarPix(rp, pix0, pix1, 20, 0.01, 0);  /* 16 */
     pixDisplayWithTitle(pix1, 500, 500, NULL, rp->display);
     pixDestroy(&pix0);
diff -Nura leptonica-1.83.1/prog/jpegio_reg.c leptonica-1.83.1-patch/prog/jpegio_reg.c
--- leptonica-1.83.1/prog/jpegio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/jpegio_reg.c	2024-09-05 14:26:11.035617826 +0800
@@ -106,7 +106,7 @@
 
         /* Test file read/write (general functions) */
     pixs = pixRead(fname);
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
     pixWrite(buf, pixs, IFF_JFIF_JPEG);
     pix1 = pixRead(buf);
     regTestCompareSimilarPix(rp, pixs, pix1, 6, 0.01, 0);
@@ -121,7 +121,7 @@
         /* Test file read/write (specialized jpeg functions) */
     pix3 = pixReadJpeg(fname, 0, 1, NULL, 0);
     regTestComparePix(rp, pixs, pix3);
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
     pixWriteJpeg(buf, pix3, 75, 0);
     pix4 = pixReadJpeg(buf, 0, 1, NULL, 0);
     regTestComparePix(rp, pix2, pix4);
@@ -152,7 +152,7 @@
 
         /* Test file read/write (general functions) */
     pixs = pixRead(fname);
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
     pixWrite(buf, pixs, IFF_JFIF_JPEG);
     pix1 = pixRead(buf);
     if (pixGetColormap(pixs) != NULL)
@@ -170,7 +170,7 @@
 
         /* Test file write (specialized jpeg function) */
     pix4 = pixRead(fname);
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
     pixWriteJpeg(buf, pix4, 75, 0);
     pix5 = pixReadJpeg(buf, 0, 1, NULL, 0);
     regTestComparePix(rp, pix5, pix5);
@@ -242,7 +242,7 @@
     snprintf(comment1, sizeof(comment1), "Test %d", rp->index + 1);
     pixSetText(pixs, comment1);
     pixSetResolution(pixs, 137, 137);
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/jpegio.%d.jpg", rp->index + 1);
     pixWrite(buf, pixs, IFF_JFIF_JPEG);
     regTestCheckFile(rp, buf);
     fp = lept_fopen(buf, "rb");
diff -Nura leptonica-1.83.1/prog/kernel_reg.c leptonica-1.83.1-patch/prog/kernel_reg.c
--- leptonica-1.83.1/prog/kernel_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/kernel_reg.c	2024-09-05 14:26:11.035617826 +0800
@@ -70,21 +70,21 @@
     pixa = pixaCreate(0);
     kel1 = kernelCreateFromString(5, 5, 2, 2, kdatastr);
     pixd = kernelDisplayInPix(kel1, 41, 2);
-    pixWrite("/tmp/lept/regout/pixkern.png", pixd, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/pixkern.png");  /* 0 */
+    pixWrite("/data/local/tmp/lept/regout/pixkern.png", pixd, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/pixkern.png");  /* 0 */
     pixaAddPix(pixa, pixd, L_INSERT);
     pixaaAddPixa(paa, pixa, L_INSERT);
     kernelDestroy(&kel1);
 
         /* Test read/write for kernel.  Note that both get
          * compared to the same golden file, which is
-         * overwritten with a copy of /tmp/lept/regout/kern2.kel */
+         * overwritten with a copy of /data/local/tmp/lept/regout/kern2.kel */
     kel1 = kernelCreateFromString(5, 5, 2, 2, kdatastr);
-    kernelWrite("/tmp/lept/regout/kern1.kel", kel1);
-    regTestCheckFile(rp, "/tmp/lept/regout/kern1.kel");  /* 1 */
-    kel2 = kernelRead("/tmp/lept/regout/kern1.kel");
-    kernelWrite("/tmp/lept/regout/kern2.kel", kel2);
-    regTestCheckFile(rp, "/tmp/lept/regout/kern2.kel");  /* 2 */
+    kernelWrite("/data/local/tmp/lept/regout/kern1.kel", kel1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/kern1.kel");  /* 1 */
+    kel2 = kernelRead("/data/local/tmp/lept/regout/kern1.kel");
+    kernelWrite("/data/local/tmp/lept/regout/kern2.kel", kel2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/kern2.kel");  /* 2 */
     regTestCompareFiles(rp, 1, 2);  /* 3 */
     kernelDestroy(&kel1);
     kernelDestroy(&kel2);
@@ -99,11 +99,11 @@
     sarrayAddString(sa, "82.    120  180   120  80", L_COPY);
     sarrayAddString(sa, "22.1   50   80    50   20", L_COPY);
     str = sarrayToString(sa, 1);
-    l_binaryWrite("/tmp/lept/regout/kernfile.kel", "w", str, strlen(str));
-    kel2 = kernelCreateFromFile("/tmp/lept/regout/kernfile.kel");
+    l_binaryWrite("/data/local/tmp/lept/regout/kernfile.kel", "w", str, strlen(str));
+    kel2 = kernelCreateFromFile("/data/local/tmp/lept/regout/kernfile.kel");
     pixd = kernelDisplayInPix(kel2, 41, 2);
-    pixWrite("/tmp/lept/regout/ker1.png", pixd, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker1.png");  /* 4 */
+    pixWrite("/data/local/tmp/lept/regout/ker1.png", pixd, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker1.png");  /* 4 */
     pixaAddPix(pixa, pixd, L_INSERT);
     sarrayDestroy(&sa);
     lept_free(str);
@@ -128,8 +128,8 @@
     pixSetPixel(pixt, 4, 2, 20);
     kel3 = kernelCreateFromPix(pixt, 1, 2);
     pixd = kernelDisplayInPix(kel3, 41, 2);
-    pixWrite("/tmp/lept/regout/ker2.png", pixd, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker2.png");  /* 5 */
+    pixWrite("/data/local/tmp/lept/regout/ker2.png", pixd, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker2.png");  /* 5 */
     pixaAddPix(pixa, pixd, L_INSERT);
     pixaaAddPixa(paa, pixa, L_INSERT);
     pixDestroy(&pixt);
@@ -142,8 +142,8 @@
     pixaAddPix(pixa, pixg, L_INSERT);
     kel1 = kernelCreateFromString(5, 5, 2, 2, kdatastr);
     pixd = pixConvolve(pixg, kel1, 8, 1);
-    pixWrite("/tmp/lept/regout/ker3.png", pixd, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker3.png");  /* 6 */
+    pixWrite("/data/local/tmp/lept/regout/ker3.png", pixd, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker3.png");  /* 6 */
     pixaAddPix(pixa, pixd, L_INSERT);
     pixaaAddPixa(paa, pixa, L_INSERT);
     pixDestroy(&pixs);
@@ -157,20 +157,20 @@
     kel2 = makeFlatKernel(11, 11, 5, 5);
     pixd = pixConvolve(pixg, kel2, 8, 1);
     pixaAddPix(pixa, pixd, L_COPY);
-    pixWrite("/tmp/lept/regout/ker4.png", pixd, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker4.png");  /* 7 */
+    pixWrite("/data/local/tmp/lept/regout/ker4.png", pixd, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker4.png");  /* 7 */
     pixt = pixBlockconv(pixg, 5, 5);
     pixaAddPix(pixa, pixt, L_COPY);
-    pixWrite("/tmp/lept/regout/ker5.png", pixt, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker5.png");  /* 8 */
+    pixWrite("/data/local/tmp/lept/regout/ker5.png", pixt, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker5.png");  /* 8 */
     if (rp->display)
         pixCompareGray(pixd, pixt, L_COMPARE_ABS_DIFF, GPLOT_PNG, NULL,
                        NULL, NULL, NULL);
     pixt2 = pixBlockconvTiled(pixg, 5, 5, 3, 6);
     pixaAddPix(pixa, pixt2, L_INSERT);
     pixaaAddPixa(paa, pixa, L_INSERT);
-    pixWrite("/tmp/lept/regout/ker5a.png", pixt2, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker5a.png");  /* 9 */
+    pixWrite("/data/local/tmp/lept/regout/ker5a.png", pixt2, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker5a.png");  /* 9 */
 
     ok = TRUE;
     for (i = 1; i <= 7; i++) {
@@ -212,24 +212,24 @@
     pixt = pixConvolve(pixs, kel3, 8, 1);
     lept_stderr("Generic convolution time: %5.3f sec\n", stopTimer());
     pixaAddPix(pixa, pixt, L_INSERT);
-    pixWrite("/tmp/lept/regout/conv1.png", pixt, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/conv1.png");  /* 10 */
+    pixWrite("/data/local/tmp/lept/regout/conv1.png", pixt, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/conv1.png");  /* 10 */
 
     startTimer();
     pixt2 = pixBlockconv(pixs, 3, 3);
     lept_stderr("Flat block convolution time: %5.3f sec\n", stopTimer());
     pixaAddPix(pixa, pixt2, L_INSERT);
-    pixWrite("/tmp/lept/regout/conv2.png", pixt2, IFF_PNG);  /* ditto */
-    regTestCheckFile(rp, "/tmp/lept/regout/conv2.png");  /* 11 */
+    pixWrite("/data/local/tmp/lept/regout/conv2.png", pixt2, IFF_PNG);  /* ditto */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/conv2.png");  /* 11 */
 
     plottype = (rp->display) ? GPLOT_PNG : 0;
     pixCompareGray(pixt, pixt2, L_COMPARE_ABS_DIFF, plottype, NULL,
                    &avediff, &rmsdiff, NULL);
-    pixp = pixRead("/tmp/lept/comp/compare_gray0.png");
+    pixp = pixRead("/data/local/tmp/lept/comp/compare_gray0.png");
     pixaAddPix(pixa, pixp, L_INSERT);
     pixaaAddPixa(paa, pixa, L_INSERT);
-    pixWrite("/tmp/lept/regout/conv3.png", pixp, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/conv3.png");  /* 12 */
+    pixWrite("/data/local/tmp/lept/regout/conv3.png", pixp, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/conv3.png");  /* 12 */
     lept_stderr("Ave diff = %6.4f, RMS diff = %6.4f\n", avediff, rmsdiff);
     if (avediff <= 0.01)
         lept_stderr("OK: avediff = %6.4f <= 0.01\n", avediff);
@@ -249,22 +249,22 @@
     startTimer();
     pixt1 = pixConvolveRGB(pixs, kel4);
     lept_stderr("Time 7x7 non-separable: %7.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/regout/conv4.jpg", pixt1, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/regout/conv4.jpg");  /* 13 */
+    pixWrite("/data/local/tmp/lept/regout/conv4.jpg", pixt1, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/conv4.jpg");  /* 13 */
 
     kelx = makeFlatKernel(1, 7, 0, 3);
     kely = makeFlatKernel(7, 1, 3, 0);
     startTimer();
     pixt2 = pixConvolveRGBSep(pixs, kelx, kely);
     lept_stderr("Time 7x1,1x7 separable: %7.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/regout/conv5.jpg", pixt2, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/regout/conv5.jpg");  /* 14 */
+    pixWrite("/data/local/tmp/lept/regout/conv5.jpg", pixt2, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/conv5.jpg");  /* 14 */
 
     startTimer();
     pixt3 = pixBlockconv(pixs, 3, 3);
     lept_stderr("Time 7x7 blockconv: %7.3f sec\n", stopTimer());
-    pixWrite("/tmp/lept/regout/conv6.jpg", pixt3, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/regout/conv6.jpg");  /* 15 */
+    pixWrite("/data/local/tmp/lept/regout/conv6.jpg", pixt3, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/conv6.jpg");  /* 15 */
     regTestComparePix(rp, pixt1, pixt2);  /* 16 */
     regTestCompareSimilarPix(rp, pixt2, pixt3, 15, 0.0005, 0);  /* 17 */
 
@@ -283,13 +283,13 @@
     kel1 = makeGaussianKernel(5, 5, 3.0, 5.0);
     kernelGetSum(kel1, &sum);
     lept_stderr("Sum for gaussian kernel = %f\n", sum);
-    kernelWrite("/tmp/lept/regout/gauss.kel", kel1);
+    kernelWrite("/data/local/tmp/lept/regout/gauss.kel", kel1);
     pixt = pixConvolve(pixs, kel1, 8, 1);
     pixt2 = pixConvolve(pixs, kel1, 16, 0);
     pixaAddPix(pixa, pixt, L_INSERT);
     pixaAddPix(pixa, pixt2, L_INSERT);
-    pixWrite("/tmp/lept/regout/ker6.png", pixt, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker6.png");  /* 18 */
+    pixWrite("/data/local/tmp/lept/regout/ker6.png", pixt, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker6.png");  /* 18 */
 
     pixt = kernelDisplayInPix(kel1, 25, 2);
     pixaAddPix(pixa, pixt, L_INSERT);
@@ -306,15 +306,15 @@
     lept_stderr("Sum for x gaussian kernel = %f\n", sum);
     kernelGetSum(kely, &sum);
     lept_stderr("Sum for y gaussian kernel = %f\n", sum);
-    kernelWrite("/tmp/lept/regout/gauss.kelx", kelx);
-    kernelWrite("/tmp/lept/regout/gauss.kely", kely);
+    kernelWrite("/data/local/tmp/lept/regout/gauss.kelx", kelx);
+    kernelWrite("/data/local/tmp/lept/regout/gauss.kely", kely);
 
     pixt = pixConvolveSep(pixs, kelx, kely, 8, 1);
     pixt2 = pixConvolveSep(pixs, kelx, kely, 16, 0);
     pixaAddPix(pixa, pixt, L_INSERT);
     pixaAddPix(pixa, pixt2, L_INSERT);
-    pixWrite("/tmp/lept/regout/ker7.png", pixt, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker7.png");  /* 19 */
+    pixWrite("/data/local/tmp/lept/regout/ker7.png", pixt, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker7.png");  /* 19 */
 
     pixt = kernelDisplayInPix(kelx, 25, 2);
     pixaAddPix(pixa, pixt, L_INSERT);
@@ -334,12 +334,12 @@
     kel1 = makeDoGKernel(7, 7, 1.5, 2.7);
     kernelGetSum(kel1, &sum);
     lept_stderr("Sum for DoG kernel = %f\n", sum);
-    kernelWrite("/tmp/lept/regout/dog.kel", kel1);
+    kernelWrite("/data/local/tmp/lept/regout/dog.kel", kel1);
     pixt = pixConvolve(pixs, kel1, 8, 0);
 /*    pixInvert(pixt, pixt); */
     pixaAddPix(pixa, pixt, L_INSERT);
-    pixWrite("/tmp/lept/regout/ker8.png", pixt, IFF_PNG);
-    regTestCheckFile(rp, "/tmp/lept/regout/ker8.png");  /* 20 */
+    pixWrite("/data/local/tmp/lept/regout/ker8.png", pixt, IFF_PNG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/ker8.png");  /* 20 */
 
     pixt = kernelDisplayInPix(kel1, 20, 2);
     pixaAddPix(pixa, pixt, L_INSERT);
@@ -348,7 +348,7 @@
 
     pixd = pixaaDisplayByPixa(paa, 10, 1.0, 20, 20, 0);
     pixDisplayWithTitle(pixd, 100, 100, NULL, rp->display);
-    pixWrite("/tmp/lept/regout/kernel.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/kernel.jpg", pixd, IFF_JFIF_JPEG);
     pixDestroy(&pixd);
     pixaaDestroy(&paa);
 
diff -Nura leptonica-1.83.1/prog/lightcolortest.c leptonica-1.83.1-patch/prog/lightcolortest.c
--- leptonica-1.83.1/prog/lightcolortest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/lightcolortest.c	2024-09-05 14:26:11.039617748 +0800
@@ -118,8 +118,8 @@
 
     lept_mkdir("lept/color");
     pixaConvertToPdf(pixa, 100, 1.0, L_FLATE_ENCODE, 0, "lightcolortest",
-                     "/tmp/lept/color/lightcolortest.pdf");
-    L_INFO("Generated pdf file: /tmp/lept/color/lightcolortest.pdf",
+                     "/data/local/tmp/lept/color/lightcolortest.pdf");
+    L_INFO("Generated pdf file: /data/local/tmp/lept/color/lightcolortest.pdf",
            __func__);
     pixaDestroy(&pixa);
     sarrayDestroy(&sa);
diff -Nura leptonica-1.83.1/prog/lineremoval_reg.c leptonica-1.83.1-patch/prog/lineremoval_reg.c
--- leptonica-1.83.1/prog/lineremoval_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/lineremoval_reg.c	2024-09-05 14:26:11.039617748 +0800
@@ -107,11 +107,11 @@
     if (rp->display) {
         lept_rmdir("lept/lines");
         lept_mkdir("lept/lines");
-        lept_stderr("Writing to: /tmp/lept/lines/lineremoval.pdf\n");
+        lept_stderr("Writing to: /data/local/tmp/lept/lines/lineremoval.pdf\n");
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, "lineremoval example",
-                         "/tmp/lept/lines/lineremoval.pdf");
+                         "/data/local/tmp/lept/lines/lineremoval.pdf");
         pix1 = pixaDisplayTiledInColumns(pixa, 5, 0.5, 30, 2);
-        pixWrite("/tmp/lept/lines/lineremoval.jpg", pix1, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/lines/lineremoval.jpg", pix1, IFF_JFIF_JPEG);
         pixDisplay(pix1, 100, 100);
         pixDestroy(&pix1);
     }
diff -Nura leptonica-1.83.1/prog/livre_adapt.c leptonica-1.83.1-patch/prog/livre_adapt.c
--- leptonica-1.83.1/prog/livre_adapt.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_adapt.c	2024-09-05 14:26:11.039617748 +0800
@@ -91,12 +91,12 @@
 
             /* Generate the output image and pdf */
     lept_mkdir("lept/livre");
-    lept_stderr("Writing jpg and pdf to: /tmp/lept/livre/adapt.*\n");
+    lept_stderr("Writing jpg and pdf to: /data/local/tmp/lept/livre/adapt.*\n");
     pix1 = pixaDisplayTiledAndScaled(pixa, 8, 350, 4, 0, 25, 2);
-    pixWrite("/tmp/lept/livre/adapt.jpg", pix1, IFF_DEFAULT);
+    pixWrite("/data/local/tmp/lept/livre/adapt.jpg", pix1, IFF_DEFAULT);
     pixDisplay(pix1, 100, 100);
     pixaConvertToPdf(pixa, 0, 1.0, 0, 0, "Livre: adaptive thresholding",
-                     "/tmp/lept/livre/adapt.pdf");
+                     "/data/local/tmp/lept/livre/adapt.pdf");
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
     return 0;
diff -Nura leptonica-1.83.1/prog/livre_hmt.c leptonica-1.83.1-patch/prog/livre_hmt.c
--- leptonica-1.83.1/prog/livre_hmt.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_hmt.c	2024-09-05 14:26:11.039617748 +0800
@@ -96,7 +96,7 @@
         /* Display the sel */
     pixsel = pixDisplayHitMissSel(pixp, selhm, 7, HitColor, MissColor);
     pixDisplay(pixsel, 1000, 300);
-    pixWrite("/tmp/lept/livre/pixsel1", pixsel, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/pixsel1", pixsel, IFF_PNG);
 
         /* Use the Sel to find all instances in the page */
     pix = pixRead("tribune-page-4x.png");  /* 4x reduced */
@@ -115,17 +115,17 @@
     selGetParameters(selhm, NULL, NULL, &cy, &cx);
     pixd1 = pixDisplayMatchedPattern(pixr, pixp, pixhmt,
                                      cx, cy, 0x0000ff00, 1.0, 5);
-    pixWrite("/tmp/lept/livre/pixd11", pixd1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/pixd11", pixd1, IFF_PNG);
 
         /* Color each instance at 0.5 scale */
     pixd2 = pixDisplayMatchedPattern(pixr, pixp, pixhmt,
                                      cx, cy, 0x0000ff00, 0.5, 5);
-    pixWrite("/tmp/lept/livre/pixd12", pixd2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/pixd12", pixd2, IFF_PNG);
 
         /* Remove each instance from the input image */
     pixd3 = pixCopy(NULL, pixr);
     pixRemoveMatchedPattern(pixd3, pixp, pixhmt, cx, cy, 1);
-    pixWrite("/tmp/lept/livre/pixr1", pixd3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/pixr1", pixd3, IFF_PNG);
 
     pixa = pixaCreate(2);
     pixaAddPix(pixa, pixs, L_CLONE);
@@ -133,7 +133,7 @@
     cols = (patno == 1) ? 1 : 2;
     width = (patno == 1) ? 800 : 400;
     pixd = pixaDisplayTiledAndScaled(pixa, 32, width, cols, 0, 30, 2);
-    pixWrite("/tmp/lept/livre/hmt.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/hmt.png", pixd, IFF_PNG);
     pixDisplay(pixd, 1000, 600);
 
     selDestroy(&selhm);
diff -Nura leptonica-1.83.1/prog/livre_makefigs.c leptonica-1.83.1-patch/prog/livre_makefigs.c
--- leptonica-1.83.1/prog/livre_makefigs.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_makefigs.c	2024-09-05 14:26:11.039617748 +0800
@@ -54,47 +54,47 @@
         /* Generate Figure 1 (page segmentation) */
     ignore = system("livre_seedgen");
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/seedgen.png /tmp/lept/livre/dia_fig1.png");
+             "cp /data/local/tmp/lept/livre/seedgen.png /data/local/tmp/lept/livre/dia_fig1.png");
     ignore = system(buf);
 
         /* Generate Figures 2-5 (page segmentation) */
     snprintf(buf, sizeof(buf), "livre_pageseg pageseg2.tif");
     ignore = system(buf);
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/segout.1.png /tmp/lept/livre/dia_fig2.png");
+             "cp /data/local/tmp/lept/livre/segout.1.png /data/local/tmp/lept/livre/dia_fig2.png");
     ignore = system(buf);
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/segout.2.png /tmp/lept/livre/dia_fig3.png");
+             "cp /data/local/tmp/lept/livre/segout.2.png /data/local/tmp/lept/livre/dia_fig3.png");
     ignore = system(buf);
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/segout.3.png /tmp/lept/livre/dia_fig4.png");
+             "cp /data/local/tmp/lept/livre/segout.3.png /data/local/tmp/lept/livre/dia_fig4.png");
     ignore = system(buf);
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/segout.4.png /tmp/lept/livre/dia_fig5.png");
+             "cp /data/local/tmp/lept/livre/segout.4.png /data/local/tmp/lept/livre/dia_fig5.png");
     ignore = system(buf);
 
         /* Generate Figure 6 (hmt sels for text orientation) */
     ignore = system("livre_orient");
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/orient.png /tmp/lept/livre/dia_fig6.png");
+             "cp /data/local/tmp/lept/livre/orient.png /data/local/tmp/lept/livre/dia_fig6.png");
     ignore = system(buf);
 
         /* Generate Figure 7 (hmt sel for fancy "Tribune") */
     ignore = system("livre_hmt 1 8");
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/hmt.png /tmp/lept/livre/dia_fig7.png");
+             "cp /data/local/tmp/lept/livre/hmt.png /data/local/tmp/lept/livre/dia_fig7.png");
     ignore = system(buf);
 
         /* Generate Figure 8 (hmt sel for fancy "T") */
     ignore = system("livre_hmt 2 4");
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/hmt.png /tmp/lept/livre/dia_fig8.png");
+             "cp /data/local/tmp/lept/livre/hmt.png /data/local/tmp/lept/livre/dia_fig8.png");
     ignore = system(buf);
 
         /* Generate Figure 9 (tophat background cleaning) */
     ignore = system("livre_tophat");
     snprintf(buf, sizeof(buf),
-             "cp /tmp/lept/livre/tophat.jpg /tmp/lept/livre/dia_fig9.jpg");
+             "cp /data/local/tmp/lept/livre/tophat.jpg /data/local/tmp/lept/livre/dia_fig9.jpg");
     ignore = system(buf);
 
         /* Run livre_adapt to generate an expanded version of Figure 9 */
diff -Nura leptonica-1.83.1/prog/livre_orient.c leptonica-1.83.1-patch/prog/livre_orient.c
--- leptonica-1.83.1/prog/livre_orient.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_orient.c	2024-09-05 14:26:11.039617748 +0800
@@ -84,7 +84,7 @@
     selaAddSel(sela, sel4, "textsel4", L_INSERT);
 
     pix1 = selaDisplayInPix(sela, 28, 3, 30, 4);
-    pixWrite("/tmp/lept/livre/orient.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/orient.png", pix1, IFF_PNG);
     pixDisplay(pix1, 1200, 1200);
 
     pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/livre_pageseg.c leptonica-1.83.1-patch/prog/livre_pageseg.c
--- leptonica-1.83.1/prog/livre_pageseg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_pageseg.c	2024-09-05 14:26:11.039617748 +0800
@@ -125,7 +125,7 @@
     pix1 = pixScaleToGray2(pixs);
     if (ws_flag || ht_flag || block_flag) pixaAddPix(pixa, pix1, L_COPY);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/orig.gray.150.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/orig.gray.150.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
     pixr = pixReduceRankBinaryCascade(pixs, 1, 0, 0, 0);
 
@@ -135,7 +135,7 @@
     pixhs = pixExpandBinaryPower2(pix2, 8);
     if (ht_flag) pixaAddPix(pixa, pixhs, L_COPY);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/htseed.150.png", pixhs, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/htseed.150.png", pixhs, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
 
@@ -143,22 +143,22 @@
     pixm = pixCloseSafeBrick(NULL, pixr, 4, 4);
     if (ht_flag) pixaAddPix(pixa, pixm, L_COPY);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/ccmask.150.png", pixm, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/ccmask.150.png", pixm, IFF_PNG);
 
         /* Fill seed into mask to get halftone mask */
     pixhm1 = pixSeedfillBinary(NULL, pixhs, pixm, 4);
     if (ht_flag) pixaAddPix(pixa, pixhm1, L_COPY);
-    if (which == 1) pixWrite("/tmp/lept/livre/htmask.150.png", pixhm1, IFF_PNG);
+    if (which == 1) pixWrite("/data/local/tmp/lept/livre/htmask.150.png", pixhm1, IFF_PNG);
     pixhm2 = pixExpandBinaryPower2(pixhm1, 2);
 
         /* Extract halftone stuff */
     pixht = pixAnd(NULL, pixhm1, pixr);
-    if (which == 1) pixWrite("/tmp/lept/livre/ht.150.png", pixht, IFF_PNG);
+    if (which == 1) pixWrite("/data/local/tmp/lept/livre/ht.150.png", pixht, IFF_PNG);
 
         /* Extract non-halftone stuff */
     pixnht = pixXor(NULL, pixht, pixr);
     if (text_flag) pixaAddPix(pixa, pixnht, L_COPY);
-    if (which == 1) pixWrite("/tmp/lept/livre/text.150.png", pixnht, IFF_PNG);
+    if (which == 1) pixWrite("/data/local/tmp/lept/livre/text.150.png", pixnht, IFF_PNG);
     pixZero(pixht, &zero);
     if (zero)
         lept_stderr("No halftone parts found\n");
@@ -168,7 +168,7 @@
         /* Get bit-inverted image */
     pixi = pixInvert(NULL, pixnht);
     if (ws_flag) pixaAddPix(pixa, pixi, L_COPY);
-    if (which == 1) pixWrite("/tmp/lept/livre/invert.150.png", pixi, IFF_PNG);
+    if (which == 1) pixWrite("/data/local/tmp/lept/livre/invert.150.png", pixi, IFF_PNG);
 
         /* The whitespace mask will break textlines where there
          * is a large amount of white space below or above.
@@ -186,7 +186,7 @@
     pix3 = pixOpenBrick(NULL, pix2, 5, 1);  /* removes thin vertical lines */
     pixvws = pixOpenBrick(NULL, pix3, 1, 200);  /* gets long vertical lines */
     if (text_flag || ws_flag) pixaAddPix(pixa, pixvws, L_COPY);
-    if (which == 1) pixWrite("/tmp/lept/livre/vertws.150.png", pixvws, IFF_PNG);
+    if (which == 1) pixWrite("/data/local/tmp/lept/livre/vertws.150.png", pixvws, IFF_PNG);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
 
@@ -195,25 +195,25 @@
     pixm1 = pixCloseSafeBrick(NULL, pixnht, 30, 1);
     if (text_flag) pixaAddPix(pixa, pixm1, L_COPY);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/textmask1.150.png", pixm1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/textmask1.150.png", pixm1, IFF_PNG);
 
         /* Next open back up the vertical whitespace corridors */
     pixm2 = pixSubtract(NULL, pixm1, pixvws);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/textmask2.150.png", pixm2, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/textmask2.150.png", pixm2, IFF_PNG);
 
         /* Do a small opening to remove noise */
     pixOpenBrick(pixm2, pixm2, 3, 3);
     if (text_flag) pixaAddPix(pixa, pixm2, L_COPY);
     if (which == 1)
-         pixWrite("/tmp/lept/livre/textmask3.150.png", pixm2, IFF_PNG);
+         pixWrite("/data/local/tmp/lept/livre/textmask3.150.png", pixm2, IFF_PNG);
     pixm3 = pixExpandBinaryPower2(pixm2, 2);
 
         /* Join pixels vertically to make text block mask */
     pixb1 = pixMorphSequence(pixm2, "c1.10 + o4.1", 0);
     if (block_flag) pixaAddPix(pixa, pixb1, L_COPY);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/textblock1.150.png", pixb1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/textblock1.150.png", pixb1, IFF_PNG);
 
         /* Solidify the textblock mask and remove noise:
          *  (1) For each c.c., close the blocks and dilate slightly
@@ -229,7 +229,7 @@
                             L_SELECT_IF_GTE, NULL);
     if (block_flag) pixaAddPix(pixa, pix3, L_COPY);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/textblock2.150.png", pix3, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/textblock2.150.png", pix3, IFF_PNG);
     pixb2 = pixExpandBinaryPower2(pix3, 2);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -241,7 +241,7 @@
     cmap = pixGetColormap(pix1);
     pixcmapResetColor(cmap, 0, 130, 130, 130);  /* set interior to gray */
     if (which == 1)
-        pixWrite("/tmp/lept/livre/textblock3.300.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/textblock3.300.png", pix1, IFF_PNG);
     pixDisplayWithTitle(pix1, 480, 360, "textblock mask with outlines", DFLAG);
     ptaaDestroy(&ptaa);
     pixDestroy(&pix1);
@@ -251,7 +251,7 @@
     pixOr(pixm3, pixm3, pix1);
     pixDestroy(&pix1);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/textmask.300.png", pixm3, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/textmask.300.png", pixm3, IFF_PNG);
     pixDisplayWithTitle(pixm3, 480, 360, "textline mask 4", DFLAG);
 
         /* Fill halftone mask (as seed) into the original */
@@ -259,7 +259,7 @@
     pixOr(pixhm2, pixhm2, pix1);
     pixDestroy(&pix1);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/htmask.300.png", pixhm2, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/htmask.300.png", pixhm2, IFF_PNG);
     pixDisplayWithTitle(pixhm2, 520, 390, "halftonemask 2", DFLAG);
 
         /* Find objects that are neither text nor halftones */
@@ -267,20 +267,20 @@
     pixnon = pixSubtract(NULL, pix1, pixhm2);  /* remove halftone pixels */
     pixDestroy(&pix1);
     if (which == 1)
-        pixWrite("/tmp/lept/livre/other.300.png", pixnon, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/livre/other.300.png", pixnon, IFF_PNG);
     pixDisplayWithTitle(pixnon, 540, 420, "other stuff", DFLAG);
 
         /* Write out b.b. for text line mask and halftone mask components */
     boxatm = pixConnComp(pixm3, NULL, 4);
     boxahm = pixConnComp(pixhm2, NULL, 8);
     if (which == 1) {
-        boxaWrite("/tmp/lept/livre/textmask.boxa", boxatm);
-        boxaWrite("/tmp/lept/livre/htmask.boxa", boxahm);
+        boxaWrite("/data/local/tmp/lept/livre/textmask.boxa", boxatm);
+        boxaWrite("/data/local/tmp/lept/livre/htmask.boxa", boxahm);
     }
 
     pix1 = pixaDisplayTiledAndScaled(pixa, 8, 250, 4, 0, 25, 2);
     pixDisplay(pix1, 0, 375 * (which - 1));
-    snprintf(buf, sizeof(buf), "/tmp/lept/livre/segout.%d.png", which);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/livre/segout.%d.png", which);
     pixWrite(buf, pix1, IFF_PNG);
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/livre_seedgen.c leptonica-1.83.1-patch/prog/livre_seedgen.c
--- leptonica-1.83.1/prog/livre_seedgen.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_seedgen.c	2024-09-05 14:26:11.039617748 +0800
@@ -64,9 +64,9 @@
 
         /* Generate the output image */
     lept_mkdir("lept/livre");
-    lept_stderr("Writing to: /tmp/lept/livre/seedgen.png\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/livre/seedgen.png\n");
     pix1 = pixaDisplayTiledAndScaled(pixa, 8, 350, 4, 0, 25, 2);
-    pixWrite("/tmp/lept/livre/seedgen.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/livre/seedgen.png", pix1, IFF_PNG);
     pixDisplay(pix1, 1100, 0);
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/livre_tophat.c leptonica-1.83.1-patch/prog/livre_tophat.c
--- leptonica-1.83.1/prog/livre_tophat.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/livre_tophat.c	2024-09-05 14:26:11.039617748 +0800
@@ -62,9 +62,9 @@
 
         /* Generate the output image */
     lept_mkdir("lept/livre");
-    lept_stderr("Writing to: /tmp/lept/livre/tophat.jpg\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/livre/tophat.jpg\n");
     pix1 = pixaDisplayTiledAndScaled(pixa, 8, 350, 3, 0, 25, 2);
-    pixWrite("/tmp/lept/livre/tophat.jpg", pix1, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/livre/tophat.jpg", pix1, IFF_JFIF_JPEG);
     pixDisplay(pix1, 1200, 800);
     pixDestroy(&pix1);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/maptest.c leptonica-1.83.1-patch/prog/maptest.c
--- leptonica-1.83.1/prog/maptest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/maptest.c	2024-09-05 14:26:11.039617748 +0800
@@ -84,12 +84,12 @@
     m = BuildMapHistogram(pix, 1, FALSE);
     TestMapIterator1(m, FALSE);
     TestMapIterator2(m, FALSE);
-    DisplayMapHistogram(m, cmap, "/tmp/lept/map/map1");
+    DisplayMapHistogram(m, cmap, "/data/local/tmp/lept/map/map1");
     l_amapDestroy(&m);
 
         /* Ditto, but just with a few pixels */
     m = BuildMapHistogram(pix, 14, TRUE);
-    DisplayMapHistogram(m, cmap, "/tmp/lept/map/map2");
+    DisplayMapHistogram(m, cmap, "/data/local/tmp/lept/map/map2");
     l_amapDestroy(&m);
 
         /* Do in-order tranversals, using the iterators */
@@ -113,8 +113,8 @@
 
         /* Build a histogram the old-fashioned way */
     na = pixGetCmapHistogram(pix, 1);
-    numaWrite("/tmp/lept/map/map2.na", na);
-    gplotSimple1(na, GPLOT_PNG, "/tmp/lept/map/map3", NULL);
+    numaWrite("/data/local/tmp/lept/map/map2.na", na);
+    gplotSimple1(na, GPLOT_PNG, "/data/local/tmp/lept/map/map3", NULL);
     numaDestroy(&na);
 
         /* Build a separate map from (rgb) --> colormap index ... */
@@ -140,7 +140,7 @@
         /* Build and display a real RGB histogram */
     pix = pixRead("wyom.jpg");
     m = pixGetColorAmapHistogram(pix, 1);
-    DisplayMapRGBHistogram(m, "/tmp/lept/map/map4");
+    DisplayMapRGBHistogram(m, "/data/local/tmp/lept/map/map4");
     pixNumColors(pix, 1, &ncolors);
     lept_stderr(" Using pixNumColors: %d\n", ncolors);
     pixCountRGBColors(pix, 1, &ncolors);
diff -Nura leptonica-1.83.1/prog/misctest1.c leptonica-1.83.1-patch/prog/misctest1.c
--- leptonica-1.83.1/prog/misctest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/misctest1.c	2024-09-05 14:26:11.039617748 +0800
@@ -109,7 +109,7 @@
     pixaAddPix(pixa1, pixd, L_INSERT);
     pixaaAddPixa(paa, pixa1, L_INSERT);
     pix1 = pixaaDisplayByPixa(paa, 10, 0.5, 40, 40, 2);
-    pixWrite("/tmp/lept/misc/mos1.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/mos1.png", pix1, IFF_PNG);
     pixDisplay(pix1, 100, 100);
     pixaaDestroy(&paa);
     pixDestroy(&pix1);
@@ -154,7 +154,7 @@
     pixDestroy(&pixc);
 
     pix1 = pixaaDisplayByPixa(paa, 10, 1.0, 20, 20, 0);
-    pixWrite("/tmp/lept/misc/mos2.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/mos2.png", pix1, IFF_PNG);
     pixDisplay(pix1, 400, 100);
     pixaaDestroy(&paa);
     pixDestroy(&pix1);
@@ -164,11 +164,11 @@
     pix1 = pixRead("feyn.tif");
     pixa1 = pixExtractTextlines(pix1, 150, 150, 0, 0, 5, 5, NULL);
     boxa1 = pixaGetBoxa(pixa1, L_CLONE);
-    boxaWrite("/tmp/lept/misc/lines1.ba", boxa1);
+    boxaWrite("/data/local/tmp/lept/misc/lines1.ba", boxa1);
     pix2 = pixaDisplayRandomCmap(pixa1, 0, 0);
     pixcmapResetColor(pixGetColormap(pix2), 0, 255, 255, 255);
     pixDisplay(pix2, 400, 0);
-    pixWrite("/tmp/lept/misc/lines1.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/lines1.png", pix2, IFF_PNG);
     boxaDestroy(&boxa1);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -179,7 +179,7 @@
     pix2 = pixaDisplayRandomCmap(pixa1, 0, 0);
     pixcmapResetColor(pixGetColormap(pix2), 0, 255, 255, 255);
     pixDisplay(pix2, 400, 400);
-    pixWrite("/tmp/lept/misc/lines2.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/lines2.png", pix2, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixaDestroy(&pixa1);
@@ -189,7 +189,7 @@
     pix2 = pixaDisplayRandomCmap(pixa1, 0, 0);
     pixcmapResetColor(pixGetColormap(pix2), 0, 255, 255, 255);
     pixDisplay(pix2, 400, 800);
-    pixWrite("/tmp/lept/misc/lines3.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/lines3.png", pix2, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixaDestroy(&pixa1);
@@ -224,7 +224,7 @@
     boxaDestroy(&boxao);
     boxaDestroy(&boxa1);
     pix1 = pixaDisplayTiledInRows(pixa1, 32, 1500, 1.0, 0, 30, 2);
-    pixWrite("/tmp/lept/misc/boxaplots.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/boxaplots.png", pix1, IFF_PNG);
     pixDisplay(pix1, 800, 0);
     pixDestroy(&pix1);
     pixaDestroy(&pixa1);
@@ -254,7 +254,7 @@
         pixDestroy(&pixd);
     }
     pix3 = pixaDisplayTiledAndScaled(pixa1, 32, 300, 7, 0, 30, 2);
-    pixWrite("/tmp/lept/misc/comps.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/comps.png", pix3, IFF_PNG);
     pixDisplay(pix3, 600, 300);
     pixaDestroy(&pixa1);
     pixDestroy(&pixs);
@@ -267,7 +267,7 @@
     boxa2 = boxaSelectBySize(boxa1, 0, 28, L_SELECT_HEIGHT, L_SELECT_IF_GT,
                              NULL),
     pix2 = pixCopyWithBoxa(pix1, boxa2, L_SET_WHITE);
-    pixWrite("/tmp/lept/misc/tallcomps.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/tallcomps.png", pix2, IFF_PNG);
     pixDisplay(pix2, 600, 600);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -285,7 +285,7 @@
         pixaaAddPixa(paa, pixa1, L_INSERT);
     }
     pix2 = pixaaDisplayByPixa(paa, 50, 1.0, 10, 5, 0);
-    pixWrite("/tmp/lept/misc/display.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/display.png", pix2, IFF_PNG);
     pixDisplay(pix2, 100, 100);
     pixaaDestroy(&paa);
     pixDestroy(&pix1);
@@ -326,7 +326,7 @@
     lept_stderr("******************************************************\n");
 
     pix3 = pixaDisplayTiledInColumns(pixa1, 10, 1.0, 15, 2);
-    pixWrite("/tmp/lept/misc/setting.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/misc/setting.png", pix3, IFF_PNG);
     pixDisplay(pix3, 500, 100);
     pixDestroy(&pix1);
     pixDestroy(&pix3);
@@ -337,8 +337,8 @@
     pixs = pixRead("feyn.tif");
     for (i = 0; i < 5; i++) {
         pixSetZlibCompression(pixs, 2 * i);
-        pixWrite("/tmp/lept/misc/zlibtest.png", pixs, IFF_PNG);
-        size = nbytesInFile("/tmp/lept/misc/zlibtest.png");
+        pixWrite("/data/local/tmp/lept/misc/zlibtest.png", pixs, IFF_PNG);
+        size = nbytesInFile("/data/local/tmp/lept/misc/zlibtest.png");
         lept_stderr("zlib level = %d, file size = %lu, delta = %lu\n",
                     2 * i, (unsigned long)size, (unsigned long)(size - zlibsize[i]));
     }
diff -Nura leptonica-1.83.1/prog/modifyhuesat.c leptonica-1.83.1-patch/prog/modifyhuesat.c
--- leptonica-1.83.1/prog/modifyhuesat.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/modifyhuesat.c	2024-09-05 14:26:11.043617670 +0800
@@ -34,7 +34,7 @@
  *     This gives a rectangle of nhue x nsat output images,
  *     where the center image is not modified.
  *
- *     Example: modifyhuesat test24.jpg 5 0.2 5 0.2 /tmp/junkout.jpg
+ *     Example: modifyhuesat test24.jpg 5 0.2 5 0.2 /data/local/tmp/junkout.jpg
  */
 
 #ifdef HAVE_CONFIG_H
diff -Nura leptonica-1.83.1/prog/morphseq_reg.c leptonica-1.83.1-patch/prog/morphseq_reg.c
--- leptonica-1.83.1/prog/morphseq_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/morphseq_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -62,13 +62,13 @@
     pixd = pixMorphSequence(pixs, SEQUENCE1, -1);
     pixDestroy(&pixd);
     pixd = pixMorphSequence(pixs, SEQUENCE1, DISPLAY_SEPARATION);
-    pixWrite("/tmp/lept/morphseq1.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq1.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
     pixd = pixMorphCompSequence(pixs, SEQUENCE2, -2);
     pixDestroy(&pixd);
     pixd = pixMorphCompSequence(pixs, SEQUENCE2, DISPLAY_SEPARATION);
-    pixWrite("/tmp/lept/morphseq2.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq2.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
     lept_stderr("\n ------------------ Error messages -----------------\n");
@@ -77,13 +77,13 @@
     pixd = pixMorphSequenceDwa(pixs, SEQUENCE2, -3);
     pixDestroy(&pixd);
     pixd = pixMorphSequenceDwa(pixs, SEQUENCE2, DISPLAY_SEPARATION);
-    pixWrite("/tmp/lept/morphseq3.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq3.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
     pixd = pixMorphCompSequenceDwa(pixs, SEQUENCE2, -4);
     pixDestroy(&pixd);
     pixd = pixMorphCompSequenceDwa(pixs, SEQUENCE2, DISPLAY_SEPARATION);
-    pixWrite("/tmp/lept/morphseq4.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq4.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
         /* 8 bpp */
@@ -91,11 +91,11 @@
     pixd = pixGrayMorphSequence(pixg, SEQUENCE3, -5, 150);
     pixDestroy(&pixd);
     pixd = pixGrayMorphSequence(pixg, SEQUENCE3, DISPLAY_SEPARATION, 150);
-    pixWrite("/tmp/lept/morphseq5.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq5.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
     pixd = pixGrayMorphSequence(pixg, SEQUENCE4, -6, 300);
-    pixWrite("/tmp/lept/morphseq6.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq6.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
 
         /* 32 bpp */
@@ -103,7 +103,7 @@
     pixd = pixColorMorphSequence(pixc, SEQUENCE5, -7, 150);
     pixDestroy(&pixd);
     pixd = pixColorMorphSequence(pixc, SEQUENCE5, DISPLAY_SEPARATION, 450);
-    pixWrite("/tmp/lept/morphseq7.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/morphseq7.png", pixd, IFF_PNG);
     pixDestroy(&pixc);
     pixDestroy(&pixd);
 
diff -Nura leptonica-1.83.1/prog/mtiff_reg.c leptonica-1.83.1-patch/prog/mtiff_reg.c
--- leptonica-1.83.1/prog/mtiff_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/mtiff_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -40,9 +40,9 @@
 #include "allheaders.h"
 #include <string.h>
 
-static const char *weasel_rev = "/tmp/lept/tiff/weasel_rev.tif";
-static const char *weasel_rev_rev = "/tmp/lept/tiff/weasel_rev_rev.tif";
-static const char *weasel_orig = "/tmp/lept/tiff/weasel_orig.tif";
+static const char *weasel_rev = "/data/local/tmp/lept/tiff/weasel_rev.tif";
+static const char *weasel_rev_rev = "/data/local/tmp/lept/tiff/weasel_rev_rev.tif";
+static const char *weasel_orig = "/data/local/tmp/lept/tiff/weasel_orig.tif";
 
 int main(int    argc,
          char **argv)
@@ -74,9 +74,9 @@
          * match to "weasel8" into a multipage tiff file.
          * Images with 1 bpp are coded as g4; the others as zip.
          * It then reads back into a pix and displays.  */
-    writeMultipageTiff(".", "weasel8.", "/tmp/lept/tiff/weasel8.tif");
-    regTestCheckFile(rp, "/tmp/lept/tiff/weasel8.tif");  /* 0 */
-    pixa = pixaReadMultipageTiff("/tmp/lept/tiff/weasel8.tif");
+    writeMultipageTiff(".", "weasel8.", "/data/local/tmp/lept/tiff/weasel8.tif");
+    regTestCheckFile(rp, "/data/local/tmp/lept/tiff/weasel8.tif");  /* 0 */
+    pixa = pixaReadMultipageTiff("/data/local/tmp/lept/tiff/weasel8.tif");
     pix1 = pixaDisplayTiledInRows(pixa, 1, 1200, 0.5, 0, 15, 4);
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 1 */
     pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
@@ -97,7 +97,7 @@
     n = 0;
     pixa = pixaCreate(8);
     do {
-        pix1 = pixReadFromMultipageTiff("/tmp/lept/tiff/weasel8.tif", &offset);
+        pix1 = pixReadFromMultipageTiff("/data/local/tmp/lept/tiff/weasel8.tif", &offset);
         if (!pix1) continue;
         pixaAddPix(pixa, pix1, L_INSERT);
         if (rp->display)
@@ -116,7 +116,7 @@
     offset = 0;
     n = 0;
     pixa = pixaCreate(8);
-    data = l_binaryRead("/tmp/lept/tiff/weasel8.tif", &size);
+    data = l_binaryRead("/data/local/tmp/lept/tiff/weasel8.tif", &size);
     do {
         pix1 = pixReadMemFromMultipageTiff(data, size, &offset);
         if (!pix1) continue;
@@ -144,14 +144,14 @@
          *  more than the printed value. */
     pix1 = pixRead("char.tif");
     startTimer();
-    pixWriteTiff("/tmp/lept/tiff/junkm.tif", pix1, IFF_TIFF_G4, "w");
+    pixWriteTiff("/data/local/tmp/lept/tiff/junkm.tif", pix1, IFF_TIFF_G4, "w");
     for (i = 1; i < 1000; i++) {
-        pixWriteTiff("/tmp/lept/tiff/junkm.tif", pix1, IFF_TIFF_G4, "a");
+        pixWriteTiff("/data/local/tmp/lept/tiff/junkm.tif", pix1, IFF_TIFF_G4, "a");
     }
-    regTestCheckFile(rp, "/tmp/lept/tiff/junkm.tif");  /* 8 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/tiff/junkm.tif");  /* 8 */
     pixDestroy(&pix1);
     if (rp->display) {
-        lept_stderr("\n1000 image file: /tmp/lept/tiff/junkm.tif\n");
+        lept_stderr("\n1000 image file: /data/local/tmp/lept/tiff/junkm.tif\n");
         lept_stderr("Time to write 1000 images: %7.3f sec\n", stopTimer());
     }
 
@@ -159,7 +159,7 @@
     offset = 0;
     n = 0;
     do {
-        pix1 = pixReadFromMultipageTiff("/tmp/lept/tiff/junkm.tif", &offset);
+        pix1 = pixReadFromMultipageTiff("/data/local/tmp/lept/tiff/junkm.tif", &offset);
         if (!pix1) continue;
         if (rp->display && (n % 100 == 0))
             lept_stderr("offset = %ld\n", (unsigned long)offset);
@@ -171,7 +171,7 @@
         lept_stderr("Time to read %d images: %6.3f sec\n", n, stopTimer());
 
     startTimer();
-    pixa = pixaReadMultipageTiff("/tmp/lept/tiff/junkm.tif");
+    pixa = pixaReadMultipageTiff("/data/local/tmp/lept/tiff/junkm.tif");
     lept_stderr("Time to read %d images and return a pixa: %6.3f sec\n",
             pixaGetCount(pixa), stopTimer());
     pix1 = pixaDisplayTiledInRows(pixa, 8, 1500, 0.8, 0, 15, 4);
@@ -191,9 +191,9 @@
     for (i = 0; i < 10; i++)
         pixaAddPix(pixa1, pix1, L_COPY);
     pixDestroy(&pix1);
-    pixaWriteMultipageTiff("/tmp/lept/tiff/junkm2.tif", pixa1);
-    regTestCheckFile(rp, "/tmp/lept/tiff/junkm2.tif");  /* 11 */
-    data = l_binaryRead("/tmp/lept/tiff/junkm2.tif", &size);  /* (2) */
+    pixaWriteMultipageTiff("/data/local/tmp/lept/tiff/junkm2.tif", pixa1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/tiff/junkm2.tif");  /* 11 */
+    data = l_binaryRead("/data/local/tmp/lept/tiff/junkm2.tif", &size);  /* (2) */
     pixa2 = pixaCreate(10);  /* (3) */
     offset = 0;
     n = 0;
@@ -242,27 +242,27 @@
         if (!pix1) continue;
         pix2 = pixConvertTo1(pix1, 128);
         if (i == 0)
-            pixWriteTiff("/tmp/lept/tiff/weasel4", pix2, IFF_TIFF_G4, "w+");
+            pixWriteTiff("/data/local/tmp/lept/tiff/weasel4", pix2, IFF_TIFF_G4, "w+");
         else
-            pixWriteTiff("/tmp/lept/tiff/weasel4", pix2, IFF_TIFF_G4, "a");
+            pixWriteTiff("/data/local/tmp/lept/tiff/weasel4", pix2, IFF_TIFF_G4, "a");
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         lept_free(filename);
     }
-    regTestCheckFile(rp, "/tmp/lept/tiff/junkm2.tif");  /* 15 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/tiff/junkm2.tif");  /* 15 */
 
         /* Write it out as a PS file */
-    lept_stderr("Writing to: /tmp/lept/tiff/weasel4.ps\n");
-    convertTiffMultipageToPS("/tmp/lept/tiff/weasel4",
-                             "/tmp/lept/tiff/weasel4.ps", 0.95);
-    regTestCheckFile(rp, "/tmp/lept/tiff/weasel4.ps");  /* 16 */
+    lept_stderr("Writing to: /data/local/tmp/lept/tiff/weasel4.ps\n");
+    convertTiffMultipageToPS("/data/local/tmp/lept/tiff/weasel4",
+                             "/data/local/tmp/lept/tiff/weasel4.ps", 0.95);
+    regTestCheckFile(rp, "/data/local/tmp/lept/tiff/weasel4.ps");  /* 16 */
 
         /* Write it out as a pdf file */
-    lept_stderr("Writing to: /tmp/lept/tiff/weasel4.pdf\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/tiff/weasel4.pdf\n");
     l_pdfSetDateAndVersion(FALSE);
-    convertTiffMultipageToPdf("/tmp/lept/tiff/weasel4",
-                              "/tmp/lept/tiff/weasel4.pdf");
-    regTestCheckFile(rp, "/tmp/lept/tiff/weasel4.pdf");  /* 17 */
+    convertTiffMultipageToPdf("/data/local/tmp/lept/tiff/weasel4",
+                              "/data/local/tmp/lept/tiff/weasel4.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/tiff/weasel4.pdf");  /* 17 */
     sarrayDestroy(&sa);
 
     /* ------------------  Test multipage I/O  -------------------*/
@@ -283,14 +283,14 @@
     for (i = 0; i < npages + 1; i++) {   /* read one beyond to catch error */
         pix1 = pixReadTiff(weasel_orig, i);
         if (!pix1) continue;
-        snprintf(buf, sizeof(buf), "/tmp/lept/tiff/%03d.tif", i);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/tiff/%03d.tif", i);
         pixWrite(buf, pix1, IFF_TIFF_ZIP);
         pixDestroy(&pix1);
     }
 
         /* Read separate page files and write reversed file */
     for (i = npages - 1; i >= 0; i--) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/tiff/%03d.tif", i);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/tiff/%03d.tif", i);
         pix1 = pixRead(buf);
         if (!pix1) continue;
         if (i == npages - 1)
@@ -359,9 +359,9 @@
     numaAddNumber(naflags, 297);  /* PAGENUMBER */
     sarrayAddString(savals, "1-412", L_COPY);
     sarrayAddString(satypes, "l_uint16-l_uint16", L_COPY);
-    pixWriteTiffCustom("/tmp/lept/tiff/tags.tif", pix1, IFF_TIFF_G4, "w", naflags,
+    pixWriteTiffCustom("/data/local/tmp/lept/tiff/tags.tif", pix1, IFF_TIFF_G4, "w", naflags,
                        savals, satypes, nasizes);
-    fprintTiffInfo(stderr, "/tmp/lept/tiff/tags.tif");
+    fprintTiffInfo(stderr, "/data/local/tmp/lept/tiff/tags.tif");
     lept_stderr("num flags = %d\n", numaGetCount(naflags));
     lept_stderr("num sizes = %d\n", numaGetCount(nasizes));
     lept_stderr("num vals = %d\n", sarrayGetCount(savals));
diff -Nura leptonica-1.83.1/prog/nearline_reg.c leptonica-1.83.1-patch/prog/nearline_reg.c
--- leptonica-1.83.1/prog/nearline_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/nearline_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -105,25 +105,25 @@
     regTestCompareValues(rp, similar, 1, 0);  /* 0 */
     numaSimilar(na3, na4, 1.0, &similar);  /* should be TRUE */
     regTestCompareValues(rp, similar, 1, 0);  /* 1 */
-    numaWrite("/tmp/lept/regout/na1.na", na1);
-    numaWrite("/tmp/lept/regout/na2.na", na2);
-    numaWrite("/tmp/lept/regout/na3.na", na3);
-    numaWrite("/tmp/lept/regout/na4.na", na4);
-    numaWrite("/tmp/lept/regout/na5.na", na5);
-    regTestCheckFile(rp, "/tmp/lept/regout/na1.na");  /* 2 */
-    regTestCheckFile(rp, "/tmp/lept/regout/na2.na");  /* 3 */
-    regTestCheckFile(rp, "/tmp/lept/regout/na3.na");  /* 4 */
-    regTestCheckFile(rp, "/tmp/lept/regout/na4.na");  /* 5 */
-    regTestCheckFile(rp, "/tmp/lept/regout/na5.na");  /* 6 */
+    numaWrite("/data/local/tmp/lept/regout/na1.na", na1);
+    numaWrite("/data/local/tmp/lept/regout/na2.na", na2);
+    numaWrite("/data/local/tmp/lept/regout/na3.na", na3);
+    numaWrite("/data/local/tmp/lept/regout/na4.na", na4);
+    numaWrite("/data/local/tmp/lept/regout/na5.na", na5);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/na1.na");  /* 2 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/na2.na");  /* 3 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/na3.na");  /* 4 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/na4.na");  /* 5 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/na5.na");  /* 6 */
 
         /* Plot the average minimums for the 3 cases */
     naa = numaaCreate(3);
     numaaAddNuma(naa, na1, L_INSERT);  /* portrait, double-sided */
     numaaAddNuma(naa, na2, L_INSERT);  /* landscape, double-sided */
     numaaAddNuma(naa, na5, L_INSERT);  /* landscape, single-sided */
-    gplotSimpleN(naa, GPLOT_PNG, "/tmp/lept/regout/nearline",
+    gplotSimpleN(naa, GPLOT_PNG, "/data/local/tmp/lept/regout/nearline",
                  "Average minimums along lines");
-    pix3 = pixRead("/tmp/lept/regout/nearline.png");
+    pix3 = pixRead("/data/local/tmp/lept/regout/nearline.png");
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 7 */
     pixDisplayWithTitle(pix3, 100, 100, NULL, rp->display);
 
@@ -152,8 +152,8 @@
                       &na2, NULL, NULL, NULL);
     pixMinMaxNearLine(pix1, 20, 200, 400, 200, 15, L_SCAN_BOTH,
                       &na3, NULL, NULL, NULL);
-    numaWrite("/tmp/lept/regout/na6.na", na1);
-    regTestCheckFile(rp, "/tmp/lept/regout/na6.na");  /* 8 */
+    numaWrite("/data/local/tmp/lept/regout/na6.na", na1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/na6.na");  /* 8 */
     n = numaGetCount(na1);
     fract = 100.0 / n;
     na4 = numaTransform(na1, 0.0, fract);
@@ -169,9 +169,9 @@
     numaaAddNuma(naa, na1, L_INSERT);
     numaaAddNuma(naa, na2, L_INSERT);
     numaaAddNuma(naa, na3, L_INSERT);
-    gplotSimpleN(naa, GPLOT_PNG, "/tmp/lept/regout/nearline2",
+    gplotSimpleN(naa, GPLOT_PNG, "/data/local/tmp/lept/regout/nearline2",
                  "Min along line");
-    pix4 = pixRead("/tmp/lept/regout/nearline2.png");
+    pix4 = pixRead("/data/local/tmp/lept/regout/nearline2.png");
     regTestWritePixAndCheck(rp, pix4, IFF_PNG);  /* 9 */
     pixDisplayWithTitle(pix4, 800, 100, NULL, rp->display);
     numaaDestroy(&naa);
diff -Nura leptonica-1.83.1/prog/newspaper_reg.c leptonica-1.83.1-patch/prog/newspaper_reg.c
--- leptonica-1.83.1/prog/newspaper_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/newspaper_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -150,8 +150,8 @@
     regTestWritePixAndCheck(rp, pixt, IFF_PNG);  /* 12 */
     pixDisplayWithTitle(pixt, 900, 300, "stuff under mask2", rp->display);
     pixaConvertToPdf(pixa1, 75, 1.0, 0, 0, "Segmentation: newspaper_reg",
-                     "/tmp/lept/regout/newspaper.pdf");
-    L_INFO("Output pdf: /tmp/lept/regout/newspaper.pdf\n", rp->testname);
+                     "/data/local/tmp/lept/regout/newspaper.pdf");
+    L_INFO("Output pdf: /data/local/tmp/lept/regout/newspaper.pdf\n", rp->testname);
 
     pixaDestroy(&pixa1);
     pixDestroy(&pixs);
diff -Nura leptonica-1.83.1/prog/numa1_reg.c leptonica-1.83.1-patch/prog/numa1_reg.c
--- leptonica-1.83.1/prog/numa1_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/numa1_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -77,7 +77,7 @@
     nahisto = numaMakeHistogramClipped(na, 6, 2000);
     nbins = numaGetCount(nahisto);
     nax = numaMakeSequence(0, 1, nbins);
-    pix1 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/tmp/lept/numa1/histo1",
+    pix1 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/data/local/tmp/lept/numa1/histo1",
                             "example histo 1", "i", "histo[i]");
     numaDestroy(&nax);
     numaDestroy(&nahisto);
@@ -86,7 +86,7 @@
     nbins = numaGetCount(nahisto);
     nax = numaMakeSequence(binstart, binsize, nbins);
     lept_stderr(" binsize = %d, binstart = %d\n", binsize, binstart);
-    pix2 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/tmp/lept/numa1/histo2",
+    pix2 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/data/local/tmp/lept/numa1/histo2",
                             "example histo 2", "i", "histo[i]");
     numaDestroy(&nax);
     numaDestroy(&nahisto);
@@ -95,7 +95,7 @@
     nbins = numaGetCount(nahisto);
     nax = numaMakeSequence(0, binsize, nbins);
     lept_stderr(" binsize = %d, binstart = %d\n", binsize, 0);
-    pix3 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/tmp/lept/numa1/histo3",
+    pix3 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/data/local/tmp/lept/numa1/histo3",
                             "example histo 3", "i", "histo[i]");
     numaDestroy(&nax);
     numaDestroy(&nahisto);
@@ -105,7 +105,7 @@
     numaGetParameters(nahisto, &startval, &fbinsize);
     nax = numaMakeSequence(startval, fbinsize, nbins);
     lept_stderr(" binsize = %7.4f, binstart = %8.3f\n", fbinsize, startval);
-    pix4 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/tmp/lept/numa1/histo4",
+    pix4 = gplotGeneralPix2(nax, nahisto, GPLOT_LINES, "/data/local/tmp/lept/numa1/histo4",
                             "example histo 4", "i", "histo[i]");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 0 */
     regTestWritePixAndCheck(rp, pix2, IFF_PNG);  /* 1 */
@@ -157,13 +157,13 @@
     pixs = pixRead("test8.jpg");
     na = pixGetGrayHistogramMasked(pixs, NULL, 0, 0, 1);
     nasy = numaGetPartialSums(na);
-    pix1 = gplotGeneralPix1(nasy, GPLOT_LINES, "/tmp/lept/numa1/int1",
+    pix1 = gplotGeneralPix1(nasy, GPLOT_LINES, "/data/local/tmp/lept/numa1/int1",
                             "partial sums", NULL, NULL);
-    pix2 = gplotGeneralPix1(na, GPLOT_LINES, "/tmp/lept/numa1/int2",
+    pix2 = gplotGeneralPix1(na, GPLOT_LINES, "/data/local/tmp/lept/numa1/int2",
                             "simple test", NULL, NULL);
     numaInterpolateEqxInterval(0.0, 1.0, na, L_LINEAR_INTERP,
                                0.0, 255.0, 15, &nax, &nay);
-    pix3 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/tmp/lept/numa1/int3",
+    pix3 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/data/local/tmp/lept/numa1/int3",
                             "test interpolation", "pix val", "num pix");
     numaDestroy(&na);
     numaDestroy(&nasy);
@@ -179,7 +179,7 @@
     nasx = numaMakeSequence(0.0, 1.0, 257);
     numaInterpolateArbxInterval(nasx, nasy, L_LINEAR_INTERP,
                                 10.0, 250.0, 23, &nax, &nay);
-    pix4 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/tmp/lept/numa1/int4",
+    pix4 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/data/local/tmp/lept/numa1/int4",
                             "arbx interpolation", "pix val", "cum num pix");
     numaDestroy(&na);
     numaDestroy(&nasx);
@@ -202,7 +202,7 @@
         numaInterpolateArbxVal(nasx, nasy, L_QUADRATIC_INTERP, xval, &yval);
         numaAddNumber(nay, yval);
     }
-    pix5 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/tmp/lept/numa1/int5",
+    pix5 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/data/local/tmp/lept/numa1/int5",
                             "arbx interpolation", "pix val", "cum num pix");
     numaDestroy(&na);
     numaDestroy(&nasx);
@@ -214,7 +214,7 @@
         /* Test interpolation */
     nasx = numaRead("testangle.na");
     nasy = numaRead("testscore.na");
-    gplot = gplotCreate("/tmp/lept/numa1/int6", GPLOT_PNG, "arbx interpolation",
+    gplot = gplotCreate("/data/local/tmp/lept/numa1/int6", GPLOT_PNG, "arbx interpolation",
                         "angle", "score");
     numaInterpolateArbxInterval(nasx, nasy, L_LINEAR_INTERP,
                                 -2.00, 0.0, 50, &nax, &nay);
@@ -228,7 +228,7 @@
     numaDestroy(&nay);
     pix6 = gplotMakeOutputPix(gplot);
     gplotDestroy(&gplot);
-    gplot = gplotCreate("/tmp/lept/numa1/int7", GPLOT_PNG, "arbx interpolation",
+    gplot = gplotCreate("/data/local/tmp/lept/numa1/int7", GPLOT_PNG, "arbx interpolation",
                         "angle", "score");
     numaInterpolateArbxInterval(nasx, nasy, L_LINEAR_INTERP,
                                 -1.2, -0.8, 50, &nax, &nay);
@@ -271,12 +271,12 @@
     nasy = numaRead("testscore.na");
         /* ---------- Plot the derivative ---------- */
     numaDifferentiateInterval(nasx, nasy, -2.0, 0.0, 50, &nadx, &nady);
-    pix1 = gplotGeneralPix2(nadx, nady, GPLOT_LINES, "/tmp/lept/numa1/diff1",
+    pix1 = gplotGeneralPix2(nadx, nady, GPLOT_LINES, "/data/local/tmp/lept/numa1/diff1",
                             "derivative", "angle", "slope");
         /*  ---------- Plot the original function ----------- */
         /*  and the integral of the derivative; the two       */
         /*  should be approximately the same.                 */
-    gplot = gplotCreate("/tmp/lept/numa1/diff2", GPLOT_PNG, "integ-diff",
+    gplot = gplotCreate("/data/local/tmp/lept/numa1/diff2", GPLOT_PNG, "integ-diff",
                         "angle", "val");
     numaInterpolateArbxInterval(nasx, nasy, L_LINEAR_INTERP,
                                 -2.00, 0.0, 50, &nafx, &nafy);
diff -Nura leptonica-1.83.1/prog/numa2_reg.c leptonica-1.83.1-patch/prog/numa2_reg.c
--- leptonica-1.83.1/prog/numa2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/numa2_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -76,16 +76,16 @@
      * -------------------------------------------------------------------*/
     na = numaRead("lyra.5.na");
     numaWindowedStats(na, 5, &na1, &na2, &na3, &na4);
-    gplotSimple1(na, GPLOT_PNG, "/tmp/lept/numa2/lyra1", "Original");
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/numa2/lyra2", "Mean");
-    gplotSimple1(na2, GPLOT_PNG, "/tmp/lept/numa2/lyra3", "Mean Square");
-    gplotSimple1(na3, GPLOT_PNG, "/tmp/lept/numa2/lyra4", "Variance");
-    gplotSimple1(na4, GPLOT_PNG, "/tmp/lept/numa2/lyra5", "RMS Difference");
-    pix1 = pixRead("/tmp/lept/numa2/lyra1.png");
-    pix2 = pixRead("/tmp/lept/numa2/lyra2.png");
-    pix3 = pixRead("/tmp/lept/numa2/lyra3.png");
-    pix4 = pixRead("/tmp/lept/numa2/lyra4.png");
-    pix5 = pixRead("/tmp/lept/numa2/lyra5.png");
+    gplotSimple1(na, GPLOT_PNG, "/data/local/tmp/lept/numa2/lyra1", "Original");
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/numa2/lyra2", "Mean");
+    gplotSimple1(na2, GPLOT_PNG, "/data/local/tmp/lept/numa2/lyra3", "Mean Square");
+    gplotSimple1(na3, GPLOT_PNG, "/data/local/tmp/lept/numa2/lyra4", "Variance");
+    gplotSimple1(na4, GPLOT_PNG, "/data/local/tmp/lept/numa2/lyra5", "RMS Difference");
+    pix1 = pixRead("/data/local/tmp/lept/numa2/lyra1.png");
+    pix2 = pixRead("/data/local/tmp/lept/numa2/lyra2.png");
+    pix3 = pixRead("/data/local/tmp/lept/numa2/lyra3.png");
+    pix4 = pixRead("/data/local/tmp/lept/numa2/lyra4.png");
+    pix5 = pixRead("/data/local/tmp/lept/numa2/lyra5.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 0 */
     regTestWritePixAndCheck(rp, pix2, IFF_PNG);  /* 1 */
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 2 */
@@ -135,16 +135,16 @@
     na2 = pixExtractOnLine(pixg, 40, 30, 40, 170, 1);
     na3 = pixExtractOnLine(pixg, 20, 170, 180, 30, 1);
     na4 = pixExtractOnLine(pixg, 20, 190, 180, 10, 1);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/numa2/ext1", "Horizontal");
-    gplotSimple1(na2, GPLOT_PNG, "/tmp/lept/numa2/ext2", "Vertical");
-    gplotSimple1(na3, GPLOT_PNG, "/tmp/lept/numa2/ext3",
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/numa2/ext1", "Horizontal");
+    gplotSimple1(na2, GPLOT_PNG, "/data/local/tmp/lept/numa2/ext2", "Vertical");
+    gplotSimple1(na3, GPLOT_PNG, "/data/local/tmp/lept/numa2/ext3",
                 "Slightly more horizontal than vertical");
-    gplotSimple1(na4, GPLOT_PNG, "/tmp/lept/numa2/ext4",
+    gplotSimple1(na4, GPLOT_PNG, "/data/local/tmp/lept/numa2/ext4",
                 "Slightly more vertical than horizontal");
-    pix1 = pixRead("/tmp/lept/numa2/ext1.png");
-    pix2 = pixRead("/tmp/lept/numa2/ext2.png");
-    pix3 = pixRead("/tmp/lept/numa2/ext3.png");
-    pix4 = pixRead("/tmp/lept/numa2/ext4.png");
+    pix1 = pixRead("/data/local/tmp/lept/numa2/ext1.png");
+    pix2 = pixRead("/data/local/tmp/lept/numa2/ext2.png");
+    pix3 = pixRead("/data/local/tmp/lept/numa2/ext3.png");
+    pix4 = pixRead("/data/local/tmp/lept/numa2/ext4.png");
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 6 */
     regTestWritePixAndCheck(rp, pix2, IFF_PNG);  /* 7 */
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 8 */
diff -Nura leptonica-1.83.1/prog/numa3_reg.c leptonica-1.83.1-patch/prog/numa3_reg.c
--- leptonica-1.83.1/prog/numa3_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/numa3_reg.c	2024-09-05 14:26:11.043617670 +0800
@@ -70,7 +70,7 @@
     pixs = pixRead("test8.jpg");
     nasy= pixGetGrayHistogramMasked(pixs, NULL, 0, 0, 1);
     numaMakeRankFromHistogram(0.0, 1.0, nasy, 350, &nax, &nay);
-    pix1 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/tmp/lept/numa1/rank1",
+    pix1 = gplotGeneralPix2(nax, nay, GPLOT_LINES, "/data/local/tmp/lept/numa1/rank1",
                             "test rank extractor", "pix val", "rank val");
     numaDestroy(&nasy);
     numaDestroy(&nax);
@@ -86,7 +86,7 @@
       numaHistogramGetValFromRank(na, rank, &val);
       numaAddNumber(nap, val);
     }
-    pix2 = gplotGeneralPix1(nap, GPLOT_LINES, "/tmp/lept/numa1/rank2",
+    pix2 = gplotGeneralPix1(nap, GPLOT_LINES, "/data/local/tmp/lept/numa1/rank2",
                             "rank value", NULL, NULL);
     pixa = pixaCreate(2);
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);  /* 0 */
@@ -107,19 +107,19 @@
      *                           Numa-morphology                          *
      * -------------------------------------------------------------------*/
     na = numaRead("lyra.5.na");
-    pix1 = gplotGeneralPix1(na, GPLOT_LINES, "/tmp/lept/numa1/lyra1",
+    pix1 = gplotGeneralPix1(na, GPLOT_LINES, "/data/local/tmp/lept/numa1/lyra1",
                             "Original", NULL, NULL);
     na1 = numaErode(na, 21);
-    pix2 = gplotGeneralPix1(na1, GPLOT_LINES, "/tmp/lept/numa1/lyra2",
+    pix2 = gplotGeneralPix1(na1, GPLOT_LINES, "/data/local/tmp/lept/numa1/lyra2",
                             "Erosion", NULL, NULL);
     na2 = numaDilate(na, 21);
-    pix3 = gplotGeneralPix1(na2, GPLOT_LINES, "/tmp/lept/numa1/lyra3",
+    pix3 = gplotGeneralPix1(na2, GPLOT_LINES, "/data/local/tmp/lept/numa1/lyra3",
                             "Dilation", NULL, NULL);
     na3 = numaOpen(na, 21);
-    pix4 = gplotGeneralPix1(na3, GPLOT_LINES, "/tmp/lept/numa1/lyra4",
+    pix4 = gplotGeneralPix1(na3, GPLOT_LINES, "/data/local/tmp/lept/numa1/lyra4",
                             "Opening", NULL, NULL);
     na4 = numaClose(na, 21);
-    pix5 = gplotGeneralPix1(na4, GPLOT_LINES, "/tmp/lept/numa1/lyra5",
+    pix5 = gplotGeneralPix1(na4, GPLOT_LINES, "/data/local/tmp/lept/numa1/lyra5",
                             "Closing", NULL, NULL);
     pixa = pixaCreate(2);
     pixaAddPix(pixa, pix1, L_INSERT);
@@ -157,7 +157,7 @@
         na3 = numaTransform(na2, 0.0, 1.0 / maxval);
         numaFindLocForThreshold(na3, 0, &thresh, NULL);
         numaAddNumber(na4, thresh);
-        snprintf(buf1, sizeof(buf1), "/tmp/lept/numa1/histoplot-%d", hw);
+        snprintf(buf1, sizeof(buf1), "/data/local/tmp/lept/numa1/histoplot-%d", hw);
         snprintf(buf2, sizeof(buf2), "halfwidth = %d, skip = 20, thresh = %d",
                  hw, thresh);
         pix1 = gplotGeneralPix1(na3, GPLOT_LINES, buf1, buf2, NULL, NULL);
@@ -167,12 +167,12 @@
         numaDestroy(&na2);
         numaDestroy(&na3);
     }
-    numaWrite("/tmp/lept/numa1/threshvals.na", na4);
-    regTestCheckFile(rp, "/tmp/lept/numa1/threshvals.na");  /* 9 */
-    L_INFO("writing /tmp/lept/numa1/histoplots.pdf\n", "numa1_reg");
+    numaWrite("/data/local/tmp/lept/numa1/threshvals.na", na4);
+    regTestCheckFile(rp, "/data/local/tmp/lept/numa1/threshvals.na");  /* 9 */
+    L_INFO("writing /data/local/tmp/lept/numa1/histoplots.pdf\n", "numa1_reg");
     pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0,
                      "Effect of smoothing on threshold value",
-                     "/tmp/lept/numa1/histoplots.pdf");
+                     "/data/local/tmp/lept/numa1/histoplots.pdf");
     numaDestroy(&na1);
     numaDestroy(&na4);
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/numaranktest.c leptonica-1.83.1-patch/prog/numaranktest.c
--- leptonica-1.83.1/prog/numaranktest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/numaranktest.c	2024-09-05 14:26:11.043617670 +0800
@@ -76,16 +76,16 @@
         numaHistogramGetRankFromVal(nah, rval, &rank);
         numaAddNumber(nar, rank);
     }
-    gplotSimple1(nar, GPLOT_PNG, "/tmp/lept/numa/rank", "rank vs val");
-    l_fileDisplay("/tmp/lept/numa/rank.png", 0, 0, 1.0);
+    gplotSimple1(nar, GPLOT_PNG, "/data/local/tmp/lept/numa/rank", "rank vs val");
+    l_fileDisplay("/data/local/tmp/lept/numa/rank.png", 0, 0, 1.0);
 
     nav = numaCreate(0);
     for (rank = 0.0; rank <= 1.0; rank += 0.01) {
         numaHistogramGetValFromRank(nah, rank, &rval);
         numaAddNumber(nav, rval);
     }
-    gplotSimple1(nav, GPLOT_PNG, "/tmp/lept/numa/val", "val vs rank");
-    l_fileDisplay("/tmp/lept/numa/val.png", 750, 0, 1.0);
+    gplotSimple1(nav, GPLOT_PNG, "/data/local/tmp/lept/numa/val", "val vs rank");
+    l_fileDisplay("/data/local/tmp/lept/numa/val.png", 750, 0, 1.0);
 
     pixDestroy(&pix);
     numaDestroy(&na);
diff -Nura leptonica-1.83.1/prog/otsutest1.c leptonica-1.83.1-patch/prog/otsutest1.c
--- leptonica-1.83.1/prog/otsutest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/otsutest1.c	2024-09-05 14:26:11.043617670 +0800
@@ -61,17 +61,17 @@
        /* Read the results back in ...  */
     pixa = pixaCreate(0);
     for (i = 0; i < NTests; i++) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/otsu/plot.%d.png", i);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/otsu/plot.%d.png", i);
         pix = pixRead(buf);
         pixaAddPix(pixa, pix, L_INSERT);
-        snprintf(buf, sizeof(buf), "/tmp/lept/otsu/plots.%d.png", i);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/otsu/plots.%d.png", i);
         pix = pixRead(buf);
         pixaAddPix(pixa, pix, L_INSERT);
     }
 
         /* ... and save into a tiled pix  */
     pix = pixaDisplayTiledInColumns(pixa, 2, 1.0, 25, 0);
-    pixWrite("/tmp/lept/otsu/plot.png", pix, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/otsu/plot.png", pix, IFF_PNG);
     pixDisplay(pix, 100, 100);
     pixaDestroy(&pixa);
     pixDestroy(&pix);
@@ -106,7 +106,7 @@
     numaReplaceNumber(nay, 1, (l_int32)(0.5 * maxnum));
 
         /* Plot the input histogram with the split location */
-    snprintf(buf, sizeof(buf), "/tmp/lept/otsu/plot.%d", i);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/otsu/plot.%d", i);
     snprintf(title, sizeof(title), "Plot %d", i);
     gplot = gplotCreate(buf, GPLOT_PNG,
                         "Histogram: mixture of 2 gaussians",
@@ -119,7 +119,7 @@
     numaDestroy(&na2);
 
         /* Plot the score function */
-    snprintf(buf, sizeof(buf), "/tmp/lept/otsu/plots.%d", i);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/otsu/plots.%d", i);
     snprintf(title, sizeof(title), "Plot %d", i);
     gplot = gplotCreate(buf, GPLOT_PNG,
                         "Otsu score function for splitting",
diff -Nura leptonica-1.83.1/prog/otsutest2.c leptonica-1.83.1-patch/prog/otsutest2.c
--- leptonica-1.83.1/prog/otsutest2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/otsutest2.c	2024-09-05 14:26:11.047617592 +0800
@@ -94,7 +94,7 @@
 
             /* Save and display the result */
         pixaAddPix(pixad, pix2, L_INSERT);
-        snprintf(textstr, sizeof(textstr), "/tmp/lept/otsu/%03d.png", i);
+        snprintf(textstr, sizeof(textstr), "/data/local/tmp/lept/otsu/%03d.png", i);
         pixWrite(textstr, pix2, IFF_PNG);
         pixDisplay(pix2, 100, 100);
         pixDestroy(&pix1);
@@ -118,9 +118,9 @@
         pixDestroy(&pix2);
     }
 
-    lept_stderr("Writing to: /tmp/lept/otsu/result1.pdf\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/otsu/result1.pdf\n");
     pixaConvertToPdf(pixad, 75, 1.0, 0, 0, "Otsu thresholding",
-                     "/tmp/lept/otsu/result1.pdf");
+                     "/data/local/tmp/lept/otsu/result1.pdf");
     bmfDestroy(&bmf);
     pixDestroy(&pixs);
     pixDestroy(&pixg);
diff -Nura leptonica-1.83.1/prog/overlap_reg.c leptonica-1.83.1-patch/prog/overlap_reg.c
--- leptonica-1.83.1/prog/overlap_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/overlap_reg.c	2024-09-05 14:26:11.047617592 +0800
@@ -177,7 +177,7 @@
     /* --------------------------------------------------------- */
     box1 = boxCreate(0, 0, 1, 1);
     lept_mkdir("lept/overlap");
-    fp = fopenWriteStream("/tmp/lept/overlap/result.dat", "w");
+    fp = fopenWriteStream("/data/local/tmp/lept/overlap/result.dat", "w");
     for (i = 0; i < 3; i++) {  /* 9 1x1 boxes on a 3x3 square */
         for (j = 0; j < 3; j++) {
             box2 = boxCreate(i, j, 1, 1);
@@ -189,7 +189,7 @@
         }
     }
     fclose(fp);
-    data = l_binaryRead("/tmp/lept/overlap/result.dat", &nbytes);
+    data = l_binaryRead("/data/local/tmp/lept/overlap/result.dat", &nbytes);
     regTestWriteDataAndCheck(rp, data, nbytes, "dat");  /* 12 */
     lept_free(data);
     boxDestroy(&box1);
diff -Nura leptonica-1.83.1/prog/pagesegtest1.c leptonica-1.83.1-patch/prog/pagesegtest1.c
--- leptonica-1.83.1/prog/pagesegtest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pagesegtest1.c	2024-09-05 14:26:11.047617592 +0800
@@ -62,7 +62,7 @@
         /* Display intermediate images in a single image */
     lept_mkdir("lept/pagseg");
     pixd = pixaDisplayTiledAndScaled(pixadb, 32, 400, 4, 0, 20, 3);
-    pixWrite("/tmp/lept/pageseg/debug.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pageseg/debug.png", pixd, IFF_PNG);
     pixaDestroy(&pixadb);
     pixDestroy(&pixd);
     return 0;
diff -Nura leptonica-1.83.1/prog/paintmask_reg.c leptonica-1.83.1-patch/prog/paintmask_reg.c
--- leptonica-1.83.1/prog/paintmask_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/paintmask_reg.c	2024-09-05 14:26:11.047617592 +0800
@@ -206,8 +206,8 @@
         /* If in testing mode, make a pdf */
     if (rp->display) {
         pixaConvertToPdf(pixa, 100, 1.0, L_FLATE_ENCODE, 0,
-                         "Paint through mask", "/tmp/lept/regout/paintmask.pdf");
-        L_INFO("Output pdf: /tmp/lept/regout/paintmask.pdf\n", rp->testname);
+                         "Paint through mask", "/data/local/tmp/lept/regout/paintmask.pdf");
+        L_INFO("Output pdf: /data/local/tmp/lept/regout/paintmask.pdf\n", rp->testname);
     }
 
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/paint_reg.c leptonica-1.83.1-patch/prog/paint_reg.c
--- leptonica-1.83.1/prog/paint_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/paint_reg.c	2024-09-05 14:26:11.047617592 +0800
@@ -294,8 +294,8 @@
         /* If in testing mode, make a pdf */
     if (rp->display) {
         pixaConvertToPdf(pixa, 100, 1.0, L_FLATE_ENCODE, 0,
-                         "Colorize and paint", "/tmp/lept/regout/paint.pdf");
-        L_INFO("Output pdf: /tmp/lept/regout/paint.pdf\n", rp->testname);
+                         "Colorize and paint", "/data/local/tmp/lept/regout/paint.pdf");
+        L_INFO("Output pdf: /data/local/tmp/lept/regout/paint.pdf\n", rp->testname);
     }
 
     pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/prog/partifytest.c leptonica-1.83.1-patch/prog/partifytest.c
--- leptonica-1.83.1/prog/partifytest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/partifytest.c	2024-09-05 14:26:11.047617592 +0800
@@ -43,9 +43,9 @@
     setLeptDebugOK(1);
     lept_mkdir("lept/partify");
 #if 0
-    partifyFiles(".", "bois", 3, "/tmp/lept/partify/bois", "/tmp/lept/partify/debug.pdf");
+    partifyFiles(".", "bois", 3, "/data/local/tmp/lept/partify/bois", "/data/local/tmp/lept/partify/debug.pdf");
 #else
-    partifyFiles(".", "ortiz", 5, "/tmp/lept/partify/ortiz", "/tmp/lept/partify/debug.pdf");
+    partifyFiles(".", "ortiz", 5, "/data/local/tmp/lept/partify/ortiz", "/data/local/tmp/lept/partify/debug.pdf");
 #endif
     return 0;
 }
diff -Nura leptonica-1.83.1/prog/partitiontest.c leptonica-1.83.1-patch/prog/partitiontest.c
--- leptonica-1.83.1/prog/partitiontest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/partitiontest.c	2024-09-05 14:26:11.047617592 +0800
@@ -160,10 +160,10 @@
     pixaAddPix(pixa, pix2, L_INSERT);
     pixDestroy(&pix1);
 
-    lept_stderr("Writing to: /tmp/lept/part/partition.pdf\n");
+    lept_stderr("Writing to: /data/local/tmp/lept/part/partition.pdf\n");
     lept_mkdir("lept/part");
     pixaConvertToPdf(pixa, 300, 1.0, L_FLATE_ENCODE, 0, "Partition test",
-                     "/tmp/lept/part/partition.pdf");
+                     "/data/local/tmp/lept/part/partition.pdf");
     pixaDestroy(&pixa);
 
     pixDestroy(&pix);
diff -Nura leptonica-1.83.1/prog/pdfio1_reg.c leptonica-1.83.1-patch/prog/pdfio1_reg.c
--- leptonica-1.83.1/prog/pdfio1_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pdfio1_reg.c	2024-09-05 14:26:11.047617592 +0800
@@ -81,33 +81,33 @@
     /* ---------------  Single image tests  ------------------- */
     lept_stderr("\n*** Writing single images as pdf files\n");
     convertToPdf("weasel2.4c.png", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file00.pdf",
+                 "/data/local/tmp/lept/pdf1/file00.pdf",
                  0, 0, 72, "weasel2.4c.png", NULL, 0);
-    convertToPdf("test24.jpg", L_JPEG_ENCODE, 0, "/tmp/lept/pdf1/file01.pdf",
+    convertToPdf("test24.jpg", L_JPEG_ENCODE, 0, "/data/local/tmp/lept/pdf1/file01.pdf",
                  0, 0, 72, "test24.jpg", NULL, 0);
-    convertToPdf("feyn.tif", L_G4_ENCODE, 0, "/tmp/lept/pdf1/file02.pdf",
+    convertToPdf("feyn.tif", L_G4_ENCODE, 0, "/data/local/tmp/lept/pdf1/file02.pdf",
                  0, 0, 300, "feyn.tif", NULL, 0);
 
     pixs = pixRead("feyn.tif");
-    pixConvertToPdf(pixs, L_G4_ENCODE, 0, "/tmp/lept/pdf1/file03.pdf", 0, 0, 300,
+    pixConvertToPdf(pixs, L_G4_ENCODE, 0, "/data/local/tmp/lept/pdf1/file03.pdf", 0, 0, 300,
                     "feyn.tif", NULL, 0);
     pixDestroy(&pixs);
 
     pixs = pixRead("test24.jpg");
-    pixConvertToPdf(pixs, L_JPEG_ENCODE, 5, "/tmp/lept/pdf1/file04.pdf",
+    pixConvertToPdf(pixs, L_JPEG_ENCODE, 5, "/data/local/tmp/lept/pdf1/file04.pdf",
                     0, 0, 72, "test24.jpg", NULL, 0);
     pixDestroy(&pixs);
 
     pixs = pixRead("feyn.tif");
     pixt = pixScaleToGray2(pixs);
-    pixWrite("/tmp/lept/pdf1/feyn8.png", pixt, IFF_PNG);
-    convertToPdf("/tmp/lept/pdf1/feyn8.png", L_JPEG_ENCODE, 0,
-                 "/tmp/lept/pdf1/file05.pdf", 0, 0, 150, "feyn8.png", NULL, 0);
+    pixWrite("/data/local/tmp/lept/pdf1/feyn8.png", pixt, IFF_PNG);
+    convertToPdf("/data/local/tmp/lept/pdf1/feyn8.png", L_JPEG_ENCODE, 0,
+                 "/data/local/tmp/lept/pdf1/file05.pdf", 0, 0, 150, "feyn8.png", NULL, 0);
     pixDestroy(&pixs);
     pixDestroy(&pixt);
 
     convertToPdf("weasel4.16g.png", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file06.pdf", 0, 0, 30,
+                 "/data/local/tmp/lept/pdf1/file06.pdf", 0, 0, 30,
                  "weasel4.16g.png", NULL, 0);
 
     pixs = pixRead("test24.jpg");
@@ -115,12 +115,12 @@
     box = boxCreate(100, 100, 100, 100);
     pixc = pixClipRectangle(pixs, box, NULL);
     pixgc = pixClipRectangle(pixg, box, NULL);
-    pixWrite("/tmp/lept/pdf1/pix32.jpg", pixc, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/pdf1/pix8.jpg", pixgc, IFF_JFIF_JPEG);
-    convertToPdf("/tmp/lept/pdf1/pix32.jpg", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file07.pdf", 0, 0, 72, "pix32.jpg", NULL, 0);
-    convertToPdf("/tmp/lept/pdf1/pix8.jpg", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file08.pdf", 0, 0, 72, "pix8.jpg", NULL, 0);
+    pixWrite("/data/local/tmp/lept/pdf1/pix32.jpg", pixc, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/pdf1/pix8.jpg", pixgc, IFF_JFIF_JPEG);
+    convertToPdf("/data/local/tmp/lept/pdf1/pix32.jpg", L_FLATE_ENCODE, 0,
+                 "/data/local/tmp/lept/pdf1/file07.pdf", 0, 0, 72, "pix32.jpg", NULL, 0);
+    convertToPdf("/data/local/tmp/lept/pdf1/pix8.jpg", L_FLATE_ENCODE, 0,
+                 "/data/local/tmp/lept/pdf1/file08.pdf", 0, 0, 72, "pix8.jpg", NULL, 0);
     pixDestroy(&pixs);
     pixDestroy(&pixg);
     pixDestroy(&pixc);
@@ -144,7 +144,7 @@
                             100 * i, 70, title, &lpd, seq);
         }
     }
-    pixConvertToPdf(pix1, L_G4_ENCODE, 0, "/tmp/lept/pdf1/file09.pdf", 0, 0, 80,
+    pixConvertToPdf(pix1, L_G4_ENCODE, 0, "/data/local/tmp/lept/pdf1/file09.pdf", 0, 0, 80,
                     NULL, &lpd, L_LAST_IMAGE);
 
         /* Now, write the 1 bpp image over the weasels */
@@ -157,7 +157,7 @@
                             100 * i, 70, title, &lpd, seq);
         }
     }
-    pixConvertToPdf(pix1, L_G4_ENCODE, 0, "/tmp/lept/pdf1/file10.pdf", 0, 0, 80,
+    pixConvertToPdf(pix1, L_G4_ENCODE, 0, "/data/local/tmp/lept/pdf1/file10.pdf", 0, 0, 80,
                     NULL, &lpd, L_LAST_IMAGE);
     l_pdfSetG4ImageMask(1);
     pixDestroy(&pix1);
@@ -169,36 +169,36 @@
     lept_stderr("\n*** Writing segmented images without image regions\n");
     pix1 = pixRead("rabi.png");
     pix2 = pixScaleToGray2(pix1);
-    pixWrite("/tmp/lept/pdf1/rabi8.jpg", pix2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/pdf1/rabi8.jpg", pix2, IFF_JFIF_JPEG);
     pix3 = pixThresholdTo4bpp(pix2, 16, 1);
-    pixWrite("/tmp/lept/pdf1/rabi4.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf1/rabi4.png", pix3, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
 
         /* 1 bpp input */
     convertToPdfSegmented("rabi.png", 300, L_G4_ENCODE, 128, NULL, 0, 0,
-                          NULL, "/tmp/lept/pdf1/file11.pdf");
+                          NULL, "/data/local/tmp/lept/pdf1/file11.pdf");
     convertToPdfSegmented("rabi.png", 300, L_JPEG_ENCODE, 128, NULL, 0, 0,
-                          NULL, "/tmp/lept/pdf1/file12.pdf");
+                          NULL, "/data/local/tmp/lept/pdf1/file12.pdf");
     convertToPdfSegmented("rabi.png", 300, L_FLATE_ENCODE, 128, NULL, 0, 0,
-                          NULL, "/tmp/lept/pdf1/file13.pdf");
+                          NULL, "/data/local/tmp/lept/pdf1/file13.pdf");
 
         /* 8 bpp input, no cmap */
-    convertToPdfSegmented("/tmp/lept/pdf1/rabi8.jpg", 150, L_G4_ENCODE, 128,
-                          NULL, 0, 0, NULL, "/tmp/lept/pdf1/file14.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf1/rabi8.jpg", 150, L_JPEG_ENCODE, 128,
-                          NULL, 0, 0, NULL, "/tmp/lept/pdf1/file15.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf1/rabi8.jpg", 150, L_FLATE_ENCODE, 128,
-                          NULL, 0, 0, NULL, "/tmp/lept/pdf1/file16.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf1/rabi8.jpg", 150, L_G4_ENCODE, 128,
+                          NULL, 0, 0, NULL, "/data/local/tmp/lept/pdf1/file14.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf1/rabi8.jpg", 150, L_JPEG_ENCODE, 128,
+                          NULL, 0, 0, NULL, "/data/local/tmp/lept/pdf1/file15.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf1/rabi8.jpg", 150, L_FLATE_ENCODE, 128,
+                          NULL, 0, 0, NULL, "/data/local/tmp/lept/pdf1/file16.pdf");
 
         /* 4 bpp input, cmap */
-    convertToPdfSegmented("/tmp/lept/pdf1/rabi4.png", 150, L_G4_ENCODE, 128,
-                          NULL, 0, 0, NULL, "/tmp/lept/pdf1/file17.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf1/rabi4.png", 150, L_JPEG_ENCODE, 128,
-                          NULL, 0, 0, NULL, "/tmp/lept/pdf1/file18.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf1/rabi4.png", 150, L_FLATE_ENCODE, 128,
-                          NULL, 0, 0, NULL, "/tmp/lept/pdf1/file19.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf1/rabi4.png", 150, L_G4_ENCODE, 128,
+                          NULL, 0, 0, NULL, "/data/local/tmp/lept/pdf1/file17.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf1/rabi4.png", 150, L_JPEG_ENCODE, 128,
+                          NULL, 0, 0, NULL, "/data/local/tmp/lept/pdf1/file18.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf1/rabi4.png", 150, L_FLATE_ENCODE, 128,
+                          NULL, 0, 0, NULL, "/data/local/tmp/lept/pdf1/file19.pdf");
 
 #endif
 
@@ -206,27 +206,27 @@
     /* ----------  Generating from 1 bpp images (high-level) -------------- */
     lept_stderr("\n*** Writing 1 bpp images as pdf files (high-level)\n");
     pix1 = pixRead("feyn-fract.tif");
-    pixWrite("/tmp/lept/pdf1/feyn-nocmap.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf1/feyn-nocmap.png", pix1, IFF_PNG);
     pix2 = pixCopy(NULL, pix1);
     cmap = pixcmapCreate(1);
     pixcmapAddColor(cmap, 0, 0, 0);  /* with cmap: black bg, white letters */
     pixcmapAddColor(cmap, 255, 255, 255);
     pixSetColormap(pix2, cmap);
-    pixWrite("/tmp/lept/pdf1/feyn-cmap1.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf1/feyn-cmap1.png", pix2, IFF_PNG);
     cmap = pixcmapCreate(1);
     pixcmapAddColor(cmap, 200, 0, 0);  /* with cmap: red bg, white letters */
     pixcmapAddColor(cmap, 255, 255, 255);
     pixSetColormap(pix1, cmap);
-    pixWrite("/tmp/lept/pdf1/feyn-cmap2.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf1/feyn-cmap2.png", pix1, IFF_PNG);
 
-    convertToPdf("/tmp/lept/pdf1/feyn-nocmap.png", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file20.pdf",
+    convertToPdf("/data/local/tmp/lept/pdf1/feyn-nocmap.png", L_FLATE_ENCODE, 0,
+                 "/data/local/tmp/lept/pdf1/file20.pdf",
                  0, 0, 0, NULL, NULL, 0);
-    convertToPdf("/tmp/lept/pdf1/feyn-cmap1.png", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file21.pdf",
+    convertToPdf("/data/local/tmp/lept/pdf1/feyn-cmap1.png", L_FLATE_ENCODE, 0,
+                 "/data/local/tmp/lept/pdf1/file21.pdf",
                  0, 0, 0, NULL, NULL, 0);
-    convertToPdf("/tmp/lept/pdf1/feyn-cmap2.png", L_FLATE_ENCODE, 0,
-                 "/tmp/lept/pdf1/file22.pdf",
+    convertToPdf("/data/local/tmp/lept/pdf1/feyn-cmap2.png", L_FLATE_ENCODE, 0,
+                 "/data/local/tmp/lept/pdf1/file22.pdf",
                  0, 0, 0, NULL, NULL, 0);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -243,23 +243,23 @@
     pixcmapAddColor(cmap, 255, 255, 255);  /* white = 0 */
     pixcmapAddColor(cmap, 0, 0, 0);  /* black = 1 */
     pixSetColormap(pix2, cmap);  /* replace with a b/w colormap */
-    pixWrite("/tmp/lept/pdf1/cat-and-mouse-cmap1.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf1/cat-and-mouse-cmap1.png", pix2, IFF_PNG);
 
         /* Generate a pdf from this pix. The pdf has the colormap */
     pixGenerateCIData(pix2, L_FLATE_ENCODE, 0, 0, &cid);
     lept_stderr("  Should have 2 colors: %d\n", cid->ncolors);
     cidConvertToPdfData(cid, "with colormap", &data8, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf1/file23.pdf", "w", data8, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf1/file23.pdf", "w", data8, nbytes);
     lept_free(data8);
 
         /* Generate a pdf from the colormap file:
          *   l_generateCIDataForPdf() calls l_generateFlateDataPdf()
          *   which calls pixRead(), removing the cmap  */
-    l_generateCIDataForPdf("/tmp/lept/pdf1/cat-and-mouse-cmap1.png",
+    l_generateCIDataForPdf("/data/local/tmp/lept/pdf1/cat-and-mouse-cmap1.png",
                            NULL, 75, &cid);
     lept_stderr("  Should have 0 colors: %d\n", cid->ncolors);
     cidConvertToPdfData(cid, "no colormap", &data8, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf1/file24.pdf", "w", data8, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf1/file24.pdf", "w", data8, nbytes);
     lept_free(data8);
 
         /* Use an arbitrary colormap */
@@ -267,52 +267,52 @@
     pixcmapAddColor(cmap, 254, 240, 185);  // yellow
     pixcmapAddColor(cmap, 50, 50, 130);   // blue
     pixSetColormap(pix2, cmap);
-    pixWrite("/tmp/lept/pdf1/cat-and-mouse-cmap2.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf1/cat-and-mouse-cmap2.png", pix2, IFF_PNG);
 
        /* Generate a pdf from this pix. The pdf has the colormap. */
     pixGenerateCIData(pix2, L_FLATE_ENCODE, 0, 0, &cid);
     lept_stderr("  Should have 2 colors: %d\n", cid->ncolors);
     cidConvertToPdfData(cid, "with colormap", &data8, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf1/file25.pdf", "w", data8, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf1/file25.pdf", "w", data8, nbytes);
     lept_free(data8);
 
         /* Generate a pdf from the cmap file.  No cmap in the pdf. */
-    l_generateCIDataForPdf("/tmp/lept/pdf1/cat-and-mouse-cmap2.png",
+    l_generateCIDataForPdf("/data/local/tmp/lept/pdf1/cat-and-mouse-cmap2.png",
                            NULL, 75, &cid);
     lept_stderr("  Should have 0 colors: %d\n", cid->ncolors);
     cidConvertToPdfData(cid, "no colormap", &data8, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf1/file26.pdf", "w", data8, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf1/file26.pdf", "w", data8, nbytes);
     lept_free(data8);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
 #endif
 
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file00.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file01.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file02.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file03.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file04.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file05.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file06.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file07.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file08.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file09.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file10.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file11.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file12.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file13.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file14.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file15.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file16.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file17.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file18.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file19.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file20.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file21.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file22.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file23.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file24.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file25.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf1/file26.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file00.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file01.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file02.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file03.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file04.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file05.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file06.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file07.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file08.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file09.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file10.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file11.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file12.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file13.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file14.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file15.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file16.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file17.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file18.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file19.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file20.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file21.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file22.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file23.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file24.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file25.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf1/file26.pdf");
     return regTestCleanup(rp);
 }
diff -Nura leptonica-1.83.1/prog/pdfio2_reg.c leptonica-1.83.1-patch/prog/pdfio2_reg.c
--- leptonica-1.83.1/prog/pdfio2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pdfio2_reg.c	2024-09-05 14:26:11.047617592 +0800
@@ -79,9 +79,9 @@
          * the demonstration. */
     pix1 = pixRead("rabi.png");
     pix2 = pixScaleToGray2(pix1);
-    pixWrite("/tmp/lept/pdf2/rabi8.jpg", pix2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/pdf2/rabi8.jpg", pix2, IFF_JFIF_JPEG);
     pix3 = pixThresholdTo4bpp(pix2, 16, 1);
-    pixWrite("/tmp/lept/pdf2/rabi4.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pdf2/rabi4.png", pix3, IFF_PNG);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
     pixSetResolution(pix1, 300, 300);
@@ -96,41 +96,41 @@
 
         /* 1 bpp input */
     convertToPdfSegmented("rabi.png", 300, L_G4_ENCODE, 128, boxa1,
-                          0, 0.25, NULL, "/tmp/lept/pdf2/file00.pdf");
+                          0, 0.25, NULL, "/data/local/tmp/lept/pdf2/file00.pdf");
     convertToPdfSegmented("rabi.png", 300, L_JPEG_ENCODE, 128, boxa1,
-                          0, 0.25, NULL, "/tmp/lept/pdf2/file01.pdf");
+                          0, 0.25, NULL, "/data/local/tmp/lept/pdf2/file01.pdf");
     convertToPdfSegmented("rabi.png", 300, L_FLATE_ENCODE, 128, boxa1,
-                          0, 0.25, NULL, "/tmp/lept/pdf2/file02.pdf");
+                          0, 0.25, NULL, "/data/local/tmp/lept/pdf2/file02.pdf");
 
         /* 8 bpp input, no cmap */
-    convertToPdfSegmented("/tmp/lept/pdf2/rabi8.jpg", 150, L_G4_ENCODE, 128,
-                          boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file03.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/rabi8.jpg", 150, L_JPEG_ENCODE, 128,
-                          boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file04.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/rabi8.jpg", 150, L_FLATE_ENCODE, 128,
-                          boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file05.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/rabi8.jpg", 150, L_G4_ENCODE, 128,
+                          boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file03.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/rabi8.jpg", 150, L_JPEG_ENCODE, 128,
+                          boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file04.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/rabi8.jpg", 150, L_FLATE_ENCODE, 128,
+                          boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file05.pdf");
 
         /* 4 bpp input, cmap */
-    convertToPdfSegmented("/tmp/lept/pdf2/rabi4.png", 150, L_G4_ENCODE, 128,
-                          boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file06.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/rabi4.png", 150, L_JPEG_ENCODE, 128,
-                          boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file07.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/rabi4.png", 150, L_FLATE_ENCODE, 128,
-                          boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file08.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/rabi4.png", 150, L_G4_ENCODE, 128,
+                          boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file06.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/rabi4.png", 150, L_JPEG_ENCODE, 128,
+                          boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file07.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/rabi4.png", 150, L_FLATE_ENCODE, 128,
+                          boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file08.pdf");
 
         /* 4 bpp input, cmap, data output */
     data = NULL;
-    convertToPdfDataSegmented("/tmp/lept/pdf2/rabi4.png", 150, L_G4_ENCODE,
+    convertToPdfDataSegmented("/data/local/tmp/lept/pdf2/rabi4.png", 150, L_G4_ENCODE,
                               128, boxa2, 0, 0.5, NULL, &data, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf2/file09.pdf", "w", data, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf2/file09.pdf", "w", data, nbytes);
     lept_free(data);
-    convertToPdfDataSegmented("/tmp/lept/pdf2/rabi4.png", 150, L_JPEG_ENCODE,
+    convertToPdfDataSegmented("/data/local/tmp/lept/pdf2/rabi4.png", 150, L_JPEG_ENCODE,
                               128, boxa2, 0, 0.5, NULL, &data, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf2/file10.pdf", "w", data, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf2/file10.pdf", "w", data, nbytes);
     lept_free(data);
-    convertToPdfDataSegmented("/tmp/lept/pdf2/rabi4.png", 150, L_FLATE_ENCODE,
+    convertToPdfDataSegmented("/data/local/tmp/lept/pdf2/rabi4.png", 150, L_FLATE_ENCODE,
                               128, boxa2, 0, 0.5, NULL, &data, &nbytes);
-    l_binaryWrite("/tmp/lept/pdf2/file11.pdf", "w", data, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/pdf2/file11.pdf", "w", data, nbytes);
     lept_free(data);
     lept_stderr("Segmented images time: %7.3f\n", stopTimer());
 
@@ -144,17 +144,17 @@
 
     pix1 = pixRead("candelabrum.011.jpg");
     pix2 = pixScale(pix1, 3.0, 3.0);
-    pixWrite("/tmp/lept/pdf2/candelabrum3.jpg", pix2, IFF_JFIF_JPEG);
-    GetImageMask(pix2, 200, &boxa1, rp, "/tmp/lept/pdf2/seg1.jpg");
-    convertToPdfSegmented("/tmp/lept/pdf2/candelabrum3.jpg", 200, L_G4_ENCODE,
+    pixWrite("/data/local/tmp/lept/pdf2/candelabrum3.jpg", pix2, IFF_JFIF_JPEG);
+    GetImageMask(pix2, 200, &boxa1, rp, "/data/local/tmp/lept/pdf2/seg1.jpg");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/candelabrum3.jpg", 200, L_G4_ENCODE,
                           100, boxa1, 0, 0.25, NULL,
-                          "/tmp/lept/pdf2/file12.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/candelabrum3.jpg", 200, L_JPEG_ENCODE,
+                          "/data/local/tmp/lept/pdf2/file12.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/candelabrum3.jpg", 200, L_JPEG_ENCODE,
                           100, boxa1, 0, 0.25, NULL,
-                          "/tmp/lept/pdf2/file13.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/candelabrum3.jpg", 200, L_FLATE_ENCODE,
+                          "/data/local/tmp/lept/pdf2/file13.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/candelabrum3.jpg", 200, L_FLATE_ENCODE,
                           100, boxa1, 0, 0.25, NULL,
-                          "/tmp/lept/pdf2/file14.pdf");
+                          "/data/local/tmp/lept/pdf2/file14.pdf");
 
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -162,25 +162,25 @@
 
     pix1 = pixRead("lion-page.00016.jpg");
     pix2 = pixScale(pix1, 3.0, 3.0);
-    pixWrite("/tmp/lept/pdf2/lion16.jpg", pix2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/pdf2/lion16.jpg", pix2, IFF_JFIF_JPEG);
     pix3 = pixRead("lion-mask.00016.tif");
     boxa1 = pixConnComp(pix3, NULL, 8);
     boxa2 = boxaTransform(boxa1, 0, 0, 3.0, 3.0);
-    convertToPdfSegmented("/tmp/lept/pdf2/lion16.jpg", 200, L_G4_ENCODE,
-                          190, boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file15.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/lion16.jpg", 200, L_JPEG_ENCODE,
-                          190, boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file16.pdf");
-    convertToPdfSegmented("/tmp/lept/pdf2/lion16.jpg", 200, L_FLATE_ENCODE,
-                          190, boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file17.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/lion16.jpg", 200, L_G4_ENCODE,
+                          190, boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file15.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/lion16.jpg", 200, L_JPEG_ENCODE,
+                          190, boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file16.pdf");
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/lion16.jpg", 200, L_FLATE_ENCODE,
+                          190, boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file17.pdf");
 
         /* Quantize the non-image part and flate encode.
          * This is useful because it results in a smaller file than
          * when you flate-encode the un-quantized non-image regions. */
     pix4 = pixScale(pix3, 3.0, 3.0);  /* higher res mask, for combining */
     pix5 = QuantizeNonImageRegion(pix2, pix4, 12);
-    pixWrite("/tmp/lept/pdf2/lion16-quant.png", pix5, IFF_PNG);
-    convertToPdfSegmented("/tmp/lept/pdf2/lion16-quant.png", 200, L_FLATE_ENCODE,
-                          190, boxa2, 0, 0.5, NULL, "/tmp/lept/pdf2/file18.pdf");
+    pixWrite("/data/local/tmp/lept/pdf2/lion16-quant.png", pix5, IFF_PNG);
+    convertToPdfSegmented("/data/local/tmp/lept/pdf2/lion16-quant.png", 200, L_FLATE_ENCODE,
+                          190, boxa2, 0, 0.5, NULL, "/data/local/tmp/lept/pdf2/file18.pdf");
     lept_stderr("Color segmented images time: %7.3f\n", stopTimer());
 
     pixDestroy(&pix1);
@@ -209,15 +209,15 @@
     pix4 = pixScaleToGray3(pix2);
     pix5 = pixScale(pix1, 0.33, 0.33);
     pix6 = pixRead("test24.jpg");
-    pixWrite("/tmp/lept/image/file1.png", pix3, IFF_PNG);  /* 10 colors */
-    pixWrite("/tmp/lept/image/file2.jpg", pix4, IFF_JFIF_JPEG); /* 256 colors */
-    pixWrite("/tmp/lept/image/file3.tif", pix5, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/image/file4.jpg", pix6, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/image/file1.png", pix3, IFF_PNG);  /* 10 colors */
+    pixWrite("/data/local/tmp/lept/image/file2.jpg", pix4, IFF_JFIF_JPEG); /* 256 colors */
+    pixWrite("/data/local/tmp/lept/image/file3.tif", pix5, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/image/file4.jpg", pix6, IFF_JFIF_JPEG);
 
     startTimer();
-    convertFilesToPdf("/tmp/lept/image", "file", 100, 0.8, 0, 75, "4 file test",
-                      "/tmp/lept/pdf2/file19.pdf");
-    lept_stderr("4-page pdf generated: /tmp/lept/pdf2/file19.pdf\n"
+    convertFilesToPdf("/data/local/tmp/lept/image", "file", 100, 0.8, 0, 75, "4 file test",
+                      "/data/local/tmp/lept/pdf2/file19.pdf");
+    lept_stderr("4-page pdf generated: /data/local/tmp/lept/pdf2/file19.pdf\n"
                 "Multi-page gen time: %7.3f\n", stopTimer());
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -227,26 +227,26 @@
     pixDestroy(&pix6);
 #endif
 
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file00.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file01.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file02.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file03.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file04.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file05.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file06.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file07.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file08.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file09.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file10.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file11.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file12.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file13.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file14.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file15.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file16.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file17.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file18.pdf");
-    regTestCheckFile(rp, "/tmp/lept/pdf2/file19.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file00.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file01.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file02.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file03.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file04.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file05.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file06.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file07.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file08.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file09.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file10.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file11.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file12.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file13.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file14.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file15.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file16.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file17.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file18.pdf");
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdf2/file19.pdf");
 
 #if 1
     /* ------------------ Test multipage pdf generation ----------------- */
@@ -254,8 +254,8 @@
 
         /* Generate a multi-page pdf from all these files */
     startTimer();
-    concatenatePdf("/tmp/lept/pdf2", "file", "/tmp/lept/pdf2/cat_lept.pdf");
-    lept_stderr("All files are concatenated: /tmp/lept/pdf2/cat_lept.pdf\n"
+    concatenatePdf("/data/local/tmp/lept/pdf2", "file", "/data/local/tmp/lept/pdf2/cat_lept.pdf");
+    lept_stderr("All files are concatenated: /data/local/tmp/lept/pdf2/cat_lept.pdf\n"
                 "Concatenation time: %7.3f\n", stopTimer());
 #endif
 
@@ -267,7 +267,7 @@
     lept_mkdir("lept/good");
     lept_cp("testfile1.pdf", "lept/good", NULL, NULL);
     lept_cp("testfile2.pdf", "lept/good", NULL, NULL);
-    concatenatePdf("/tmp/lept/good", "file", "/tmp/lept/pdf2/good.pdf");
+    concatenatePdf("/data/local/tmp/lept/good", "file", "/data/local/tmp/lept/pdf2/good.pdf");
 
         /* Make a bad version with the pdf id removed, so that it is not
          * recognized as a pdf */
@@ -275,16 +275,16 @@
     lept_mkdir("lept/bad");
     ba = l_byteaInitFromFile("testfile2.pdf");
     data = l_byteaGetData(ba, &nbytes);
-    l_binaryWrite("/tmp/lept/bad/testfile0.notpdf.pdf", "w",
+    l_binaryWrite("/data/local/tmp/lept/bad/testfile0.notpdf.pdf", "w",
                   data + 10, nbytes - 10);
 
         /* Make a version with a corrupted trailer */
     if (data)
         data[2297] = '2';  /* munge trailer object 6: change 458 --> 428 */
-    l_binaryWrite("/tmp/lept/bad/testfile2.bad.pdf", "w", data, nbytes);
+    l_binaryWrite("/data/local/tmp/lept/bad/testfile2.bad.pdf", "w", data, nbytes);
     l_byteaDestroy(&ba);
 
-        /* Copy testfile1.pdf to the /tmp/lept/bad directory.  Then
+        /* Copy testfile1.pdf to the /data/local/tmp/lept/bad directory.  Then
          * run concat on the bad files.  The "not pdf" file should be
          * ignored, and the corrupted pdf file should be properly parsed,
          * so the resulting concatenated pdf files should be identical.  */
@@ -292,9 +292,9 @@
     lept_stderr("******************************************************\n");
     lept_stderr("* The next 3 error messages are intentional          *\n");
     lept_cp("testfile1.pdf", "lept/bad", NULL, NULL);
-    concatenatePdf("/tmp/lept/bad", "file", "/tmp/lept/pdf2/bad.pdf");
+    concatenatePdf("/data/local/tmp/lept/bad", "file", "/data/local/tmp/lept/pdf2/bad.pdf");
     lept_stderr("******************************************************\n");
-    filesAreIdentical("/tmp/lept/pdf2/good.pdf", "/tmp/lept/pdf2/bad.pdf",
+    filesAreIdentical("/data/local/tmp/lept/pdf2/good.pdf", "/data/local/tmp/lept/pdf2/bad.pdf",
                       &same);
     if (same)
         lept_stderr("Fixed: files are the same\nAttempt succeeded\n");
@@ -310,8 +310,8 @@
     l_int32  ret;
 
     lept_stderr("\n*** pdftk writes multipage pdfs from images\n");
-    tempfile1 = genPathname("/tmp/lept/pdf2", "file*.pdf");
-    tempfile2 = genPathname("/tmp/lept/pdf2", "cat_pdftk.pdf");
+    tempfile1 = genPathname("/data/local/tmp/lept/pdf2", "file*.pdf");
+    tempfile2 = genPathname("/data/local/tmp/lept/pdf2", "cat_pdftk.pdf");
     snprintf(buffer, sizeof(buffer), "pdftk %s output %s",
              tempfile1, tempfile2);
     ret = system(buffer);  /* pdftk */
diff -Nura leptonica-1.83.1/prog/pdfseg_reg.c leptonica-1.83.1-patch/prog/pdfseg_reg.c
--- leptonica-1.83.1/prog/pdfseg_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pdfseg_reg.c	2024-09-05 14:26:11.047617592 +0800
@@ -78,8 +78,8 @@
         /* Image region input.  */
     pix1 = pixRead("wet-day.jpg");
     pix2 = pixScaleToSize(pix1, WIDTH, 0);
-    pixWrite("/tmp/lept/pdfseg/0.jpg", pix2, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/0.jpg");   /* 0 */
+    pixWrite("/data/local/tmp/lept/pdfseg/0.jpg", pix2, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/0.jpg");   /* 0 */
     box = boxCreate(105, 161, 620, 872);   /* image region */
     boxa1 = boxaCreate(1);
     boxaAddBox(boxa1, box, L_INSERT);
@@ -97,8 +97,8 @@
     pix7 = pixMaskConnComp(pix6, 8, &boxa1);
     pix8 = pixReduceBinary2(pix7, NULL);  /* back to w = WIDTH */
     pix9 = pixBackgroundNormSimple(pix2, pix8, NULL);
-    pixWrite("/tmp/lept/pdfseg/1.jpg", pix9, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/1.jpg");   /* 1 */
+    pixWrite("/data/local/tmp/lept/pdfseg/1.jpg", pix9, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/1.jpg");   /* 1 */
     boxa2 = boxaTransform(boxa1, 0, 0, 0.5, 0.5);  /* back to w = WIDTH */
     boxaaAddBoxa(baa, boxa2, L_INSERT);
     boxaDestroy(&boxa1);
@@ -115,8 +115,8 @@
         /* Use mask to find image region */
     pix1 = pixRead("lion-page.00016.jpg");
     pix2 = pixScaleToSize(pix1, WIDTH, 0);
-    pixWrite("/tmp/lept/pdfseg/2.jpg", pix2, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/2.jpg");   /* 2 */
+    pixWrite("/data/local/tmp/lept/pdfseg/2.jpg", pix2, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/2.jpg");   /* 2 */
     pix3 = pixRead("lion-mask.00016.tif");
     pix4 = pixScaleToSize(pix3, WIDTH, 0);
     boxa1 = pixConnComp(pix4, NULL, 8);
@@ -130,8 +130,8 @@
     pix1 = pixRead("rabi.png");
     scalefactor = (l_float32)WIDTH / (l_float32)pixGetWidth(pix1);
     pix2 = pixScaleToGray(pix1, scalefactor);
-    pixWrite("/tmp/lept/pdfseg/3.jpg", pix2, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/3.jpg");   /* 3 */
+    pixWrite("/data/local/tmp/lept/pdfseg/3.jpg", pix2, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/3.jpg");   /* 3 */
     pix3 = pixGenerateHalftoneMask(pix1, NULL, NULL, NULL);
     pix4 = pixMorphSequence(pix3, "c20.1 + c1.20", 0);
     boxa1 = pixConnComp(pix4, NULL, 8);
@@ -147,8 +147,8 @@
     pix1 = pixRead("lucasta.047.jpg");
     pix2 = pixScaleToSize(pix1, WIDTH, 0);
     boxa1 = boxaCreate(1);
-    pixWrite("/tmp/lept/pdfseg/4.jpg", pix2, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/4.jpg");   /* 4 */
+    pixWrite("/data/local/tmp/lept/pdfseg/4.jpg", pix2, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/4.jpg");   /* 4 */
     boxaaAddBoxa(baa, boxa1, L_INSERT);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -156,8 +156,8 @@
         /* Page that is all image */
     pix1 = pixRead("map1.jpg");
     pix2 = pixScaleToSize(pix1, WIDTH, 0);
-    pixWrite("/tmp/lept/pdfseg/5.jpg", pix2, IFF_JFIF_JPEG);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/5.jpg");   /* 5 */
+    pixWrite("/data/local/tmp/lept/pdfseg/5.jpg", pix2, IFF_JFIF_JPEG);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/5.jpg");   /* 5 */
     h = pixGetHeight(pix2);
     box = boxCreate(0, 0, WIDTH, h);
     boxa1 = boxaCreate(1);
@@ -167,16 +167,16 @@
     pixDestroy(&pix2);
 
         /* Save the boxaa file */
-    boxaaWrite("/tmp/lept/pdfseg/images.baa", baa);
-    regTestCheckFile(rp, "/tmp/lept/pdfseg/images.baa");   /* 6 */
+    boxaaWrite("/data/local/tmp/lept/pdfseg/images.baa", baa);
+    regTestCheckFile(rp, "/data/local/tmp/lept/pdfseg/images.baa");   /* 6 */
 
         /* Do the conversion */
     l_pdfSetDateAndVersion(FALSE);
-    convertSegmentedFilesToPdf("/tmp/lept/pdfseg", "jpg", 100, L_G4_ENCODE,
+    convertSegmentedFilesToPdf("/data/local/tmp/lept/pdfseg", "jpg", 100, L_G4_ENCODE,
                                140, baa, 75, 0.6, "Segmentation Test",
-                               "/tmp/lept/regout/pdfseg.7.pdf");
-    L_INFO("Generated pdf file: /tmp/lept/regout/pdfseg.7.pdf\n", rp->testname);
-    regTestCheckFile(rp, "/tmp/lept/regout/pdfseg.7.pdf");   /* 7 */
+                               "/data/local/tmp/lept/regout/pdfseg.7.pdf");
+    L_INFO("Generated pdf file: /data/local/tmp/lept/regout/pdfseg.7.pdf\n", rp->testname);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/pdfseg.7.pdf");   /* 7 */
 
     boxaaDestroy(&baa);
     return regTestCleanup(rp);
diff -Nura leptonica-1.83.1/prog/percolatetest.c leptonica-1.83.1-patch/prog/percolatetest.c
--- leptonica-1.83.1/prog/percolatetest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/percolatetest.c	2024-09-05 14:26:11.051617513 +0800
@@ -74,7 +74,7 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 0, 0);
-    pixWrite("/tmp/lept/perc/file1.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/perc/file1.png", pix3, IFF_PNG);
     pixDestroy(&pixs);
     pixDestroy(&pix1);
     pixDestroy(&pix3);
@@ -98,7 +98,7 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 0, 560);
-    pixWrite("/tmp/lept/perc/file2.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/perc/file2.png", pix3, IFF_PNG);
     pixDestroy(&pixs);
     pixDestroy(&pix1);
     pixDestroy(&pix3);
@@ -128,8 +128,8 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 0, 0);
-    pixWrite("/tmp/lept/perc/file3.png", pix3, IFF_PNG);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot1",
+    pixWrite("/data/local/tmp/lept/perc/file3.png", pix3, IFF_PNG);
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot1",
                  "Number of components: 4 cc");
     pixDestroy(&pixs);
     pixDestroy(&pix1);
@@ -161,8 +161,8 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 0, 360);
-    pixWrite("/tmp/lept/perc/file4.png", pix3, IFF_PNG);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot2",
+    pixWrite("/data/local/tmp/lept/perc/file4.png", pix3, IFF_PNG);
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot2",
                  "Number of components: 8 cc");
     pixDestroy(&pixs);
     pixDestroy(&pix1);
@@ -192,8 +192,8 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 0, 0);
-    pixWrite("/tmp/lept/perc/file5.png", pix3, IFF_PNG);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot3",
+    pixWrite("/data/local/tmp/lept/perc/file5.png", pix3, IFF_PNG);
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot3",
                  "Number of components: 4 connected");
     pixDestroy(&pixs);
     pixDestroy(&pix1);
@@ -223,8 +223,8 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 340, 0);
-    pixWrite("/tmp/lept/perc/file6.png", pix3, IFF_PNG);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot4",
+    pixWrite("/data/local/tmp/lept/perc/file6.png", pix3, IFF_PNG);
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot4",
                  "Number of components: 8 connected");
     pixDestroy(&pixs);
     pixDestroy(&pix1);
@@ -254,8 +254,8 @@
     }
     pix3 = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 30, 2);
     pixDisplay(pix3, 0, 0);
-    pixWrite("/tmp/lept/perc/file7.png", pix3, IFF_PNG);
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot5",
+    pixWrite("/data/local/tmp/lept/perc/file7.png", pix3, IFF_PNG);
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot5",
                  "Number of components: 8 connected");
     pixDestroy(&pixs);
     pixDestroy(&pix1);
@@ -287,9 +287,9 @@
     }
 
     lept_stderr("Plot the 10M points: this takes about 20 seconds\n");
-    gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot6",
+    gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot6",
                  "Number of components: 4 connected, 8 million pixels");
-    pix3 = pixRead("/tmp/lept/plot6.png");
+    pix3 = pixRead("/data/local/tmp/lept/plot6.png");
     pixDisplay(pix3, 500, 0);
     pixDestroy(&pixs);
     pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/pixa1_reg.c leptonica-1.83.1-patch/prog/pixa1_reg.c
--- leptonica-1.83.1/prog/pixa1_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixa1_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -98,7 +98,7 @@
         pixDestroy(&pixd);
     }
 
-    gplot = gplotCreate("/tmp/lept/pixa/root1", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/pixa/root1", GPLOT_PNG,
                         "Select large: number of cc vs size removed",
                         "min size", "number of c.c.");
     gplotAddPlot(gplot, nax, nay1, GPLOT_LINES, "select if both");
@@ -146,7 +146,7 @@
         pixDestroy(&pixd);
     }
 
-    gplot = gplotCreate("/tmp/lept/pixa/root2", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/pixa/root2", GPLOT_PNG,
                         "Remove large: number of cc vs size removed",
                         "min size", "number of c.c.");
     gplotAddPlot(gplot, nax, nay1, GPLOT_LINES, "select if both");
@@ -158,7 +158,7 @@
 
     pixd = pixaDisplayTiledInRows(pixa, 32, 1500, 1.0, 0, 20, 2);
     pixDisplayWithTitle(pixd, 100, 0, NULL, rp->display);
-    pixWrite("/tmp/lept/pixa/root.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pixa/root.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
     pixaDestroy(&pixa);
 
diff -Nura leptonica-1.83.1/prog/pixa2_reg.c leptonica-1.83.1-patch/prog/pixa2_reg.c
--- leptonica-1.83.1/prog/pixa2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixa2_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -72,7 +72,7 @@
     pixaInitFull(pixa, pix1, NULL);  /* fill it up */
     pixd = pixaDisplayTiledInRows(pixa, 32, 1000, 1.0, 0, 25, 2);
     pixDisplayWithTitle(pixd, 100, 100, NULL, rp->display);
-    pixWrite("/tmp/lept/regout/pixa2-1.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/pixa2-1.jpg", pixd, IFF_JFIF_JPEG);
     pixDestroy(&pix1);
     pixDestroy(&pixd);
 
@@ -91,7 +91,7 @@
     }
     pixd = pixaDisplayTiledInRows(pixa, 32, 1000, 1.0, 0, 25, 2);
     pixDisplayWithTitle(pixd, 400, 100, NULL, rp->display);
-    pixWrite("/tmp/lept/regout/pixa2-2.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/pixa2-2.jpg", pixd, IFF_JFIF_JPEG);
     pixDestroy(&pixd);
 
     /* ---------------- And again, reversing the order ------------------*/
@@ -112,7 +112,7 @@
     }
     pixd = pixaDisplayTiledInRows(pixa, 32, 1000, 1.0, 0, 25, 2);
     pixDisplayWithTitle(pixd, 700, 100, NULL, rp->display);
-    pixWrite("/tmp/lept/regout/pixa2-3.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/pixa2-3.jpg", pixd, IFF_JFIF_JPEG);
     pixDestroy(&pixd);
     sarrayDestroy(&sa3);
 
diff -Nura leptonica-1.83.1/prog/pixaatest.c leptonica-1.83.1-patch/prog/pixaatest.c
--- leptonica-1.83.1/prog/pixaatest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixaatest.c	2024-09-05 14:26:11.051617513 +0800
@@ -67,38 +67,38 @@
     pixGetDimensions(pixs, &w, NULL, &d);
     pixa = pixaSplitPix(pixs, nx, ny, 0, 0);
 /*    pixa = pixaSplitPix(pixs, nx, ny, 2, 0xff000000);  */ /* red border */
-    pixWrite("/tmp/lept/paa/pix0", pixa->pix[0], IFF_PNG);
-    pixWrite("/tmp/lept/paa/pix9", pixa->pix[9], IFF_PNG);
+    pixWrite("/data/local/tmp/lept/paa/pix0", pixa->pix[0], IFF_PNG);
+    pixWrite("/data/local/tmp/lept/paa/pix9", pixa->pix[9], IFF_PNG);
     pixaConvertToPdf(pixa, 50, 1.0, 0, 95, "individual",
-                     "/tmp/lept/paa/out1.pdf");
+                     "/data/local/tmp/lept/paa/out1.pdf");
 
         /* Generate two pixaa by sampling the pixa, and write them to file */
     pixaa1 = pixaaCreateFromPixa(pixa, nx, L_CHOOSE_CONSECUTIVE, L_CLONE);
     pixaa2 = pixaaCreateFromPixa(pixa, nx, L_CHOOSE_SKIP_BY, L_CLONE);
-    pixaaWrite("/tmp/lept/paa/pts1.paa", pixaa1);
-    pixaaWrite("/tmp/lept/paa/pts2.paa", pixaa2);
+    pixaaWrite("/data/local/tmp/lept/paa/pts1.paa", pixaa1);
+    pixaaWrite("/data/local/tmp/lept/paa/pts2.paa", pixaa2);
     pixaDestroy(&pixa);
     pixaaDestroy(&pixaa1);
     pixaaDestroy(&pixaa2);
 
         /* Read each pixaa from file; tile/scale into a pixa */
-    pixaa1 = pixaaRead("/tmp/lept/paa/pts1.paa");
-    pixaa2 = pixaaRead("/tmp/lept/paa/pts2.paa");
+    pixaa1 = pixaaRead("/data/local/tmp/lept/paa/pts1.paa");
+    pixaa2 = pixaaRead("/data/local/tmp/lept/paa/pts2.paa");
     tilewidth = w / nx;
     pixad1 = pixaaDisplayTiledAndScaled(pixaa1, d, tilewidth, ncols, 0, 10, 0);
     pixad2 = pixaaDisplayTiledAndScaled(pixaa2, d, tilewidth, ncols, 0, 10, 0);
 
         /* Generate a pdf from each pixa */
     pixaConvertToPdf(pixad1, 50, 1.0, 0, 75, "consecutive",
-                     "/tmp/lept/paa/out2.pdf");
+                     "/data/local/tmp/lept/paa/out2.pdf");
     pixaConvertToPdf(pixad2, 50, 1.0, 0, 75, "skip_by",
-                     "/tmp/lept/paa/out3.pdf");
+                     "/data/local/tmp/lept/paa/out3.pdf");
 
         /* Write each pixa to a set of files, and generate a PS */
-    pixaWriteFiles("/tmp/lept/paa/split1.", pixad1, IFF_JFIF_JPEG);
-    pixaWriteFiles("/tmp/lept/paa/split2.", pixad2, IFF_JFIF_JPEG);
-    convertFilesToPS("/tmp/lept/paa", "split1", 40, "/tmp/lept/paa/out1out1.ps");
-    convertFilesToPS("/tmp/lept/paa", "split2", 40, "/tmp/lept/paa/out1out2.ps");
+    pixaWriteFiles("/data/local/tmp/lept/paa/split1.", pixad1, IFF_JFIF_JPEG);
+    pixaWriteFiles("/data/local/tmp/lept/paa/split2.", pixad2, IFF_JFIF_JPEG);
+    convertFilesToPS("/data/local/tmp/lept/paa", "split1", 40, "/data/local/tmp/lept/paa/out1out1.ps");
+    convertFilesToPS("/data/local/tmp/lept/paa", "split2", 40, "/data/local/tmp/lept/paa/out1out2.ps");
 
     pixDestroy(&pixs);
     pixaaDestroy(&pixaa1);
diff -Nura leptonica-1.83.1/prog/pixadisp_reg.c leptonica-1.83.1-patch/prog/pixadisp_reg.c
--- leptonica-1.83.1/prog/pixadisp_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixadisp_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -193,12 +193,12 @@
 
     if (rp->display) {
         lept_mkdir("lept/padisp");
-        lept_stderr("Writing to: /tmp/lept/padisp/pixadisp.pdf\n");
+        lept_stderr("Writing to: /data/local/tmp/lept/padisp/pixadisp.pdf\n");
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, "pixadisp-test",
-                         "/tmp/lept/padisp/pixadisp.pdf");
-        lept_stderr("Writing to: /tmp/lept/padisp/pixadisp.jpg\n");
+                         "/data/local/tmp/lept/padisp/pixadisp.pdf");
+        lept_stderr("Writing to: /data/local/tmp/lept/padisp/pixadisp.jpg\n");
         pix1 = pixaDisplayTiledInColumns(pixa, 2, 0.5, 30, 2);
-        pixWrite("/tmp/lept/padisp/pixadisp.jpg", pix1, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/padisp/pixadisp.jpg", pix1, IFF_JFIF_JPEG);
         pixDisplay(pix1, 100, 100);
         pixDestroy(&pix1);
     }
diff -Nura leptonica-1.83.1/prog/pixalloc_reg.c leptonica-1.83.1-patch/prog/pixalloc_reg.c
--- leptonica-1.83.1/prog/pixalloc_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixalloc_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -81,7 +81,7 @@
     numaAddNumber(nas, 3);
     numaAddNumber(nas, 2);
     setPixMemoryManager(pmsCustomAlloc, pmsCustomDealloc);
-    pmsCreate(200000, 400000, nas, "/tmp/lept/alloc/file1.log");
+    pmsCreate(200000, 400000, nas, "/data/local/tmp/lept/alloc/file1.log");
 
         /* Make the pix and do successive copies and removals of the copies */
     pixas = GenerateSetOfMargePix();
@@ -120,7 +120,7 @@
     numaAddNumber(nab, 100);
     setPixMemoryManager(pmsCustomAlloc, pmsCustomDealloc);
     if (logging)   /* use logging == 0 for speed comparison */
-        pmsCreate(20, 40, nab, "/tmp/lept/alloc/file2.log");
+        pmsCreate(20, 40, nab, "/data/local/tmp/lept/alloc/file2.log");
     else
         pmsCreate(20, 40, nab, NULL);
     pixs = pixRead("feyn.tif");
diff -Nura leptonica-1.83.1/prog/pixcomp_reg.c leptonica-1.83.1-patch/prog/pixcomp_reg.c
--- leptonica-1.83.1/prog/pixcomp_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixcomp_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -161,13 +161,13 @@
     sarrayDestroy(&sa);
 
         /* Test serialized I/O */
-    pixacompWrite("/tmp/lept/comp/file1.pac", pixac);
-    regTestCheckFile(rp, "/tmp/lept/comp/file1.pac");  /* 7 */
-    pixac1 = pixacompRead("/tmp/lept/comp/file1.pac");
-    pixacompWrite("/tmp/lept/comp/file2.pac", pixac1);
-    regTestCheckFile(rp, "/tmp/lept/comp/file2.pac");  /* 8 */
+    pixacompWrite("/data/local/tmp/lept/comp/file1.pac", pixac);
+    regTestCheckFile(rp, "/data/local/tmp/lept/comp/file1.pac");  /* 7 */
+    pixac1 = pixacompRead("/data/local/tmp/lept/comp/file1.pac");
+    pixacompWrite("/data/local/tmp/lept/comp/file2.pac", pixac1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/comp/file2.pac");  /* 8 */
     regTestCompareFiles(rp, 7, 8);  /* 9 */
-    pixac2 = pixacompRead("/tmp/lept/comp/file2.pac");
+    pixac2 = pixacompRead("/data/local/tmp/lept/comp/file2.pac");
     pixa1 = pixaCreateFromPixacomp(pixac2, L_COPY);
     pix1 = pixaDisplayTiledAndScaled(pixa1, 32, 250, 4, 0, 20, 2);
     regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG);  /* 10 */
@@ -181,10 +181,10 @@
     pixac1 = pixacompReadMem(data1, size1);
     pixacompWriteMem(&data2, &size2, pixac1);
     pixac2 = pixacompReadMem(data2, size2);
-    pixacompWrite("/tmp/lept/comp/file3.pac", pixac1);
-    regTestCheckFile(rp, "/tmp/lept/comp/file3.pac");  /* 11 */
-    pixacompWrite("/tmp/lept/comp/file4.pac", pixac2);
-    regTestCheckFile(rp, "/tmp/lept/comp/file4.pac");  /* 12 */
+    pixacompWrite("/data/local/tmp/lept/comp/file3.pac", pixac1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/comp/file3.pac");  /* 11 */
+    pixacompWrite("/data/local/tmp/lept/comp/file4.pac", pixac2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/comp/file4.pac");  /* 12 */
     regTestCompareFiles(rp, 11, 12);  /* 13 */
     pixacompDestroy(&pixac1);
     pixacompDestroy(&pixac2);
diff -Nura leptonica-1.83.1/prog/pixserial_reg.c leptonica-1.83.1-patch/prog/pixserial_reg.c
--- leptonica-1.83.1/prog/pixserial_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pixserial_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -75,8 +75,8 @@
             /* Serialize to memory */
         pixSerializeToMemory(pixs, &data32, &size);
             /* Just for fun, write and read back from file */
-        l_binaryWrite("/tmp/lept/regout/array", "w", data32, size);
-        data32r = (l_uint32 *)l_binaryRead("/tmp/lept/regout/array", &size);
+        l_binaryWrite("/data/local/tmp/lept/regout/array", "w", data32, size);
+        data32r = (l_uint32 *)l_binaryRead("/data/local/tmp/lept/regout/array", &size);
             /* Deserialize */
         pixd = pixDeserializeFromMemory(data32r, size);
         regTestComparePix(rp, pixs, pixd);  /* i */
@@ -93,7 +93,7 @@
         box = boxCreate(0, 0, L_MIN(150, w), L_MIN(150, h));
         pixt = pixClipRectangle(pixs, box, NULL);
         boxDestroy(&box);
-        snprintf(buf, sizeof(buf), "/tmp/lept/regout/pixs.%d.spix",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/pixs.%d.spix",
                  rp->index + 1);
         pixWrite(buf, pixt, IFF_SPIX);
         regTestCheckFile(rp, buf);  /* nfiles + 2 * i */
diff -Nura leptonica-1.83.1/prog/plottest.c leptonica-1.83.1-patch/prog/plottest.c
--- leptonica-1.83.1/prog/plottest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/plottest.c	2024-09-05 14:26:11.051617513 +0800
@@ -89,7 +89,7 @@
     }
 
         /* Show the plot */
-    gplot1 = gplotCreate("/tmp/lept/plot/set1", GPLOT_OUTPUT, "Example plots",
+    gplot1 = gplotCreate("/data/local/tmp/lept/plot/set1", GPLOT_OUTPUT, "Example plots",
                          "theta", "f(theta)");
     gplotAddPlot(gplot1, nax, nay1, GPLOT_STYLE, "sin (2.4 * theta)");
     gplotAddPlot(gplot1, nax, nay2, GPLOT_STYLE, "cos (2.4 * theta)");
@@ -97,21 +97,21 @@
 
         /* Also save the plot to png */
     gplot1->outformat = GPLOT_PNG;
-    pngname = genPathname("/tmp/lept/plot", "set1.png");
+    pngname = genPathname("/data/local/tmp/lept/plot", "set1.png");
     stringReplace(&gplot1->outname, pngname);
     gplotMakeOutput(gplot1);
-    l_fileDisplay("/tmp/lept/plot/set1.png", 100, 100, 1.0);
+    l_fileDisplay("/data/local/tmp/lept/plot/set1.png", 100, 100, 1.0);
     lept_free(pngname);
 
         /* Test gplot serialization */
-    gplotWrite("/tmp/lept/plot/plot1.gp", gplot1);
-    if ((gplot2 = gplotRead("/tmp/lept/plot/plot1.gp")) == NULL)
+    gplotWrite("/data/local/tmp/lept/plot/plot1.gp", gplot1);
+    if ((gplot2 = gplotRead("/data/local/tmp/lept/plot/plot1.gp")) == NULL)
         return ERROR_INT("gplotRead failure!", __func__, 1);
-    gplotWrite("/tmp/lept/plot/plot2.gp", gplot2);
+    gplotWrite("/data/local/tmp/lept/plot/plot2.gp", gplot2);
 
         /* Are the two written gplot files the same? */
-    str1 = (char *)l_binaryRead("/tmp/lept/plot/plot1.gp", &size1);
-    str2 = (char *)l_binaryRead("/tmp/lept/plot/plot2.gp", &size2);
+    str1 = (char *)l_binaryRead("/data/local/tmp/lept/plot/plot1.gp", &size1);
+    str2 = (char *)l_binaryRead("/data/local/tmp/lept/plot/plot2.gp", &size2);
     if (size1 != size2)
         lept_stderr("Error: size1 = %lu, size2 = %lu\n",
                     (unsigned long)size1, (unsigned long)size2);
@@ -125,23 +125,23 @@
     lept_free(str2);
 
         /* Read from file and regenerate the plot */
-    gplot3 = gplotRead("/tmp/lept/plot/plot2.gp");
+    gplot3 = gplotRead("/data/local/tmp/lept/plot/plot2.gp");
     stringReplace(&gplot3->title , "Example plots regen");
     gplot3->outformat = GPLOT_PNG;
     gplotMakeOutput(gplot3);
 
         /* Build gplot but do not make the output formatted stuff */
-    gplot4 = gplotCreate("/tmp/lept/plot/set2", GPLOT_OUTPUT,
+    gplot4 = gplotCreate("/data/local/tmp/lept/plot/set2", GPLOT_OUTPUT,
                          "Example plots 2", "theta", "f(theta)");
     gplotAddPlot(gplot4, nax, nay1, GPLOT_STYLE, "sin (2.4 * theta)");
     gplotAddPlot(gplot4, nax, nay2, GPLOT_STYLE, "cos (2.4 * theta)");
 
         /* Write, read back, and generate the plot */
-    gplotWrite("/tmp/lept/plot/plot4.gp", gplot4);
-    if ((gplot5 = gplotRead("/tmp/lept/plot/plot4.gp")) == NULL)
+    gplotWrite("/data/local/tmp/lept/plot/plot4.gp", gplot4);
+    if ((gplot5 = gplotRead("/data/local/tmp/lept/plot/plot4.gp")) == NULL)
         return ERROR_INT("gplotRead failure!", __func__, 1);
     gplotMakeOutput(gplot5);
-    l_fileDisplay("/tmp/lept/plot/set2.png", 750, 100, 1.0);
+    l_fileDisplay("/data/local/tmp/lept/plot/set2.png", 750, 100, 1.0);
 
     gplotDestroy(&gplot1);
     gplotDestroy(&gplot2);
diff -Nura leptonica-1.83.1/prog/pngio_reg.c leptonica-1.83.1-patch/prog/pngio_reg.c
--- leptonica-1.83.1/prog/pngio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pngio_reg.c	2024-09-05 14:26:11.051617513 +0800
@@ -328,8 +328,8 @@
     pixSetColormap(pix1, cmap);
     pixcmapAddRGBA(cmap, 180, 130, 220, 0);  /* transparent */
     pixcmapAddRGBA(cmap, 20, 120, 0, 255);  /* opaque */
-    pixWrite("/tmp/lept/regout/1bpp-trans.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/1bpp-trans.png");
+    pixWrite("/data/local/tmp/lept/regout/1bpp-trans.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/1bpp-trans.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("1bpp_trans: success\n");
@@ -338,7 +338,7 @@
     pixDisplayWithTitle(pix2, 700, 0, NULL, rp->display);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
-    fp = fopenReadStream("/tmp/lept/regout/1bpp-trans.png");
+    fp = fopenReadStream("/data/local/tmp/lept/regout/1bpp-trans.png");
     fgetPngColormapInfo(fp, &cmap, &transp);
     if (fp) fclose(fp);
     if (transp)
@@ -363,8 +363,8 @@
     pixSetColormap(pix1, cmap);
     pixcmapAddRGBA(cmap, 180, 130, 220, 255);  /* color, opaque */
     pixcmapAddRGBA(cmap, 20, 120, 0, 255);  /* color, opaque */
-    pixWrite("/tmp/lept/regout/1bpp-color.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/1bpp-color.png");
+    pixWrite("/data/local/tmp/lept/regout/1bpp-color.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/1bpp-color.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("1bpp_color: success\n");
@@ -373,7 +373,7 @@
     pixDisplayWithTitle(pix2, 700, 100, NULL, rp->display);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
-    fp = fopenReadStream("/tmp/lept/regout/1bpp-color.png");
+    fp = fopenReadStream("/data/local/tmp/lept/regout/1bpp-color.png");
     fgetPngColormapInfo(fp, &cmap, &transp);
     if (fp) fclose(fp);
     if (transp)
@@ -397,8 +397,8 @@
     pixSetColormap(pix1, cmap);
     pixcmapAddRGBA(cmap, 180, 180, 180, 255);  /* light, opaque */
     pixcmapAddRGBA(cmap, 60, 60, 60, 255);  /* dark, opaque */
-    pixWrite("/tmp/lept/regout/1bpp-gray.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/1bpp-gray.png");
+    pixWrite("/data/local/tmp/lept/regout/1bpp-gray.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/1bpp-gray.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("1bpp_gray: success\n");
@@ -422,8 +422,8 @@
     pixSetColormap(pix1, cmap);
     pixcmapAddRGBA(cmap, 0, 0, 0, 255);  /* black, opaque */
     pixcmapAddRGBA(cmap, 255, 255, 255, 255);  /* white, opaque */
-    pixWrite("/tmp/lept/regout/1bpp-bw1.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/1bpp-bw1.png");
+    pixWrite("/data/local/tmp/lept/regout/1bpp-bw1.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/1bpp-bw1.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("1bpp_bw1: success\n");
@@ -447,8 +447,8 @@
     pixSetColormap(pix1, cmap);
     pixcmapAddRGBA(cmap, 255, 255, 255, 255);  /* white, opaque */
     pixcmapAddRGBA(cmap, 0, 0, 0, 255);  /* black, opaque */
-    pixWrite("/tmp/lept/regout/1bpp-bw2.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/1bpp-bw2.png");
+    pixWrite("/data/local/tmp/lept/regout/1bpp-bw2.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/1bpp-bw2.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("1bpp_bw2: success\n");
@@ -478,8 +478,8 @@
     pix1 = pixRead("weasel2.4g.png");
     cmap = pixGetColormap(pix1);
     pixcmapSetAlpha(cmap, 2, 100);
-    pixWrite("/tmp/lept/regout/2bpp-cmap-trans.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/2bpp-cmap-trans.png");
+    pixWrite("/data/local/tmp/lept/regout/2bpp-cmap-trans.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/2bpp-cmap-trans.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("2bpp-cmap-trans: success\n");
@@ -509,8 +509,8 @@
     pix1 = pixRead("weasel4.5g.png");
     cmap = pixGetColormap(pix1);
     pixcmapSetAlpha(cmap, 2, 60);
-    pixWrite("/tmp/lept/regout/4bpp-cmap-trans.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/4bpp-cmap-trans.png");
+    pixWrite("/data/local/tmp/lept/regout/4bpp-cmap-trans.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/4bpp-cmap-trans.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("4bpp-cmap-trans: success\n");
@@ -541,8 +541,8 @@
     cmap = pixGetColormap(pix1);
     pixcmapSetAlpha(cmap, 2, 80);
     pixcmapSetAlpha(cmap, 3, 80);
-    pixWrite("/tmp/lept/regout/8bpp-cmap-trans.png", pix1, IFF_PNG);
-    pix2 = pixRead("/tmp/lept/regout/8bpp-cmap-trans.png");
+    pixWrite("/data/local/tmp/lept/regout/8bpp-cmap-trans.png", pix1, IFF_PNG);
+    pix2 = pixRead("/data/local/tmp/lept/regout/8bpp-cmap-trans.png");
     pixEqual(pix1, pix2, &same);
     if (same)
         lept_stderr("8bpp-cmap-trans: success\n");
@@ -566,8 +566,8 @@
     pix2 = pixColorSegment(pix1, 75, 10, 8, 7, 0);
     cmap = pixGetColormap(pix2);
     pixcmapSetAlpha(cmap, 0, 0);  /* set blueish sky color to transparent */
-    pixWrite("/tmp/lept/regout/8bpp-trans.png", pix2, IFF_PNG);
-    pix3 = pixRead("/tmp/lept/regout/8bpp-trans.png");
+    pixWrite("/data/local/tmp/lept/regout/8bpp-trans.png", pix2, IFF_PNG);
+    pix3 = pixRead("/data/local/tmp/lept/regout/8bpp-trans.png");
     pixEqual(pix2, pix3, &same);
     if (same)
         lept_stderr("8bpp_trans: success\n");
@@ -577,7 +577,7 @@
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
-    fp = fopenReadStream("/tmp/lept/regout/8bpp-trans.png");
+    fp = fopenReadStream("/data/local/tmp/lept/regout/8bpp-trans.png");
     fgetPngColormapInfo(fp, &cmap, &transp);
     if (fp) fclose(fp);
     if (transp)
diff -Nura leptonica-1.83.1/prog/pnmio_reg.c leptonica-1.83.1-patch/prog/pnmio_reg.c
--- leptonica-1.83.1/prog/pnmio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/pnmio_reg.c	2024-09-05 14:26:11.055617434 +0800
@@ -62,18 +62,18 @@
 
         /* Test 1 bpp (pbm) read/write */
     pix1 = pixRead("char.tif");
-    fp = lept_fopen("/tmp/lept/pnm/pix1.1.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix1.1.pnm", "wb");
     pixWriteStreamAsciiPnm(fp, pix1);
     lept_fclose(fp);
-    pix2 = pixRead("/tmp/lept/pnm/pix1.1.pnm");
-    pixWrite("/tmp/lept/pnm/pix2.1.pnm", pix2, IFF_PNM);
-    pix3 = pixRead("/tmp/lept/pnm/pix2.1.pnm");
+    pix2 = pixRead("/data/local/tmp/lept/pnm/pix1.1.pnm");
+    pixWrite("/data/local/tmp/lept/pnm/pix2.1.pnm", pix2, IFF_PNM);
+    pix3 = pixRead("/data/local/tmp/lept/pnm/pix2.1.pnm");
     regTestComparePix(rp, pix1, pix3);  /* 0 */
         /* write PAM */
-    fp = lept_fopen("/tmp/lept/pnm/pix3.1.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix3.1.pnm", "wb");
     pixWriteStreamPam(fp, pix1);
     lept_fclose(fp);
-    pix4 = pixRead("/tmp/lept/pnm/pix3.1.pnm");
+    pix4 = pixRead("/data/local/tmp/lept/pnm/pix3.1.pnm");
     regTestComparePix(rp, pix1, pix4);  /* 1 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -83,18 +83,18 @@
         /* Test 2, 4 and 8 bpp (pgm) read/write */
     pix1 = pixRead("weasel8.png");
     pix2 = pixThresholdTo2bpp(pix1, 4, 0);
-    fp = lept_fopen("/tmp/lept/pnm/pix2.2.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix2.2.pnm", "wb");
     pixWriteStreamAsciiPnm(fp, pix2);
     lept_fclose(fp);
-    pix3 = pixRead("/tmp/lept/pnm/pix2.2.pnm");
-    pixWrite("/tmp/lept/pnm/pix3.2.pnm", pix3, IFF_PNM);
-    pix4 = pixRead("/tmp/lept/pnm/pix3.2.pnm");
+    pix3 = pixRead("/data/local/tmp/lept/pnm/pix2.2.pnm");
+    pixWrite("/data/local/tmp/lept/pnm/pix3.2.pnm", pix3, IFF_PNM);
+    pix4 = pixRead("/data/local/tmp/lept/pnm/pix3.2.pnm");
     regTestComparePix(rp, pix2, pix4);  /* 2 */
         /* write PAM */
-    fp = lept_fopen("/tmp/lept/pnm/pix4.2.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix4.2.pnm", "wb");
     pixWriteStreamPam(fp, pix2);
     lept_fclose(fp);
-    pix5 = pixRead("/tmp/lept/pnm/pix4.2.pnm");
+    pix5 = pixRead("/data/local/tmp/lept/pnm/pix4.2.pnm");
     regTestComparePix(rp, pix2, pix5);  /* 3 */
     pixDestroy(&pix2);
     pixDestroy(&pix3);
@@ -102,36 +102,36 @@
     pixDestroy(&pix5);
 
     pix2 = pixThresholdTo4bpp(pix1, 16, 0);
-    fp = lept_fopen("/tmp/lept/pnm/pix2.4.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix2.4.pnm", "wb");
     pixWriteStreamAsciiPnm(fp, pix2);
     lept_fclose(fp);
-    pix3 = pixRead("/tmp/lept/pnm/pix2.4.pnm");
-    pixWrite("/tmp/lept/pnm/pix3.4.pnm", pix3, IFF_PNM);
-    pix4 = pixRead("/tmp/lept/pnm/pix3.4.pnm");
+    pix3 = pixRead("/data/local/tmp/lept/pnm/pix2.4.pnm");
+    pixWrite("/data/local/tmp/lept/pnm/pix3.4.pnm", pix3, IFF_PNM);
+    pix4 = pixRead("/data/local/tmp/lept/pnm/pix3.4.pnm");
     regTestComparePix(rp, pix2, pix4);  /* 4 */
         /* write PAM */
-    fp = lept_fopen("/tmp/lept/pnm/pix4.4.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix4.4.pnm", "wb");
     pixWriteStreamPam(fp, pix2);
     lept_fclose(fp);
-    pix5 = pixRead("/tmp/lept/pnm/pix4.4.pnm");
+    pix5 = pixRead("/data/local/tmp/lept/pnm/pix4.4.pnm");
     regTestComparePix(rp, pix2, pix5);  /* 5 */
     pixDestroy(&pix2);
     pixDestroy(&pix3);
     pixDestroy(&pix4);
     pixDestroy(&pix5);
 
-    fp = lept_fopen("/tmp/lept/pnm/pix1.8.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix1.8.pnm", "wb");
     pixWriteStreamAsciiPnm(fp, pix1);
     lept_fclose(fp);
-    pix2 = pixRead("/tmp/lept/pnm/pix1.8.pnm");
-    pixWrite("/tmp/lept/pnm/pix2.8.pnm", pix2, IFF_PNM);
-    pix3 = pixRead("/tmp/lept/pnm/pix2.8.pnm");
+    pix2 = pixRead("/data/local/tmp/lept/pnm/pix1.8.pnm");
+    pixWrite("/data/local/tmp/lept/pnm/pix2.8.pnm", pix2, IFF_PNM);
+    pix3 = pixRead("/data/local/tmp/lept/pnm/pix2.8.pnm");
     regTestComparePix(rp, pix1, pix3);  /* 6 */
         /* write PAM */
-    fp = lept_fopen("/tmp/lept/pnm/pix3.8.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix3.8.pnm", "wb");
     pixWriteStreamPam(fp, pix1);
     lept_fclose(fp);
-    pix4 = pixRead("/tmp/lept/pnm/pix3.8.pnm");
+    pix4 = pixRead("/data/local/tmp/lept/pnm/pix3.8.pnm");
     regTestComparePix(rp, pix1, pix4);  /* 7 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -140,14 +140,14 @@
 
         /* Test ppm (24 bpp rgb) read/write */
     pix1 = pixRead("marge.jpg");
-    fp = lept_fopen("/tmp/lept/pnm/pix1.24.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix1.24.pnm", "wb");
         /* write ascii */
     pixWriteStreamAsciiPnm(fp, pix1);
     lept_fclose(fp);
-    pix2 = pixRead("/tmp/lept/pnm/pix1.24.pnm");
+    pix2 = pixRead("/data/local/tmp/lept/pnm/pix1.24.pnm");
         /* write pnm */
-    pixWrite("/tmp/lept/pnm/pix2.24.pnm", pix2, IFF_PNM);
-    pix3 = pixRead("/tmp/lept/pnm/pix2.24.pnm");
+    pixWrite("/data/local/tmp/lept/pnm/pix2.24.pnm", pix2, IFF_PNM);
+    pix3 = pixRead("/data/local/tmp/lept/pnm/pix2.24.pnm");
     regTestComparePix(rp, pix1, pix3);  /* 8 */
     pixDestroy(&pix3);
         /* write mem pnm */
@@ -156,10 +156,10 @@
     regTestComparePix(rp, pix1, pix3);  /* 9 */
     lept_free(data);
         /* write pam */
-    fp = lept_fopen("/tmp/lept/pnm/pix3.24.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix3.24.pnm", "wb");
     pixWriteStreamPam(fp, pix1);
     lept_fclose(fp);
-    pix4 = pixRead("/tmp/lept/pnm/pix3.24.pnm");
+    pix4 = pixRead("/data/local/tmp/lept/pnm/pix3.24.pnm");
     regTestComparePix(rp, pix1, pix4);  /* 10 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
@@ -168,12 +168,12 @@
 
         /* Test pam (32 bpp rgba) read/write */
     pix1 = pixRead("test32-alpha.png");
-    fp = lept_fopen("/tmp/lept/pnm/pix1.32.pnm", "wb");
+    fp = lept_fopen("/data/local/tmp/lept/pnm/pix1.32.pnm", "wb");
     pixWriteStreamPam(fp, pix1);
     lept_fclose(fp);
-    pix2 = pixRead("/tmp/lept/pnm/pix1.32.pnm");
-    pixWrite("/tmp/lept/pnm/pix2.32.pnm", pix2, IFF_PNM);
-    pix3 = pixRead("/tmp/lept/pnm/pix2.32.pnm");
+    pix2 = pixRead("/data/local/tmp/lept/pnm/pix1.32.pnm");
+    pixWrite("/data/local/tmp/lept/pnm/pix2.32.pnm", pix2, IFF_PNM);
+    pix3 = pixRead("/data/local/tmp/lept/pnm/pix2.32.pnm");
     regTestComparePix(rp, pix1, pix3);  /* 11 */
     pixDestroy(&pix1);
     pixDestroy(&pix2);
diff -Nura leptonica-1.83.1/prog/printimage.c leptonica-1.83.1-patch/prog/printimage.c
--- leptonica-1.83.1/prog/printimage.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/printimage.c	2024-09-05 14:26:11.055617434 +0800
@@ -35,7 +35,7 @@
  *
  *   The simplest input would be something like
  *        printimage myfile.jpg
- *   This generates the PostScript file /tmp/print_image.ps, but
+ *   This generates the PostScript file /data/local/tmp/print_image.ps, but
  *   does not send it to a printer.
  *
  *   If you have lpr, you can specify a printer; e.g.
@@ -53,12 +53,12 @@
  *
  *   By default, the intermediate PostScript file generated is
  *   level 3 (compressed):
- *       /tmp/print_image.ps
+ *       /data/local/tmp/print_image.ps
  *
  *   If your system does not have lpr, it likely has lp.  You can run
  *   printimage to make the PostScript file, and then print with lp:
- *       lp -d <printer> /tmp/print_image.ps
- *       lp -d <printer> -o ColorModel=Color /tmp/print_image.ps
+ *       lp -d <printer> /data/local/tmp/print_image.ps
+ *       lp -d <printer> -o ColorModel=Color /data/local/tmp/print_image.ps
  *   etc.
  *
  *   ***************************************************************
@@ -119,7 +119,7 @@
         pix1 = pixClone(pixs);
     }
     scale = L_MIN(FILL_FACTOR * 2550 / w, FILL_FACTOR * 3300 / h);
-    fname = genPathname("/tmp", "print_image.ps");
+    fname = genPathname("/data/local/tmp", "print_image.ps");
 #if USE_COMPRESSED
     index = 0;
     pixWriteCompressedToPS(pix1, fname, (l_int32)(300. / scale), 3, &index);
diff -Nura leptonica-1.83.1/prog/printsplitimage.c leptonica-1.83.1-patch/prog/printsplitimage.c
--- leptonica-1.83.1/prog/printsplitimage.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/printsplitimage.c	2024-09-05 14:26:11.055617434 +0800
@@ -44,8 +44,8 @@
  *
  *   If your system does not have lpr, it likely has lp.  You can run
  *   printsplitimage to make the PostScript files, and print them with lp:
- *       lp -d <printer> /tmp/lept/split/image0.ps
- *       lp -d <printer> /tmp/lept/split/image1.ps
+ *       lp -d <printer> /data/local/tmp/lept/split/image0.ps
+ *       lp -d <printer> /data/local/tmp/lept/split/image1.ps
  *       ...
  *   To print in color, see prog/printimage.c.
  *
@@ -118,7 +118,7 @@
         pixGetDimensions(pixt, &w, &h, NULL);
         scale = L_MIN(FILL_FACTOR * 2550 / w, FILL_FACTOR * 3300 / h);
         snprintf(buf, sizeof(buf), "image%d.ps", i);
-        fname = genPathname("/tmp/lept/split", buf);
+        fname = genPathname("/data/local/tmp/lept/split", buf);
         lept_stderr("fname: %s\n", fname);
         sarrayAddString(sa, fname, L_INSERT);
 #if USE_COMPRESSED
diff -Nura leptonica-1.83.1/prog/printtiff.c leptonica-1.83.1-patch/prog/printtiff.c
--- leptonica-1.83.1/prog/printtiff.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/printtiff.c	2024-09-05 14:26:11.055617434 +0800
@@ -32,16 +32,16 @@
  *   Prints a multipage tiff file of 1 bpp images to a printer.
  *   If the tiff is at standard fax resolution, it expands the
  *   vertical size by a factor of two before encapsulating in
- *   ccittg4 encoded PostScript.  The PostScript file is left in /tmp,
+ *   ccittg4 encoded PostScript.  The PostScript file is left in /data/local/tmp,
  *   and erased (deleted, removed, unlinked) on the next invocation.
  *
  *   If the printer is not specified, this just writes the PostScript
- *   file /tmp/print_tiff.ps.
+ *   file /data/local/tmp/print_tiff.ps.
  *
  *   If your system does not have lpr, it likely has lp.  You can run
  *   printtiff to make the PostScript file, and then print with lp:
- *       lp -d <printer> /tmp/print_tiff.ps
- *       lp -d <printer> -o ColorModel=Color /tmp/print_tiff.ps
+ *       lp -d <printer> /data/local/tmp/print_tiff.ps
+ *       lp -d <printer> -o ColorModel=Color /data/local/tmp/print_tiff.ps
  *   etc.
  *
  *   ***************************************************************
@@ -83,7 +83,7 @@
 
     setLeptDebugOK(1);
     (void)lept_rm(NULL, TEMP_PS);
-    tempfile = genPathname("/tmp", TEMP_PS);
+    tempfile = genPathname("/data/local/tmp", TEMP_PS);
     convertTiffMultipageToPS(filein, tempfile, FILL_FACTOR);
 
     if (argc == 3) {
diff -Nura leptonica-1.83.1/prog/psio_reg.c leptonica-1.83.1-patch/prog/psio_reg.c
--- leptonica-1.83.1/prog/psio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/psio_reg.c	2024-09-05 14:26:11.055617434 +0800
@@ -94,10 +94,10 @@
     pixs = pixRead("feyn-fract.tif");
     pixGetDimensions(pixs, &w, &h, NULL);
     scale = L_MIN(factor * 2550 / w, factor * 3300 / h);
-    fp1 = lept_fopen("/tmp/lept/regout/psio0.ps", "wb+");
+    fp1 = lept_fopen("/data/local/tmp/lept/regout/psio0.ps", "wb+");
     pixWriteStreamPS(fp1, pixs, NULL, 300, scale);
     lept_fclose(fp1);
-    regTestCheckFile(rp, "/tmp/lept/regout/psio0.ps");  /* 0 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio0.ps");  /* 0 */
     pixDestroy(&pixs);
 
         /* Uncompressed PS with scaling, with LL corner at (1500, 1500) mils */
@@ -106,48 +106,48 @@
     scale = L_MIN(factor * 2550 / w, factor * 3300 / h);
     box = boxCreate(1500, 1500, (l_int32)(1000 * scale * w / 300),
                     (l_int32)(1000 * scale * h / 300));
-    fp1 = lept_fopen("/tmp/lept/regout/psio1.ps", "wb+");
+    fp1 = lept_fopen("/data/local/tmp/lept/regout/psio1.ps", "wb+");
     pixWriteStreamPS(fp1, pixs, box, 300, 1.0);
     lept_fclose(fp1);
-    regTestCheckFile(rp, "/tmp/lept/regout/psio1.ps");  /* 1 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio1.ps");  /* 1 */
     boxDestroy(&box);
     pixDestroy(&pixs);
 
         /* DCT compressed PS with LL corner at (300, 1000) pixels */
     pixs = pixRead("marge.jpg");
     pixt = pixConvertTo32(pixs);
-    pixWrite("/tmp/lept/regout/psio2.jpg", pixt, IFF_JFIF_JPEG);
-    convertJpegToPS("/tmp/lept/regout/psio2.jpg", "/tmp/lept/regout/psio3.ps",
+    pixWrite("/data/local/tmp/lept/regout/psio2.jpg", pixt, IFF_JFIF_JPEG);
+    convertJpegToPS("/data/local/tmp/lept/regout/psio2.jpg", "/data/local/tmp/lept/regout/psio3.ps",
                     "w", 300, 1000, 0, 4.0, 1, 1);
-    regTestCheckFile(rp, "/tmp/lept/regout/psio2.jpg");  /* 2 */
-    regTestCheckFile(rp, "/tmp/lept/regout/psio3.ps");  /* 3 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio2.jpg");  /* 2 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio3.ps");  /* 3 */
     pixDestroy(&pixt);
     pixDestroy(&pixs);
 
         /* For each page, apply tiff g4 image first; then jpeg or png over it */
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio4.ps", "w",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio4.ps", "w",
                   0, 0, 0, 1.0, 1, 1, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio4.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio4.ps",
                     "a", 500, 100, 300, 2.0, 1,  0);
-    convertFlateToPS("weasel4.11c.png", "/tmp/lept/regout/psio4.ps",
+    convertFlateToPS("weasel4.11c.png", "/data/local/tmp/lept/regout/psio4.ps",
                      "a", 300, 400, 300, 6.0, 1,  0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio4.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio4.ps",
                     "a", 100, 800, 300, 1.5, 1, 1);
 
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio4.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio4.ps",
                   "a", 0, 0, 0, 1.0, 2, 1, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio4.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio4.ps",
                     "a", 1000, 700, 300, 2.0, 2, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio4.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio4.ps",
                     "a", 100, 200, 300, 2.0, 2, 1);
 
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio4.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio4.ps",
                   "a", 0, 0, 0, 1.0, 3, 1, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio4.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio4.ps",
                     "a", 200, 200, 300, 2.0, 3, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio4.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio4.ps",
                     "a", 200, 900, 300, 2.0, 3, 1);
-    regTestCheckFile(rp, "/tmp/lept/regout/psio4.ps");  /* 4 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio4.ps");  /* 4 */
 
         /* Now apply jpeg first; then paint through a g4 mask.
          * For gv, the first image with a b.b. determines the
@@ -167,82 +167,82 @@
          * the images remain in the background of the text. */
     pixs = pixRead("wyom.jpg");
     pixt = pixScaleToSize(pixs, 2528, 3300);
-    pixWrite("/tmp/lept/regout/psio5.jpg", pixt, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/regout/psio5.jpg", pixt, IFF_JFIF_JPEG);
     pixDestroy(&pixs);
     pixDestroy(&pixt);
-    convertJpegToPS("/tmp/lept/regout/psio5.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("/data/local/tmp/lept/regout/psio5.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                       "w", 0, 0, 300, 1.0, 1, 0);
-    convertFlateToPS("weasel8.240c.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel8.240c.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 100, 100, 300, 5.0, 1, 0);
-    convertFlateToPS("weasel8.149g.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel8.149g.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 200, 300, 300, 5.0, 1, 0);
-    convertFlateToPS("weasel4.11c.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel4.11c.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 300, 500, 300, 5.0, 1, 0);
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio5.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio5.ps",
                   "a", 0, 0, 0, 1.0, 1, 1, 1);
 
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 500, 100, 300, 2.0, 2,  0);
-    convertFlateToPS("weasel4.11c.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel4.11c.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 300, 400, 300, 6.0, 2,  0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 100, 800, 300, 1.5, 2, 0);
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio5.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio5.ps",
                   "a", 0, 0, 0, 1.0, 2, 1, 1);
 
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 500, 100, 300, 2.0, 3,  0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 100, 800, 300, 2.0, 3, 0);
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio5.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio5.ps",
                   "a", 0, 0, 0, 1.0, 3, 1, 1);
 
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 700, 700, 300, 2.0, 4, 0);
-    convertFlateToPS("weasel8.149g.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel8.149g.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 400, 400, 300, 5.0, 4, 0);
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio5.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio5.ps",
                   "a", 0, 0, 0, 1.0, 4, 1, 0);
-    convertFlateToPS("weasel8.240c.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel8.240c.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 100, 220, 300, 5.0, 4, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 100, 200, 300, 2.0, 4, 1);
 
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 200, 200, 300, 1.5, 5, 0);
-    convertFlateToPS("weasel8.240c.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel8.240c.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 140, 80, 300, 7.0, 5, 0);
-    convertG4ToPS("feyn.tif", "/tmp/lept/regout/psio5.ps",
+    convertG4ToPS("feyn.tif", "/data/local/tmp/lept/regout/psio5.ps",
                   "a", 0, 0, 0, 1.0, 5, 1, 0);
-    convertFlateToPS("weasel8.149g.png", "/tmp/lept/regout/psio5.ps",
+    convertFlateToPS("weasel8.149g.png", "/data/local/tmp/lept/regout/psio5.ps",
                      "a", 280, 310, 300, 5.0, 4, 0);
-    convertJpegToPS("marge.jpg", "/tmp/lept/regout/psio5.ps",
+    convertJpegToPS("marge.jpg", "/data/local/tmp/lept/regout/psio5.ps",
                     "a", 200, 900, 300, 2.0, 5, 1);
-    regTestCheckFile(rp, "/tmp/lept/regout/psio5.ps");  /* 5 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio5.ps");  /* 5 */
 
         /* Generation using segmentation masks */
     convertSegmentedPagesToPS(".", "lion-page", 10, ".", "lion-mask", 10,
                               0, 100, 2.0, 0.8, 190,
-                              "/tmp/lept/regout/psio6.ps");
-    regTestCheckFile(rp, "/tmp/lept/regout/psio6.ps");  /* 6 */
+                              "/data/local/tmp/lept/regout/psio6.ps");
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio6.ps");  /* 6 */
 
         /* PS generation for embeddding */
-    convertJpegToPSEmbed("tetons.jpg", "/tmp/lept/regout/psio7.ps");
-    regTestCheckFile(rp, "/tmp/lept/regout/psio7.ps");  /* 7 */
+    convertJpegToPSEmbed("tetons.jpg", "/data/local/tmp/lept/regout/psio7.ps");
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio7.ps");  /* 7 */
 
-    convertG4ToPSEmbed("feyn-fract.tif", "/tmp/lept/regout/psio8.ps");
-    regTestCheckFile(rp, "/tmp/lept/regout/psio8.ps");  /* 8 */
+    convertG4ToPSEmbed("feyn-fract.tif", "/data/local/tmp/lept/regout/psio8.ps");
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio8.ps");  /* 8 */
 
-    convertFlateToPSEmbed("weasel8.240c.png", "/tmp/lept/regout/psio9.ps");
-    regTestCheckFile(rp, "/tmp/lept/regout/psio9.ps");  /* 9 */
+    convertFlateToPSEmbed("weasel8.240c.png", "/data/local/tmp/lept/regout/psio9.ps");
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio9.ps");  /* 9 */
 
         /* Writing compressed from a pixa */
     sa = sarrayCreate(0);
     for (i = 0; i < 11; i++)
         sarrayAddString(sa, WeaselNames[i], L_COPY);
     pixa = pixaReadFilesSA(sa);
-    pixaWriteCompressedToPS(pixa, "/tmp/lept/regout/psio10.ps", 0, 3);
-    regTestCheckFile(rp, "/tmp/lept/regout/psio10.ps");  /* 10 */
+    pixaWriteCompressedToPS(pixa, "/data/local/tmp/lept/regout/psio10.ps", 0, 3);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psio10.ps");  /* 10 */
     pixaDestroy(&pixa);
     sarrayDestroy(&sa);
 
diff -Nura leptonica-1.83.1/prog/psioseg_reg.c leptonica-1.83.1-patch/prog/psioseg_reg.c
--- leptonica-1.83.1/prog/psioseg_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/psioseg_reg.c	2024-09-05 14:26:11.055617434 +0800
@@ -126,19 +126,19 @@
 
          /* Write out the files to be imaged */
     lept_mkdir("lept/psio");
-    pixWrite("/tmp/lept/psio/image_001.tif", pixs, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_002.tif", pixht, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_003.tif", pixtxt, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_004.jpg", pixcs2, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/psio/mask_004.tif", pixmfull, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_005.jpg", pix32, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/psio/mask_005.tif", pixht, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_006.jpg", pix8g, IFF_JFIF_JPEG);
-    pixWrite("/tmp/lept/psio/mask_006.tif", pixht, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_007.png", pix8c, IFF_PNG);
-    pixWrite("/tmp/lept/psio/mask_007.tif", pixht, IFF_TIFF_G4);
-    pixWrite("/tmp/lept/psio/image_008.png", pix4c, IFF_PNG);
-    pixWrite("/tmp/lept/psio/mask_008.tif", pixht, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_001.tif", pixs, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_002.tif", pixht, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_003.tif", pixtxt, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_004.jpg", pixcs2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/psio/mask_004.tif", pixmfull, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_005.jpg", pix32, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/psio/mask_005.tif", pixht, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_006.jpg", pix8g, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/psio/mask_006.tif", pixht, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_007.png", pix8c, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/psio/mask_007.tif", pixht, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/psio/image_008.png", pix4c, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/psio/mask_008.tif", pixht, IFF_TIFF_G4);
     pixDestroy(&pixs);
     pixDestroy(&pixc);
     pixDestroy(&pixht);
@@ -152,21 +152,21 @@
     pixDestroy(&pix4c);
 
         /* Generate the 8 page ps */
-    convertSegmentedPagesToPS("/tmp/lept/psio", "image_", 6, "/tmp/lept/psio",
+    convertSegmentedPagesToPS("/data/local/tmp/lept/psio", "image_", 6, "/data/local/tmp/lept/psio",
                               "mask_", 5, 0, 10, 2.0, 0.15, 190,
-                              "/tmp/lept/regout/psioseg.5.ps");
-    regTestCheckFile(rp, "/tmp/lept/regout/psioseg.5.ps");  /* 5 */
-    L_INFO("Output ps: /tmp/lept/regout/psioseg.5.ps\n", rp->testname);
+                              "/data/local/tmp/lept/regout/psioseg.5.ps");
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/psioseg.5.ps");  /* 5 */
+    L_INFO("Output ps: /data/local/tmp/lept/regout/psioseg.5.ps\n", rp->testname);
 
         /* For convenience, also generate a pdf of this, using ps2pdf */
-    psname = genPathname("/tmp/lept/regout", "psioseg.5.ps");
-    pdfname = genPathname("/tmp/lept/regout", "psioseg.5.pdf");
+    psname = genPathname("/data/local/tmp/lept/regout", "psioseg.5.ps");
+    pdfname = genPathname("/data/local/tmp/lept/regout", "psioseg.5.pdf");
     snprintf(buf, sizeof(buf), "ps2pdf %s %s", psname, pdfname);
     ret = system(buf);  /* ps2pdf */
     lept_free(psname);
     lept_free(pdfname);
     if (!ret)
-        L_INFO("Output pdf: /tmp/lept/regout/psioseg.5.pdf\n", rp->testname);
+        L_INFO("Output pdf: /data/local/tmp/lept/regout/psioseg.5.pdf\n", rp->testname);
     else
         L_WARNING("ps2pdf failed to generate pdf\n", rp->testname);
 
diff -Nura leptonica-1.83.1/prog/ptra2_reg.c leptonica-1.83.1-patch/prog/ptra2_reg.c
--- leptonica-1.83.1/prog/ptra2_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/ptra2_reg.c	2024-09-05 14:26:11.055617434 +0800
@@ -92,18 +92,18 @@
 
         /* Sort by x */
     boxa1 = boxaSort(boxa, L_SORT_BY_X, L_SORT_INCREASING, &nad1);
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/boxa1.%d.ba", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/boxa1.%d.ba", index);
     boxaWrite(buf, boxa1);
     regTestCheckFile(rp, buf);  /* 0 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/nad1.%d.na", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/nad1.%d.na", index);
     numaWrite(buf, nad1);
     regTestCheckFile(rp, buf);  /* 1 */
 
     boxa2 = boxaBinSort(boxa, L_SORT_BY_X, L_SORT_INCREASING, &nad2);
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/boxa2.%d.ba", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/boxa2.%d.ba", index);
     boxaWrite(buf, boxa2);
     regTestCheckFile(rp, buf);  /* 2 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/nad2.%d.na", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/nad2.%d.na", index);
     numaWrite(buf, nad2);
     regTestCheckFile(rp, buf);  /* 3 */
 
@@ -115,7 +115,7 @@
     regTestCompareValues(rp, 1, same, 0.0);  /* 5 */
     if (rp->display && same)
         lept_stderr("boxa1 and boxa2 are same at maxdiff = 2\n");
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/naindex.%d.na", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/naindex.%d.na", index);
     numaWrite(buf, naindex);
     regTestCheckFile(rp, buf);  /* 6 */
     numaDestroy(&naindex);
@@ -173,10 +173,10 @@
         numaDestroy(&na);
     }
 
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/boxa3.%d.ba", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/boxa3.%d.ba", index);
     boxaWrite(buf, boxa3);
     regTestCheckFile(rp, buf);  /* 7 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/nad3.%d.na", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/nad3.%d.na", index);
     numaWrite(buf, nad3);
     regTestCheckFile(rp, buf);  /* 8 */
 
@@ -209,25 +209,25 @@
 
     pixa1 = pixaSort(pixa, L_SORT_BY_X, L_SORT_INCREASING, &nap1, L_CLONE);
     boxa1 = pixaGetBoxa(pixa1, L_CLONE);
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/bap1.%d.ba", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/bap1.%d.ba", index);
     boxaWrite(buf, boxa1);
     regTestCheckFile(rp, buf);  /* 0 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/nap1.%d.na", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/nap1.%d.na", index);
     numaWrite(buf, nap1);
     regTestCheckFile(rp, buf);  /* 1 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/pixa1.%d.pa", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/pixa1.%d.pa", index);
     pixaWrite(buf, pixa1);
     regTestCheckFile(rp, buf);  /* 2 */
 
     pixa2 = pixaBinSort(pixa, L_SORT_BY_X, L_SORT_INCREASING, &nap2, L_CLONE);
     boxa2 = pixaGetBoxa(pixa2, L_CLONE);
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/bap2.%d.ba", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/bap2.%d.ba", index);
     boxaWrite(buf, boxa2);
     regTestCheckFile(rp, buf);  /* 3 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/nap2.%d.na", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/nap2.%d.na", index);
     numaWrite(buf, nap2);
     regTestCheckFile(rp, buf);  /* 4 */
-    snprintf(buf, sizeof(buf), "/tmp/lept/ptra/pixa2.%d.pa", index);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ptra/pixa2.%d.pa", index);
     pixaWrite(buf, pixa2);
     regTestCheckFile(rp, buf);  /* 5 */
 
diff -Nura leptonica-1.83.1/prog/rank_reg.c leptonica-1.83.1-patch/prog/rank_reg.c
--- leptonica-1.83.1/prog/rank_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/rank_reg.c	2024-09-05 14:26:11.055617434 +0800
@@ -107,7 +107,7 @@
     nax = numaMakeSequence(1, 1, 20);
     nay1 = numaCreate(20);
     nay2 = numaCreate(20);
-    gplot = gplotCreate("/tmp/lept/rank/plots", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/rank/plots", GPLOT_PNG,
                         "sec/MPix vs filter size", "size", "time");
     pixa = pixaCreate(20);
     for (i = 1; i <= 20; i++) {
@@ -131,7 +131,7 @@
     gplotAddPlot(gplot, nax, nay2, GPLOT_LINES, "horizontal");
     gplotMakeOutput(gplot);
     gplotDestroy(&gplot);
-    pix1 = pixRead("/tmp/lept/rank/plots.png");
+    pix1 = pixRead("/data/local/tmp/lept/rank/plots.png");
     pixDisplayWithTitle(pix1, 100, 100, NULL, rp->display);
     pixDestroy(&pix1);
     pixDestroy(&pix0);
diff -Nura leptonica-1.83.1/prog/recog_bootnum1.c leptonica-1.83.1-patch/prog/recog_bootnum1.c
--- leptonica-1.83.1/prog/recog_bootnum1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recog_bootnum1.c	2024-09-05 14:26:11.055617434 +0800
@@ -46,9 +46,9 @@
  *      (b) Add code to MakeBootnum1() for this set, selecting with the
  *          string those templates you want to use.
  *      (c) Run recog_bootnum.
- *          * This makes a new /tmp/lept/recog/digits/bootnum1.pa.
+ *          * This makes a new /data/local/tmp/lept/recog/digits/bootnum1.pa.
  *            Replace prog/recog/digits/bootnum1.pa with this.
- *          * This makes new files: /tmp/lept/auto/autogen.101.{h,c}.
+ *          * This makes new files: /data/local/tmp/lept/auto/autogen.101.{h,c}.
  *            The .h file is the only one we need to use.
  *            Replace the encoded string in src/bootnumgen1.c with the
  *            one in autogen.101.h, and recompile.
@@ -82,7 +82,7 @@
     /* ----------------------- Bootnum 1 --------------------- */
         /* Make the bootnum pixa from the images */
     pixa1 = MakeBootnum1();
-    pixaWrite("/tmp/lept/recog/digits/bootnum1.pa", pixa1);
+    pixaWrite("/data/local/tmp/lept/recog/digits/bootnum1.pa", pixa1);
     pix1 = pixaDisplayTiledWithText(pixa1, 1500, 1.0, 10, 2, 6, 0xff000000);
     pixDisplay(pix1, 100, 0);
     pixDestroy(&pix1);
@@ -92,8 +92,8 @@
          * Note: the actual code we use is in bootnumgen1.c, and
          * has already been compiled into the library. */
     strc = strcodeCreate(101);  /* arbitrary integer */
-    strcodeGenerate(strc, "/tmp/lept/recog/digits/bootnum1.pa", "PIXA");
-    strcodeFinalize(&strc, "/tmp/lept/auto");
+    strcodeGenerate(strc, "/data/local/tmp/lept/recog/digits/bootnum1.pa", "PIXA");
+    strcodeFinalize(&strc, "/data/local/tmp/lept/auto");
     lept_free(strc);
 
         /* Generate the bootnum1 pixa from the generated code */
@@ -114,7 +114,7 @@
     /* ----------------------- Bootnum 2 --------------------- */
         /* Read bootnum 2 */
     pixa2 = pixaRead("recog/digits/bootnum2.pa");
-    pixaWrite("/tmp/lept/recog/digits/bootnum2.pa", pixa2);
+    pixaWrite("/data/local/tmp/lept/recog/digits/bootnum2.pa", pixa2);
     pix1 = pixaDisplayTiledWithText(pixa2, 1500, 1.0, 10, 2, 6, 0xff000000);
     pixDisplay(pix1, 100, 700);
     pixDestroy(&pix1);
@@ -123,8 +123,8 @@
         /* Generate the code to make the bootnum2 pixa.
          * Note: the actual code we use is in bootnumgen2.c. */
     strc = strcodeCreate(102);  /* another arbitrary integer */
-    strcodeGenerate(strc, "/tmp/lept/recog/digits/bootnum2.pa", "PIXA");
-    strcodeFinalize(&strc, "/tmp/lept/auto");
+    strcodeGenerate(strc, "/data/local/tmp/lept/recog/digits/bootnum2.pa", "PIXA");
+    strcodeFinalize(&strc, "/data/local/tmp/lept/auto");
     lept_free(strc);
 
         /* Generate the bootnum2 pixa from the generated code */
@@ -148,7 +148,7 @@
          * has already been compiled into the library. */
     strc = strcodeCreate(103);  /* arbitrary integer */
     strcodeGenerate(strc, "recog/digits/bootnum3.pa", "PIXA");
-    strcodeFinalize(&strc, "/tmp/lept/auto");
+    strcodeFinalize(&strc, "/data/local/tmp/lept/auto");
     lept_free(strc);
 
         /* Generate the bootnum3 pixa from the generated code */
@@ -168,10 +168,10 @@
 #if 0
     pixa1 = l_bootnum_gen1();
 /*    pixa1 = pixaRead("recog/digits/bootnum1.pa"); */
-    pixaWrite("/tmp/lept/junk.pa", pixa1);
-    pixa2 = pixaRead("/tmp/lept/junk.pa");
-    pixaWrite("/tmp/lept/junk1.pa", pixa2);
-    pixa3 = pixaRead("/tmp/lept/junk1.pa");
+    pixaWrite("/data/local/tmp/lept/junk.pa", pixa1);
+    pixa2 = pixaRead("/data/local/tmp/lept/junk.pa");
+    pixaWrite("/data/local/tmp/lept/junk1.pa", pixa2);
+    pixa3 = pixaRead("/data/local/tmp/lept/junk1.pa");
     n = pixaGetCount(pixa3);
     for (i = 0; i < n; i++) {
         pix = pixaGetPix(pixa3, i, L_CLONE);
@@ -312,7 +312,7 @@
 
         /* Phase 2: generate pixa consisting of 1 bpp, single character pix */
     pixa = recogExtractPixa(recog);
-    pixaWrite("/tmp/lept/recog/digits/bootnum2.pa", pixa);
+    pixaWrite("/data/local/tmp/lept/recog/digits/bootnum2.pa", pixa);
     recogDestroy(&recog);
     return pixa;
 }
diff -Nura leptonica-1.83.1/prog/recog_bootnum2.c leptonica-1.83.1-patch/prog/recog_bootnum2.c
--- leptonica-1.83.1/prog/recog_bootnum2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recog_bootnum2.c	2024-09-05 14:26:11.055617434 +0800
@@ -69,18 +69,18 @@
     pixa1 = pixaRead(buf);
 
         /* Number and show the input images */
-    snprintf(buf, sizeof(buf), "/tmp/lept/digit/%s.orig-num", rootname);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/digit/%s.orig-num", rootname);
     PixaDisplayNumbered(pixa1, buf);
 
         /* Remove some of them */
     na1 = numaCreateFromString(removeset);
     pixaRemoveSelected(pixa1, na1);
     numaDestroy(&na1);
-    snprintf(buf, sizeof(buf), "/tmp/lept/digit/%s.filt.pa", rootname);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/digit/%s.filt.pa", rootname);
     pixaWrite(buf, pixa1);
 
         /* Number and show the filtered images */
-    snprintf(buf, sizeof(buf), "/tmp/lept/digit/%s.filt-num", rootname);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/digit/%s.filt-num", rootname);
     PixaDisplayNumbered(pixa1, buf);
 
         /* Extract the largest c.c., clip to the foreground,
@@ -117,18 +117,18 @@
         pixSetText(pix1, buf);
         pixDestroy(&pix1);
     }
-    snprintf(buf, sizeof(buf), "/tmp/lept/digit/%s.comp.pa", rootname);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/digit/%s.comp.pa", rootname);
     pixaWrite(buf, pixa2);
 
         /* Number and show the resulting binary templates */
-    snprintf(buf, sizeof(buf), "/tmp/lept/digit/%s.comp-num", rootname);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/digit/%s.comp-num", rootname);
     PixaDisplayNumbered(pixa2, buf);
 
         /* Save the binary templates as a packed tiling (tiff g4).
          * This is the most efficient way to represent the templates. */
     pix1 = pixaDisplayOnLattice(pixa2, 20, 30, NULL, NULL);
     pixDisplay(pix1, 1000, 500);
-    snprintf(buf, sizeof(buf), "/tmp/lept/digit/%s.comp.tif", rootname);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/digit/%s.comp.tif", rootname);
     pixWrite(buf, pix1, IFF_TIFF_G4);
 
         /* The number of templates is in the pix text string; check it. */
diff -Nura leptonica-1.83.1/prog/recog_bootnum3.c leptonica-1.83.1-patch/prog/recog_bootnum3.c
--- leptonica-1.83.1/prog/recog_bootnum3.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recog_bootnum3.c	2024-09-05 14:26:11.055617434 +0800
@@ -77,14 +77,14 @@
         pixaDestroy(&pixa2);
     }
         /* Write it out (and copy to recog/digits/bootnum4.pa) */
-    pixaWrite("/tmp/lept/digit/bootnum4.pa", pixa1);
+    pixaWrite("/data/local/tmp/lept/digit/bootnum4.pa", pixa1);
     pixaDestroy(&pixa1);
 
         /* Generate the stringcode in two files for this pixa.
          * Both files are then assempled into the source file
          * bootnumgen4.c, which is compiled into the library.  */
     strc = strcodeCreate(212);   // arbitrary integer
-    strcodeGenerate(strc, "/tmp/lept/digit/bootnum4.pa", "PIXA");
+    strcodeGenerate(strc, "/data/local/tmp/lept/digit/bootnum4.pa", "PIXA");
     strcodeFinalize(&strc, ".");
     return 0;
 }
diff -Nura leptonica-1.83.1/prog/recogsort.c leptonica-1.83.1-patch/prog/recogsort.c
--- leptonica-1.83.1/prog/recogsort.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogsort.c	2024-09-05 14:26:11.055617434 +0800
@@ -95,7 +95,7 @@
         boxaaWriteStream(stderr, baa1);
         numaaWriteStream(stderr, naa1);
         pixaAddPix(pixa2, pixdb, L_INSERT);
-/*        pixaWrite("/tmp/pixa.pa", pixa2); */
+/*        pixaWrite("/data/local/tmp/pixa.pa", pixa2); */
         pixDestroy(&pix1);
         boxaWriteStderr(boxa3);
         boxaDestroy(&boxa3);
@@ -105,10 +105,10 @@
     }
 
     pix3 = pixaDisplayLinearly(pixa2, L_VERT, 1.0, 0, 20, 1, NULL);
-    pixWrite("/tmp/lept/recog/pix3.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/recog/pix3.png", pix3, IFF_PNG);
     pix4 = pixaDisplayTiledInRows(pixa3, 32, 1500, 1.0, 0, 20, 2);
     pixDisplay(pix4, 500, 0);
-    pixWrite("/tmp/lept/recog/pix4.png", pix4, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/recog/pix4.png", pix4, IFF_PNG);
     pixaDestroy(&pixa2);
     pixaDestroy(&pixa3);
     pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/recogtest1.c leptonica-1.83.1-patch/prog/recogtest1.c
--- leptonica-1.83.1/prog/recogtest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogtest1.c	2024-09-05 14:26:11.059617356 +0800
@@ -76,7 +76,7 @@
     pixa1 = pixaRead("recog/digits/bootnum1.pa");
     recog1 = recogCreateFromPixa(pixa1, scaledw, scaledh, linew, 120, 1);
     pix1 = pixaDisplayTiledWithText(pixa1, 1400, 1.0, 10, 2, 6, 0xff000000);
-    pixWrite("/tmp/lept/digits/bootnum1.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/bootnum1.png", pix1, IFF_PNG);
     pixDisplay(pix1, 800, 800);
     pixDestroy(&pix1);
     pixaDestroy(&pixa1);
@@ -92,30 +92,30 @@
     recogAverageSamples(recog1, 1);
     recogShowAverageTemplates(recog1);
     pix1 = pixaGetPix(recog1->pixadb_ave, 0, L_CLONE);
-    pixWrite("/tmp/lept/digits/unscaled_ave.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/unscaled_ave.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
     pix1 = pixaGetPix(recog1->pixadb_ave, 1, L_CLONE);
-    pixWrite("/tmp/lept/digits/scaled_ave.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/scaled_ave.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
 #endif
 
 #if 1
     recogDebugAverages(recog1, 0);
     recogShowMatchesInRange(recog1, recog1->pixa_tr, 0.65, 1.0, 0);
-    pixWrite("/tmp/lept/digits/match_ave1.png", recog1->pixdb_range, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/match_ave1.png", recog1->pixdb_range, IFF_PNG);
     recogShowMatchesInRange(recog1, recog1->pixa_tr, 0.0, 1.0, 0);
-    pixWrite("/tmp/lept/digits/match_ave2.png", recog1->pixdb_range, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/match_ave2.png", recog1->pixdb_range, IFF_PNG);
 #endif
 
 #if 1
     lept_stderr("Print stats 2\n");
     recogShowContent(stderr, recog1, 2, 1);
-    recogWrite("/tmp/lept/digits/rec1.rec", recog1);
-    recog2 = recogRead("/tmp/lept/digits/rec1.rec");
+    recogWrite("/data/local/tmp/lept/digits/rec1.rec", recog1);
+    recog2 = recogRead("/data/local/tmp/lept/digits/rec1.rec");
     recogShowContent(stderr, recog2, 3, 1);
-    recogWrite("/tmp/lept/digits/rec2.rec", recog2);
-    filesAreIdentical("/tmp/lept/digits/rec1.rec",
-                      "/tmp/lept/digits/rec2.rec", &same);
+    recogWrite("/data/local/tmp/lept/digits/rec2.rec", recog2);
+    filesAreIdentical("/data/local/tmp/lept/digits/rec1.rec",
+                      "/data/local/tmp/lept/digits/rec2.rec", &same);
     if (!same)
         lept_stderr("Error in serialization!\n");
     recogDestroy(&recog2);
@@ -164,7 +164,7 @@
     recog2 = recogCreateFromPixa(pixa1, 0, 40, 0, 128, 1);
     recogShowContent(stderr, recog2, 3, 1);
     recogDebugAverages(recog2, 3);
-    pixWrite("/tmp/lept/digits/averages.png", recog2->pixdb_ave, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/averages.png", recog2->pixdb_ave, IFF_PNG);
     recogShowAverageTemplates(recog2);
     pixaDestroy(&pixa1);
     recogDestroy(&recog2);
diff -Nura leptonica-1.83.1/prog/recogtest2.c leptonica-1.83.1-patch/prog/recogtest2.c
--- leptonica-1.83.1/prog/recogtest2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogtest2.c	2024-09-05 14:26:11.059617356 +0800
@@ -87,7 +87,7 @@
          * and scaled versions of the templates */
     pixa1 = (PIXA *)l_bootnum_gen1();  /* from recog/digits/bootnum1.pa */
     recogboot = recogCreateFromPixa(pixa1, 0, 40, linew, 128, 1);
-    recogWrite("/tmp/lept/recog/boot1.rec", recogboot);
+    recogWrite("/data/local/tmp/lept/recog/boot1.rec", recogboot);
     recogShowContent(stderr, recogboot, 1, 1);
     pixaDestroy(&pixa1);
 
@@ -105,9 +105,9 @@
         recog1 = recogCreateFromPixa(pixa3, 0, 40, linew, 128, 1);
         recogShowContent(stderr, recog1, 2, 1);
         if (i == 0)
-            recogWrite("/tmp/lept/recog/recog1.rec", recog1);
+            recogWrite("/data/local/tmp/lept/recog/recog1.rec", recog1);
         else  /* i == 1 */
-            recogWrite("/tmp/lept/recog/recog2.rec", recog1);
+            recogWrite("/data/local/tmp/lept/recog/recog2.rec", recog1);
         pixaDestroy(&pixa2);
         pixaDestroy(&pixa3);
         recogDestroy(&recog1);
@@ -121,7 +121,7 @@
         /* Generate the boot recog, and show the unscaled and scaled
          * versions of the templates */
     recogboot = recogMakeBootDigitRecog(0, 40, linew, 1, 1);
-    recogWrite("/tmp/lept/recog/boot2.rec", recogboot);
+    recogWrite("/data/local/tmp/lept/recog/boot2.rec", recogboot);
     recogShowContent(stderr, recogboot, 3, 1);
 
         /* Generate a BAR for a set of images from one book.
@@ -136,9 +136,9 @@
         recog1 = recogCreateFromPixa(pixa3, 0, 40, linew, 128, 1);
         recogShowContent(stderr, recog1, 4, 1);
         if (i == 0)
-            recogWrite("/tmp/lept/recog/recog3.rec", recog1);
+            recogWrite("/data/local/tmp/lept/recog/recog3.rec", recog1);
         else if (i == 1)
-            recogWrite("/tmp/lept/recog/recog4.rec", recog1);
+            recogWrite("/data/local/tmp/lept/recog/recog4.rec", recog1);
         pixaDestroy(&pixa2);
         pixaDestroy(&pixa3);
         recogDestroy(&recog1);
@@ -163,7 +163,7 @@
     recogDebugAverages(recog, 1);
     recogShowContent(stderr, recog, 1);
     recogShowMatchesInRange(recog, recog->pixa_tr, 0.75, 1.0, 1);
-    pixWrite("/tmp/lept/recog/range.png", recog->pixdb_range, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/recog/range.png", recog->pixdb_range, IFF_PNG);
 #endif
 
     /* ----------------------------------------------------------- */
@@ -178,7 +178,7 @@
     pix2 = pixaDisplayTiledInRows(pixa1, 32, 600, 1.0, 0, 20, 2);
     pixDisplay(pix2, 0, 1000);
     pixDisplay(pix3, 600, 1000);
-    pixWrite("/tmp/lept/recog/extract.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/recog/extract.png", pix3, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
diff -Nura leptonica-1.83.1/prog/recogtest3.c leptonica-1.83.1-patch/prog/recogtest3.c
--- leptonica-1.83.1/prog/recogtest3.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogtest3.c	2024-09-05 14:26:11.059617356 +0800
@@ -131,11 +131,11 @@
     recogShowContent(stderr, recog2, 2, 1);
 
         /* Test recog serialization */
-    recogWrite("/tmp/lept/recog/recog2.rec", recog2);
-    recog3 = recogRead("/tmp/lept/recog/recog2.rec");
-    recogWrite("/tmp/lept/recog/recog3.rec", recog3);
-    filesAreIdentical("/tmp/lept/recog/recog2.rec",
-                      "/tmp/lept/recog/recog3.rec", &same);
+    recogWrite("/data/local/tmp/lept/recog/recog2.rec", recog2);
+    recog3 = recogRead("/data/local/tmp/lept/recog/recog2.rec");
+    recogWrite("/data/local/tmp/lept/recog/recog3.rec", recog3);
+    filesAreIdentical("/data/local/tmp/lept/recog/recog2.rec",
+                      "/data/local/tmp/lept/recog/recog3.rec", &same);
     if (!same)
         lept_stderr("Error in serialization!\n");
     recogDestroy(&recog3);
diff -Nura leptonica-1.83.1/prog/recogtest4.c leptonica-1.83.1-patch/prog/recogtest4.c
--- leptonica-1.83.1/prog/recogtest4.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogtest4.c	2024-09-05 14:26:11.059617356 +0800
@@ -76,7 +76,7 @@
     recog = recogCreateFromPixa(pixa1, 0, 0, 0, 128, 1);
 #endif
     recogAverageSamples(recog, 1);
-    recogWrite("/tmp/lept/recog/rec1.rec", recog);
+    recogWrite("/data/local/tmp/lept/recog/rec1.rec", recog);
 
         /* Show the templates */
     if (recogDebugAverages(recog, 1) != 0) {
@@ -99,7 +99,7 @@
         pix2 = GetBigComponent(pix1);
         boxa = recogDecode(recog, pix2, 2, &pixdb);
         pixDisplay(pixdb, 300, 100);
-        snprintf(buf, sizeof(buf), "/tmp/lept/recog/did-%d.png", item);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/recog/did-%d.png", item);
         pixWrite(buf, pixdb, IFF_PNG);
         pixDestroy(&pixdb);
         boxaDestroy(&boxa);
diff -Nura leptonica-1.83.1/prog/recogtest5.c leptonica-1.83.1-patch/prog/recogtest5.c
--- leptonica-1.83.1/prog/recogtest5.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogtest5.c	2024-09-05 14:26:11.059617356 +0800
@@ -65,7 +65,7 @@
     pixa1 = pixaRead("recog/sets/train01.pa");
     recog = recogCreateFromPixa(pixa1, 0, 0, 0, 128, 1);  /* no scaling */
     recogAverageSamples(recog, 1);
-    recogWrite("/tmp/lept/recog/rec1.rec", recog);
+    recogWrite("/data/local/tmp/lept/recog/rec1.rec", recog);
 
         /* Show the templates */
     recogDebugAverages(recog, 1);
diff -Nura leptonica-1.83.1/prog/recogtest7.c leptonica-1.83.1-patch/prog/recogtest7.c
--- leptonica-1.83.1/prog/recogtest7.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/recogtest7.c	2024-09-05 14:26:11.059617356 +0800
@@ -74,8 +74,8 @@
     pix3 = pixaDisplayTiledWithText(pixa3, 1400, 1.0, 10, 2, 6, 0xff000000);
     pixEqual(pix2, pix3, &same);
     if (!same) L_ERROR("Bad! The displayed pix differ!\n", __func__);
-    pixWrite("/tmp/lept/digits/pix1.png", pix1, IFF_PNG);
-    pixWrite("/tmp/lept/digits/bootnum4.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/pix1.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/bootnum4.png", pix1, IFF_PNG);
     pixaDestroy(&pixa1);
     pixaDestroy(&pixa2);
     pixDestroy(&pix1);
@@ -95,10 +95,10 @@
     recogAverageSamples(recog1, 1);
     recogShowAverageTemplates(recog1);
     pix1 = pixaGetPix(recog1->pixadb_ave, 0, L_CLONE);
-    pixWrite("/tmp/lept/digits/unscaled_ave.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/unscaled_ave.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
     pix1 = pixaGetPix(recog1->pixadb_ave, 1, L_CLONE);
-    pixWrite("/tmp/lept/digits/scaled_ave.png", pix1, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/scaled_ave.png", pix1, IFF_PNG);
     pixDestroy(&pix1);
     recogDestroy(&recog1);
 #endif
@@ -113,10 +113,10 @@
     lept_stderr("\nShow matches against all inputs for given range\n");
     recogDebugAverages(recog1, 0);
     recogShowMatchesInRange(recog1, recog1->pixa_tr, 0.85, 1.00, 1);
-    pixWrite("/tmp/lept/digits/match_input.png", recog1->pixdb_range, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/match_input.png", recog1->pixdb_range, IFF_PNG);
     lept_stderr("\nShow best match against average template\n");
     recogShowMatchesInRange(recog1, recog1->pixa_u, 0.65, 1.00, 1);
-    pixWrite("/tmp/lept/digits/match_ave.png", recog1->pixdb_range, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/digits/match_ave.png", recog1->pixdb_range, IFF_PNG);
     pixaDestroy(&pixa1);
 #endif
 
@@ -125,13 +125,13 @@
     recogShowContent(stderr, recog1, 2, 1);
 
     lept_stderr("\nTest serialization\n");
-    recogWrite("/tmp/lept/digits/rec1.rec", recog1);
-    recog2 = recogRead("/tmp/lept/digits/rec1.rec");
+    recogWrite("/data/local/tmp/lept/digits/rec1.rec", recog1);
+    recog2 = recogRead("/data/local/tmp/lept/digits/rec1.rec");
     lept_stderr("Contents of recog after write/read:\n");
     recogShowContent(stderr, recog2, 3, 1);
-    recogWrite("/tmp/lept/digits/rec2.rec", recog2);
-    filesAreIdentical("/tmp/lept/digits/rec1.rec",
-                      "/tmp/lept/digits/rec2.rec", &same);
+    recogWrite("/data/local/tmp/lept/digits/rec2.rec", recog2);
+    filesAreIdentical("/data/local/tmp/lept/digits/rec1.rec",
+                      "/data/local/tmp/lept/digits/rec2.rec", &same);
     if (!same)
         lept_stderr("Error in serialization!\n");
     recogDestroy(&recog1);
diff -Nura leptonica-1.83.1/prog/rectangle_reg.c leptonica-1.83.1-patch/prog/rectangle_reg.c
--- leptonica-1.83.1/prog/rectangle_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/rectangle_reg.c	2024-09-05 14:26:11.059617356 +0800
@@ -104,7 +104,7 @@
                                 L_GEOMETRIC_UNION, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 2);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 1 */
     if (rp->display) l_fileDisplay(newpath, 0, 500, 0.4);
     lept_free(newpath);
@@ -113,7 +113,7 @@
                                 L_GEOMETRIC_INTERSECTION, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 3);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 2 */
     if (rp->display) l_fileDisplay(newpath, 200, 500, 0.4);
     lept_free(newpath);
@@ -122,7 +122,7 @@
                                 L_LARGEST_AREA, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 4);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 3 */
     if (rp->display) l_fileDisplay(newpath, 400, 500, 0.4);
     lept_free(newpath);
@@ -131,7 +131,7 @@
                                 L_SMALLEST_AREA, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 5);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 4 */
     if (rp->display) l_fileDisplay(newpath, 600, 500, 0.4);
     lept_free(newpath);
@@ -141,7 +141,7 @@
                                 L_GEOMETRIC_UNION, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 6);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 5 */
     if (rp->display) l_fileDisplay(newpath, 800, 500, 0.4);
     lept_free(newpath);
@@ -150,7 +150,7 @@
                                 L_GEOMETRIC_INTERSECTION, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 7);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 6 */
     if (rp->display) l_fileDisplay(newpath, 1000, 500, 0.4);
     lept_free(newpath);
@@ -159,7 +159,7 @@
                                 L_LARGEST_AREA, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 8);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 7 */
     if (rp->display) l_fileDisplay(newpath, 1200, 500, 0.4);
     lept_free(newpath);
@@ -168,7 +168,7 @@
                                 L_SMALLEST_AREA, TRUE);
     boxDestroy(&box2);
     snprintf(buf, sizeof(buf), "rectangle.%02d.png", 9);
-    lept_cp("/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
+    lept_cp("/data/local/tmp/lept/rect/fitrect.png", "lept/regout", buf, &newpath);
     regTestCheckFile(rp, newpath);  /* 8 */
     if (rp->display) l_fileDisplay(newpath, 1400, 500, 0.4);
     lept_free(newpath);
diff -Nura leptonica-1.83.1/prog/renderfonts.c leptonica-1.83.1-patch/prog/renderfonts.c
--- leptonica-1.83.1/prog/renderfonts.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/renderfonts.c	2024-09-05 14:26:11.059617356 +0800
@@ -58,7 +58,7 @@
     lept_stderr("n = %d\n", pixaGetCount(bmf->pixa));
     pix = pixaGetPix(bmf->pixa, 6, L_CLONE);
     pixSetMaskedGeneral(pixs, pix, 0x45, 140, 165);
-    pixWrite("/tmp/lept/render/char.png", pixs, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/render/char.png", pixs, IFF_PNG);
     pixDisplay(pixs, 0, 0);
     pixDestroy(&pix);
     pixDestroy(&pixs);
@@ -72,7 +72,7 @@
 
     pixSetTextline(pixs, bmf, "This is a funny cat!", 0x4080ff00, 50, 250,
                    &width, &overflow);
-    pixWrite("/tmp/lept/render/line.png", pixs, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/render/line.png", pixs, IFF_JFIF_JPEG);
     pixDisplay(pixs, 450, 0);
     lept_stderr("Text width = %d\n", width);
     if (overflow)
@@ -90,7 +90,7 @@
     wtext = pixGetWidth(pixs) - 70;
     pixSetTextblock(pixs, bmf, textstr, 0x90804000, 50, 50, wtext,
                     1, &overflow);
-    pixWrite("/tmp/lept/render/block.png", pixs, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/render/block.png", pixs, IFF_JFIF_JPEG);
     pixDisplay(pixs, 0, 500);
     if (overflow)
         lept_stderr("Text overflow beyond image boundary\n");
diff -Nura leptonica-1.83.1/prog/rotatetest1.c leptonica-1.83.1-patch/prog/rotatetest1.c
--- leptonica-1.83.1/prog/rotatetest1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/rotatetest1.c	2024-09-05 14:26:11.059617356 +0800
@@ -131,7 +131,7 @@
     for (i = 0; i < NTIMES; i++) {
         pixRotateShearIP(pixs, w/2, h/2, -deg2rad * angle, L_BRING_IN_WHITE);
     }
-    pixWrite("/usr/tmp/junkout", pixs, IFF_PNG);
+    pixWrite("/usr/data/local/tmp/junkout", pixs, IFF_PNG);
 }
 #endif
 
@@ -156,21 +156,21 @@
     startTimer();
     pix1 = pixRotateAMColor(pixs, 0.12, 0xffffff00);
     lept_stderr(" standard color rotate: %7.2f sec\n", stopTimer());
-    pixWrite("/tmp/lept/rotate/color1.jpg", pix1, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/rotate/color1.jpg", pix1, IFF_JFIF_JPEG);
     startTimer();
     pix2 = pixRotateAMColorFast(pixs, 0.12, 0xffffff00);
     lept_stderr(" fast color rotate: %7.2f sec\n", stopTimer());
-    pixWrite("/tmp/lept/rotate/color2.jpg", pix2, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/rotate/color2.jpg", pix2, IFF_JFIF_JPEG);
     pixd = pixAbsDifference(pix1, pix2);
     pixGetColorHistogram(pixd, 1, &nar, &nag, &nab);
     naseq = numaMakeSequence(0., 1., 256);
-    gplot = gplotCreate("/tmp/lept/rotate/absdiff", GPLOT_PNG,
+    gplot = gplotCreate("/data/local/tmp/lept/rotate/absdiff", GPLOT_PNG,
                         "Number vs diff", "diff", "number");
     gplotAddPlot(gplot, naseq, nar, GPLOT_POINTS, "red");
     gplotAddPlot(gplot, naseq, nag, GPLOT_POINTS, "green");
     gplotAddPlot(gplot, naseq, nab, GPLOT_POINTS, "blue");
     gplotMakeOutput(gplot);
-    l_fileDisplay("/tmp/lept/rotate/absdiff.png", 100, 100, 1.0);
+    l_fileDisplay("/data/local/tmp/lept/rotate/absdiff.png", 100, 100, 1.0);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pixd);
@@ -195,7 +195,7 @@
     ang = 7.0 * deg2rad;
     pixGetDimensions(pixs, &w, &h, NULL);
     pixd = pixRotate(pixs, ang, rotflag, L_BRING_IN_WHITE, w, h);
-    pixWrite("/tmp/lept/rotate/rot7.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/rotate/rot7.png", pixd, IFF_PNG);
     for (i = 1; i < 180; i++) {
         pixs = pixd;
         pixd = pixRotate(pixs, ang, rotflag, L_BRING_IN_WHITE, w, h);
@@ -203,7 +203,7 @@
         pixDestroy(&pixs);
     }
 
-    pixWrite("/tmp/lept/rotate/spin.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/rotate/spin.png", pixd, IFF_PNG);
     pixDisplay(pixd, 0, 0);
 
     for (i = 0; i < 180; i++) {
@@ -213,7 +213,7 @@
         pixDestroy(&pixs);
     }
 
-    pixWrite("/tmp/lept/rotate/unspin.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/rotate/unspin.png", pixd, IFF_PNG);
     pixDisplay(pixd, 0, 500);
     pixDestroy(&pixd);
 #endif
diff -Nura leptonica-1.83.1/prog/runlengthtest.c leptonica-1.83.1-patch/prog/runlengthtest.c
--- leptonica-1.83.1/prog/runlengthtest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/runlengthtest.c	2024-09-05 14:26:11.059617356 +0800
@@ -65,12 +65,12 @@
     pixDisplay(pix5, 1800, 0);
     pixDisplay(pix6, 1200, 0);
     pixDisplay(pix7, 1800, 0);
-    pixWrite("/tmp/lept/run/pixh.png", pix2, IFF_PNG);
-    pixWrite("/tmp/lept/run/pixv.png", pix3, IFF_PNG);
-    pixWrite("/tmp/lept/run/pixmin.png", pix4, IFF_PNG);
-    pixWrite("/tmp/lept/run/pixminlog.png", pix5, IFF_PNG);
-    pixWrite("/tmp/lept/run/pixmax.png", pix6, IFF_PNG);
-    pixWrite("/tmp/lept/run/pixmaxlog.png", pix7, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/pixh.png", pix2, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/pixv.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/pixmin.png", pix4, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/pixminlog.png", pix5, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/pixmax.png", pix6, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/pixmaxlog.png", pix7, IFF_PNG);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
@@ -82,8 +82,8 @@
         /* Set 2 */
     startTimer();
     pix1 = pixRead("test24.jpg");
-    pixWriteJpeg("/tmp/lept/run/junk24.jpg", pix1, 5, 0);
-    pix2 = pixRead("/tmp/lept/run/junk24.jpg");
+    pixWriteJpeg("/data/local/tmp/lept/run/junk24.jpg", pix1, 5, 0);
+    pix2 = pixRead("/data/local/tmp/lept/run/junk24.jpg");
     pixCompareGrayOrRGB(pix1, pix2, L_COMPARE_ABS_DIFF, GPLOT_PNG,
                         NULL, &avediff, &rmsdiff, &pix3);
     lept_stderr("Ave diff = %6.3f, RMS diff = %6.3f\n", avediff, rmsdiff);
@@ -92,8 +92,8 @@
     lept_stderr("Time for set 2: %7.3f sec\n", stopTimer());
     pixDisplay(pix4, 0, 800);
     pixDisplay(pix5, 1000, 800);
-    pixWrite("/tmp/lept/run/linear.png", pix4, IFF_PNG);
-    pixWrite("/tmp/lept/run/log.png", pix5, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/linear.png", pix4, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/run/log.png", pix5, IFF_PNG);
 
     pixDestroy(&pix1);
     pixDestroy(&pix2);
diff -Nura leptonica-1.83.1/prog/scaletest2.c leptonica-1.83.1-patch/prog/scaletest2.c
--- leptonica-1.83.1/prog/scaletest2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/scaletest2.c	2024-09-05 14:26:11.059617356 +0800
@@ -60,22 +60,22 @@
         PIX  *pixd;
 
         pixd = pixScaleToGray2(pixs);
-        pixWrite("/tmp/lept/scale/s2g_2x", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_2x", pixd, IFF_PNG);
         pixDestroy(&pixd);
         pixd = pixScaleToGray3(pixs);
-        pixWrite("/tmp/lept/scale/s2g_3x", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_3x", pixd, IFF_PNG);
         pixDestroy(&pixd);
         pixd = pixScaleToGray4(pixs);
-        pixWrite("/tmp/lept/scale/s2g_4x", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_4x", pixd, IFF_PNG);
         pixDestroy(&pixd);
         pixd = pixScaleToGray6(pixs);
-        pixWrite("/tmp/lept/scale/s2g_6x", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_6x", pixd, IFF_PNG);
         pixDestroy(&pixd);
         pixd = pixScaleToGray8(pixs);
-        pixWrite("/tmp/lept/scale/s2g_8x", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_8x", pixd, IFF_PNG);
         pixDestroy(&pixd);
         pixd = pixScaleToGray16(pixs);
-        pixWrite("/tmp/lept/scale/s2g_16x", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_16x", pixd, IFF_PNG);
         pixDestroy(&pixd);
     }
 #endif
@@ -87,55 +87,55 @@
         PIX  *pixt, *pixd;
 
         pixd = pixScaleToGray8(pixs);
-        pixWrite("/tmp/lept/scale/s2g_8.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_8.png", pixd, IFF_PNG);
         pixDestroy(&pixd);
 
         pixd = pixScaleToGray(pixs, 0.124);
-        pixWrite("/tmp/lept/scale/s2g_124.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_124.png", pixd, IFF_PNG);
         pixDestroy(&pixd);
 
         pixd = pixScaleToGray(pixs, 0.284);
-        pixWrite("/tmp/lept/scale/s2g_284.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_284.png", pixd, IFF_PNG);
         pixDestroy(&pixd);
 
         pixt = pixScaleToGray4(pixs);
         pixd = pixScaleBySampling(pixt, 284./250., 284./250.);
-        pixWrite("/tmp/lept/scale/s2g_284.2.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_284.2.png", pixd, IFF_PNG);
         pixDestroy(&pixt);
         pixDestroy(&pixd);
 
         pixt = pixScaleToGray4(pixs);
         pixd = pixScaleGrayLI(pixt, 284./250., 284./250.);
-        pixWrite("/tmp/lept/scale/s2g_284.3.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_284.3.png", pixd, IFF_PNG);
         pixDestroy(&pixt);
         pixDestroy(&pixd);
 
         pixt = pixScaleBinary(pixs, 284./250., 284./250.);
         pixd = pixScaleToGray4(pixt);
-        pixWrite("/tmp/lept/scale/s2g_284.4.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_284.4.png", pixd, IFF_PNG);
         pixDestroy(&pixt);
         pixDestroy(&pixd);
 
         pixt = pixScaleToGray4(pixs);
         pixd = pixScaleGrayLI(pixt, 0.49, 0.49);
-        pixWrite("/tmp/lept/scale/s2g_42.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_42.png", pixd, IFF_PNG);
         pixDestroy(&pixt);
         pixDestroy(&pixd);
 
         pixt = pixScaleToGray4(pixs);
         pixd = pixScaleSmooth(pixt, 0.49, 0.49);
-        pixWrite("/tmp/lept/scale/s2g_4sm.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_4sm.png", pixd, IFF_PNG);
         pixDestroy(&pixt);
         pixDestroy(&pixd);
 
         pixt = pixScaleBinary(pixs, .16/.125, .16/.125);
         pixd = pixScaleToGray8(pixt);
-        pixWrite("/tmp/lept/scale/s2g_16.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_16.png", pixd, IFF_PNG);
         pixDestroy(&pixt);
         pixDestroy(&pixd);
 
         pixd = pixScaleToGray(pixs, .16);
-        pixWrite("/tmp/lept/scale/s2g_16.2.png", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/s2g_16.2.png", pixd, IFF_PNG);
         pixDestroy(&pixd);
     }
 #endif
@@ -149,9 +149,9 @@
         pixt1 = pixScaleSmooth(pixs, 0.154, 0.154);
         lept_stderr("fast scale: %5.3f sec\n", stopTimer());
         pixDisplayWithTitle(pixt1, 0, 0, "smooth scaling", DISPLAY);
-        pixWrite("/tmp/lept/scale/smooth1.png", pixt1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/smooth1.png", pixt1, IFF_PNG);
         pixt2 = pixUnsharpMasking(pixt1, 1, 0.3);
-        pixWrite("/tmp/lept/scale/smooth2.png", pixt2, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/smooth2.png", pixt2, IFF_PNG);
         pixDisplayWithTitle(pixt2, 200, 0, "sharp scaling", DISPLAY);
         pixDestroy(&pixt1);
         pixDestroy(&pixt2);
@@ -232,7 +232,7 @@
         pixt1 = pixScaleSmooth(pixs, SCALING, SCALING);
         lept_stderr("fast scale: %5.3f sec\n", stopTimer());
         pixDisplayWithTitle(pixt1, 0, 0, "smooth scaling", DISPLAY);
-        pixWrite("/tmp/lept/scale/sm_1.png", pixt1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/sm_1.png", pixt1, IFF_PNG);
         pixt2 = pixUnsharpMasking(pixt1, 1, 0.3);
         pixDisplayWithTitle(pixt2, 150, 0, "sharpened scaling", DISPLAY);
 
@@ -241,7 +241,7 @@
         pixt4 = pixScaleBySampling(pixt3, SCALING, SCALING);
         lept_stderr("slow scale: %5.3f sec\n", stopTimer());
         pixDisplayWithTitle(pixt4, 200, 200, "sampled scaling", DISPLAY);
-        pixWrite("/tmp/lept/scale/sm_2.png", pixt4, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/scale/sm_2.png", pixt4, IFF_PNG);
 
         startTimer();
         pixt5 = pixUnsharpMasking(pixs, smooth, FRACT);
@@ -249,7 +249,7 @@
         pixt7 = pixScaleBySampling(pixt6, SCALING, SCALING);
         lept_stderr("very slow scale + sharp: %5.3f sec\n", stopTimer());
         pixDisplayWithTitle(pixt7, 500, 200, "sampled scaling", DISPLAY);
-        pixWrite("/tmp/lept/scale/sm_3.jpg", pixt7, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/scale/sm_3.jpg", pixt7, IFF_JFIF_JPEG);
 
         pixDestroy(&pixt1);
         pixDestroy(&pixt2);
@@ -274,23 +274,23 @@
         startTimer();
         pix1 = pixScaleColorLI(pixs, 2.00001, 2.0);
         lept_stderr(" Time with regular LI: %7.3f\n", stopTimer());
-        pixWrite("/tmp/lept/scale/color1.jpg", pix1, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/scale/color1.jpg", pix1, IFF_JFIF_JPEG);
         startTimer();
         pix2 = pixScaleColorLI(pixs, 2.0, 2.0);
         lept_stderr(" Time with 2x LI: %7.3f\n", stopTimer());
-        pixWrite("/tmp/lept/scale/color2.jpg", pix2, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/scale/color2.jpg", pix2, IFF_JFIF_JPEG);
 
         pixd = pixAbsDifference(pix1, pix2);
         pixGetColorHistogram(pixd, 1, &nar, &nag, &nab);
         naseq = numaMakeSequence(0., 1., 256);
-        gplot = gplotCreate("/tmp/lept/scale/c_absdiff", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/scale/c_absdiff", GPLOT_PNG,
                             "Number vs diff", "diff", "number");
         gplotSetScaling(gplot, GPLOT_LOG_SCALE_Y);
         gplotAddPlot(gplot, naseq, nar, GPLOT_POINTS, "red");
         gplotAddPlot(gplot, naseq, nag, GPLOT_POINTS, "green");
         gplotAddPlot(gplot, naseq, nab, GPLOT_POINTS, "blue");
         gplotMakeOutput(gplot);
-        l_fileDisplay("/tmp/lept/scale/c_absdiff.png", 0, 100, 1.0);
+        l_fileDisplay("/data/local/tmp/lept/scale/c_absdiff.png", 0, 100, 1.0);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         pixDestroy(&pixd);
@@ -333,18 +333,18 @@
         pix2 = pixScaleGrayLI(pix0, 4.0, 4.0);
         lept_stderr(" Time with 2x LI: %7.3f\n", stopTimer());
 #endif
-        pixWrite("/tmp/lept/scale/gray1", pix1, IFF_JFIF_JPEG);
-        pixWrite("/tmp/lept/scale/gray2", pix2, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/scale/gray1", pix1, IFF_JFIF_JPEG);
+        pixWrite("/data/local/tmp/lept/scale/gray2", pix2, IFF_JFIF_JPEG);
 
         pixd = pixAbsDifference(pix1, pix2);
         nagray = pixGetGrayHistogram(pixd, 1);
         naseq = numaMakeSequence(0., 1., 256);
-        gplot = gplotCreate("/tmp/lept/scale/g_absdiff", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/scale/g_absdiff", GPLOT_PNG,
                             "Number vs diff", "diff", "number");
         gplotSetScaling(gplot, GPLOT_LOG_SCALE_Y);
         gplotAddPlot(gplot, naseq, nagray, GPLOT_POINTS, "gray");
         gplotMakeOutput(gplot);
-        l_fileDisplay("/tmp/lept/scale/g_absdiff.png", 750, 100, 1.0);
+        l_fileDisplay("/data/local/tmp/lept/scale/g_absdiff.png", 750, 100, 1.0);
         pixDestroy(&pixt);
         pixDestroy(&pix0);
         pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/prog/seedfilltest.c leptonica-1.83.1-patch/prog/seedfilltest.c
--- leptonica-1.83.1/prog/seedfilltest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/seedfilltest.c	2024-09-05 14:26:11.063617278 +0800
@@ -87,8 +87,8 @@
     pixInvert(pixd, pixd);
     pixDisplay(pixmi, 500, 100);
     pixDisplay(pixd, 1000, 100);
-    pixWrite("/tmp/junkpixm.png", pixmi, IFF_PNG);
-    pixWrite("/tmp/junkpixd.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixm.png", pixmi, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixd.png", pixd, IFF_PNG);
 #endif
 
 #if 0
@@ -103,8 +103,8 @@
     pixInvert(pixd, pixd);
     pixDisplay(pixmi, 500, 100);
     pixDisplay(pixd, 1000, 100);
-    pixWrite("/tmp/junkpixm.png", pixmi, IFF_PNG);
-    pixWrite("/tmp/junkpixd.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixm.png", pixmi, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixd.png", pixd, IFF_PNG);
 #endif
 
 #if 0
@@ -118,8 +118,8 @@
 /*    pixInvert(pixd, pixd); */
     pixDisplay(pixmi, 500, 100);
     pixDisplay(pixd, 1000, 100);
-    pixWrite("/tmp/junkpixm.png", pixmi, IFF_PNG);
-    pixWrite("/tmp/junkpixd.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixm.png", pixmi, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixd.png", pixd, IFF_PNG);
 #endif
 
 #if 0
@@ -132,7 +132,7 @@
 
     pixWrite(fileout, pixd, IFF_PNG);
     pixOr(pixd, pixd, pixm);
-    pixWrite("/tmp/junkout1.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkout1.png", pixd, IFF_PNG);
 #endif
 
 #if 0
@@ -147,7 +147,7 @@
 
     pixWrite(fileout, pixd, IFF_PNG);
     pixOr(pixd, pixd, pixm);
-    pixWrite("/tmp/junkout1.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkout1.png", pixd, IFF_PNG);
 #endif
 
         /* use same connectivity to compare with the result of the
@@ -156,7 +156,7 @@
     pixDestroy(&pixd);
     pixd = pixSeedfillMorph(pixs, pixmi, 100, CONNECTIVITY);
     pixOr(pixd, pixd, pixm);
-    pixWrite("/tmp/junkout2.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkout2.png", pixd, IFF_PNG);
 #endif
 
     pixDestroy(&pixs);
diff -Nura leptonica-1.83.1/prog/selio_reg.c leptonica-1.83.1-patch/prog/selio_reg.c
--- leptonica-1.83.1/prog/selio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/selio_reg.c	2024-09-05 14:26:11.063617278 +0800
@@ -84,11 +84,11 @@
 
         /* selaRead() / selaWrite()  */
     sela1 = selaAddBasic(NULL);
-    selaWrite("/tmp/lept/regout/sel.0.sela", sela1);
-    regTestCheckFile(rp, "/tmp/lept/regout/sel.0.sela");  /* 0 */
-    sela2 = selaRead("/tmp/lept/regout/sel.0.sela");
-    selaWrite("/tmp/lept/regout/sel.1.sela", sela2);
-    regTestCheckFile(rp, "/tmp/lept/regout/sel.1.sela");  /* 1 */
+    selaWrite("/data/local/tmp/lept/regout/sel.0.sela", sela1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/sel.0.sela");  /* 0 */
+    sela2 = selaRead("/data/local/tmp/lept/regout/sel.0.sela");
+    selaWrite("/data/local/tmp/lept/regout/sel.1.sela", sela2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/sel.1.sela");  /* 1 */
     regTestCompareFiles(rp, 0, 1);  /* 2 */
     selaDestroy(&sela1);
     selaDestroy(&sela2);
@@ -98,8 +98,8 @@
     pix = selaDisplayInPix(sela1, 31, 3, 15, 4);
     regTestWritePixAndCheck(rp, pix, IFF_PNG);  /* 3 */
     pixDisplayWithTitle(pix, 100, 100, NULL, rp->display);
-    selaWrite("/tmp/lept/regout/sel.3.sela", sela1);
-    regTestCheckFile(rp, "/tmp/lept/regout/sel.3.sela");  /* 4 */
+    selaWrite("/data/local/tmp/lept/regout/sel.3.sela", sela1);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/sel.3.sela");  /* 4 */
     pixDestroy(&pix);
     selaDestroy(&sela1);
 
@@ -113,8 +113,8 @@
     selaAddSel(sela2, sel, NULL, 0);
     sel = selCreateFromString(textsel4, 5, 6, "textsel4");
     selaAddSel(sela2, sel, NULL, 0);
-    selaWrite("/tmp/lept/regout/sel.4.sela", sela2);
-    regTestCheckFile(rp, "/tmp/lept/regout/sel.4.sela");  /* 5 */
+    selaWrite("/data/local/tmp/lept/regout/sel.4.sela", sela2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/sel.4.sela");  /* 5 */
     regTestCompareFiles(rp, 4, 5);  /* 6 */
     selaDestroy(&sela2);
 
diff -Nura leptonica-1.83.1/prog/skewtest.c leptonica-1.83.1-patch/prog/skewtest.c
--- leptonica-1.83.1/prog/skewtest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/skewtest.c	2024-09-05 14:26:11.063617278 +0800
@@ -86,7 +86,7 @@
 
         /* Find the skew angle various ways */
     pix = pixConvertTo1(pixs, BIN_THRESHOLD);
-    pixWrite("/tmp/lept/deskew/binarized.tif", pix, IFF_TIFF_G4);
+    pixWrite("/data/local/tmp/lept/deskew/binarized.tif", pix, IFF_TIFF_G4);
     pixFindSkew(pix, &angle, &conf);
     lept_stderr("pixFindSkew():\n"
                 "  conf = %5.3f, angle = %7.3f degrees\n", conf, angle);
@@ -111,7 +111,7 @@
 
         /* Use top-level */
     pixd = pixDeskew(pixs, 0);
-    pixWriteImpliedFormat("/tmp/lept/deskew/result1", pixd, 0, 0);
+    pixWriteImpliedFormat("/data/local/tmp/lept/deskew/result1", pixd, 0, 0);
     pixDestroy(&pix);
     pixDestroy(&pixd);
 
@@ -121,7 +121,7 @@
     pix = pixConvertTo1(pixs, BIN_THRESHOLD);
     if (pixGetDepth(pixs) == 1) {
         pixd = pixDeskew(pix, DESKEW_REDUCTION);
-        pixWrite("/tmp/lept/deskew/result2", pixd, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/deskew/result2", pixd, IFF_PNG);
     }
     else {
         ret = pixFindSkewSweepAndSearch(pix, &angle, &conf, SWEEP_REDUCTION2,
@@ -136,7 +136,7 @@
                                  L_BRING_IN_WHITE, 0, 0);
             else
                 pixd = pixClone(pixs);
-            pixWrite("/tmp/lept/deskew/result2", pixd, IFF_PNG);
+            pixWrite("/data/local/tmp/lept/deskew/result2", pixd, IFF_PNG);
             pixDestroy(&pixd);
         }
     }
@@ -151,7 +151,7 @@
     startTimer();
     pixd = pixDeskew(pixs, DESKEW_REDUCTION);
     lept_stderr("Time to deskew = %7.4f sec\n", stopTimer());
-    pixWrite("/tmp/lept/deskew/result3", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/deskew/result3", pixd, IFF_PNG);
     pixDestroy(&pixd);
 #endif
 
diff -Nura leptonica-1.83.1/prog/smoothedge_reg.c leptonica-1.83.1-patch/prog/smoothedge_reg.c
--- leptonica-1.83.1/prog/smoothedge_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/smoothedge_reg.c	2024-09-05 14:26:11.063617278 +0800
@@ -71,7 +71,7 @@
 
         /* Display at 2x scaling */
     pixd = pixaDisplayTiledAndScaled(pixa, 32, 2 * (w + 10), 2, 0, 25, 2);
-    pixWrite("/tmp/junkpixd.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/junkpixd.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
     pixaDestroy(&pixa);
     return 0;
@@ -88,10 +88,10 @@
 PIX       *pixt1, *pixt2;
 
     pixMeasureEdgeSmoothness(pixs, side, minjump, minreversal, &jpl,
-                             &jspl, &rpl, "/tmp/junkedge.png");
+                             &jspl, &rpl, "/data/local/tmp/junkedge.png");
     lept_stderr("side = %d: jpl = %6.3f, jspl = %6.3f, rpl = %6.3f\n",
                 side, jpl, jspl, rpl);
-    pixt1 = pixRead("/tmp/junkedge.png");
+    pixt1 = pixRead("/data/local/tmp/junkedge.png");
     pixt2 = pixAddBorder(pixt1, 10, 0);  /* 10 pixel white border */
     pixaAddPix(pixa, pixt2, L_INSERT);
     pixDestroy(&pixt1);
diff -Nura leptonica-1.83.1/prog/sorttest.c leptonica-1.83.1-patch/prog/sorttest.c
--- leptonica-1.83.1/prog/sorttest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/sorttest.c	2024-09-05 14:26:11.063617278 +0800
@@ -61,14 +61,14 @@
     boxas = boxaSort(boxa, L_SORT_BY_PERIMETER, L_SORT_DECREASING, NULL);
     ns = boxaGetCount(boxas);
     lept_stderr("Number of cc: n = %d, ns = %d\n", n, ns);
-    boxaWrite("/tmp/junkboxa.ba", boxas);
+    boxaWrite("/data/local/tmp/junkboxa.ba", boxas);
 
     for (i = 0; i < n; i++) {
         box = boxaGetBox(boxas, i, L_CLONE);
         pixRenderBox(pixs, box, 2, L_FLIP_PIXELS);
         boxDestroy(&box);
     }
-    pixWrite("/tmp/junkout.png", pixs, IFF_PNG);
+    pixWrite("/data/local/tmp/junkout.png", pixs, IFF_PNG);
     boxaDestroy(&boxa);
     boxaDestroy(&boxas);
 #endif
@@ -81,13 +81,13 @@
     pixas = pixaSort(pixa, L_SORT_BY_Y, L_SORT_INCREASING, NULL, L_CLONE);
     ns = pixaGetCount(pixas);
     lept_stderr("Number of cc: n = %d, ns = %d\n", n, ns);
-    pixaWrite("/tmp/pixa.pa", pixas);
-    pixas2 = pixaRead("/tmp/pixa.pa");
-    pixaWrite("/tmp/pixa2.pa", pixas2);
+    pixaWrite("/data/local/tmp/pixa.pa", pixas);
+    pixas2 = pixaRead("/data/local/tmp/pixa.pa");
+    pixaWrite("/data/local/tmp/pixa2.pa", pixas2);
 
     pixt = pixaDisplayOnLattice(pixas, 100, 100, NULL, NULL);
-    pixWrite("/tmp/sorted.png", pixt, IFF_PNG);
-    boxaWrite("/tmp/boxa.ba", pixas->boxa);
+    pixWrite("/data/local/tmp/sorted.png", pixt, IFF_PNG);
+    boxaWrite("/data/local/tmp/boxa.ba", pixas->boxa);
     pixDestroy(&pixt);
     pixaDestroy(&pixa);
     pixaDestroy(&pixas);
diff -Nura leptonica-1.83.1/prog/string_reg.c leptonica-1.83.1-patch/prog/string_reg.c
--- leptonica-1.83.1/prog/string_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/string_reg.c	2024-09-05 14:26:11.063617278 +0800
@@ -102,14 +102,14 @@
     data1 = arrayReplaceEachSequence((l_uint8 *)str1, size1,
                                      (l_uint8 *)"Destroy", 7,
                                      (l_uint8 *)"####", 4, &size2, &count);
-    l_binaryWrite("/tmp/lept/string/string1.txt", "w", data1, size2);
-    regTestCheckFile(rp, "/tmp/lept/string/string1.txt");  /* 8 */
+    l_binaryWrite("/data/local/tmp/lept/string/string1.txt", "w", data1, size2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/string1.txt");  /* 8 */
     regTestCompareValues(rp, 35, count, 0.0);  /* 9 */
     data2 = arrayReplaceEachSequence((l_uint8 *)str1, size1,
                                      (l_uint8 *)"Destroy", 7,
                                      NULL, 0, &size2, &count);
-    l_binaryWrite("/tmp/lept/string/string2.txt", "w", data2, size2);
-    regTestCheckFile(rp, "/tmp/lept/string/string2.txt");  /* 10 */
+    l_binaryWrite("/data/local/tmp/lept/string/string2.txt", "w", data2, size2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/string2.txt");  /* 10 */
     regTestCompareValues(rp, 35, count, 0.0);  /* 11 */
     lept_free(data1);
     lept_free(data2);
@@ -127,18 +127,18 @@
     str4 = sarrayToString(sa2, 1);
     str5 = sarrayToString(sa3, 0);
     str6 = sarrayToString(sa3, 1);
-    l_binaryWrite("/tmp/lept/string/test1.txt", "w", str1, strlen(str1));
-    l_binaryWrite("/tmp/lept/string/test2.txt", "w", str2, strlen(str2));
-    l_binaryWrite("/tmp/lept/string/test3.txt", "w", str3, strlen(str3));
-    l_binaryWrite("/tmp/lept/string/test4.txt", "w", str4, strlen(str4));
-    l_binaryWrite("/tmp/lept/string/test5.txt", "w", str5, strlen(str5));
-    l_binaryWrite("/tmp/lept/string/test6.txt", "w", str6, strlen(str6));
-    regTestCheckFile(rp, "/tmp/lept/string/test1.txt");  /* 12 */
-    regTestCheckFile(rp, "/tmp/lept/string/test2.txt");  /* 13 */
-    regTestCheckFile(rp, "/tmp/lept/string/test3.txt");  /* 14 */
-    regTestCheckFile(rp, "/tmp/lept/string/test4.txt");  /* 15 */
-    regTestCheckFile(rp, "/tmp/lept/string/test5.txt");  /* 16 */
-    regTestCheckFile(rp, "/tmp/lept/string/test6.txt");  /* 17 */
+    l_binaryWrite("/data/local/tmp/lept/string/test1.txt", "w", str1, strlen(str1));
+    l_binaryWrite("/data/local/tmp/lept/string/test2.txt", "w", str2, strlen(str2));
+    l_binaryWrite("/data/local/tmp/lept/string/test3.txt", "w", str3, strlen(str3));
+    l_binaryWrite("/data/local/tmp/lept/string/test4.txt", "w", str4, strlen(str4));
+    l_binaryWrite("/data/local/tmp/lept/string/test5.txt", "w", str5, strlen(str5));
+    l_binaryWrite("/data/local/tmp/lept/string/test6.txt", "w", str6, strlen(str6));
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test1.txt");  /* 12 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test2.txt");  /* 13 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test3.txt");  /* 14 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test4.txt");  /* 15 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test5.txt");  /* 16 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test6.txt");  /* 17 */
     regTestCompareFiles(rp, 14, 16);  /* 18 */
     lept_free(str0);
     lept_free(str1);
@@ -154,11 +154,11 @@
         /* Test sarray serialization */
     str1 = (char *)l_binaryRead("kernel_reg.c", &size1);
     sa1 = sarrayCreateLinesFromString(str1, 0);
-    sarrayWrite("/tmp/lept/string/test7.txt", sa1);
-    sa2 = sarrayRead("/tmp/lept/string/test7.txt");
-    sarrayWrite("/tmp/lept/string/test8.txt", sa2);
-    regTestCheckFile(rp, "/tmp/lept/string/test7.txt");  /* 19 */
-    regTestCheckFile(rp, "/tmp/lept/string/test8.txt");  /* 20 */
+    sarrayWrite("/data/local/tmp/lept/string/test7.txt", sa1);
+    sa2 = sarrayRead("/data/local/tmp/lept/string/test7.txt");
+    sarrayWrite("/data/local/tmp/lept/string/test8.txt", sa2);
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test7.txt");  /* 19 */
+    regTestCheckFile(rp, "/data/local/tmp/lept/string/test8.txt");  /* 20 */
     regTestCompareFiles(rp, 19, 20);  /* 21 */
     lept_free(str1);
     sarrayDestroy(&sa1);
@@ -169,14 +169,14 @@
          *   - remove the 10 bytes
          *   - recover the 200 bytes and insert back  */
     fileReplaceBytes("kernel_reg.c", 100, 200, (l_uint8 *)"abcdefghij",
-                     sizeof("abcdefghij"), "/tmp/lept/string/junk1.txt");
+                     sizeof("abcdefghij"), "/data/local/tmp/lept/string/junk1.txt");
     str1 = (char *)l_binaryRead("kernel_reg.c", &size1);
-    fileReplaceBytes("/tmp/lept/string/junk1.txt", 100, sizeof("abcdefghij"),
-                     NULL, 0, "/tmp/lept/string/junk2.txt");
+    fileReplaceBytes("/data/local/tmp/lept/string/junk1.txt", 100, sizeof("abcdefghij"),
+                     NULL, 0, "/data/local/tmp/lept/string/junk2.txt");
     str2 = stringCopySegment(str1, 100, 200);
-    fileReplaceBytes("/tmp/lept/string/junk2.txt", 100, 0, (l_uint8 *)str2,
-                     strlen(str2), "/tmp/lept/string/junk3.txt");
-    str3 = (char *)l_binaryRead("/tmp/lept/string/junk3.txt", &size2);
+    fileReplaceBytes("/data/local/tmp/lept/string/junk2.txt", 100, 0, (l_uint8 *)str2,
+                     strlen(str2), "/data/local/tmp/lept/string/junk3.txt");
+    str3 = (char *)l_binaryRead("/data/local/tmp/lept/string/junk3.txt", &size2);
     regTestCompareStrings(rp, (l_uint8 *)str1, size1, (l_uint8 *)str3, size2);
                                                                 /* 22 */
     lept_free(str1);
@@ -185,11 +185,11 @@
 
         /* File splitting by lines */
     str1 = (char *)l_binaryRead("kernel_reg.c", &size1);
-    fileSplitLinesUniform("kernel_reg.c", 3, 1, "/tmp/lept/string/split",
+    fileSplitLinesUniform("kernel_reg.c", 3, 1, "/data/local/tmp/lept/string/split",
                           ".txt");
     str2 = NULL;
     for (i = 0; i < 3; i++) {  /* put the pieces back together */
-        snprintf(fname, sizeof(fname), "/tmp/lept/string/split_%d.txt", i);
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/string/split_%d.txt", i);
         str3 = (char *)l_binaryRead(fname, &size2);
         stringJoinIP(&str2, str3);
         lept_free(str3);
diff -Nura leptonica-1.83.1/prog/stringtemplate1.txt leptonica-1.83.1-patch/prog/stringtemplate1.txt
--- leptonica-1.83.1/prog/stringtemplate1.txt	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/stringtemplate1.txt	2024-09-05 14:26:11.063617278 +0800
@@ -73,16 +73,16 @@
 ---    case 0:
 ---        data1 = decodeBase64(l_strdata_0, strlen(l_strdata_0), &size1);
 ---        data2 = zlibUncompress(data1, size1, &size2);
----        l_binaryWrite("/tmp/lept/auto/data.bin", "w", data2, size2);
----        result = (void *)pixaRead("/tmp/lept/auto/data.bin");
+---        l_binaryWrite("/data/local/tmp/lept/auto/data.bin", "w", data2, size2);
+---        result = (void *)pixaRead("/data/local/tmp/lept/auto/data.bin");
 ---        lept_free(data1);
 ---        lept_free(data2);
 ---        break;
 ---    case 1:
 ---        data1 = decodeBase64(l_strdata_1, strlen(l_strdata_1), &size1);
 ---        data2 = zlibUncompress(data1, size1, &size2);
----        l_binaryWrite("/tmp/lept/auto/data.bin", "w", data2, size2);
----        result = (void *)pixaRead("/tmp/lept/auto/data.bin");
+---        l_binaryWrite("/data/local/tmp/lept/auto/data.bin", "w", data2, size2);
+---        result = (void *)pixaRead("/data/local/tmp/lept/auto/data.bin");
 ---        lept_free(data1);
 ---        lept_free(data2);
 ---        break;
diff -Nura leptonica-1.83.1/prog/tiffpdftest.c leptonica-1.83.1-patch/prog/tiffpdftest.c
--- leptonica-1.83.1/prog/tiffpdftest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/tiffpdftest.c	2024-09-05 14:26:11.063617278 +0800
@@ -67,20 +67,20 @@
     pixa1 = pixaCreate(2);
     pixaAddPix(pixa1, pix1, L_INSERT);
     pixaAddPix(pixa1, pix2, L_INSERT);
-    lept_stderr("Writing /tmp/lept/tiffpdf/set1.pdf\n");
+    lept_stderr("Writing /data/local/tmp/lept/tiffpdf/set1.pdf\n");
     pixaConvertToPdf(pixa1, 100, 1.0, L_G4_ENCODE, 0, NULL,
-        "/tmp/lept/tiffpdf/set1.pdf");
+        "/data/local/tmp/lept/tiffpdf/set1.pdf");
 
         /* Extract the images */
-    lept_rmdir("lept/tmp");
-    lept_mkdir("lept/tmp");
+    lept_rmdir("lept/data/local/tmp");
+    lept_mkdir("lept/data/local/tmp");
     snprintf(buf, sizeof(buf),
-             "pdftoppm -r 300 /tmp/lept/tiffpdf/set1.pdf /tmp/lept/tmp/sevens");
+             "pdftoppm -r 300 /data/local/tmp/lept/tiffpdf/set1.pdf /data/local/tmp/lept/data/local/tmp/sevens");
     ret = system(buf);
 
         /* Re-wrap them */
-    pix1 = pixRead("/tmp/lept/tmp/sevens-1.ppm");
-    pix2 = pixRead("/tmp/lept/tmp/sevens-2.ppm");
+    pix1 = pixRead("/data/local/tmp/lept/data/local/tmp/sevens-1.ppm");
+    pix2 = pixRead("/data/local/tmp/lept/data/local/tmp/sevens-2.ppm");
     pix3 = pixConvertTo1(pix1, 160);
     pix4 = pixConvertTo1(pix2, 160);
     pixCompareBinary(pix3, pix4, L_COMPARE_XOR, &fract, NULL);
@@ -89,22 +89,22 @@
     pixa2 = pixaCreate(2);
     pixaAddPix(pixa2, pix3, L_INSERT);
     pixaAddPix(pixa2, pix4, L_INSERT);
-    lept_stderr("Writing /tmp/lept/tiffpdf/set2.pdf\n");
+    lept_stderr("Writing /data/local/tmp/lept/tiffpdf/set2.pdf\n");
     pixaConvertToPdf(pixa2, 300, 1.0, L_G4_ENCODE, 0, NULL,
-        "/tmp/lept/tiffpdf/set2.pdf");
+        "/data/local/tmp/lept/tiffpdf/set2.pdf");
     pixDestroy(&pix1);
     pixDestroy(&pix2);
 
         /* Extract the images again */
-    lept_rmdir("lept/tmp");
-    lept_mkdir("lept/tmp");
+    lept_rmdir("lept/data/local/tmp");
+    lept_mkdir("lept/data/local/tmp");
     snprintf(buf, sizeof(buf),
-             "pdftoppm -r 300 /tmp/lept/tiffpdf/set2.pdf /tmp/lept/tmp/sevens");
+             "pdftoppm -r 300 /data/local/tmp/lept/tiffpdf/set2.pdf /data/local/tmp/lept/data/local/tmp/sevens");
     ret = system(buf);
 
         /* And wrap them up again */
-    pix1 = pixRead("/tmp/lept/tmp/sevens-1.ppm");
-    pix2 = pixRead("/tmp/lept/tmp/sevens-2.ppm");
+    pix1 = pixRead("/data/local/tmp/lept/data/local/tmp/sevens-1.ppm");
+    pix2 = pixRead("/data/local/tmp/lept/data/local/tmp/sevens-2.ppm");
     pix3 = pixConvertTo1(pix1, 160);
     pix4 = pixConvertTo1(pix2, 160);
     pixCompareBinary(pix3, pix4, L_COMPARE_XOR, &fract, NULL);
@@ -113,9 +113,9 @@
     pixa3 = pixaCreate(2);
     pixaAddPix(pixa3, pix3, L_INSERT);
     pixaAddPix(pixa3, pix4, L_INSERT);
-    lept_stderr("Writing /tmp/lept/tiffpdf/set3.pdf\n");
+    lept_stderr("Writing /data/local/tmp/lept/tiffpdf/set3.pdf\n");
     pixaConvertToPdf(pixa3, 300, 1.0, L_G4_ENCODE, 0, NULL,
-        "/tmp/lept/tiffpdf/set3.pdf");
+        "/data/local/tmp/lept/tiffpdf/set3.pdf");
     pixDestroy(&pix1);
     pixDestroy(&pix2);
 
diff -Nura leptonica-1.83.1/prog/trctest.c leptonica-1.83.1-patch/prog/trctest.c
--- leptonica-1.83.1/prog/trctest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/trctest.c	2024-09-05 14:26:11.063617278 +0800
@@ -27,7 +27,7 @@
 /*
  * trctest.c
  *
- *   Example: trctest wet-day.jpg 3.1 50 160 /tmp/junk.png
+ *   Example: trctest wet-day.jpg 3.1 50 160 /data/local/tmp/junk.png
  */
 
 #ifdef HAVE_CONFIG_H
diff -Nura leptonica-1.83.1/prog/underlinetest.c leptonica-1.83.1-patch/prog/underlinetest.c
--- leptonica-1.83.1/prog/underlinetest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/underlinetest.c	2024-09-05 14:26:11.063617278 +0800
@@ -87,7 +87,7 @@
     lept_stderr("\n");
 
     pixd = pixaDisplayTiledInColumns(pixa, 4, 0.6, 20, 2);
-    pixWrite("/tmp/lept/underline/result.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/underline/result.png", pixd, IFF_PNG);
     pixDisplay(pixd, 100, 100);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
diff -Nura leptonica-1.83.1/prog/warpertest.c leptonica-1.83.1-patch/prog/warpertest.c
--- leptonica-1.83.1/prog/warpertest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/warpertest.c	2024-09-05 14:26:11.063617278 +0800
@@ -85,9 +85,9 @@
     pixDestroy(&pixs);
 
     pixaConvertToPdf(pixa, 100, 1.0, L_JPEG_ENCODE, 0, "warp.pdf",
-                     "/tmp/lept/warp/warp.pdf");
+                     "/data/local/tmp/lept/warp/warp.pdf");
     pixd = pixaDisplayTiledInRows(pixa, 32, 2000, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/warp/warp.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/warp/warp.jpg", pixd, IFF_JFIF_JPEG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 #endif
@@ -123,9 +123,9 @@
     pixDestroy(&pixs);
 
     pixaConvertToPdf(pixa, 100, 1.0, L_FLATE_ENCODE, 0, "quad_vshear.pdf",
-                     "/tmp/lept/warp/quad_vshear.pdf");
+                     "/data/local/tmp/lept/warp/quad_vshear.pdf");
     pixd = pixaDisplayTiledInRows(pixa, 32, 2000, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/warp/quad_vshear.jpg", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/warp/quad_vshear.jpg", pixd, IFF_PNG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 #endif
@@ -153,9 +153,9 @@
     pixDestroy(&pixs);
 
     pixaConvertToPdf(pixa, 100, 1.0, L_JPEG_ENCODE, 0, "linear_hstretch.pdf",
-                     "/tmp/lept/warp/linear_hstretch.pdf");
+                     "/data/local/tmp/lept/warp/linear_hstretch.pdf");
     pixd = pixaDisplayTiledInRows(pixa, 32, 2500, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/warp/linear_hstretch.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/warp/linear_hstretch.jpg", pixd, IFF_JFIF_JPEG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 #endif
@@ -183,9 +183,9 @@
     pixDestroy(&pixs);
 
     pixaConvertToPdf(pixa, 100, 1.0, L_JPEG_ENCODE, 0, "quad_hstretch.pdf",
-                     "/tmp/lept/warp/quad_hstretch.pdf");
+                     "/data/local/tmp/lept/warp/quad_hstretch.pdf");
     pixd = pixaDisplayTiledInRows(pixa, 32, 2500, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/warp/quad_hstretch.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/warp/quad_hstretch.jpg", pixd, IFF_JFIF_JPEG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 #endif
@@ -213,9 +213,9 @@
     pixDestroy(&pixs);
 
     pixaConvertToPdf(pixa, 100, 1.0, L_JPEG_ENCODE, 0, "hshear.pdf",
-                     "/tmp/lept/warp/hshear.pdf");
+                     "/data/local/tmp/lept/warp/hshear.pdf");
     pixd = pixaDisplayTiledInRows(pixa, 32, 2500, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/warp/hshear.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/warp/hshear.jpg", pixd, IFF_JFIF_JPEG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 #endif
@@ -243,9 +243,9 @@
 
     pixDestroy(&pixs);
     pixaConvertToPdf(pixa, 100, 1.0, L_JPEG_ENCODE, 0, "vshear.pdf",
-                     "/tmp/lept/warp/vshear.pdf");
+                     "/data/local/tmp/lept/warp/vshear.pdf");
     pixd = pixaDisplayTiledInRows(pixa, 32, 2500, 1.0, 0, 20, 2);
-    pixWrite("/tmp/lept/warp/vshear.jpg", pixd, IFF_JFIF_JPEG);
+    pixWrite("/data/local/tmp/lept/warp/vshear.jpg", pixd, IFF_JFIF_JPEG);
     pixaDestroy(&pixa);
     pixDestroy(&pixd);
 #endif
diff -Nura leptonica-1.83.1/prog/webpanimio_reg.c leptonica-1.83.1-patch/prog/webpanimio_reg.c
--- leptonica-1.83.1/prog/webpanimio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/webpanimio_reg.c	2024-09-05 14:26:11.067617200 +0800
@@ -85,9 +85,9 @@
     pixa = pixaCreate(6);
     pixaAddPix(pixa, pix1, L_COPY);
     pixaAddPix(pixa, pix2, L_COPY);
-    pixaWriteWebPAnim("/tmp/lept/webpanim/margeanim.webp", pixa, niters,
+    pixaWriteWebPAnim("/data/local/tmp/lept/webpanim/margeanim.webp", pixa, niters,
                       duration, 80, 0);
-    regTestCheckFile(rp, "/tmp/lept/webpanim/margeanim.webp");
+    regTestCheckFile(rp, "/data/local/tmp/lept/webpanim/margeanim.webp");
     pixaDestroy(&pixa);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
diff -Nura leptonica-1.83.1/prog/webpio_reg.c leptonica-1.83.1-patch/prog/webpio_reg.c
--- leptonica-1.83.1/prog/webpio_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/webpio_reg.c	2024-09-05 14:26:11.067617200 +0800
@@ -102,7 +102,7 @@
     pixs = pixRead(fname);
     lept_stderr("Time to read jpg: %7.3f\n", stopTimer());
     startTimer();
-    snprintf(buf, sizeof(buf), "/tmp/lept/webp/webpio.%d.webp", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/webp/webpio.%d.webp", rp->index + 1);
     pixWrite(buf, pixs, IFF_WEBP);
     lept_stderr("Time to write webp: %7.3f\n", stopTimer());
     regTestCheckFile(rp, buf);
@@ -130,11 +130,11 @@
 PIX       *pixs, *pix1;
 
     pixs = pixRead(fname);
-    snprintf(buf, sizeof(buf), "/tmp/lept/webp/webpio.%d.webp", rp->index + 1);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/webp/webpio.%d.webp", rp->index + 1);
     if (lossless) startTimer();
-    pixWriteWebP("/tmp/lept/webp/junk.webp", pixs, quality, lossless);
+    pixWriteWebP("/data/local/tmp/lept/webp/junk.webp", pixs, quality, lossless);
     if (lossless) lept_stderr("Lossless write: %7.3f sec\n", stopTimer());
-    pix1 = pixRead("/tmp/lept/webp/junk.webp");
+    pix1 = pixRead("/data/local/tmp/lept/webp/junk.webp");
     pixGetPSNR(pixs, pix1, 4, &psnr);
     if (lossless)
         lept_stderr("lossless; psnr should be 1000: psnr = %7.3f\n", psnr);
diff -Nura leptonica-1.83.1/prog/wordboxes_reg.c leptonica-1.83.1-patch/prog/wordboxes_reg.c
--- leptonica-1.83.1/prog/wordboxes_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/wordboxes_reg.c	2024-09-05 14:26:11.067617200 +0800
@@ -116,9 +116,9 @@
     pix2 = pixClipRectangle(pix1, box1, NULL);
     box2 = boxCreate(150, 130, 1500, 355);
     pixFindWordAndCharacterBoxes(pix2, box2, 130, &boxa1, &boxaa1,
-                                 "/tmp/lept/testboxes");
-    pix3 = pixRead("/tmp/lept/testboxes/words.png");
-    pix4 = pixRead("/tmp/lept/testboxes/chars.png");
+                                 "/data/local/tmp/lept/testboxes");
+    pix3 = pixRead("/data/local/tmp/lept/testboxes/words.png");
+    pix4 = pixRead("/data/local/tmp/lept/testboxes/chars.png");
     regTestWritePixAndCheck(rp, pix3, IFF_PNG);  /* 16 */
     regTestWritePixAndCheck(rp, pix4, IFF_PNG);  /* 17 */
     pixDisplayWithTitle(pix3, 200, 1000, NULL, rp->display);
@@ -251,10 +251,10 @@
 
         /* Find the adjacent boxes and their distances */
     boxaFindNearestBoxes(boxa1, L_NON_NEGATIVE, 0, &naai, &naad);
-    numaaWrite("/tmp/lept/regout/index.naa", naai);
-    regTestCheckFile(rp, "/tmp/lept/regout/index.naa");
-    numaaWrite("/tmp/lept/regout/dist.naa", naad);
-    regTestCheckFile(rp, "/tmp/lept/regout/dist.naa");
+    numaaWrite("/data/local/tmp/lept/regout/index.naa", naai);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/index.naa");
+    numaaWrite("/data/local/tmp/lept/regout/dist.naa", naad);
+    regTestCheckFile(rp, "/data/local/tmp/lept/regout/dist.naa");
 
         /* For a few boxes, show the (up to 4) adjacent boxes */
     n = boxaGetCount(boxa1);
diff -Nura leptonica-1.83.1/prog/writetext_reg.c leptonica-1.83.1-patch/prog/writetext_reg.c
--- leptonica-1.83.1/prog/writetext_reg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/writetext_reg.c	2024-09-05 14:26:11.067617200 +0800
@@ -29,7 +29,7 @@
  *
  *   Regression test for writing a block of text in one of 4 locations
  *   relative to a pix.  This tests writing on 8 different types of images.
- *   Output is written to /tmp/lept/regout/pixd[1,2,3,4].png
+ *   Output is written to /data/local/tmp/lept/regout/pixd[1,2,3,4].png
  */
 
 #ifdef HAVE_CONFIG_H
diff -Nura leptonica-1.83.1/prog/yuvtest.c leptonica-1.83.1-patch/prog/yuvtest.c
--- leptonica-1.83.1/prog/yuvtest.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/prog/yuvtest.c	2024-09-05 14:26:11.067617200 +0800
@@ -66,7 +66,7 @@
 
     pixd = pixaDisplayTiledAndScaled(pixa, 32, 755, 1, 0, 20, 2);
     pixDisplay(pixd, 100, 0);
-    pixWrite("/tmp/lept/yuv/yuv1.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/yuv/yuv1.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
     pixaDestroy(&pixa);
 
@@ -81,7 +81,7 @@
 
     pixd = pixaDisplayTiledAndScaled(pixa, 32, 755, 1, 0, 20, 2);
     pixDisplay(pixd, 600, 0);
-    pixWrite("/tmp/lept/yuv/yuv2.png", pixd, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/yuv/yuv2.png", pixd, IFF_PNG);
     pixDestroy(&pixd);
     pixaDestroy(&pixa);
     bmfDestroy(&bmf);
diff -Nura leptonica-1.83.1/README.html leptonica-1.83.1-patch/README.html
--- leptonica-1.83.1/README.html	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/README.html	2024-09-05 14:26:11.067617200 +0800
@@ -415,10 +415,10 @@
        -fsanitize=fuzzer,memory,undefined"
 
    When an oss-fuzz issue has been created, download the Reproducer
-   Testcase file (e.g, name it "/tmp/payload").  To run one of the
+   Testcase file (e.g, name it "/data/local/tmp/payload").  To run one of the
    fuzzing executables in bin/fuzzer, e.g., pix4_fuzzer:
        cd ../../prog/fuzzing
-       ../../bin/fuzzer/pix4_fuzzer /tmp/payload
+       ../../bin/fuzzer/pix4_fuzzer /data/local/tmp/payload
 
 5. The 270+ programs in the prog directory are an integral part of this
    package.  They can be divided into four groups:
diff -Nura leptonica-1.83.1/src/baseline.c leptonica-1.83.1-patch/src/baseline.c
--- leptonica-1.83.1/src/baseline.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/baseline.c	2024-09-05 14:26:11.071617122 +0800
@@ -157,8 +157,8 @@
 
     if (pixadb) {  /* show the difference signal */
         lept_mkdir("lept/baseline");
-        gplotSimple1(nadiff, GPLOT_PNG, "/tmp/lept/baseline/diff", "Diff Sig");
-        pix2 = pixRead("/tmp/lept/baseline/diff.png");
+        gplotSimple1(nadiff, GPLOT_PNG, "/data/local/tmp/lept/baseline/diff", "Diff Sig");
+        pix2 = pixRead("/data/local/tmp/lept/baseline/diff.png");
         pixaAddPix(pixadb, pix2, L_INSERT);
     }
 
@@ -206,12 +206,12 @@
     }
 
     if (pixadb) {  /* show the raster locations for the peaks */
-        gplot = gplotCreate("/tmp/lept/baseline/loc", GPLOT_PNG, "Peak locs",
+        gplot = gplotCreate("/data/local/tmp/lept/baseline/loc", GPLOT_PNG, "Peak locs",
                             "rasterline", "height");
         gplotAddPlot(gplot, naloc, naval, GPLOT_POINTS, "locs");
         gplotMakeOutput(gplot);
         gplotDestroy(&gplot);
-        pix2 = pixRead("/tmp/lept/baseline/loc.png");
+        pix2 = pixRead("/data/local/tmp/lept/baseline/loc.png");
         pixaAddPix(pixadb, pix2, L_INSERT);
     }
     numaDestroy(&naval);
@@ -267,7 +267,7 @@
             ptaGetIPt(pta, i + 1, &x2, &y2);
             pixRenderLineArb(pix1, x1, y1, x2, y2, 2, 255, 0, 0);
         }
-        pixWriteDebug("/tmp/lept/baseline/baselines.png", pix1, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/baseline/baselines.png", pix1, IFF_PNG);
         pixaAddPix(pixadb, pixScale(pix1, 0.25, 0.25), L_INSERT);
         pixDestroy(&pix1);
     }
@@ -576,7 +576,7 @@
     if (debug) {
         lept_mkdir("lept/baseline");
         ptaGetArrays(pta, &nax, &nay);
-        gplot = gplotCreate("/tmp/lept/baseline/skew", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/baseline/skew", GPLOT_PNG,
                             "skew as fctn of y", "y (in raster lines from top)",
                             "angle (in degrees)");
         gplotAddPlot(gplot, NULL, naskew, GPLOT_POINTS, "linear lsf");
diff -Nura leptonica-1.83.1/src/binarize.c leptonica-1.83.1-patch/src/binarize.c
--- leptonica-1.83.1/src/binarize.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/binarize.c	2024-09-05 14:26:11.071617122 +0800
@@ -1067,7 +1067,7 @@
     }
     if (debugflag) {
         lept_mkdir("lept/binarize");
-        gplot = gplotCreate("/tmp/lept/binarize", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/binarize", GPLOT_PNG,
                             "number of cc vs. threshold",
                             "threshold", "number of cc");
         gplotAddPlot(gplot, NULL, na4, GPLOT_LINES, "plot 4cc");
@@ -1192,8 +1192,8 @@
 
     if (ppixhisto) {
         lept_mkdir("lept/histo");
-        gplotSimple1(na3, GPLOT_PNG, "/tmp/lept/histo/histo", NULL);
-        *ppixhisto = pixRead("/tmp/lept/histo/histo.png");
+        gplotSimple1(na3, GPLOT_PNG, "/data/local/tmp/lept/histo/histo", NULL);
+        *ppixhisto = pixRead("/data/local/tmp/lept/histo/histo.png");
     }
     if (pnahisto)
         *pnahisto = na3;
diff -Nura leptonica-1.83.1/src/bmf.c leptonica-1.83.1-patch/src/bmf.c
--- leptonica-1.83.1/src/bmf.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/bmf.c	2024-09-05 14:26:11.071617122 +0800
@@ -611,11 +611,11 @@
         pixRenderLine(pix1, 0, yval, pixGetWidth(pix1), yval, 1,
                       L_FLIP_PIXELS);
         if (i == 0 )
-            pixWriteDebug("/tmp/baseline/row0.png", pix1, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/baseline/row0.png", pix1, IFF_PNG);
         else if (i == 1)
-            pixWriteDebug("/tmp/baseline/row1.png", pix1, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/baseline/row1.png", pix1, IFF_PNG);
         else
-            pixWriteDebug("/tmp/baseline/row2.png", pix1, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/baseline/row2.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
 #endif  /* DEBUG_BASELINE */
 
diff -Nura leptonica-1.83.1/src/boxfunc5.c leptonica-1.83.1-patch/src/boxfunc5.c
--- leptonica-1.83.1/src/boxfunc5.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/boxfunc5.c	2024-09-05 14:26:11.071617122 +0800
@@ -138,37 +138,37 @@
     boxaSplitEvenOdd(boxas, 0, &boxae, &boxao);
     if (debug) {
         lept_mkdir("lept/smooth");
-        boxaWriteDebug("/tmp/lept/smooth/boxae.ba", boxae);
-        boxaWriteDebug("/tmp/lept/smooth/boxao.ba", boxao);
+        boxaWriteDebug("/data/local/tmp/lept/smooth/boxae.ba", boxae);
+        boxaWriteDebug("/data/local/tmp/lept/smooth/boxao.ba", boxao);
     }
 
     boxamede = boxaWindowedMedian(boxae, halfwin, debug);
     boxamedo = boxaWindowedMedian(boxao, halfwin, debug);
     if (debug) {
-        boxaWriteDebug("/tmp/lept/smooth/boxamede.ba", boxamede);
-        boxaWriteDebug("/tmp/lept/smooth/boxamedo.ba", boxamedo);
+        boxaWriteDebug("/data/local/tmp/lept/smooth/boxamede.ba", boxamede);
+        boxaWriteDebug("/data/local/tmp/lept/smooth/boxamedo.ba", boxamedo);
     }
 
     boxame = boxaModifyWithBoxa(boxae, boxamede, subflag, maxdiff, extrapixels);
     boxamo = boxaModifyWithBoxa(boxao, boxamedo, subflag, maxdiff, extrapixels);
     if (debug) {
-        boxaWriteDebug("/tmp/lept/smooth/boxame.ba", boxame);
-        boxaWriteDebug("/tmp/lept/smooth/boxamo.ba", boxamo);
+        boxaWriteDebug("/data/local/tmp/lept/smooth/boxame.ba", boxame);
+        boxaWriteDebug("/data/local/tmp/lept/smooth/boxamo.ba", boxamo);
     }
 
     boxad = boxaMergeEvenOdd(boxame, boxamo, 0);
     if (debug) {
         boxaPlotSides(boxas, NULL, NULL, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/smooth/plotsides1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/smooth/plotsides1.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         boxaPlotSides(boxad, NULL, NULL, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/smooth/plotsides2.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/smooth/plotsides2.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         boxaPlotSizes(boxas, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/smooth/plotsizes1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/smooth/plotsizes1.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         boxaPlotSizes(boxad, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/smooth/plotsizes2.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/smooth/plotsizes2.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
 
@@ -247,16 +247,16 @@
     if (debug) {
         lept_mkdir("lept/windowed");
         boxaPlotSides(boxaf, NULL, NULL, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/windowed/plotsides1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/windowed/plotsides1.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         boxaPlotSides(boxad, NULL, NULL, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/windowed/plotsides2.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/windowed/plotsides2.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         boxaPlotSizes(boxaf, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/windowed/plotsizes1.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/windowed/plotsizes1.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         boxaPlotSizes(boxad, NULL, NULL, NULL, &pix1);
-        pixWrite("/tmp/lept/windowed/plotsizes2.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/windowed/plotsizes2.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
 
@@ -743,7 +743,7 @@
     if (pixadb) {
         lept_mkdir("lept/boxa");
         pix1 = pixaDisplayTiledInColumns(pixadb, ncols, 1.0, 30, 2);
-        pixWrite("/tmp/lept/boxa/recon_sides.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/boxa/recon_sides.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
 
@@ -1226,7 +1226,7 @@
  *      (2) If there are invalid boxes (e.g., if only even or odd
  *          indices have valid boxes), this will fill them with the
  *          nearest valid box before plotting.
- *      (3) The plotfiles are put in /tmp/lept/plots/, and are named
+ *      (3) The plotfiles are put in /data/local/tmp/lept/plots/, and are named
  *          either with %plotname or, if NULL, a default name.  If
  *          %plotname is used, make sure it has no whitespace characters.
  * </pre>
@@ -1283,11 +1283,11 @@
 
     lept_mkdir("lept/plots");
     if (plotname) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/plots/sides.%s", plotname);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/plots/sides.%s", plotname);
         snprintf(titlebuf, sizeof(titlebuf), "%s: Box sides vs. box index",
                  plotname);
     } else {
-        snprintf(buf, sizeof(buf), "/tmp/lept/plots/sides.%d", plotid++);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/plots/sides.%d", plotid++);
         snprintf(titlebuf, sizeof(titlebuf), "Box sides vs. box index");
     }
     gplot = gplotCreate(buf, GPLOT_PNG, titlebuf,
@@ -1357,7 +1357,7 @@
  *      (2) If there are invalid boxes (e.g., if only even or odd
  *          indices have valid boxes), this will fill them with the
  *          nearest valid box before plotting.
- *      (3) The plotfiles are put in /tmp/lept/plots/, and are named
+ *      (3) The plotfiles are put in /data/local/tmp/lept/plots/, and are named
  *          either with %plotname or, if NULL, a default name.  If
  *          %plotname is used, make sure it has no whitespace characters.
  * </pre>
@@ -1400,11 +1400,11 @@
 
     lept_mkdir("lept/plots");
     if (plotname) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/plots/size.%s", plotname);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/plots/size.%s", plotname);
         snprintf(titlebuf, sizeof(titlebuf), "%s: Box size vs. box index",
                  plotname);
     } else {
-        snprintf(buf, sizeof(buf), "/tmp/lept/plots/size.%d", plotid++);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/plots/size.%d", plotid++);
         snprintf(titlebuf, sizeof(titlebuf), "Box size vs. box index");
     }
     gplot = gplotCreate(buf, GPLOT_PNG, titlebuf,
diff -Nura leptonica-1.83.1/src/ccthin.c leptonica-1.83.1-patch/src/ccthin.c
--- leptonica-1.83.1/src/ccthin.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/ccthin.c	2024-09-05 14:26:11.071617122 +0800
@@ -457,7 +457,7 @@
         char  buf[32];
         lept_mkdir("/lept/sels");
         pix1 = selaDisplayInPix(sela2, 35, 3, 15, 4);
-        snprintf(buf, sizeof(buf), "/tmp/lept/sels/set%d.png", index);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/sels/set%d.png", index);
         pixWrite(buf, pix1, IFF_PNG);
         pixDisplay(pix1, 100, 100);
         pixDestroy(&pix1);
diff -Nura leptonica-1.83.1/src/classapp.c leptonica-1.83.1-patch/src/classapp.c
--- leptonica-1.83.1/src/classapp.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/classapp.c	2024-09-05 14:26:11.071617122 +0800
@@ -562,7 +562,7 @@
     boxa1 = boxaTransform(boxa1a, 0, 0, 1.0 / scalefact, 1.0 / scalefact);
     if (debugdir) {
         loc = 0;
-        subdir = stringReplaceSubstr(debugdir, "/tmp/", "", &loc, NULL);
+        subdir = stringReplaceSubstr(debugdir, "/data/local/tmp/", "", &loc, NULL);
         lept_mkdir(subdir);
         LEPT_FREE(subdir);
         pix4 = pixConvertTo32(pix2);
diff -Nura leptonica-1.83.1/src/colorseg.c leptonica-1.83.1-patch/src/colorseg.c
--- leptonica-1.83.1/src/colorseg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/colorseg.c	2024-09-05 14:26:11.071617122 +0800
@@ -151,20 +151,20 @@
         return (PIX *)ERROR_PTR("pixd not made", __func__, NULL);
     if (debugflag) {
         lept_mkdir("lept/segment");
-        pixWriteDebug("/tmp/lept/segment/colorseg1.png", pixd, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/segment/colorseg1.png", pixd, IFF_PNG);
     }
 
         /* Phase 2; refinement in pixel assignment */
     countarray = (l_int32 *)LEPT_CALLOC(256, sizeof(l_int32));
     pixAssignToNearestColor(pixd, pixs, NULL, LEVEL_IN_OCTCUBE, countarray);
     if (debugflag)
-        pixWriteDebug("/tmp/lept/segment/colorseg2.png", pixd, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/segment/colorseg2.png", pixd, IFF_PNG);
 
         /* Phase 3: noise removal by separately closing each color */
     pixColorSegmentClean(pixd, selsize, countarray);
     LEPT_FREE(countarray);
     if (debugflag)
-        pixWriteDebug("/tmp/lept/segment/colorseg3.png", pixd, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/segment/colorseg3.png", pixd, IFF_PNG);
 
         /* Phase 4: removal of colors with small population and
          * reassignment of pixels to remaining colors */
diff -Nura leptonica-1.83.1/src/compare.c leptonica-1.83.1-patch/src/compare.c
--- leptonica-1.83.1/src/compare.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/compare.c	2024-09-05 14:26:11.075617043 +0800
@@ -919,14 +919,14 @@
         na = pixGetGrayHistogram(pixt, 1);
         numaGetNonzeroRange(na, TINY, &first, &last);
         nac = numaClipToInterval(na, 0, last);
-        snprintf(buf, sizeof(buf), "/tmp/lept/comp/compare_gray%d", index);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/comp/compare_gray%d", index);
         gplot = gplotCreate(buf, plottype,
                             "Pixel Difference Histogram", "diff val",
                             "number of pixels");
         gplotAddPlot(gplot, NULL, nac, GPLOT_LINES, "gray");
         gplotMakeOutput(gplot);
         gplotDestroy(&gplot);
-        snprintf(buf, sizeof(buf), "/tmp/lept/comp/compare_gray%d.png",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/comp/compare_gray%d.png",
                  index++);
         l_fileDisplay(buf, 100, 100, 1.0);
         numaDestroy(&na);
@@ -1048,7 +1048,7 @@
         narc = numaClipToInterval(nar, 0, last);
         nagc = numaClipToInterval(nag, 0, last);
         nabc = numaClipToInterval(nab, 0, last);
-        snprintf(buf, sizeof(buf), "/tmp/lept/comp/compare_rgb%d", index);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/comp/compare_rgb%d", index);
         gplot = gplotCreate(buf, plottype,
                             "Pixel Difference Histogram", "diff val",
                             "number of pixels");
@@ -1057,7 +1057,7 @@
         gplotAddPlot(gplot, NULL, nabc, GPLOT_LINES, "blue");
         gplotMakeOutput(gplot);
         gplotDestroy(&gplot);
-        snprintf(buf, sizeof(buf), "/tmp/lept/comp/compare_rgb%d.png",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/comp/compare_rgb%d.png",
                  index++);
         l_fileDisplay(buf, 100, 100, 1.0);
         numaDestroy(&nar);
@@ -1415,9 +1415,9 @@
         lept_mkdir("lept/comp");
         numaGetNonzeroRange(nan, 0.0, &first, &last);
         nac = numaClipToInterval(nan, first, last);
-        gplotSimple1(nac, GPLOT_PNG, "/tmp/lept/comp/histo",
+        gplotSimple1(nac, GPLOT_PNG, "/data/local/tmp/lept/comp/histo",
                      "Difference histogram");
-        l_fileDisplay("/tmp/lept/comp/histo.png", 500, 0, 1.0);
+        l_fileDisplay("/data/local/tmp/lept/comp/histo.png", 500, 0, 1.0);
         lept_stderr("\nNonzero values in normalized histogram:");
         numaWriteStderr(nac);
         numaDestroy(&nac);
@@ -2027,9 +2027,9 @@
         }
         fact = L_MAX(2, 1000 / nim);
         pix3 = pixExpandReplicate(pix2, fact);
-        lept_stderr("Writing to /tmp/lept/comp/scorearray.png\n");
+        lept_stderr("Writing to /data/local/tmp/lept/comp/scorearray.png\n");
         lept_mkdir("lept/comp");
-        pixWrite("/tmp/lept/comp/scorearray.png", pix3, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/comp/scorearray.png", pix3, IFF_PNG);
         pixDestroy(&pix2);
         pixDestroy(&pix3);
         *pscores = scores;
@@ -2311,7 +2311,7 @@
     }
 
     if (pixa) {
-        snprintf(buf, sizeof(buf), "/tmp/lept/comp/tiledhistos.%d.pdf",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/comp/tiledhistos.%d.pdf",
                  debugindex);
         lept_stderr("Writing to %s\n", buf);
         pixaConvertToPdf(pixa, 300, 1.0, L_FLATE_ENCODE, 0, NULL, buf);
@@ -2534,7 +2534,7 @@
         numaGetMax(na2, &maxval, NULL);
         na3 = numaTransform(na2, 0, 255.0 / maxval);
         if (pixadebug) {
-            snprintf(buf, sizeof(buf), "/tmp/lept/compplot/plot.%d", i);
+            snprintf(buf, sizeof(buf), "/data/local/tmp/lept/compplot/plot.%d", i);
             gplotSimple1(na3, GPLOT_PNG, buf, "Histos");
         }
 
@@ -2546,7 +2546,7 @@
     if (pixadebug) {
         pix1 = pixaDisplayTiledInColumns(pixa1, nx, 1.0, 30, 2);
         pixaAddPix(pixadebug, pix1, L_INSERT);
-        pixa2 = pixaReadFiles("/tmp/lept/compplot", ".png");
+        pixa2 = pixaReadFiles("/data/local/tmp/lept/compplot", ".png");
         pixa3 = pixaScale(pixa2, 0.4, 0.4);
         pix1 = pixaDisplayTiledInColumns(pixa3, nx, 1.0, 30, 2);
         pixaAddPix(pixadebug, pix1, L_INSERT);
@@ -2750,7 +2750,7 @@
         numaAddNumber(nascore, score);
         minscore = L_MIN(minscore, score);
         if (pixadebug) {
-            snprintf(buf1, sizeof(buf1), "/tmp/lept/comptile/plot.%d", i);
+            snprintf(buf1, sizeof(buf1), "/data/local/tmp/lept/comptile/plot.%d", i);
             gplotSimple2(na1, na2, GPLOT_PNG, buf1, "Histos");
         }
         numaDestroy(&na1);
@@ -2761,7 +2761,7 @@
     if (pixadebug) {
         for (i = 0; i < n; i++) {
             PIX  *pix1, *pix2;
-            snprintf(buf1, sizeof(buf1), "/tmp/lept/comptile/plot.%d.png", i);
+            snprintf(buf1, sizeof(buf1), "/data/local/tmp/lept/comptile/plot.%d.png", i);
             pix1 = pixRead(buf1);
             numaGetFValue(nadist, i, &dist);
             numaGetFValue(nascore, i, &score);
@@ -2771,11 +2771,11 @@
             pixaAddPix(pixadebug, pix2, L_INSERT);
             pixDestroy(&pix1);
         }
-        lept_stderr("Writing to /tmp/lept/comptile/comparegray.pdf\n");
+        lept_stderr("Writing to /data/local/tmp/lept/comptile/comparegray.pdf\n");
         pixaConvertToPdf(pixadebug, 300, 1.0, L_FLATE_ENCODE, 0, NULL,
-                         "/tmp/lept/comptile/comparegray.pdf");
-        numaWriteDebug("/tmp/lept/comptile/scores.na", nascore);
-        numaWriteDebug("/tmp/lept/comptile/dists.na", nadist);
+                         "/data/local/tmp/lept/comptile/comparegray.pdf");
+        numaWriteDebug("/data/local/tmp/lept/comptile/scores.na", nascore);
+        numaWriteDebug("/data/local/tmp/lept/comptile/dists.na", nadist);
     }
 
     bmfDestroy(&bmf);
@@ -3035,7 +3035,7 @@
         na5 = numaTransform(na3, 0, 255.0 / maxval1);
         na6 = numaTransform(na4, 0, 255.0 / maxval2);
         if (pixadebug) {
-            gplotSimple2(na5, na6, GPLOT_PNG, "/tmp/lept/comp/plot1", "Histos");
+            gplotSimple2(na5, na6, GPLOT_PNG, "/data/local/tmp/lept/comp/plot1", "Histos");
         }
 
             /* To compare histograms, use the normalized earthmover distance.
@@ -3057,7 +3057,7 @@
             pix6 = pixScaleToSize(pix4, wscale, 0);
             pixaAddPix(pixa3, pix5, L_INSERT);
             pixaAddPix(pixa3, pix6, L_INSERT);
-            pix7 = pixRead("/tmp/lept/comp/plot1.png");
+            pix7 = pixRead("/data/local/tmp/lept/comp/plot1.png");
             pix8 = pixScaleToSize(pix7, 700, 0);
             snprintf(buf, sizeof(buf), "%5.3f", score);
             pix9 = pixAddTextlines(pix8, bmf, buf, 0x0000ff00, L_ADD_RIGHT);
@@ -3081,8 +3081,8 @@
 
     if (pixadebug) {
         pixaConvertToPdf(pixadebug, 300, 1.0, L_FLATE_ENCODE, 0, NULL,
-                         "/tmp/lept/comp/comparegray.pdf");
-        numaWriteDebug("/tmp/lept/comp/tilescores.na", na7);
+                         "/data/local/tmp/lept/comp/comparegray.pdf");
+        numaWriteDebug("/data/local/tmp/lept/comp/tilescores.na", na7);
     }
 
     bmfDestroy(&bmf);
@@ -3408,10 +3408,10 @@
 
     if (debugflag) {
         pixaConvertToPdf(pixadb, 300, 1.0, L_FLATE_ENCODE, 0, NULL,
-                         "/tmp/lept/comp/compare.pdf");
-        convertFilesToPdf("/tmp/lept/comp", "correl_", 30, 1.0, L_FLATE_ENCODE,
+                         "/data/local/tmp/lept/comp/compare.pdf");
+        convertFilesToPdf("/data/local/tmp/lept/comp", "correl_", 30, 1.0, L_FLATE_ENCODE,
                           0, "Correlation scores at levels 1 through 5",
-                          "/tmp/lept/comp/correl.pdf");
+                          "/data/local/tmp/lept/comp/correl.pdf");
         pixaDestroy(&pixadb);
     }
 
@@ -3533,7 +3533,7 @@
         lept_mkdir("lept/comp");
         pix3 = fpixDisplayMaxDynamicRange(fpix);
         pix4 = pixExpandReplicate(pix3, 20);
-        snprintf(buf, sizeof(buf), "/tmp/lept/comp/correl_%d.png",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/comp/correl_%d.png",
                  debugflag);
         pixWrite(buf, pix4, IFF_PNG);
         pixDestroy(&pix3);
diff -Nura leptonica-1.83.1/src/conncomp.c leptonica-1.83.1-patch/src/conncomp.c
--- leptonica-1.83.1/src/conncomp.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/conncomp.c	2024-09-05 14:26:11.075617043 +0800
@@ -270,7 +270,7 @@
     pixCountPixels(pix1, &iszero, NULL);
     lept_stderr("Number of remaining pixels = %d\n", iszero);
     lept_mkdir("lept/cc");
-    pixWriteDebug("/tmp/lept/cc/remain.png", pix1, IFF_PNG);
+    pixWriteDebug("/data/local/tmp/lept/cc/remain.png", pix1, IFF_PNG);
 #endif  /* DEBUG */
 
         /* Remove old boxa of pixa and replace with a copy */
@@ -360,7 +360,7 @@
     pixCountPixels(pix1, &iszero, NULL);
     lept_stderr("Number of remaining pixels = %d\n", iszero);
     lept_mkdir("lept/cc");
-    pixWriteDebug("/tmp/lept/cc/remain.png", pix1, IFF_PNG);
+    pixWriteDebug("/data/local/tmp/lept/cc/remain.png", pix1, IFF_PNG);
 #endif  /* DEBUG */
 
         /* Cleanup, freeing the fillsegs on each stack */
diff -Nura leptonica-1.83.1/src/dewarp2.c leptonica-1.83.1-patch/src/dewarp2.c
--- leptonica-1.83.1/src/dewarp2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/dewarp2.c	2024-09-05 14:26:11.075617043 +0800
@@ -171,7 +171,7 @@
         lept_rmdir("lept/dewmod");  /* erase previous images */
         lept_mkdir("lept/dewmod");
         pixDisplayWithTitle(pixs, 0, 0, "pixs", 1);
-        pixWriteDebug("/tmp/lept/dewmod/0010.png", pixs, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0010.png", pixs, IFF_PNG);
     }
 
         /* Make initial estimate of centers of textlines */
@@ -185,7 +185,7 @@
         pta = generatePtaFilledCircle(1);
         pix2 = pixGenerateFromPta(pta, 5, 5);
         pix3 = pixDisplayPtaaPattern(NULL, pix1, ptaa1, pix2, 2, 2);
-        pixWriteDebug("/tmp/lept/dewmod/0020.png", pix3, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0020.png", pix3, IFF_PNG);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         pixDestroy(&pix3);
@@ -201,7 +201,7 @@
         pta = generatePtaFilledCircle(1);
         pix2 = pixGenerateFromPta(pta, 5, 5);
         pix3 = pixDisplayPtaaPattern(NULL, pix1, ptaa2, pix2, 2, 2);
-        pixWriteDebug("/tmp/lept/dewmod/0030.png", pix3, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0030.png", pix3, IFF_PNG);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         pixDestroy(&pix3);
@@ -250,16 +250,16 @@
     if (debugfile) {
         dewarpPopulateFullRes(dew, NULL, 0, 0);
         pix1 = fpixRenderContours(dew->fullvdispar, 3.0, 0.15);
-        pixWriteDebug("/tmp/lept/dewmod/0060.png", pix1, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0060.png", pix1, IFF_PNG);
         pixDisplay(pix1, 1000, 0);
         pixDestroy(&pix1);
         if (ret == 0) {
             pix1 = fpixRenderContours(dew->fullhdispar, 3.0, 0.15);
-            pixWriteDebug("/tmp/lept/dewmod/0070.png", pix1, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/lept/dewmod/0070.png", pix1, IFF_PNG);
             pixDisplay(pix1, 1000, 0);
             pixDestroy(&pix1);
         }
-        convertFilesToPdf("/tmp/lept/dewmod", NULL, 135, 1.0, 0, 0,
+        convertFilesToPdf("/data/local/tmp/lept/dewmod", NULL, 135, 1.0, 0, 0,
                           "Dewarp Build Model", debugfile);
         lept_stderr("pdf file: %s\n", debugfile);
     }
@@ -293,8 +293,8 @@
  *          Constraint checking is done after building the models,
  *          and before inserting reference models.
  *      (4) This sets the vsuccess flag to 1 on success.
- *      (5) Pix debug output goes to /tmp/dewvert/ for collection into
- *          a pdf.  Non-pix debug output goes to /tmp.
+ *      (5) Pix debug output goes to /data/local/tmp/dewvert/ for collection into
+ *          a pdf.  Non-pix debug output goes to /data/local/tmp.
  * </pre>
  */
 l_ok
@@ -366,7 +366,7 @@
         pta = generatePtaFilledCircle(1);
         pixcirc = pixGenerateFromPta(pta, 5, 5);
         pix2 = pixDisplayPtaaPattern(NULL, pix1, ptaat, pixcirc, 2, 2);
-        pixWriteDebug("/tmp/lept/dewmod/0041.png", pix2, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0041.png", pix2, IFF_PNG);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
         ptaDestroy(&pta);
@@ -428,8 +428,8 @@
     numaDestroy(&nacurve1);
     numaDestroy(&namidysi);
     if (dew->debug) {
-        numaWriteDebug("/tmp/lept/dewdebug/midys.na", namidys);
-        numaWriteDebug("/tmp/lept/dewdebug/curves.na", nacurves);
+        numaWriteDebug("/data/local/tmp/lept/dewdebug/midys.na", namidys);
+        numaWriteDebug("/data/local/tmp/lept/dewdebug/curves.na", nacurves);
         pix1 = pixConvertTo32(pixdb);
         ptacirc = generatePtaFilledCircle(5);
         pixcirc = pixGenerateFromPta(ptacirc, 11, 11);
@@ -438,7 +438,7 @@
         srand(3);  /* use the same colors for text and reference lines */
         pixRenderMidYs(pix1, namidys, 2);
         pix2 = (rotflag) ? pixRotateOrth(pix1, 3) : pixClone(pix1);
-        pixWriteDebug("/tmp/lept/dewmod/0042.png", pix2, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0042.png", pix2, IFF_PNG);
         pixDisplay(pix2, 0, 0);
         ptaDestroy(&ptacirc);
         pixDestroy(&pixcirc);
@@ -464,7 +464,7 @@
         ptaDestroy(&pta);
     }
     if (dew->debug) {
-        ptaaWriteDebug("/tmp/lept/dewdebug/ptaa3.ptaa", ptaa3, 0);
+        ptaaWriteDebug("/data/local/tmp/lept/dewdebug/ptaa3.ptaa", ptaa3, 0);
     }
 
         /* Generate ptaa4 by taking vertical 'columns' from ptaa3.
@@ -485,7 +485,7 @@
         ptaaAddPta(ptaa4, pta, L_INSERT);
     }
     if (dew->debug) {
-        ptaaWriteDebug("/tmp/lept/dewdebug/ptaa4.ptaa", ptaa4, 0);
+        ptaaWriteDebug("/data/local/tmp/lept/dewdebug/ptaa4.ptaa", ptaa4, 0);
     }
 
         /* Do quadratic fit vertically on each of the pixel columns
@@ -510,11 +510,11 @@
         ptaDestroy(&pta);
     }
     if (dew->debug) {
-        ptaaWriteDebug("/tmp/lept/dewdebug/ptaa5.ptaa", ptaa5, 0);
-        convertFilesToPdf("/tmp/lept/dewmod", "004", 135, 1.0, 0, 0,
+        ptaaWriteDebug("/data/local/tmp/lept/dewdebug/ptaa5.ptaa", ptaa5, 0);
+        convertFilesToPdf("/data/local/tmp/lept/dewmod", "004", 135, 1.0, 0, 0,
                           "Dewarp Vert Disparity",
-                          "/tmp/lept/dewarp/vert_disparity.pdf");
-        lept_stderr("pdf file: /tmp/lept/dewarp/vert_disparity.pdf\n");
+                          "/data/local/tmp/lept/dewarp/vert_disparity.pdf");
+        lept_stderr("pdf file: /data/local/tmp/lept/dewarp/vert_disparity.pdf\n");
     }
 
         /* Save the result in a fpix at the specified subsampling  */
@@ -556,7 +556,7 @@
  *      (3) This sets the hsuccess flag to 1 on success.
  *      (4) Internally in ptal1, ptar1, ptal2, ptar2: x and y are reversed,
  *          so the 'y' value is horizontal distance across the image width.
- *      (5) Debug output goes to /tmp/lept/dewmod/ for collection into a pdf.
+ *      (5) Debug output goes to /data/local/tmp/lept/dewmod/ for collection into a pdf.
  * </pre>
  */
 l_ok
@@ -594,8 +594,8 @@
     if (dew->debug) {
         lept_mkdir("lept/dewdebug");
         lept_mkdir("lept/dewarp");
-        ptaWriteDebug("/tmp/lept/dewdebug/endpts_left1.pta", ptal1, 1);
-        ptaWriteDebug("/tmp/lept/dewdebug/endpts_right1.pta", ptar1, 1);
+        ptaWriteDebug("/data/local/tmp/lept/dewdebug/endpts_left1.pta", ptal1, 1);
+        ptaWriteDebug("/data/local/tmp/lept/dewdebug/endpts_right1.pta", ptar1, 1);
     }
 
         /* Filter the points by x-location to prevent 2-column images
@@ -709,7 +709,7 @@
         pixDisplayPta(pix1, pix1, pta2);
         pixRenderHorizEndPoints(pix1, ptal2, ptar2, 0xff000000);
         pixDisplay(pix1, 600, 800);
-        pixWriteDebug("/tmp/lept/dewmod/0051.png", pix1, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0051.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
 
         pix1 = pixDisplayPta(NULL, dew->pixs, pta1);
@@ -718,11 +718,11 @@
         ptarft = ptaTranspose(ptar3);
         pixRenderHorizEndPoints(pix1, ptalft, ptarft, 0x0000ff00);
         pixDisplay(pix1, 800, 800);
-        pixWriteDebug("/tmp/lept/dewmod/0052.png", pix1, IFF_PNG);
-        convertFilesToPdf("/tmp/lept/dewmod", "005", 135, 1.0, 0, 0,
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0052.png", pix1, IFF_PNG);
+        convertFilesToPdf("/data/local/tmp/lept/dewmod", "005", 135, 1.0, 0, 0,
                           "Dewarp Horiz Disparity",
-                          "/tmp/lept/dewarp/horiz_disparity.pdf");
-        lept_stderr("pdf file: /tmp/lept/dewarp/horiz_disparity.pdf\n");
+                          "/data/local/tmp/lept/dewarp/horiz_disparity.pdf");
+        lept_stderr("pdf file: /data/local/tmp/lept/dewarp/horiz_disparity.pdf\n");
         pixDestroy(&pix1);
         ptaDestroy(&pta1);
         ptaDestroy(&pta2);
@@ -845,9 +845,9 @@
 
     if (debugflag) {
         lept_mkdir("lept/dewmod");
-        pixWriteDebug("/tmp/lept/dewmod/0011.tif", pix1, IFF_TIFF_G4);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0011.tif", pix1, IFF_TIFF_G4);
         pixDisplayWithTitle(pix1, 0, 600, "pix1", 1);
-        pixWriteDebug("/tmp/lept/dewmod/0012.tif", pix2, IFF_TIFF_G4);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0012.tif", pix2, IFF_TIFF_G4);
         pixDisplayWithTitle(pix2, 0, 800, "pix2", 1);
     }
     pixDestroy(&pix1);
@@ -871,7 +871,7 @@
     }
     if (debugflag) {
         pix2 = pixaDisplay(pixa2, w, h);
-        pixWriteDebug("/tmp/lept/dewmod/0013.tif", pix2, IFF_TIFF_G4);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0013.tif", pix2, IFF_TIFF_G4);
         pixDisplayWithTitle(pix2, 0, 1000, "pix2", 1);
         pixDestroy(&pix2);
     }
@@ -890,7 +890,7 @@
     if (debugflag) {
         pix1 = pixCreateTemplate(pixs);
         pix2 = pixDisplayPtaa(pix1, ptaa);
-        pixWriteDebug("/tmp/lept/dewmod/0014.tif", pix2, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0014.tif", pix2, IFF_PNG);
         pixDisplayWithTitle(pix2, 0, 1200, "pix3", 1);
         pixDestroy(&pix1);
         pixDestroy(&pix2);
@@ -1144,8 +1144,8 @@
         }
     }
     if (dew->debug) {
-        ptaWriteDebug("/tmp/lept/dewdebug/endpts_left2.pta", ptal1, 1);
-        ptaWriteDebug("/tmp/lept/dewdebug/endpts_right2.pta", ptar1, 1);
+        ptaWriteDebug("/data/local/tmp/lept/dewdebug/endpts_left2.pta", ptal1, 1);
+        ptaWriteDebug("/data/local/tmp/lept/dewdebug/endpts_right2.pta", ptar1, 1);
     }
 
     n = L_MIN(ptaGetCount(ptal1), ptaGetCount(ptar1));
@@ -1169,8 +1169,8 @@
         return 1;
     }
     if (dew->debug) {
-        ptaWriteDebug("/tmp/lept/dewdebug/endpts_left3.pta", ptal2, 1);
-        ptaWriteDebug("/tmp/lept/dewdebug/endpts_right3.pta", ptar2, 1);
+        ptaWriteDebug("/data/local/tmp/lept/dewdebug/endpts_left3.pta", ptal2, 1);
+        ptaWriteDebug("/data/local/tmp/lept/dewdebug/endpts_right3.pta", ptar2, 1);
     }
 
     *pptalf = ptal2;
@@ -1475,7 +1475,7 @@
  *          of width 50 pixels, and compute every 25 pixels.  Similar results
  *          are obtained counting c.c. that either intersect the window
  *          or are fully contained within it.
- *      (6) Debug output goes to /tmp/lept/dewmod/ for collection into a pdf.
+ *      (6) Debug output goes to /data/local/tmp/lept/dewmod/ for collection into a pdf.
  * </pre>
  */
 l_ok
@@ -1527,9 +1527,9 @@
     }
     if (dew->debug) {
         lept_mkdir("lept/dew");
-        gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/dew/0091", NULL);
-        lept_mv("/tmp/lept/dew/0091.png", "lept/dewmod", NULL, NULL);
-        pixWriteDebug("/tmp/lept/dewmod/0090.png", pix1, IFF_PNG);
+        gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/dew/0091", NULL);
+        lept_mv("/data/local/tmp/lept/dew/0091.png", "lept/dewmod", NULL, NULL);
+        pixWriteDebug("/data/local/tmp/lept/dewmod/0090.png", pix1, IFF_PNG);
     }
     pixDestroy(&pix1);
     boxaDestroy(&boxa2);
@@ -1574,8 +1574,8 @@
     if (dew->debug) {
         L_INFO("Slope-disparity: first = %d, last = %d, fract = %7.3f\n",
                __func__, first, last, fract);
-        gplotSimple1(na2, GPLOT_PNG, "/tmp/lept/dew/0092", NULL);
-        lept_mv("/tmp/lept/dew/0092.png", "lept/dewmod", NULL, NULL);
+        gplotSimple1(na2, GPLOT_PNG, "/data/local/tmp/lept/dew/0092", NULL);
+        lept_mv("/data/local/tmp/lept/dew/0092.png", "lept/dewmod", NULL, NULL);
     }
     if (fract < fractthresh) {
         L_INFO("Small slope-disparity: first = %d, last = %d, fract = %7.3f\n",
@@ -1597,8 +1597,8 @@
     numaDestroy(&na3);
     if (dew->debug) {
         L_INFO("Average background density: %5.1f\n", __func__, aveval);
-        gplotSimple1(na2, GPLOT_PNG, "/tmp/lept/dew/0093", NULL);
-        lept_mv("/tmp/lept/dew/0093.png", "lept/dewmod", NULL, NULL);
+        gplotSimple1(na2, GPLOT_PNG, "/data/local/tmp/lept/dew/0093", NULL);
+        lept_mv("/data/local/tmp/lept/dew/0093.png", "lept/dewmod", NULL, NULL);
     }
 
         /* Fit the normalized density curve to a quartic */
@@ -1609,9 +1609,9 @@
     ptaGetArrays(pta1, &na4, NULL);
     if (dew->debug) {
         gplot = gplotSimpleXY1(na4, na3, GPLOT_LINES, GPLOT_PNG,
-                              "/tmp/lept/dew/0094", NULL);
+                              "/data/local/tmp/lept/dew/0094", NULL);
         gplotDestroy(&gplot);
-        lept_mv("/tmp/lept/dew/0094.png", "lept/dewmod", NULL, NULL);
+        lept_mv("/data/local/tmp/lept/dew/0094.png", "lept/dewmod", NULL, NULL);
     }
     ptaDestroy(&pta1);
 
@@ -1736,7 +1736,7 @@
         lept_mkdir("lept/dewmod");
         lept_mkdir("lept/dewarp");
         pixDisplayWithTitle(pixs, 0, 0, "pixs", 1);
-        pixWriteDebug("/tmp/lept/dewline/001.png", pixs, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewline/001.png", pixs, IFF_PNG);
     }
 
         /* Extract and solidify the horizontal and vertical lines.  We use
@@ -1789,7 +1789,7 @@
         if (debugfile) {
             pix1 = pixConvertTo32(pix);
             pix2 = pixDisplayPtaa(pix1, ptaa1);
-            snprintf(buf, sizeof(buf), "/tmp/lept/dewline/%03d.png", 2 + 2 * i);
+            snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewline/%03d.png", 2 + 2 * i);
             pixWriteDebug(buf, pix2, IFF_PNG);
             pixDestroy(&pix1);
             pixDestroy(&pix2);
@@ -1801,7 +1801,7 @@
         if (debugfile) {
             pix1 = pixConvertTo32(pix);
             pix2 = pixDisplayPtaa(pix1, ptaa2);
-            snprintf(buf, sizeof(buf), "/tmp/lept/dewline/%03d.png", 3 + 2 * i);
+            snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewline/%03d.png", 3 + 2 * i);
             pixWriteDebug(buf, pix2, IFF_PNG);
             pixDestroy(&pix1);
             pixDestroy(&pix2);
@@ -1831,7 +1831,7 @@
                 dew->samphdispar = fpixRotateOrth(dew->sampvdispar, 3);
                 fpixDestroy(&dew->sampvdispar);
                 if (debugfile)
-                    lept_mv("/tmp/lept/dewarp/vert_disparity.pdf",
+                    lept_mv("/data/local/tmp/lept/dewarp/vert_disparity.pdf",
                             "lept/dewarp", "horiz_disparity.pdf", NULL);
             }
             dew->hsuccess = dew->vsuccess;
@@ -1852,17 +1852,17 @@
         if (dew->vsuccess == 1) {
             dewarpPopulateFullRes(dew, NULL, 0, 0);
             pix1 = fpixRenderContours(dew->fullvdispar, 3.0, 0.15);
-            pixWriteDebug("/tmp/lept/dewline/006.png", pix1, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/lept/dewline/006.png", pix1, IFF_PNG);
             pixDisplay(pix1, 1000, 0);
             pixDestroy(&pix1);
         }
         if (dew->hsuccess == 1) {
             pix1 = fpixRenderContours(dew->fullhdispar, 3.0, 0.15);
-            pixWriteDebug("/tmp/lept/dewline/007.png", pix1, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/lept/dewline/007.png", pix1, IFF_PNG);
             pixDisplay(pix1, 1000, 0);
             pixDestroy(&pix1);
         }
-        convertFilesToPdf("/tmp/lept/dewline", NULL, 135, 1.0, 0, 0,
+        convertFilesToPdf("/data/local/tmp/lept/dewline", NULL, 135, 1.0, 0, 0,
                           "Dewarp Build Line Model", debugfile);
         lept_stderr("pdf file: %s\n", debugfile);
     }
diff -Nura leptonica-1.83.1/src/dewarp3.c leptonica-1.83.1-patch/src/dewarp3.c
--- leptonica-1.83.1/src/dewarp3.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/dewarp3.c	2024-09-05 14:26:11.075617043 +0800
@@ -150,8 +150,8 @@
         pixDisplayWithTitle(pixv, 300, 0, "pixv", 1);
         lept_rmdir("lept/dewapply");  /* remove previous images */
         lept_mkdir("lept/dewapply");
-        pixWriteDebug("/tmp/lept/dewapply/001.png", pixs, IFF_PNG);
-        pixWriteDebug("/tmp/lept/dewapply/002.png", pixv, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewapply/001.png", pixs, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewapply/002.png", pixv, IFF_PNG);
     }
 
         /* Optionally, correct for horizontal disparity */
@@ -164,7 +164,7 @@
                 *ppixd = pixh;
                 if (debugfile) {
                     pixDisplayWithTitle(pixh, 600, 0, "pixh", 1);
-                    pixWriteDebug("/tmp/lept/dewapply/003.png", pixh, IFF_PNG);
+                    pixWriteDebug("/data/local/tmp/lept/dewapply/003.png", pixh, IFF_PNG);
                 }
             } else {
                 L_ERROR("horiz disparity failed on page %d\n",
@@ -176,7 +176,7 @@
     if (debugfile) {
         dew1 = dewarpaGetDewarp(dewa, pageno);
         dewarpDebug(dew1, "lept/dewapply", 0);
-        convertFilesToPdf("/tmp/lept/dewapply", NULL, 250, 1.0, 0, 0,
+        convertFilesToPdf("/data/local/tmp/lept/dewapply", NULL, 250, 1.0, 0, 0,
                          "Dewarp Apply Disparity", debugfile);
         lept_stderr("pdf file: %s\n", debugfile);
     }
@@ -571,12 +571,12 @@
         lept_mkdir("lept/dewboxa");
         pix1 = pixConvertTo32(pixs);
         pixRenderBoxaArb(pix1, boxas, 2, 255, 0, 0);
-        pixWriteDebug("/tmp/lept/dewboxa/01.png", pix1, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewboxa/01.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         pixv = pixApplyVertDisparity(dew, pixs, 255);
         pix1 = pixConvertTo32(pixv);
         pixRenderBoxaArb(pix1, boxav, 2, 0, 255, 0);
-        pixWriteDebug("/tmp/lept/dewboxa/02.png", pix1, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/dewboxa/02.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
     }
 
@@ -596,7 +596,7 @@
                     pixh = pixApplyHorizDisparity(dew, pixv, 255);
                     pix1 = pixConvertTo32(pixh);
                     pixRenderBoxaArb(pix1, boxah, 2, 0, 0, 255);
-                    pixWriteDebug("/tmp/lept/dewboxa/03.png", pix1, IFF_PNG);
+                    pixWriteDebug("/data/local/tmp/lept/dewboxa/03.png", pix1, IFF_PNG);
                     pixDestroy(&pixh);
                     pixDestroy(&pix1);
                 }
@@ -608,7 +608,7 @@
         pixDestroy(&pixv);
         dew1 = dewarpaGetDewarp(dewa, pageno);
         dewarpDebug(dew1, "lept/dewapply", 0);
-        convertFilesToPdf("/tmp/lept/dewboxa", NULL, 135, 1.0, 0, 0,
+        convertFilesToPdf("/data/local/tmp/lept/dewboxa", NULL, 135, 1.0, 0, 0,
                          "Dewarp Apply Disparity Boxa", debugfile);
         lept_stderr("Dewarp Apply Disparity Boxa pdf file: %s\n",
                 debugfile);
diff -Nura leptonica-1.83.1/src/dewarp4.c leptonica-1.83.1-patch/src/dewarp4.c
--- leptonica-1.83.1/src/dewarp4.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/dewarp4.c	2024-09-05 14:26:11.075617043 +0800
@@ -249,7 +249,7 @@
         /* Generate the page model */
     dew = dewarpCreate(pixb, 0);
     dewarpaInsertDewarp(dewa, dew);
-    debugfile = (debug) ? "/tmp/lept/dewarp/singlepage_model.pdf" : NULL;
+    debugfile = (debug) ? "/data/local/tmp/lept/dewarp/singlepage_model.pdf" : NULL;
     dewarpBuildPageModel(dew, debugfile);
     dewarpaModelStatus(dewa, 0, &vsuccess, NULL);
     if (vsuccess == 0) {
@@ -259,7 +259,7 @@
     }
 
         /* Apply the page model */
-    debugfile = (debug) ? "/tmp/lept/dewarp/singlepage_apply.pdf" : NULL;
+    debugfile = (debug) ? "/data/local/tmp/lept/dewarp/singlepage_apply.pdf" : NULL;
     ret = dewarpaApplyDisparity(dewa, 0, pixs, 255, 0, 0, ppixd, debugfile);
     if (ret)
         L_ERROR("invalid model; failure to apply disparity\n", __func__);
@@ -955,7 +955,7 @@
         snprintf(buf, sizeof(buf), "Page %d", i);
         pixd = pixAddSingleTextblock(pixt, bmf, buf, 0x0000ff00,
                                      L_ADD_BELOW, NULL);
-        snprintf(buf, sizeof(buf), "/tmp/lept/dewarp1/arrays_%04d.png", i);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/dewarp1/arrays_%04d.png", i);
         pixWriteDebug(buf, pixd, IFF_PNG);
         pixaDestroy(&pixa);
         pixDestroy(&pixt);
@@ -965,9 +965,9 @@
     lept_stderr("\n");
 
     lept_stderr("Generating pdf of contour plots\n");
-    convertFilesToPdf("/tmp/lept/dewarp1", "arrays_", 90, 1.0, L_FLATE_ENCODE,
-                      0, "Disparity arrays", "/tmp/lept/disparity_arrays.pdf");
-    lept_stderr("Output written to: /tmp/lept/disparity_arrays.pdf\n");
+    convertFilesToPdf("/data/local/tmp/lept/dewarp1", "arrays_", 90, 1.0, L_FLATE_ENCODE,
+                      0, "Disparity arrays", "/data/local/tmp/lept/disparity_arrays.pdf");
+    lept_stderr("Output written to: /data/local/tmp/lept/disparity_arrays.pdf\n");
     return 0;
 }
 
@@ -976,7 +976,7 @@
  * \brief   dewarpDebug()
  *
  * \param[in]    dew
- * \param[in]    subdirs   one or more subdirectories of /tmp; e.g., "dew1"
+ * \param[in]    subdirs   one or more subdirectories of /data/local/tmp; e.g., "dew1"
  * \param[in]    index     to help label output images; e.g., the page number
  * \return  0 if OK, 1 on error
  *
@@ -984,7 +984,7 @@
  * Notes:
  *      (1) Prints dewarp fields and generates disparity array contour images.
  *          The contour images are written to file:
- *                /tmp/[subdirs]/pixv_[index].png
+ *                /data/local/tmp/[subdirs]/pixv_[index].png
  * </pre>
  */
 l_ok
@@ -1033,7 +1033,7 @@
 
     dewarpPopulateFullRes(dew, NULL, 0, 0);
     lept_mkdir(subdirs);
-    outdir = pathJoin("/tmp", subdirs);
+    outdir = pathJoin("/data/local/tmp", subdirs);
     if (svd) {
         pixv = fpixRenderContours(dew->fullvdispar, 3.0, 0.15);
         snprintf(fname, sizeof(fname), "%s/pixv_%d.png", outdir, index);
@@ -1133,7 +1133,7 @@
             snprintf(bufstr, sizeof(bufstr), "Page %d; no dewarp\n", i);
         pixt2 = pixAddSingleTextblock(pixt1, bmf, bufstr, 0x0000ff00,
                                       L_ADD_BELOW, 0);
-        snprintf(bufstr, sizeof(bufstr), "/tmp/lept/dewarp_pdfout/%05d", i);
+        snprintf(bufstr, sizeof(bufstr), "/data/local/tmp/lept/dewarp_pdfout/%05d", i);
         pixWriteDebug(bufstr, pixt2, IFF_JFIF_JPEG);
         pixaDestroy(&pixa);
         pixDestroy(&pixs);
@@ -1143,7 +1143,7 @@
     lept_stderr("\n");
 
     lept_stderr("Generating pdf of result\n");
-    convertFilesToPdf("/tmp/lept/dewarp_pdfout", NULL, 100, 1.0, L_JPEG_ENCODE,
+    convertFilesToPdf("/data/local/tmp/lept/dewarp_pdfout", NULL, 100, 1.0, L_JPEG_ENCODE,
                       0, "Dewarp sequence", pdfout);
     lept_stderr("Output written to: %s\n", pdfout);
     bmfDestroy(&bmf);
diff -Nura leptonica-1.83.1/src/environ.h leptonica-1.83.1-patch/src/environ.h
--- leptonica-1.83.1/src/environ.h	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/environ.h	2024-09-05 14:26:11.075617043 +0800
@@ -211,9 +211,9 @@
  * It is desirable on Windows to have all temp files written to the same
  * subdirectory of the Windows <Temp> directory, because files under <Temp>
  * persist after reboot, and the regression tests write a lot of files.
- * We write all test files to /tmp/lept or subdirectories of /tmp/lept.
+ * We write all test files to /data/local/tmp/lept or subdirectories of /data/local/tmp/lept.
  * Windows temp files are specified as in unix, but have the translation
- *        /tmp/lept/xxx  -->   <Temp>/lept/xxx
+ *        /data/local/tmp/lept/xxx  -->   <Temp>/lept/xxx
  *--------------------------------------------------------------------*/
 
 
diff -Nura leptonica-1.83.1/src/finditalic.c leptonica-1.83.1-patch/src/finditalic.c
--- leptonica-1.83.1/src/finditalic.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/finditalic.c	2024-09-05 14:26:11.075617043 +0800
@@ -179,7 +179,7 @@
         PIX   *pix1, *pix2, *pix3;
         pixa1 = pixaCreate(0);
         boxat = pixConnComp(pixm, NULL, 8);
-        boxaWriteDebug("/tmp/lept/ital/ital.ba", boxat);
+        boxaWriteDebug("/data/local/tmp/lept/ital/ital.ba", boxat);
         pixaAddPix(pixa1, pixs, L_COPY);  /* orig */
         pixaAddPix(pixa1, pixsd, L_COPY);  /* seed */
         pix1 = pixConvertTo32(pixm);
@@ -198,7 +198,7 @@
         pixDestroy(&pix2);
         pixDestroy(&pix3);
         pix2 = pixaDisplayTiledInColumns(pixa1, 1, 0.5, 20, 2);
-        snprintf(buf, sizeof(buf), "/tmp/lept/ital/ital.%d.png", type);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ital/ital.%d.png", type);
         pixWriteDebug(buf, pix2, IFF_PNG);
         pixDestroy(&pix2);
 
@@ -209,7 +209,7 @@
         res = pixGetWidth(pixs) / 12;
         L_INFO("resolution = %d\n", __func__, res);
         l_pdfSetDateAndVersion(0);
-        snprintf(buf, sizeof(buf), "/tmp/lept/ital/ital.%d.pdf", type);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/ital/ital.%d.pdf", type);
         pixaConvertToPdf(pixa1, res, 1.0, L_FLATE_ENCODE, 75, "Italic Finder",
                          buf);
         l_pdfSetDateAndVersion(1);
@@ -225,7 +225,7 @@
         upper = L_MAX(30, 3 * size);
         na = pixRunHistogramMorph(pix1, L_RUN_OFF, L_HORIZ, upper);
         pixDestroy(&pix1);
-        gplot = gplotCreate("/tmp/lept/ital/runhisto", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/ital/runhisto", GPLOT_PNG,
                 "Histogram of horizontal runs of white pixels, vs length",
                 "run length", "number of runs");
         gplotAddPlot(gplot, NULL, na, GPLOT_LINES, "plot1");
diff -Nura leptonica-1.83.1/src/flipdetect.c leptonica-1.83.1-patch/src/flipdetect.c
--- leptonica-1.83.1/src/flipdetect.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/flipdetect.c	2024-09-05 14:26:11.079616965 +0800
@@ -618,7 +618,7 @@
         pixAnd(pix1, pix1, pixm);
     pix3 = pixReduceRankBinaryCascade(pix1, 1, 1, 0, 0);
     pixCountPixels(pix3, &countup, NULL);
-    pixDebugFlipDetect("/tmp/lept/orient/up.png", pixs, pix1, debug);
+    pixDebugFlipDetect("/data/local/tmp/lept/orient/up.png", pixs, pix1, debug);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
@@ -631,7 +631,7 @@
         pixAnd(pix1, pix1, pixm);
     pix3 = pixReduceRankBinaryCascade(pix1, 1, 1, 0, 0);
     pixCountPixels(pix3, &countdown, NULL);
-    pixDebugFlipDetect("/tmp/lept/orient/down.png", pixs, pix1, debug);
+    pixDebugFlipDetect("/data/local/tmp/lept/orient/down.png", pixs, pix1, debug);
     pixDestroy(&pix1);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
@@ -645,7 +645,7 @@
         *pconf = 2. * ((nup - ndown) / sqrt(nup + ndown));
 
     if (debug) {
-        if (pixm) pixWriteDebug("/tmp/lept/orient/pixm1.png", pixm, IFF_PNG);
+        if (pixm) pixWriteDebug("/data/local/tmp/lept/orient/pixm1.png", pixm, IFF_PNG);
         lept_stderr("nup = %7.3f, ndown = %7.3f, conf = %7.3f\n",
                 nup, ndown, *pconf);
         if (*pconf > DefaultMinUpDownConf)
@@ -745,7 +745,7 @@
     pix1 = pixHMT(NULL, pix0, sel1);
     pix3 = pixReduceRankBinaryCascade(pix1, 1, 1, 0, 0);
     pixCountPixels(pix3, &count1, NULL);
-    pixDebugFlipDetect("/tmp/lept/orient/right.png", pixs, pix1, debug);
+    pixDebugFlipDetect("/data/local/tmp/lept/orient/right.png", pixs, pix1, debug);
     pixDestroy(&pix1);
     pixDestroy(&pix3);
 
@@ -753,7 +753,7 @@
     pix2 = pixHMT(NULL, pix0, sel2);
     pix3 = pixReduceRankBinaryCascade(pix2, 1, 1, 0, 0);
     pixCountPixels(pix3, &count2, NULL);
-    pixDebugFlipDetect("/tmp/lept/orient/left.png", pixs, pix2, debug);
+    pixDebugFlipDetect("/data/local/tmp/lept/orient/left.png", pixs, pix2, debug);
     pixDestroy(&pix2);
     pixDestroy(&pix3);
 
diff -Nura leptonica-1.83.1/src/flipdetectdwa.c.notused leptonica-1.83.1-patch/src/flipdetectdwa.c.notused
--- leptonica-1.83.1/src/flipdetectdwa.c.notused	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/flipdetectdwa.c.notused	2024-09-05 14:26:11.079616965 +0800
@@ -265,7 +265,7 @@
     if (debug) {
         if (pixm) {
             lept_mkdir("lept/orient");
-            pixWriteDebug("/tmp/lept/orient/pixm2.png", pixm, IFF_PNG);
+            pixWriteDebug("/data/local/tmp/lept/orient/pixm2.png", pixm, IFF_PNG);
         }
         lept_stderr("nup = %7.3f, ndown = %7.3f, conf = %7.3f\n",
                 nup, ndown, *pconf);
diff -Nura leptonica-1.83.1/src/gplot.c leptonica-1.83.1-patch/src/gplot.c
--- leptonica-1.83.1/src/gplot.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/gplot.c	2024-09-05 14:26:11.079616965 +0800
@@ -92,7 +92,7 @@
  *         Specify the root of output files, the output format,
  *         and the title (optional), but not the x and y coordinate labels
  *         or the plot labels.  The plotstyle defaults to GPLOT_LINES.
- *            gplotSimple2(na1, na2, GPLOT_PNG, "/tmp/lept/histo/gray",
+ *            gplotSimple2(na1, na2, GPLOT_PNG, "/data/local/tmp/lept/histo/gray",
  *                         "gray histogram");
  *         Multiple plots can be generated using gplotSimpleN().
  *
@@ -101,7 +101,7 @@
  *         and optionally the title, but not the x and y coordinate labels
  *         or the plot labels.
  *            gplotSimpleXY1(na1, na2, GPLOT_LINES, GPLOT_PNG,
- *                           "/tmp/lept/histo/gray", "gray histogram");
+ *                           "/data/local/tmp/lept/histo/gray", "gray histogram");
  *         Multiple plots can be generated using gplotSimpleXYN().
  *
  *         -- Simple plots returning a pix --
@@ -117,7 +117,7 @@
  *         the title and axis labels.  This does not allow the individual
  *         plots to have plot labels, or to use different plotstyles
  *         for each plot.
- *            Pix *pix = gplotGeneralPix2(na1, na2, "/tmp/lept/histo/gray",
+ *            Pix *pix = gplotGeneralPix2(na1, na2, "/data/local/tmp/lept/histo/gray",
  *                                   GPLOT_LINES, "gray histogram",
  *                                   "pix value", "num pixels");
  *         Multiple plots can be generated using gplotGeneralPixN().
@@ -447,7 +447,7 @@
  *      (2) Along with gplotMakeOutputPix(), these are the only functions
  *          in this file that requires the gnuplot executable to
  *          actually generate the plot.
- *      (3) The command file name for unix is canonical (i.e., directory /tmp)
+ *      (3) The command file name for unix is canonical (i.e., directory /data/local/tmp)
  *          but the temp filename paths in the command file must be correct.
  *      (4) The gnuplot program for Windows is wgnuplot.exe.
  * </pre>
@@ -763,7 +763,7 @@
         return (PIX *)ERROR_PTR("na not defined", __func__, NULL);
 
     lept_mkdir("lept/gplot/pix");
-    snprintf(buf, sizeof(buf), "/tmp/lept/gplot/pix1.%d", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/gplot/pix1.%d", index++);
     gplot = gplotSimpleXY1(NULL, na, GPLOT_LINES, GPLOT_PNG, buf, title);
     if (!gplot)
         return (PIX *)ERROR_PTR("failed to generate plot", __func__, NULL);
@@ -805,7 +805,7 @@
         return (PIX *)ERROR_PTR("both na1, na2 not defined", __func__, NULL);
 
     lept_mkdir("lept/gplot/pix");
-    snprintf(buf, sizeof(buf), "/tmp/lept/gplot/pix2.%d", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/gplot/pix2.%d", index++);
     gplot = gplotSimpleXY2(NULL, na1, na2, GPLOT_LINES, GPLOT_PNG, buf, title);
     if (!gplot)
         return (PIX *)ERROR_PTR("failed to generate plot", __func__, NULL);
@@ -846,7 +846,7 @@
         return (PIX *)ERROR_PTR("naa not defined", __func__, NULL);
 
     lept_mkdir("lept/gplot/pix");
-    snprintf(buf, sizeof(buf), "/tmp/lept/gplot/pixN.%d", index++);
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/gplot/pixN.%d", index++);
     gplot = gplotSimpleXYN(NULL, naa, GPLOT_LINES, GPLOT_PNG, buf, title);
     if (!gplot)
         return (PIX *)ERROR_PTR("failed to generate plot", __func__, NULL);
diff -Nura leptonica-1.83.1/src/gplot.h leptonica-1.83.1-patch/src/gplot.h
--- leptonica-1.83.1/src/gplot.h	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/gplot.h	2024-09-05 14:26:11.079616965 +0800
@@ -36,8 +36,8 @@
  *   We used to support X11 output, but recent versions of gnuplot do not
  *   support the X11 terminal.  To get display to your screen, use
  *   GPLOT_PNG output; e.g.,
- *       gplotSimple1(na, GPLOT_PNG, "/tmp/someroot", ...);
- *       l_fileDisplay("/tmp/someroot.png", ...);
+ *       gplotSimple1(na, GPLOT_PNG, "/data/local/tmp/someroot", ...);
+ *       l_fileDisplay("/data/local/tmp/someroot.png", ...);
  * </pre>
  */
 
diff -Nura leptonica-1.83.1/src/jbclass.c leptonica-1.83.1-patch/src/jbclass.c
--- leptonica-1.83.1/src/jbclass.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/jbclass.c	2024-09-05 14:26:11.079616965 +0800
@@ -1521,14 +1521,14 @@
             L_INFO("Best dilation: %d\n", __func__, L_MAX(3, ibest + 1));
             naseq = numaMakeSequence(1, 1, numaGetCount(nacc));
             pix3 = gplotGeneralPix2(naseq, nacc, GPLOT_LINES,
-                                    "/tmp/lept/jb/numcc",
+                                    "/data/local/tmp/lept/jb/numcc",
                                     "Number of cc vs. horizontal dilation",
                                     "Sel horiz", "Number of cc");
             pixaAddPix(pixadb, pix3, L_INSERT);
             numaDestroy(&naseq);
             naseq = numaMakeSequence(1, 1, numaGetCount(nadiff));
             pix3 = gplotGeneralPix2(naseq, nadiff, GPLOT_LINES,
-                                    "/tmp/lept/jb/diffcc",
+                                    "/data/local/tmp/lept/jb/diffcc",
                                     "Diff count of cc vs. horizontal dilation",
                                     "Sel horiz", "Diff in cc");
             pixaAddPix(pixadb, pix3, L_INSERT);
@@ -2060,7 +2060,7 @@
     jbdata->napage = napage;
     jbdata->ptaul = ptaul;
 
-    LEPT_FREE(data);
+    // LEPT_FREE(data);
     sarrayDestroy(&sa);
     return jbdata;
 }
diff -Nura leptonica-1.83.1/src/morphseq.c leptonica-1.83.1-patch/src/morphseq.c
--- leptonica-1.83.1/src/morphseq.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/morphseq.c	2024-09-05 14:26:11.079616965 +0800
@@ -241,7 +241,7 @@
     }
 
     if (pdfout) {
-        snprintf(fname, sizeof(fname), "/tmp/lept/seq_output_%d.pdf",
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/seq_output_%d.pdf",
                  L_ABS(dispsep));
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, fname, fname);
         pixaDestroy(&pixa);
@@ -407,7 +407,7 @@
     }
 
     if (pdfout) {
-        snprintf(fname, sizeof(fname), "/tmp/lept/seq_output_%d.pdf",
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/seq_output_%d.pdf",
                  L_ABS(dispsep));
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, fname, fname);
         pixaDestroy(&pixa);
@@ -554,7 +554,7 @@
     }
 
     if (pdfout) {
-        snprintf(fname, sizeof(fname), "/tmp/lept/seq_output_%d.pdf",
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/seq_output_%d.pdf",
                  L_ABS(dispsep));
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, fname, fname);
         pixaDestroy(&pixa);
@@ -701,7 +701,7 @@
     }
 
     if (pdfout) {
-        snprintf(fname, sizeof(fname), "/tmp/lept/seq_output_%d.pdf",
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/seq_output_%d.pdf",
                  L_ABS(dispsep));
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, fname, fname);
         pixaDestroy(&pixa);
@@ -1044,7 +1044,7 @@
     }
 
     if (pdfout) {
-        snprintf(fname, sizeof(fname), "/tmp/lept/seq_output_%d.pdf",
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/seq_output_%d.pdf",
                  L_ABS(dispsep));
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, fname, fname);
         pixaDestroy(&pixa);
@@ -1218,7 +1218,7 @@
     }
 
     if (pdfout) {
-        snprintf(fname, sizeof(fname), "/tmp/lept/seq_output_%d.pdf",
+        snprintf(fname, sizeof(fname), "/data/local/tmp/lept/seq_output_%d.pdf",
                  L_ABS(dispsep));
         pixaConvertToPdf(pixa, 0, 1.0, L_FLATE_ENCODE, 0, fname, fname);
         pixaDestroy(&pixa);
diff -Nura leptonica-1.83.1/src/numafunc2.c leptonica-1.83.1-patch/src/numafunc2.c
--- leptonica-1.83.1/src/numafunc2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/numafunc2.c	2024-09-05 14:26:11.083616887 +0800
@@ -2080,7 +2080,7 @@
     if (pnascore) {  /* debug mode */
         lept_stderr("minrange = %d, maxrange = %d\n", minrange, maxrange);
         lept_stderr("minval = %10.0f\n", minval);
-        gplotSimple1(nascore, GPLOT_PNG, "/tmp/lept/nascore",
+        gplotSimple1(nascore, GPLOT_PNG, "/data/local/tmp/lept/nascore",
                      "Score for split distribution");
         *pnascore = nascore;
     } else {
diff -Nura leptonica-1.83.1/src/pageseg.c leptonica-1.83.1-patch/src/pageseg.c
--- leptonica-1.83.1/src/pageseg.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/pageseg.c	2024-09-05 14:26:11.087616808 +0800
@@ -219,7 +219,7 @@
         PTAA     *ptaa;
         ptaa = pixGetOuterBordersPtaa(pixtb);
         lept_mkdir("lept/pageseg");
-        ptaaWriteDebug("/tmp/lept/pageseg/tb_outlines.ptaa", ptaa, 1);
+        ptaaWriteDebug("/data/local/tmp/lept/pageseg/tb_outlines.ptaa", ptaa, 1);
         pix1 = pixRenderRandomCmapPtaa(pixtb, ptaa, 1, 16, 1);
         cmap = pixGetColormap(pix1);
         pixcmapResetColor(cmap, 0, 130, 130, 130);
@@ -233,17 +233,17 @@
         bahm = pixConnComp(pixhm, NULL, 4);
         batm = pixConnComp(pixtm, NULL, 4);
         batb = pixConnComp(pixtb, NULL, 4);
-        boxaWriteDebug("/tmp/lept/pageseg/htmask.boxa", bahm);
-        boxaWriteDebug("/tmp/lept/pageseg/textmask.boxa", batm);
-        boxaWriteDebug("/tmp/lept/pageseg/textblock.boxa", batb);
+        boxaWriteDebug("/data/local/tmp/lept/pageseg/htmask.boxa", bahm);
+        boxaWriteDebug("/data/local/tmp/lept/pageseg/textmask.boxa", batm);
+        boxaWriteDebug("/data/local/tmp/lept/pageseg/textblock.boxa", batb);
         boxaDestroy(&bahm);
         boxaDestroy(&batm);
         boxaDestroy(&batb);
     }
     if (pixadb) {
         pixaConvertToPdf(pixadb, 0, 1.0, 0, 0, "Debug page segmentation",
-                         "/tmp/lept/pageseg/debug.pdf");
-        L_INFO("Writing debug pdf to /tmp/lept/pageseg/debug.pdf\n", __func__);
+                         "/data/local/tmp/lept/pageseg/debug.pdf");
+        L_INFO("Writing debug pdf to /data/local/tmp/lept/pageseg/debug.pdf\n", __func__);
     }
 
     if (ppixhm)
@@ -850,7 +850,7 @@
 #if 0
     if (ppixdebug && nsplit > 0) {
         lept_mkdir("lept/split");
-        gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/split/split", NULL);
+        gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/split/split", NULL);
     }
 #endif
 
@@ -1277,8 +1277,8 @@
     na1 = pixCountByColumn(pix4, NULL);
 
     if (pixadb) {
-        gplotSimple1(na1, GPLOT_PNG, "/tmp/lept/plot", NULL);
-        pix5 = pixRead("/tmp/lept/plot.png");
+        gplotSimple1(na1, GPLOT_PNG, "/data/local/tmp/lept/plot", NULL);
+        pix5 = pixRead("/data/local/tmp/lept/plot.png");
         pixaAddPix(pixadb, pix5, L_INSERT);
     }
 
@@ -2319,11 +2319,11 @@
         if (box5) pixRenderBoxArb(pixdb2, box5, 4, 0, 0, 255);
         pixaAddPix(pixadb, pixdb2, L_INSERT);
         res = pixGetXRes(pixs);
-        L_INFO("Writing debug files to /tmp/lept/rect/\n", __func__);
+        L_INFO("Writing debug files to /data/local/tmp/lept/rect/\n", __func__);
         pixaConvertToPdf(pixadb, res, 1.0, L_DEFAULT_ENCODE, 75, NULL,
-                        "/tmp/lept/rect/fitrect.pdf");
+                        "/data/local/tmp/lept/rect/fitrect.pdf");
         pix1 = pixaDisplayTiledAndScaled(pixadb, 32, 800, 1, 0, 40, 2);
-        pixWrite("/tmp/lept/rect/fitrect.png", pix1, IFF_PNG);
+        pixWrite("/data/local/tmp/lept/rect/fitrect.png", pix1, IFF_PNG);
         pixDestroy(&pix1);
         pixDestroy(&pixdb1);
         pixaDestroy(&pixadb);
diff -Nura leptonica-1.83.1/src/pix3.c leptonica-1.83.1-patch/src/pix3.c
--- leptonica-1.83.1/src/pix3.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/pix3.c	2024-09-05 14:26:11.087616808 +0800
@@ -1385,9 +1385,9 @@
     if (debug) {
         lept_rmdir("masknear");  /* erase previous images */
         lept_mkdir("masknear");
-        pixWriteDebug("/tmp/masknear/input.png", pix1, IFF_PNG);
-        pixWriteDebug("/tmp/masknear/adjusted.png", pix2, IFF_PNG);
-        pixWriteDebug("/tmp/masknear/outerfive.png", pix3, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/masknear/input.png", pix1, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/masknear/adjusted.png", pix2, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/masknear/outerfive.png", pix3, IFF_PNG);
         lept_stderr("Input box; with adjusted sides; clipped\n");
         boxPrintStreamInfo(stderr, box);
         boxPrintStreamInfo(stderr, box1);
diff -Nura leptonica-1.83.1/src/pix4.c leptonica-1.83.1-patch/src/pix4.c
--- leptonica-1.83.1/src/pix4.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/pix4.c	2024-09-05 14:26:11.087616808 +0800
@@ -2604,7 +2604,7 @@
     }
     if (array && pixadb) {
         pixd = pixDisplayColorArray(array, nbins, 200, 5, fontsize);
-        pixWriteDebug("/tmp/lept/regout/rankhisto.png", pixd, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/regout/rankhisto.png", pixd, IFF_PNG);
         pixDestroy(&pixd);
     }
 
@@ -3465,7 +3465,7 @@
 
     if (ppixdb) {
         lept_mkdir("lept/redout");
-        gplot = gplotCreate("/tmp/lept/redout/histplot", GPLOT_PNG, "Histogram",
+        gplot = gplotCreate("/data/local/tmp/lept/redout/histplot", GPLOT_PNG, "Histogram",
                             "Grayscale value", "Number of pixels");
         gplotAddPlot(gplot, NULL, na, GPLOT_LINES, NULL);
         nax = numaMakeConstant(thresh, 2);
diff -Nura leptonica-1.83.1/src/pixafunc2.c leptonica-1.83.1-patch/src/pixafunc2.c
--- leptonica-1.83.1/src/pixafunc2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/pixafunc2.c	2024-09-05 14:26:11.087616808 +0800
@@ -865,7 +865,7 @@
     }
     if (boxaWriteMem(&data, &size, boxa) == 0)
         pixSetText(pixd, (char *)data);  /* data is ascii */
-    LEPT_FREE(data);
+    // LEPT_FREE(data);
     boxaDestroy(&boxa);
 
     numaDestroy(&nainrow);
@@ -990,7 +990,7 @@
         /* Save the boxa in the text field of the output pix */
     if (boxaWriteMem(&data, &size, boxa) == 0)
         pixSetText(pixd, (char *)data);  /* data is ascii */
-    LEPT_FREE(data);
+    // LEPT_FREE(data);
 
     pixaDestroy(&pixa2);
     return pixd;
@@ -2329,7 +2329,7 @@
  * <pre>
  * Notes:
  *      (1) For each requested output, %nsplit files are written into
- *          directory /tmp/lept/split/.
+ *          directory /data/local/tmp/lept/split/.
  *      (2) This is useful when a pixa is so large that the images
  *          are not conveniently displayed as a single tiled image at
  *          full resolution.
@@ -2370,17 +2370,17 @@
             pixDestroy(&pix1);
         }
         if (write_pixa) {
-            snprintf(buf, sizeof(buf), "/tmp/lept/split/split%d.pa", i + 1);
+            snprintf(buf, sizeof(buf), "/data/local/tmp/lept/split/split%d.pa", i + 1);
             pixaWriteDebug(buf, pixa1);
         }
         if (write_pix) {
-            snprintf(buf, sizeof(buf), "/tmp/lept/split/split%d.tif", i + 1);
+            snprintf(buf, sizeof(buf), "/data/local/tmp/lept/split/split%d.tif", i + 1);
             pix1 = pixaDisplayTiledInRows(pixa1, 1, outwidth, 1.0, 0, 20, 2);
             pixWriteDebug(buf, pix1, IFF_TIFF_G4);
             pixDestroy(&pix1);
         }
         if (write_pdf) {
-            snprintf(buf, sizeof(buf), "/tmp/lept/split/split%d.pdf", i + 1);
+            snprintf(buf, sizeof(buf), "/data/local/tmp/lept/split/split%d.pdf", i + 1);
             pixaConvertToPdf(pixa1, 0, 1.0, L_G4_ENCODE, 0, buf, buf);
         }
         pixaDestroy(&pixa1);
@@ -2405,7 +2405,7 @@
  *                          use 0 for no border
  * \param[in]    fontsize   to print tail of filename with image.  Valid set is
  *                          {4,6,8,10,12,14,16,18,20}.  Use 0 to disable.
- * \param[in]    outdir     subdirectory of /tmp to put N-up tiled images
+ * \param[in]    outdir     subdirectory of /data/local/tmp to put N-up tiled images
  * \return  0 if OK, 1 on error
  *
  * <pre>
diff -Nura leptonica-1.83.1/src/pixcomp.c leptonica-1.83.1-patch/src/pixcomp.c
--- leptonica-1.83.1/src/pixcomp.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/pixcomp.c	2024-09-05 14:26:11.087616808 +0800
@@ -2330,7 +2330,7 @@
  * \brief   pixacompWriteFiles()
  *
  * \param[in]    pixac
- * \param[in]    subdir    subdirectory of /tmp
+ * \param[in]    subdir    subdirectory of /data/local/tmp
  * \return  0 if OK, 1 on error
  */
 l_ok
@@ -2350,7 +2350,7 @@
     n = pixacompGetCount(pixac);
     for (i = 0; i < n; i++) {
         pixc = pixacompGetPixcomp(pixac, i, L_NOCOPY);
-        snprintf(buf, sizeof(buf), "/tmp/%s/%03d", subdir, i);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/%s/%03d", subdir, i);
         pixcompWriteFile(buf, pixc);
     }
     return 0;
diff -Nura leptonica-1.83.1/src/ptafunc1.c leptonica-1.83.1-patch/src/ptafunc1.c
--- leptonica-1.83.1/src/ptafunc1.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/ptafunc1.c	2024-09-05 14:26:11.091616730 +0800
@@ -1858,13 +1858,13 @@
             numaAddNumber(nab, bval);
         }
 
-        snprintf(buffer, sizeof(buffer), "/tmp/lept/plot/%03d", count++);
+        snprintf(buffer, sizeof(buffer), "/data/local/tmp/lept/plot/%03d", count++);
         rtitle = stringJoin("Red: ", title);
         gplotSimple1(nar, outformat, buffer, rtitle);
-        snprintf(buffer, sizeof(buffer), "/tmp/lept/plot/%03d", count++);
+        snprintf(buffer, sizeof(buffer), "/data/local/tmp/lept/plot/%03d", count++);
         gtitle = stringJoin("Green: ", title);
         gplotSimple1(nag, outformat, buffer, gtitle);
-        snprintf(buffer, sizeof(buffer), "/tmp/lept/plot/%03d", count++);
+        snprintf(buffer, sizeof(buffer), "/data/local/tmp/lept/plot/%03d", count++);
         btitle = stringJoin("Blue: ", title);
         gplotSimple1(nab, outformat, buffer, btitle);
         numaDestroy(&nar);
@@ -1885,7 +1885,7 @@
             numaAddNumber(na, (l_float32)val);
         }
 
-        snprintf(buffer, sizeof(buffer), "/tmp/lept/plot/%03d", count++);
+        snprintf(buffer, sizeof(buffer), "/data/local/tmp/lept/plot/%03d", count++);
         gplotSimple1(na, outformat, buffer, title);
         numaDestroy(&na);
     }
diff -Nura leptonica-1.83.1/src/readbarcode.c leptonica-1.83.1-patch/src/readbarcode.c
--- leptonica-1.83.1/src/readbarcode.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/readbarcode.c	2024-09-05 14:26:11.091616730 +0800
@@ -234,7 +234,7 @@
 
 #if  DEBUG_DESKEW
     pix3 = pixaDisplayTiledInRows(pixa, 8, 1000, 1.0, 0, 30, 2);
-    pixWrite("/tmp/lept/pix3.png", pix3, IFF_PNG);
+    pixWrite("/data/local/tmp/lept/pix3.png", pix3, IFF_PNG);
     pixDestroy(&pix3);
 #endif  /* DEBUG_DESKEW */
 
@@ -742,7 +742,7 @@
 
     if (debugflag) {
         lept_mkdir("lept/barcode");
-        gplot = gplotCreate("/tmp/lept/barcode/signal", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/barcode/signal", GPLOT_PNG,
                             "Pixel values", "dist in pixels", "value");
         gplotAddPlot(gplot, nax, nay, GPLOT_LINES, "plot 1");
         gplotMakeOutput(gplot);
@@ -891,7 +891,7 @@
 
     if (debugflag) {
         lept_mkdir("lept/barcode");
-        gplot = gplotCreate("/tmp/lept/barcode/histw", GPLOT_PNG,
+        gplot = gplotCreate("/data/local/tmp/lept/barcode/histw", GPLOT_PNG,
                             "Raw width histogram", "Width", "Number");
         gplotAddPlot(gplot, NULL, naehist, GPLOT_LINES, "plot black");
         gplotAddPlot(gplot, NULL, naohist, GPLOT_LINES, "plot white");
diff -Nura leptonica-1.83.1/src/readfile.c leptonica-1.83.1-patch/src/readfile.c
--- leptonica-1.83.1/src/readfile.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/readfile.c	2024-09-05 14:26:11.091616730 +0800
@@ -79,21 +79,21 @@
 #include "allheaders.h"
 
     /* Output files for ioFormatTest(). */
-static const char *FILE_BMP  =  "/tmp/lept/format/file.bmp";
-static const char *FILE_PNG  =  "/tmp/lept/format/file.png";
-static const char *FILE_PNM  =  "/tmp/lept/format/file.pnm";
-static const char *FILE_G3   =  "/tmp/lept/format/file_g3.tif";
-static const char *FILE_G4   =  "/tmp/lept/format/file_g4.tif";
-static const char *FILE_RLE  =  "/tmp/lept/format/file_rle.tif";
-static const char *FILE_PB   =  "/tmp/lept/format/file_packbits.tif";
-static const char *FILE_LZW  =  "/tmp/lept/format/file_lzw.tif";
-static const char *FILE_ZIP  =  "/tmp/lept/format/file_zip.tif";
-static const char *FILE_TIFF_JPEG =  "/tmp/lept/format/file_jpeg.tif";
-static const char *FILE_TIFF =  "/tmp/lept/format/file.tif";
-static const char *FILE_JPG  =  "/tmp/lept/format/file.jpg";
-static const char *FILE_GIF  =  "/tmp/lept/format/file.gif";
-static const char *FILE_WEBP =  "/tmp/lept/format/file.webp";
-static const char *FILE_JP2K =  "/tmp/lept/format/file.jp2";
+static const char *FILE_BMP  =  "/data/local/tmp/lept/format/file.bmp";
+static const char *FILE_PNG  =  "/data/local/tmp/lept/format/file.png";
+static const char *FILE_PNM  =  "/data/local/tmp/lept/format/file.pnm";
+static const char *FILE_G3   =  "/data/local/tmp/lept/format/file_g3.tif";
+static const char *FILE_G4   =  "/data/local/tmp/lept/format/file_g4.tif";
+static const char *FILE_RLE  =  "/data/local/tmp/lept/format/file_rle.tif";
+static const char *FILE_PB   =  "/data/local/tmp/lept/format/file_packbits.tif";
+static const char *FILE_LZW  =  "/data/local/tmp/lept/format/file_lzw.tif";
+static const char *FILE_ZIP  =  "/data/local/tmp/lept/format/file_zip.tif";
+static const char *FILE_TIFF_JPEG =  "/data/local/tmp/lept/format/file_jpeg.tif";
+static const char *FILE_TIFF =  "/data/local/tmp/lept/format/file.tif";
+static const char *FILE_JPG  =  "/data/local/tmp/lept/format/file.jpg";
+static const char *FILE_GIF  =  "/data/local/tmp/lept/format/file.gif";
+static const char *FILE_WEBP =  "/data/local/tmp/lept/format/file.webp";
+static const char *FILE_JP2K =  "/data/local/tmp/lept/format/file.jp2";
 
     /* There are two jp2 formats, and two codecs associated with them:
      *    OPJ_CODEC_J2K (L_J2K_CODEC) is associated with JP2K_CODESTREAM
@@ -1244,7 +1244,7 @@
  * <pre>
  * Notes:
  *      (1) This writes and reads a set of output files losslessly
- *          in different formats to /tmp/format/, and tests that the
+ *          in different formats to /data/local/tmp/format/, and tests that the
  *          result before and after is unchanged.
  *      (2) This should work properly on input images of any depth,
  *          with and without colormaps.
diff -Nura leptonica-1.83.1/src/recogident.c leptonica-1.83.1-patch/src/recogident.c
--- leptonica-1.83.1/src/recogident.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/recogident.c	2024-09-05 14:26:11.095616652 +0800
@@ -342,7 +342,7 @@
     boxaDestroy(&boxa1);
     if (pixa) {  /* debug */
         pix3 = pixaDisplayTiledInColumns(pixa, 1, 1.0, 20, 2);
-        snprintf(buf, sizeof(buf), "/tmp/lept/recog/decode-%d.png", ind++);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/recog/decode-%d.png", ind++);
         pixWrite(buf, pix3, IFF_PNG);
         pixaDestroy(&pixa);
         pixDestroy(&pix3);
@@ -828,7 +828,7 @@
         lept_mkdir("lept/recog");
         pixt1 = fpixDisplayMaxDynamicRange(fpix);
         pixt2 = pixExpandReplicate(pixt1, 5);
-        snprintf(buf, sizeof(buf), "/tmp/lept/recog/junkbs_%d.png", debugflag);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/recog/junkbs_%d.png", debugflag);
         pixWrite(buf, pixt2, IFF_PNG);
         pixDestroy(&pixt1);
         pixDestroy(&pixt2);
diff -Nura leptonica-1.83.1/src/recogtrain.c leptonica-1.83.1-patch/src/recogtrain.c
--- leptonica-1.83.1/src/recogtrain.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/recogtrain.c	2024-09-05 14:26:11.095616652 +0800
@@ -1984,14 +1984,14 @@
     if (display) {
         lept_mkdir("lept/recog");
         pix = pixaaDisplayByPixa(recog->pixaa_u, 50, 1.0, 20, 20, 0);
-        snprintf(buf, sizeof(buf), "/tmp/lept/recog/templates_u.%d.png", index);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/recog/templates_u.%d.png", index);
         pixWriteDebug(buf, pix, IFF_PNG);
         pixDisplay(pix, 0, 200 * index);
         pixDestroy(&pix);
         if (recog->train_done) {
             pix = pixaaDisplayByPixa(recog->pixaa, 50, 1.0, 20, 20, 0);
             snprintf(buf, sizeof(buf),
-                     "/tmp/lept/recog/templates.%d.png", index);
+                     "/data/local/tmp/lept/recog/templates.%d.png", index);
             pixWriteDebug(buf, pix, IFF_PNG);
             pixDisplay(pix, 800, 200 * index);
             pixDestroy(&pix);
@@ -2068,7 +2068,7 @@
     recog->pixdb_ave = pixaaDisplayByPixa(paa2, 50, 1.0, 20, 20, 0);
     if (debug % 2) {
         lept_mkdir("lept/recog");
-        pixWriteDebug("/tmp/lept/recog/templ_match.png", recog->pixdb_ave,
+        pixWriteDebug("/data/local/tmp/lept/recog/templ_match.png", recog->pixdb_ave,
                       IFF_PNG);
         pixDisplay(recog->pixdb_ave, 100, 100);
     }
diff -Nura leptonica-1.83.1/src/regutils.c leptonica-1.83.1-patch/src/regutils.c
--- leptonica-1.83.1/src/regutils.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/regutils.c	2024-09-05 14:26:11.099616574 +0800
@@ -101,7 +101,7 @@
  *              the results to a file.  The output, which includes
  *              logging of all reg test failures plus a SUCCESS or
  *              FAILURE summary for each test, is appended to the file
- *              "/tmp/lept/reg_results.txt.  For this case, as in Case 2,
+ *              "/data/local/tmp/lept/reg_results.txt.  For this case, as in Case 2,
  *              the display field in rp is set to FALSE, preventing
  *              image display.
  *          Case 2:
@@ -154,7 +154,7 @@
         /* Only open a stream to a temp file for the 'compare' case */
     if (argc == 1 || !strcmp(argv[1], "compare")) {
         rp->mode = L_REG_COMPARE;
-        rp->tempfile = stringNew("/tmp/lept/regout/regtest_output.txt");
+        rp->tempfile = stringNew("/data/local/tmp/lept/regout/regtest_output.txt");
         rp->fp = fopenWriteStream(rp->tempfile, "wb");
         if (rp->fp == NULL) {
             rp->success = FALSE;
@@ -200,7 +200,7 @@
  * <pre>
  * Notes:
  *      (1) This copies anything written to the temporary file to the
- *          output file /tmp/lept/reg_results.txt.
+ *          output file /data/local/tmp/lept/reg_results.txt.
  * </pre>
  */
 l_ok
@@ -243,7 +243,7 @@
         snprintf(result, sizeof(result), "FAILURE: %s_reg\n", rp->testname);
     message = stringJoin(text, result);
     LEPT_FREE(text);
-    results_file = stringNew("/tmp/lept/reg_results.txt");
+    results_file = stringNew("/data/local/tmp/lept/reg_results.txt");
     fileAppendString(results_file, message);
     retval = (rp->success) ? 0 : 1;
     LEPT_FREE(results_file);
@@ -326,15 +326,15 @@
         /* Output on failure */
     if (!same) {
             /* Write the two strings to file */
-        snprintf(buf, sizeof(buf), "/tmp/lept/regout/string1_%d_%zu",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/string1_%d_%zu",
                  rp->index, bytes1);
         l_binaryWrite(buf, "w", string1, bytes1);
-        snprintf(buf, sizeof(buf), "/tmp/lept/regout/string2_%d_%zu",
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/string2_%d_%zu",
                  rp->index, bytes2);
         l_binaryWrite(buf, "w", string2, bytes2);
 
             /* Report comparison failure */
-        snprintf(buf, sizeof(buf), "/tmp/lept/regout/string*_%d_*", rp->index);
+        snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/string*_%d_*", rp->index);
         if (rp->fp) {
             fprintf(rp->fp,
                     "Failure in %s_reg: string comp for index %d; "
@@ -474,14 +474,14 @@
  *           * "compare": compares %localname contents with the golden file
  *           * "display": this does nothing
  *      (2) The canonical format of the golden filenames is:
- *            /tmp/lept/golden/[root of main name]_golden.[index].
+ *            /data/local/tmp/lept/golden/[root of main name]_golden.[index].
  *                                                       [ext of localname]
  *          e.g.,
- *             /tmp/lept/golden/maze_golden.0.png
- *      (3) The local file can be made in any subdirectory of /tmp/lept,
- *          including /tmp/lept/regout/.
+ *             /data/local/tmp/lept/golden/maze_golden.0.png
+ *      (3) The local file can be made in any subdirectory of /data/local/tmp/lept,
+ *          including /data/local/tmp/lept/regout/.
  *      (4) It is important to add an extension to the local name, such as
- *             /tmp/lept/maze/file1.png    (extension ".png")
+ *             /data/local/tmp/lept/maze/file1.png    (extension ".png")
  *          because the extension is added to the name of the golden file.
  * </pre>
  */
@@ -512,7 +512,7 @@
 
         /* Generate the golden file name; used in 'generate' and 'compare' */
     splitPathAtExtension(localname, NULL, &ext);
-    snprintf(namebuf, sizeof(namebuf), "/tmp/lept/golden/%s_golden.%02d%s",
+    snprintf(namebuf, sizeof(namebuf), "/data/local/tmp/lept/golden/%s_golden.%02d%s",
              rp->testname, rp->index, ext);
     LEPT_FREE(ext);
 
@@ -585,10 +585,10 @@
  * Notes:
  *      (1) This only does something in "compare" mode.
  *      (2) The canonical format of the golden filenames is:
- *            /tmp/lept/golden/[root of main name]_golden.[index].
+ *            /data/local/tmp/lept/golden/[root of main name]_golden.[index].
  *                                                      [ext of localname]
  *          e.g.,
- *            /tmp/lept/golden/maze_golden.0.png
+ *            /data/local/tmp/lept/golden/maze_golden.0.png
  * </pre>
  */
 l_ok
@@ -617,7 +617,7 @@
 
         /* Generate the golden file names */
     snprintf(namebuf, sizeof(namebuf), "%s_golden.%02d", rp->testname, index1);
-    sa = getSortedPathnamesInDirectory("/tmp/lept/golden", namebuf, 0, 0);
+    sa = getSortedPathnamesInDirectory("/data/local/tmp/lept/golden", namebuf, 0, 0);
     if (sarrayGetCount(sa) != 1) {
         sarrayDestroy(&sa);
         rp->success = FALSE;
@@ -628,7 +628,7 @@
     sarrayDestroy(&sa);
 
     snprintf(namebuf, sizeof(namebuf), "%s_golden.%02d", rp->testname, index2);
-    sa = getSortedPathnamesInDirectory("/tmp/lept/golden", namebuf, 0, 0);
+    sa = getSortedPathnamesInDirectory("/data/local/tmp/lept/golden", namebuf, 0, 0);
     if (sarrayGetCount(sa) != 1) {
         sarrayDestroy(&sa);
         rp->success = FALSE;
@@ -673,9 +673,9 @@
  *             (b) make a local file and "compare" with the golden file
  *             (c) make a local file and "display" the results
  *      (2) The canonical format of the local filename is:
- *            /tmp/lept/regout/[root of main name].[count].[format extension]
+ *            /data/local/tmp/lept/regout/[root of main name].[count].[format extension]
  *          e.g., for scale_reg,
- *            /tmp/lept/regout/scale.0.png
+ *            /data/local/tmp/lept/regout/scale.0.png
  *          The golden file name mirrors this in the usual way.
  *      (3) The check is done between the written files, which requires
  *          the files to be identical. The exception is for GIF, which
@@ -705,7 +705,7 @@
     changeFormatForMissingLib(&format);
 
         /* Generate the local file name */
-    snprintf(namebuf, sizeof(namebuf), "/tmp/lept/regout/%s.%02d.%s",
+    snprintf(namebuf, sizeof(namebuf), "/data/local/tmp/lept/regout/%s.%02d.%s",
              rp->testname, rp->index + 1, ImageFileFormatExtensions[format]);
 
         /* Write the local file */
@@ -739,9 +739,9 @@
  *             (b) make a local file and "compare" with the golden file
  *             (c) make a local file and "display" the results
  *      (2) The canonical format of the local filename is:
- *            /tmp/lept/regout/[root of main name].[count].[ext]
+ *            /data/local/tmp/lept/regout/[root of main name].[count].[ext]
  *          e.g., for the first boxaa in quadtree_reg,
- *            /tmp/lept/regout/quadtree.0.baa
+ *            /data/local/tmp/lept/regout/quadtree.0.baa
  *          The golden file name mirrors this in the usual way.
  *      (3) The data can be anything.  It is most useful for serialized
  *          output of data, such as boxa, pta, etc.
@@ -767,7 +767,7 @@
     }
 
         /* Generate the local file name */
-    snprintf(namebuf, sizeof(namebuf), "/tmp/lept/regout/%s.%02d.%s",
+    snprintf(namebuf, sizeof(namebuf), "/data/local/tmp/lept/regout/%s.%02d.%s",
              rp->testname, rp->index + 1, ext);
 
         /* Write the local file */
@@ -812,7 +812,7 @@
         return (char *)ERROR_PTR("rp not defined", __func__, NULL);
 
     ind = (index >= 0) ? index : rp->index;
-    snprintf(buf, sizeof(buf), "/tmp/lept/regout/%s.%02d.%s",
+    snprintf(buf, sizeof(buf), "/data/local/tmp/lept/regout/%s.%02d.%s",
              rp->testname, ind, ImageFileFormatExtensions[format]);
     return stringNew(buf);
 }
diff -Nura leptonica-1.83.1/src/regutils.h leptonica-1.83.1-patch/src/regutils.h
--- leptonica-1.83.1/src/regutils.h	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/regutils.h	2024-09-05 14:26:11.099616574 +0800
@@ -49,7 +49,7 @@
  *           Using 'compare' on the command line is optional.
  *
  *       Case 2: distance_reg generate
- *           This generates golden files in /tmp for the reg test.
+ *           This generates golden files in /data/local/tmp for the reg test.
  *
  *       Case 3: distance_reg display
  *           This runs the test but makes no comparison of the output
diff -Nura leptonica-1.83.1/src/sel2.c leptonica-1.83.1-patch/src/sel2.c
--- leptonica-1.83.1/src/sel2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/sel2.c	2024-09-05 14:26:11.099616574 +0800
@@ -513,11 +513,11 @@
         lept_mkdir("lept/sel");
         pixaGetPixDimensions(pixa, 0, &w, NULL, NULL);
         pixt = pixaDisplayTiledAndScaled(pixa, 32, w, 1, 0, 10, 2);
-        pixWriteDebug("/tmp/lept/sel/xsel1.png", pixt, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/sel/xsel1.png", pixt, IFF_PNG);
         pixDisplay(pixt, 0, 100);
         pixDestroy(&pixt);
         pixt = selaDisplayInPix(sela, 15, 2, 20, 1);
-        pixWriteDebug("/tmp/lept/sel/xsel2.png", pixt, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/sel/xsel2.png", pixt, IFF_PNG);
         pixDisplay(pixt, 500, 100);
         pixDestroy(&pixt);
         selaWriteStream(stderr, sela);
@@ -643,11 +643,11 @@
         lept_mkdir("lept/sel");
         pixaGetPixDimensions(pixa, 0, &w, NULL, NULL);
         pixt = pixaDisplayTiledAndScaled(pixa, 32, w, 4, 0, 10, 2);
-        pixWriteDebug("/tmp/lept/sel/tsel1.png", pixt, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/sel/tsel1.png", pixt, IFF_PNG);
         pixDisplay(pixt, 0, 100);
         pixDestroy(&pixt);
         pixt = selaDisplayInPix(sela, 15, 2, 20, 4);
-        pixWriteDebug("/tmp/lept/sel/tsel2.png", pixt, IFF_PNG);
+        pixWriteDebug("/data/local/tmp/lept/sel/tsel2.png", pixt, IFF_PNG);
         pixDisplay(pixt, 500, 100);
         pixDestroy(&pixt);
         selaWriteStream(stderr, sela);
diff -Nura leptonica-1.83.1/src/stringcode.c leptonica-1.83.1-patch/src/stringcode.c
--- leptonica-1.83.1/src/stringcode.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/stringcode.c	2024-09-05 14:26:11.099616574 +0800
@@ -205,7 +205,7 @@
  *
  * \param[in]    filein    containing filenames of serialized data
  * \param[in]    fileno    integer that labels the two output files
- * \param[in]    outdir    [optional] if null, files are made in /tmp/lept/auto
+ * \param[in]    outdir    [optional] if null, files are made in /data/local/tmp/lept/auto
  * \return  0 if OK, 1 on error
  *
  * <pre>
@@ -324,7 +324,7 @@
  *
  * \param[in,out]  pstrcode   destroys and sets to null after .c and .h files
  *                            have been generated
- * \param[in]      outdir     [optional] if NULL, make files in /tmp/lept/auto
+ * \param[in]      outdir     [optional] if NULL, make files in /data/local/tmp/lept/auto
  * \return     0 if OK; 1 on error
  */
 l_int32
@@ -344,8 +344,8 @@
         return ERROR_INT("No input data", __func__, 1);
     strcode = *pstrcode;
     if (!outdir) {
-        L_INFO("no outdir specified; writing to /tmp/lept/auto\n", __func__);
-        realoutdir = stringNew("/tmp/lept/auto");
+        L_INFO("no outdir specified; writing to /data/local/tmp/lept/auto\n", __func__);
+        realoutdir = stringNew("/data/local/tmp/lept/auto");
     } else {
         realoutdir = stringNew(outdir);
     }
diff -Nura leptonica-1.83.1/src/stringtemplate1.txt leptonica-1.83.1-patch/src/stringtemplate1.txt
--- leptonica-1.83.1/src/stringtemplate1.txt	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/stringtemplate1.txt	2024-09-05 14:26:11.099616574 +0800
@@ -73,16 +73,16 @@
 ---    case 0:
 ---        data1 = decodeBase64(l_strdata_0, strlen(l_strdata_0), &size1);
 ---        data2 = zlibUncompress(data1, size1, &size2);
----        l_binaryWrite("/tmp/lept/auto/data.bin", "w", data2, size2);
----        result = (void *)pixaRead("/tmp/lept/auto/data.bin");
+---        l_binaryWrite("/data/local/tmp/lept/auto/data.bin", "w", data2, size2);
+---        result = (void *)pixaRead("/data/local/tmp/lept/auto/data.bin");
 ---        lept_free(data1);
 ---        lept_free(data2);
 ---        break;
 ---    case 1:
 ---        data1 = decodeBase64(l_strdata_1, strlen(l_strdata_1), &size1);
 ---        data2 = zlibUncompress(data1, size1, &size2);
----        l_binaryWrite("/tmp/lept/auto/data.bin", "w", data2, size2);
----        result = (void *)pixaRead("/tmp/lept/auto/data.bin");
+---        l_binaryWrite("/data/local/tmp/lept/auto/data.bin", "w", data2, size2);
+---        result = (void *)pixaRead("/data/local/tmp/lept/auto/data.bin");
 ---        lept_free(data1);
 ---        lept_free(data2);
 ---        break;
diff -Nura leptonica-1.83.1/src/utils2.c leptonica-1.83.1-patch/src/utils2.c
--- leptonica-1.83.1/src/utils2.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/utils2.c	2024-09-05 14:26:11.099616574 +0800
@@ -134,16 +134,16 @@
  *  This is important:
  *  (1) With the exception of splitPathAtDirectory(), splitPathAtExtension()
   *     and genPathname(), all input pathnames must have unix separators.
- *  (2) On Windows, when you specify a read or write to "/tmp/...",
+ *  (2) On Windows, when you specify a read or write to "/data/local/tmp/...",
  *      the filename is rewritten to use the Windows temp directory:
- *         /tmp  ==>   [Temp]...    (Windows)
+ *         /data/local/tmp  ==>   [Temp]...    (Windows)
  *  (3) This filename rewrite, along with the conversion from unix
  *      to Windows pathnames, happens in genPathname().
  *  (4) Use fopenReadStream() and fopenWriteStream() to open files,
  *      because these use genPathname() to find the platform-dependent
  *      filenames.  Likewise for l_binaryRead() and l_binaryWrite().
  *  (5) For moving, copying and removing files and directories that are in
- *      subdirectories of /tmp, use the lept_*() file system shell wrappers:
+ *      subdirectories of /data/local/tmp, use the lept_*() file system shell wrappers:
  *         lept_mkdir(), lept_rmdir(), lept_mv(), lept_rm() and lept_cp().
  *  (6) Use the lept_*() C library wrappers.  These work properly on
  *      Windows, where the same DLL must perform complementary operations
@@ -165,7 +165,7 @@
  *      fopenWriteStream(); these call genPathname() to ensure that
  *      if it is a temp file, the correct path is used.  To indicate
  *      that this is a temp file, the application is written with the
- *      root directory of the path in a canonical form: "/tmp".
+ *      root directory of the path in a canonical form: "/data/local/tmp".
  *  (9) Why is it that multi-platform directory functions like lept_mkdir()
  *      and lept_rmdir(), as well as associated file functions like
  *      lept_rm(), lept_mv() and lept_cp(), only work in the temp dir?
@@ -1778,7 +1778,7 @@
  *      (3) The output filenames are in the form:
  *               <rootpath>_N.<ext>, N = 1, ... n
  *      (4) This handles the temp directory pathname conversion on Windows:
- *              /tmp  ==>  [Windows Temp directory]
+ *              /data/local/tmp  ==>  [Windows Temp directory]
  *      (5) Files can also be sharded into sets of lines by the program 'split':
  *              split -n l/<n> <filename>
  *          Using 'split', the resulting files have approximately equal
@@ -1857,7 +1857,7 @@
  *      (1) This should be used whenever you want to run fopen() to
  *          read from a stream.  Never call fopen() directory.
  *      (2) This handles the temp directory pathname conversion on Windows:
- *              /tmp  ==>  [Windows Temp directory]
+ *              /data/local/tmp  ==>  [Windows Temp directory]
  * </pre>
  */
 FILE *
@@ -1898,7 +1898,7 @@
  *      (1) This should be used whenever you want to run fopen() to
  *          write or append to a stream.  Never call fopen() directory.
  *      (2) This handles the temp directory pathname conversion on Windows:
- *              /tmp  ==>  [Windows Temp directory]
+ *              /data/local/tmp  ==>  [Windows Temp directory]
  * </pre>
  */
 FILE *
@@ -2116,21 +2116,21 @@
 
 /*--------------------------------------------------------------------*
  *                Multi-platform file system operations               *
- *         [ These only write to /tmp or its subdirectories ]         *
+ *         [ These only write to /data/local/tmp or its subdirectories ]         *
  *--------------------------------------------------------------------*/
 /*!
  * \brief   lept_mkdir()
  *
- * \param[in]    subdir    of /tmp or its equivalent on Windows
+ * \param[in]    subdir    of /data/local/tmp or its equivalent on Windows
  * \return  0 on success, non-zero on failure
  *
  * <pre>
  * Notes:
  *      (1) %subdir is a partial path that can consist of one or more
  *          directories.
- *      (2) This makes any subdirectories of /tmp that are required.
+ *      (2) This makes any subdirectories of /data/local/tmp that are required.
  *      (3) The root temp directory is:
- *            /tmp    (unix)  [default]
+ *            /data/local/tmp    (unix)  [default]
  *            [Temp]  (Windows)
  * </pre>
  */
@@ -2159,7 +2159,7 @@
     sa = sarrayCreate(0);
     sarraySplitString(sa, subdir, "/");
     n = sarrayGetCount(sa);
-    dir = genPathname("/tmp", NULL);
+    dir = genPathname("/data/local/tmp", NULL);
        /* Make sure the tmp directory exists */
 #ifndef _WIN32
     ret = mkdir(dir, 0777);
@@ -2191,7 +2191,7 @@
 /*!
  * \brief   lept_rmdir()
  *
- * \param[in]    subdir    of /tmp or its equivalent on Windows
+ * \param[in]    subdir    of /data/local/tmp or its equivalent on Windows
  * \return  0 on success, non-zero on failure
  *
  * <pre>
@@ -2200,7 +2200,7 @@
  *          directories.
  *      (2) This removes all files from the specified subdirectory of
  *          the root temp directory:
- *            /tmp    (unix)
+ *            /data/local/tmp    (unix)
  *            [Temp]  (Windows)
  *          and then removes the subdirectory.
  *      (3) The combination
@@ -2225,7 +2225,7 @@
         return ERROR_INT("subdir not an actual subdirectory", __func__, 1);
 
         /* Find the temp subdirectory */
-    dir = pathJoin("/tmp", subdir);
+    dir = pathJoin("/data/local/tmp", subdir);
     if (!dir)
         return ERROR_INT("directory name not made", __func__, 1);
     lept_direxists(dir, &exists);
@@ -2250,7 +2250,7 @@
     }
 
 #ifndef _WIN32
-    realdir = genPathname("/tmp", subdir);
+    realdir = genPathname("/data/local/tmp", subdir);
     ret = rmdir(realdir);
     LEPT_FREE(realdir);
 #else
@@ -2275,10 +2275,10 @@
  * <pre>
  * Notes:
  *      (1) Always use unix pathname separators.
- *      (2) By calling genPathname(), if the pathname begins with "/tmp"
+ *      (2) By calling genPathname(), if the pathname begins with "/data/local/tmp"
  *          this does an automatic directory translation on Windows
  *          to a path in the Windows [Temp] directory:
- *             "/tmp"  ==>  [Temp] (Windows)
+ *             "/data/local/tmp"  ==>  [Temp] (Windows)
  * </pre>
  */
 void
@@ -2317,23 +2317,23 @@
 /*!
  * \brief   lept_rm_match()
  *
- * \param[in]    subdir    [optional] if NULL, the removed files are in /tmp
+ * \param[in]    subdir    [optional] if NULL, the removed files are in /data/local/tmp
  * \param[in]    substr    [optional] pattern to match in filename
  * \return  0 on success, non-zero on failure
  *
  * <pre>
  * Notes:
- *      (1) This removes the matched files in /tmp or a subdirectory of /tmp.
- *          Use NULL for %subdir if the files are in /tmp.
+ *      (1) This removes the matched files in /data/local/tmp or a subdirectory of /data/local/tmp.
+ *          Use NULL for %subdir if the files are in /data/local/tmp.
  *      (2) If %substr == NULL, this removes all files in the directory.
  *          If %substr == "" (empty), this removes no files.
  *          If both %subdir == NULL and %substr == NULL, this removes
- *          all files in /tmp.
+ *          all files in /data/local/tmp.
  *      (3) Use unix pathname separators.
- *      (4) By calling genPathname(), if the pathname begins with "/tmp"
+ *      (4) By calling genPathname(), if the pathname begins with "/data/local/tmp"
  *          this does an automatic directory translation on Windows
  *          to a path in the Windows [Temp] directory:
- *             "/tmp"  ==>  [Temp] (Windows)
+ *             "/data/local/tmp"  ==>  [Temp] (Windows)
  *      (5) Error conditions:
  *            * returns -1 if the directory is not found
  *            * returns the number of files (> 0) that it was unable to remove.
@@ -2376,7 +2376,7 @@
 /*!
  * \brief   lept_rm()
  *
- * \param[in]    subdir    [optional] subdir of '/tmp'; can be NULL
+ * \param[in]    subdir    [optional] subdir of '/data/local/tmp'; can be NULL
  * \param[in]    tail      filename without the directory
  * \return  0 on success, non-zero on failure
  *
@@ -2384,7 +2384,7 @@
  * Notes:
  *      (1) By calling genPathname(), this does an automatic directory
  *          translation on Windows to a path in the Windows [Temp] directory:
- *             "/tmp/..."  ==>  [Temp]/... (Windows)
+ *             "/data/local/tmp/..."  ==>  [Temp]/... (Windows)
  * </pre>
  */
 l_int32
@@ -2421,7 +2421,7 @@
  *      (2) Use unix pathname separators.
  *      (3) There is no name translation.
  *      (4) Unlike the other lept_* functions in this section, this can remove
- *          any file -- it is not restricted to files that are in /tmp or a
+ *          any file -- it is not restricted to files that are in /data/local/tmp or a
  *          subdirectory of it.
  * </pre>
  */
@@ -2456,12 +2456,12 @@
  *
  * <pre>
  * Notes:
- *      (1) This moves %srcfile to /tmp or to a subdirectory of /tmp.
+ *      (1) This moves %srcfile to /data/local/tmp or to a subdirectory of /data/local/tmp.
  *      (2) %srcfile can either be a full path or relative to the
  *          current directory.
- *      (3) %newdir can either specify an existing subdirectory of /tmp
+ *      (3) %newdir can either specify an existing subdirectory of /data/local/tmp
  *          or can be NULL.  In the latter case, the file will be written
- *          into /tmp.
+ *          into /data/local/tmp.
  *      (4) %newtail can either specify a filename tail or, if NULL,
  *          the filename is taken from src-tail, the tail of %srcfile.
  *      (5) For debugging, the computed newpath can be returned.  It must
@@ -2469,13 +2469,13 @@
  *      (6) Reminders:
  *          (a) specify files using unix pathnames
  *          (b) for Windows, translates
- *                 /tmp  ==>  [Temp]
+ *                 /data/local/tmp  ==>  [Temp]
  *              where [Temp] is the Windows temp directory
  *      (7) Examples:
- *          * newdir = NULL,    newtail = NULL    ==> /tmp/src-tail
- *          * newdir = NULL,    newtail = abc     ==> /tmp/abc
- *          * newdir = def/ghi, newtail = NULL    ==> /tmp/def/ghi/src-tail
- *          * newdir = def/ghi, newtail = abc     ==> /tmp/def/ghi/abc
+ *          * newdir = NULL,    newtail = NULL    ==> /data/local/tmp/src-tail
+ *          * newdir = NULL,    newtail = abc     ==> /data/local/tmp/abc
+ *          * newdir = def/ghi, newtail = NULL    ==> /data/local/tmp/def/ghi/src-tail
+ *          * newdir = def/ghi, newtail = abc     ==> /data/local/tmp/def/ghi/abc
  * </pre>
  */
 l_int32
@@ -2491,9 +2491,9 @@
     if (!srcfile)
         return ERROR_INT("srcfile not defined", __func__, 1);
 
-        /* Require output pathname to be in /tmp/ or a subdirectory */
+        /* Require output pathname to be in /data/local/tmp/ or a subdirectory */
     if (makeTempDirname(newtemp, sizeof(newtemp), newdir) == 1)
-        return ERROR_INT("newdir not NULL or a subdir of /tmp", __func__, 1);
+        return ERROR_INT("newdir not NULL or a subdir of /data/local/tmp", __func__, 1);
 
         /* Get canonical src pathname */
     splitPathAtDirectory(srcfile, &dir, &srctail);
@@ -2552,12 +2552,12 @@
  *
  * <pre>
  * Notes:
- *      (1) This copies %srcfile to /tmp or to a subdirectory of /tmp.
+ *      (1) This copies %srcfile to /data/local/tmp or to a subdirectory of /data/local/tmp.
  *      (2) %srcfile can either be a full path or relative to the
  *          current directory.
- *      (3) %newdir can either specify an existing subdirectory of /tmp,
+ *      (3) %newdir can either specify an existing subdirectory of /data/local/tmp,
  *          or can be NULL.  In the latter case, the file will be written
- *          into /tmp.
+ *          into /data/local/tmp.
  *      (4) %newtail can either specify a filename tail or, if NULL,
  *          the filename is taken from src-tail, the tail of %srcfile.
  *      (5) For debugging, the computed newpath can be returned.  It must
@@ -2565,13 +2565,13 @@
  *      (6) Reminders:
  *          (a) specify files using unix pathnames
  *          (b) for Windows, translates
- *                 /tmp  ==>  [Temp]
+ *                 /data/local/tmp  ==>  [Temp]
  *              where [Temp] is the Windows temp directory
  *      (7) Examples:
- *          * newdir = NULL,    newtail = NULL    ==> /tmp/src-tail
- *          * newdir = NULL,    newtail = abc     ==> /tmp/abc
- *          * newdir = def/ghi, newtail = NULL    ==> /tmp/def/ghi/src-tail
- *          * newdir = def/ghi, newtail = abc     ==> /tmp/def/ghi/abc
+ *          * newdir = NULL,    newtail = NULL    ==> /data/local/tmp/src-tail
+ *          * newdir = NULL,    newtail = abc     ==> /data/local/tmp/abc
+ *          * newdir = def/ghi, newtail = NULL    ==> /data/local/tmp/def/ghi/src-tail
+ *          * newdir = def/ghi, newtail = abc     ==> /data/local/tmp/def/ghi/abc
  *
  * </pre>
  */
@@ -2588,9 +2588,9 @@
     if (!srcfile)
         return ERROR_INT("srcfile not defined", __func__, 1);
 
-        /* Require output pathname to be in /tmp or a subdirectory */
+        /* Require output pathname to be in /data/local/tmp or a subdirectory */
     if (makeTempDirname(newtemp, sizeof(newtemp), newdir) == 1)
-        return ERROR_INT("newdir not NULL or a subdir of /tmp", __func__, 1);
+        return ERROR_INT("newdir not NULL or a subdir of /data/local/tmp", __func__, 1);
 
        /* Get canonical src pathname */
     splitPathAtDirectory(srcfile, &dir, &srctail);
@@ -2705,14 +2705,14 @@
  *          tail ptr.
  *      (3) This function makes decisions based only on the lexical
  *          structure of the input.  Examples:
- *            /usr/tmp/abc.d  -->  dir: /usr/tmp/       tail: abc.d
- *            /usr/tmp/       -->  dir: /usr/tmp/       tail: [empty string]
- *            /usr/tmp        -->  dir: /usr/           tail: tmp
+ *            /usr/data/local/tmp/abc.d  -->  dir: /usr/data/local/tmp/       tail: abc.d
+ *            /usr/data/local/tmp/       -->  dir: /usr/data/local/tmp/       tail: [empty string]
+ *            /usr/data/local/tmp        -->  dir: /usr/           tail: tmp
  *            abc.d           -->  dir: [empty string]  tail: abc.d
- *      (4  Consider the first example above: /usr/tmp/abc.d.
+ *      (4  Consider the first example above: /usr/data/local/tmp/abc.d.
  *          Suppose you want the stem of the file, abc, without either
  *          the directory or the extension.  This can be extracted in two steps:
- *              splitPathAtDirectory("usr/tmp/abc.d", NULL, &tail);
+ *              splitPathAtDirectory("usr/data/local/tmp/abc.d", NULL, &tail);
  *                   [sets tail: "abc.d"]
  *              splitPathAtExtension(tail, &basename, NULL);
  *                   [sets basename: "abc"]
@@ -2781,9 +2781,9 @@
  *          for the extension ptr.
  *      (3) This function makes decisions based only on the lexical
  *          structure of the input.  Examples:
- *            /usr/tmp/abc.jpg  -->  basename: /usr/tmp/abc    ext: .jpg
- *            /usr/tmp/.jpg     -->  basename: /usr/tmp/       ext: .jpg
- *            /usr/tmp.jpg/     -->  basename: /usr/tmp.jpg/   ext: [empty str]
+ *            /usr/data/local/tmp/abc.jpg  -->  basename: /usr/data/local/tmp/abc    ext: .jpg
+ *            /usr/data/local/tmp/.jpg     -->  basename: /usr/data/local/tmp/       ext: .jpg
+ *            /usr/data/local/tmp.jpg/     -->  basename: /usr/data/local/tmp.jpg/   ext: [empty str]
  *            ./.jpg            -->  basename: ./              ext: .jpg
  *      (4) The input can have either forward (unix) or backward (win)
  *          slash separators.  The output has unix separators.
@@ -2852,11 +2852,11 @@
  *      (6) The result is not canonicalized or tested for correctness:
  *          garbage in (e.g., /&%), garbage out.
  *      (7) Examples:
- *             //tmp// + //abc/  -->  /tmp/abc
+ *             //data/local/tmp// + //abc/  -->  /data/local/tmp/abc
  *             tmp/ + /abc/      -->  tmp/abc
  *             tmp/ + abc/       -->  tmp/abc
- *             /tmp/ + ///       -->  /tmp
- *             /tmp/ + NULL      -->  /tmp
+ *             /data/local/tmp/ + ///       -->  /data/local/tmp
+ *             /data/local/tmp/ + NULL      -->  /data/local/tmp
  *             // + /abc//       -->  /abc
  *             // + NULL         -->  /
  *             NULL + /abc/def/  -->  /abc/def
@@ -2866,7 +2866,7 @@
  *             "" + ""           -->  (empty string)
  *             "" + /            -->  /
  *             ".." + /etc/foo   -->  NULL
- *             /tmp + ".."       -->  NULL
+ *             /data/local/tmp + ".."       -->  NULL
  * </pre>
  */
 char *
@@ -3046,11 +3046,11 @@
  *              %fname == NULL.
  *            * from the name of a file in the local directory placed in
  *              %fname, with %dir == NULL.
- *            * if in a "/tmp" directory and on Windows, the Windows
+ *            * if in a "/data/local/tmp" directory and on Windows, the Windows
  *              temp directory is used.
- *      (2) On Windows, if the root of %dir is '/tmp', this does a name
+ *      (2) On Windows, if the root of %dir is '/data/local/tmp', this does a name
  *          translation:
- *             "/tmp"  ==>  [Temp] (Windows)
+ *             "/data/local/tmp"  ==>  [Temp] (Windows)
  *          where [Temp] is the Windows temp directory.
  *      (3) On unix, the TMPDIR variable is ignored.  No rewriting
  *          of temp directories is permitted.
@@ -3106,13 +3106,13 @@
 
         /* First handle %dir (which may be a full pathname).
          * There is no path rewriting on unix, and on win32, we do not
-         * rewrite unless the specified directory is /tmp or
-         * a subdirectory of /tmp */
+         * rewrite unless the specified directory is /data/local/tmp or
+         * a subdirectory of /data/local/tmp */
     if (!is_win32 || dirlen < 4 ||
-        (dirlen == 4 && strncmp(cdir, "/tmp", 4) != 0) ||  /* not in "/tmp" */
-        (dirlen > 4 && strncmp(cdir, "/tmp/", 5) != 0)) {  /* not in "/tmp/" */
+        (dirlen == 4 && strncmp(cdir, "/data/local/tmp", 4) != 0) ||  /* not in "/data/local/tmp" */
+        (dirlen > 4 && strncmp(cdir, "/data/local/tmp/", 5) != 0)) {  /* not in "/data/local/tmp/" */
         stringCopy(pathout, cdir, dirlen);
-    } else {  /* Rewrite for win32 with "/tmp" specified for the directory. */
+    } else {  /* Rewrite for win32 with "/data/local/tmp" specified for the directory. */
 #ifdef _WIN32
         l_int32 tmpdirlen;
         char tmpdir[MAX_PATH];
@@ -3156,7 +3156,7 @@
  *          written into %result with unix separators.
  *      (2) Caller allocates %result, large enough to hold the path,
  *          which is:
- *            /tmp/%subdir       (unix)
+ *            /data/local/tmp/%subdir       (unix)
  *            [Temp]/%subdir     (Windows, macOS, iOS)
  *          where [Temp] is a path determined
  *             - on Windows: by GetTempPath()
@@ -3199,7 +3199,7 @@
         dir = pathJoin(result, subdir);
     }
 #else
-    dir = pathJoin("/tmp", subdir);
+    dir = pathJoin("/data/local/tmp", subdir);
 #endif /*  ~ __APPLE__ */
 
 #ifndef _WIN32
@@ -3267,7 +3267,7 @@
  * <pre>
  * Notes:
  *      (1) On unix, this makes a filename of the form
- *               "/tmp/lept.XXXXXX",
+ *               "/data/local/tmp/lept.XXXXXX",
  *          where each X is a random character.
  *      (2) On Windows, this makes a filename of the form
  *               "/[Temp]/lp.XXXXXX".
diff -Nura leptonica-1.83.1/src/writefile.c leptonica-1.83.1-patch/src/writefile.c
--- leptonica-1.83.1/src/writefile.c	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/src/writefile.c	2024-09-05 14:26:11.099616574 +0800
@@ -840,7 +840,7 @@
  *          with xv, because xv automatically downscales large images
  *          by subsampling, which looks poor.  For 1 bpp, we use
  *          scale-to-gray to get decent-looking anti-aliased images.
- *          In all cases, we write a temporary file to /tmp/lept/disp,
+ *          In all cases, we write a temporary file to /data/local/tmp/lept/disp,
  *          that is read by the display program.
  *      (5) The temporary file is written as png if, after initial
  *          processing for special cases, any of these obtain:
@@ -974,10 +974,10 @@
     index++;
     if (pixGetDepth(pix2) < 8 || pixGetColormap(pix2) ||
         (w < MaxSizeForPng && h < MaxSizeForPng)) {
-        snprintf(buffer, Bufsize, "/tmp/lept/disp/write.%03d.png", index);
+        snprintf(buffer, Bufsize, "/data/local/tmp/lept/disp/write.%03d.png", index);
         pixWrite(buffer, pix2, IFF_PNG);
     } else {
-        snprintf(buffer, Bufsize, "/tmp/lept/disp/write.%03d.jpg", index);
+        snprintf(buffer, Bufsize, "/data/local/tmp/lept/disp/write.%03d.jpg", index);
         pixWrite(buffer, pix2, IFF_JFIF_JPEG);
     }
     tempname = genPathname(buffer, NULL);
diff -Nura leptonica-1.83.1/version-notes.html leptonica-1.83.1-patch/version-notes.html
--- leptonica-1.83.1/version-notes.html	2023-01-26 14:12:24.000000000 +0800
+++ leptonica-1.83.1-patch/version-notes.html	2024-09-05 14:26:11.103616495 +0800
@@ -271,7 +271,7 @@
           rootnames containing any of: ;&|>"?*$()/<
         * CVE-2017-18196: duplicated path components.
           This was fixed in 1.75.3.
-        * CVE-2018-7441: hardcoded /tmp pathnames.
+        * CVE-2018-7441: hardcoded /data/local/tmp pathnames.
           These are all wrapped in special debug functions that are not
           enabled by default in the distribution, starting with 1.76.0.
         * CVE-2018-7247: input 'rootname' can overflow a buffer.
@@ -480,12 +480,12 @@
        All lept_* functions have been rewritten to avoid path rewrites for
        output to temp files, which were introduced in 1.72.
        Now, (1) files are written to the directory specified and (2) we
-       are careful to write to subdirectories of /tmp/lept/ for all test
+       are careful to write to subdirectories of /data/local/tmp/lept/ for all test
        programs, starting with the reg tests and prog/dewarp* and
        prog/recog*.  This also required re-writing stringcode.c and
        stringtemplate1.txt to write temp files to subdirectories.
        Goal is to write to the specified path while not spamming the
-       /tmp and /tmp/lept directories.  This is particularly important
+       /data/local/tmp and /data/local/tmp/lept directories.  This is particularly important
        on windows because files in the <TEMP> directory are not cleared
        on reboot.
        Naming changes (to avoid collisions):
@@ -558,9 +558,9 @@
         l_binaryReadStream() can now be used to capture data piped
         in via stdin.
        Font directory now arg passed in everywhere (not hardcoded)
-       Don't write temporary files to /tmp; only to a small number of
-       subdirectories, to avoid spamming the /tmp directory.  E.g.,
-       for regression tests, the current output is now to /tmp/regout/.
+       Don't write temporary files to /data/local/tmp; only to a small number of
+       subdirectories, to avoid spamming the /data/local/tmp directory.  E.g.,
+       for regression tests, the current output is now to /data/local/tmp/regout/.
        For jpeg reading modify pixReadJpeg() to take as a hint
         a bit flag that allows extraction of only the luminance channel.
        Allow wrapping of pdf objects from png images without transcoding