termux-packages/x11-packages/fltk/03-fix-hardcoded-paths.patch

259 lines
13 KiB
Diff

diff -uNr fltk-1.3.5/fluid/ExternalCodeEditor_UNIX.cxx fltk-1.3.5.mod/fluid/ExternalCodeEditor_UNIX.cxx
--- fltk-1.3.5/fluid/ExternalCodeEditor_UNIX.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/fluid/ExternalCodeEditor_UNIX.cxx 2019-05-19 17:18:25.294720046 +0300
@@ -214,8 +214,8 @@
// Returns pointer to static memory.
//
const char* ExternalCodeEditor::tmpdir_name() {
- static char dirname[100];
- snprintf(dirname, sizeof(dirname), "/tmp/.fluid-%ld", (long)getpid());
+ static char dirname[100] = {0};
+ snprintf(dirname, sizeof(dirname), "/data/data/com.termux/files/usr/tmp/.fluid-%ld", (long)getpid());
return dirname;
}
diff -uNr fltk-1.3.5/src/Fl_File_Browser.cxx fltk-1.3.5.mod/src/Fl_File_Browser.cxx
--- fltk-1.3.5/src/Fl_File_Browser.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/src/Fl_File_Browser.cxx 2019-05-19 17:18:25.295720052 +0300
@@ -624,13 +624,16 @@
// Open the file that contains a list of mounted filesystems...
//
- mtab = fl_fopen("/etc/mnttab", "r"); // Fairly standard
+ mtab = fl_fopen("/data/data/com.termux/files/usr/etc/mnttab", "r"); // Fairly standard
if (mtab == NULL)
- mtab = fl_fopen("/etc/mtab", "r"); // More standard
+ mtab = fl_fopen("/data/data/com.termux/files/usr/etc/mtab", "r"); // More standard
if (mtab == NULL)
- mtab = fl_fopen("/etc/fstab", "r"); // Otherwise fallback to full list
+ mtab = fl_fopen("/data/data/com.termux/files/usr/etc/fstab", "r"); // Otherwise fallback to full list
if (mtab == NULL)
- mtab = fl_fopen("/etc/vfstab", "r"); // Alternate full list file
+ mtab = fl_fopen("/data/data/com.termux/files/usr/etc/vfstab", "r"); // Alternate full list file
+
+ if (mtab == NULL)
+ mtab = fl_fopen("/proc/mounts", "r"); // Try to use /proc/mounts
if (mtab != NULL)
{
diff -uNr fltk-1.3.5/src/Fl_File_Icon2.cxx fltk-1.3.5.mod/src/Fl_File_Icon2.cxx
--- fltk-1.3.5/src/Fl_File_Icon2.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/src/Fl_File_Icon2.cxx 2019-05-19 17:18:25.297720063 +0300
@@ -677,9 +677,9 @@
if (!kdedir) {
// Figure out where KDE is installed...
if ((kdedir = getenv("KDEDIR")) == NULL) {
- if (!access("/opt/kde", F_OK)) kdedir = "/opt/kde";
- else if (!access("/usr/local/share/mimelnk", F_OK)) kdedir = "/usr/local";
- else kdedir = "/usr";
+ if (!access("/data/data/com.termux/files/usr/opt/kde", F_OK)) kdedir = "/data/data/com.termux/files/usr/opt/kde";
+ else if (!access("/data/data/com.termux/files/usr/share/mimelnk", F_OK)) kdedir = "/data/data/com.termux/files/usr";
+ else kdedir = "/data/data/com.termux/files/usr";
}
}
@@ -715,66 +715,66 @@
snprintf(filename, sizeof(filename), "%s/share/mimelnk", kdedir);
load_kde_icons(filename, icondir);
- } else if (!access("/usr/share/icons/folder.xpm", F_OK)) {
+ } else if (!access("/data/data/com.termux/files/usr/share/icons/folder.xpm", F_OK)) {
// Load GNOME icons...
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/share/icons/page.xpm");
+ icon->load_image("/data/data/com.termux/files/usr/share/icons/page.xpm");
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
- icon->load_image("/usr/share/icons/folder.xpm");
- } else if (!access("/usr/dt/appconfig/icons", F_OK)) {
+ icon->load_image("/data/data/com.termux/files/usr/share/icons/folder.xpm");
+ } else if (!access("/data/data/com.termux/files/usr/dt/appconfig/icons", F_OK)) {
// Load CDE icons...
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/dt/appconfig/icons/C/Dtdata.m.pm");
+ icon->load_image("/data/data/com.termux/files/usr/dt/appconfig/icons/C/Dtdata.m.pm");
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
- icon->load_image("/usr/dt/appconfig/icons/C/DtdirB.m.pm");
+ icon->load_image("/data/data/com.termux/files/usr/dt/appconfig/icons/C/DtdirB.m.pm");
icon = new Fl_File_Icon("core", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/dt/appconfig/icons/C/Dtcore.m.pm");
+ icon->load_image("/data/data/com.termux/files/usr/dt/appconfig/icons/C/Dtcore.m.pm");
icon = new Fl_File_Icon("*.{bmp|bw|gif|jpg|pbm|pcd|pgm|ppm|png|ras|rgb|tif|xbm|xpm}", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/dt/appconfig/icons/C/Dtimage.m.pm");
+ icon->load_image("/data/data/com.termux/files/usr/dt/appconfig/icons/C/Dtimage.m.pm");
icon = new Fl_File_Icon("*.{eps|pdf|ps}", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/dt/appconfig/icons/C/Dtps.m.pm");
+ icon->load_image("/data/data/com.termux/files/usr/dt/appconfig/icons/C/Dtps.m.pm");
icon = new Fl_File_Icon("*.ppd", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/dt/appconfig/icons/C/DtPrtpr.m.pm");
- } else if (!access("/usr/lib/filetype", F_OK)) {
+ icon->load_image("/data/data/com.termux/files/usr/dt/appconfig/icons/C/DtPrtpr.m.pm");
+ } else if (!access("/data/data/com.termux/files/usr/lib/filetype", F_OK)) {
// Load SGI icons...
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/iconlib/generic.doc.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/iconlib/generic.doc.fti");
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
- icon->load_fti("/usr/lib/filetype/iconlib/generic.folder.closed.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/iconlib/generic.folder.closed.fti");
icon = new Fl_File_Icon("core", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/default/iconlib/CoreFile.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/default/iconlib/CoreFile.fti");
icon = new Fl_File_Icon("*.{bmp|bw|gif|jpg|pbm|pcd|pgm|ppm|png|ras|rgb|tif|xbm|xpm}", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/system/iconlib/ImageFile.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/system/iconlib/ImageFile.fti");
- if (!access("/usr/lib/filetype/install/iconlib/acroread.doc.fti", F_OK)) {
+ if (!access("/data/data/com.termux/files/usr/lib/filetype/install/iconlib/acroread.doc.fti", F_OK)) {
icon = new Fl_File_Icon("*.{eps|ps}", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
icon = new Fl_File_Icon("*.pdf", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/install/iconlib/acroread.doc.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/install/iconlib/acroread.doc.fti");
} else {
icon = new Fl_File_Icon("*.{eps|pdf|ps}", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
}
- if (!access("/usr/lib/filetype/install/iconlib/html.fti", F_OK)) {
+ if (!access("/data/data/com.termux/files/usr/lib/filetype/install/iconlib/html.fti", F_OK)) {
icon = new Fl_File_Icon("*.{htm|html|shtml}", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/iconlib/generic.doc.fti");
- icon->load_fti("/usr/lib/filetype/install/iconlib/html.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/iconlib/generic.doc.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/install/iconlib/html.fti");
}
- if (!access("/usr/lib/filetype/install/iconlib/color.ps.idle.fti", F_OK)) {
+ if (!access("/data/data/com.termux/files/usr/lib/filetype/install/iconlib/color.ps.idle.fti", F_OK)) {
icon = new Fl_File_Icon("*.ppd", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/install/iconlib/color.ps.idle.fti");
+ icon->load_fti("/data/data/com.termux/files/usr/lib/filetype/install/iconlib/color.ps.idle.fti");
}
} else {
// Create the default icons...
diff -uNr fltk-1.3.5/src/fl_open_uri.cxx fltk-1.3.5.mod/src/fl_open_uri.cxx
--- fltk-1.3.5/src/fl_open_uri.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/src/fl_open_uri.cxx 2019-05-19 17:18:25.298720069 +0300
@@ -275,7 +275,7 @@
*end; // End of filename buffer
- if ((path = getenv("PATH")) == NULL) path = "/bin:/usr/bin";
+ if ((path = getenv("PATH")) == NULL) path = "/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/xbin:/system/bin";
for (ptr = filename, end = filename + filesize - 1; *path; path ++) {
if (*path == ':') {
diff -uNr fltk-1.3.5/src/Fl_Preferences.cxx fltk-1.3.5.mod/src/Fl_Preferences.cxx
--- fltk-1.3.5/src/Fl_Preferences.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/src/Fl_Preferences.cxx 2019-05-19 17:18:25.299720075 +0300
@@ -963,7 +963,8 @@
vendor_(0L),
application_(0L) {
- char filename[ FL_PATH_MAX ]; filename[0] = 0;
+ char filename[ FL_PATH_MAX ] = {0};
+
#ifdef WIN32
# define FLPREFS_RESOURCE "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
# define FLPREFS_RESOURCEW L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
@@ -1049,7 +1050,7 @@
break;
}
case SYSTEM:
- strcpy(filename, "/etc/fltk/");
+ strcpy(filename, "/data/data/com.termux/files/usr/etc/fltk/");
break;
}
snprintf(filename + strlen(filename), sizeof(filename) - strlen(filename),
@@ -1162,20 +1163,6 @@
fprintf( f, "; application: %s\n", application_ );
prefs_->node->write( f );
fclose( f );
-#if !(defined(__APPLE__) || defined(WIN32))
- // unix: make sure that system prefs are user-readable
- if (strncmp(filename_, "/etc/fltk/", 10) == 0) {
- char *p;
- p = filename_ + 9;
- do { // for each directory to the pref file
- *p = 0;
- fl_chmod(filename_, 0755); // rwxr-xr-x
- *p = '/';
- p = strchr(p+1, '/');
- } while (p);
- fl_chmod(filename_, 0644); // rw-r--r--
- }
-#endif
return 0;
}
@@ -1191,12 +1178,6 @@
if ( !s ) return 0;
*s = 0;
char ret = fl_make_path( path );
-#if !(defined(__APPLE__) || defined(WIN32))
- // unix: make sure that system prefs dir. is user-readable
- if (strncmp(path, "/etc/fltk/", 10) == 0) {
- fl_chmod(path, 0755); // rwxr-xr-x
- }
-#endif
strcpy( s, "/" );
return ret;
}
diff -uNr fltk-1.3.5/src/Fl_x.cxx fltk-1.3.5.mod/src/Fl_x.cxx
--- fltk-1.3.5/src/Fl_x.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/src/Fl_x.cxx 2019-05-19 17:18:25.301720087 +0300
@@ -1481,9 +1481,9 @@
if (!fl_selection_requestor) return 0;
if (Fl::e_clipboard_type == Fl::clipboard_image) {
if (bytesread == 0) return 0;
- static char tmp_fname[21];
+ static char tmp_fname[52] = {0};
static Fl_Shared_Image *shared = 0;
- strcpy(tmp_fname, "/tmp/clipboardXXXXXX");
+ strcpy(tmp_fname, "/data/data/com.termux/files/usr/tmp/clipboardXXXXXX");
int fd = mkstemp(tmp_fname);
if (fd == -1) return 0;
uchar *p = sn_buffer; ssize_t towrite = bytesread, written;
diff -uNr fltk-1.3.5/src/print_panel.cxx fltk-1.3.5.mod/src/print_panel.cxx
--- fltk-1.3.5/src/print_panel.cxx 2019-03-03 10:40:23.000000000 +0200
+++ fltk-1.3.5.mod/src/print_panel.cxx 2019-05-19 17:18:25.302720092 +0300
@@ -533,7 +533,7 @@
defname[0] = '\0';
// get names of all printers and of default one
- if ((lpstat = popen("LC_MESSAGES=C LANG=C /bin/sh -c '(lpstat -p -d ) 2>&-'", "r")) != NULL) { // try first with SystemV printing system
+ if ((lpstat = popen("LC_MESSAGES=C LANG=C /data/data/com.termux/files/usr/bin/sh -c '(lpstat -p -d ) 2>&-'", "r")) != NULL) { // try first with SystemV printing system
while (fgets(line, sizeof(line), lpstat)) {
if (!strncmp(line, "printer ", 8) &&
sscanf(line + 8, "%s", name) == 1) {
@@ -550,7 +550,7 @@
pclose(lpstat);
}
- if (print_choice->size() == 2 && (lpstat = fopen("/etc/printcap", "r"))) { // try next with BSD printing system
+ if (print_choice->size() == 2 && (lpstat = fopen("/data/data/com.termux/files/usr/etc/printcap", "r"))) { // try next with BSD printing system
while (fgets(line, sizeof(line),lpstat)) { // get names of all known printers
if (*line == '#' || (p = strchr(line, '|')) == NULL) continue;
*p = 0;
@@ -593,7 +593,7 @@
status[0] = 0;
if (print_choice->value()) {
strcpy(status, "printer status unavailable");
- snprintf(command, sizeof(command), "/bin/sh -c \"(lpstat -p '%s' ) 2>&-\" ", printer); // try first with SystemV printing system
+ snprintf(command, sizeof(command), "/data/data/com.termux/files/usr/bin/sh -c \"(lpstat -p '%s' ) 2>&-\" ", printer); // try first with SystemV printing system
if ((lpstat = popen(command, "r")) != NULL) {
if (fgets(status, sizeof(status), lpstat) == 0) { // if no reply
pclose(lpstat);