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

259 lines
12 KiB
Diff
Raw Normal View History

2019-05-19 16:32:37 +02:00
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), "@TERMUX_PREFIX@/tmp/.fluid-%ld", (long)getpid());
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/etc/mnttab", "r"); // Fairly standard
2019-05-19 16:32:37 +02:00
if (mtab == NULL)
- mtab = fl_fopen("/etc/mtab", "r"); // More standard
+ mtab = fl_fopen("@TERMUX_PREFIX@/etc/mtab", "r"); // More standard
2019-05-19 16:32:37 +02:00
if (mtab == NULL)
- mtab = fl_fopen("/etc/fstab", "r"); // Otherwise fallback to full list
+ mtab = fl_fopen("@TERMUX_PREFIX@/etc/fstab", "r"); // Otherwise fallback to full list
2019-05-19 16:32:37 +02:00
if (mtab == NULL)
- mtab = fl_fopen("/etc/vfstab", "r"); // Alternate full list file
+ mtab = fl_fopen("@TERMUX_PREFIX@/etc/vfstab", "r"); // Alternate full list file
2019-05-19 16:32:37 +02:00
+
+ 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("@TERMUX_PREFIX@/opt/kde", F_OK)) kdedir = "@TERMUX_PREFIX@/opt/kde";
+ else if (!access("@TERMUX_PREFIX@/share/mimelnk", F_OK)) kdedir = "@TERMUX_PREFIX@";
+ else kdedir = "@TERMUX_PREFIX@";
2019-05-19 16:32:37 +02:00
}
}
@@ -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("@TERMUX_PREFIX@/share/icons/folder.xpm", F_OK)) {
2019-05-19 16:32:37 +02:00
// Load GNOME icons...
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/share/icons/page.xpm");
+ icon->load_image("@TERMUX_PREFIX@/share/icons/page.xpm");
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/share/icons/folder.xpm");
+ } else if (!access("@TERMUX_PREFIX@/dt/appconfig/icons", F_OK)) {
2019-05-19 16:32:37 +02:00
// 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("@TERMUX_PREFIX@/dt/appconfig/icons/C/Dtdata.m.pm");
2019-05-19 16:32:37 +02:00
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
- icon->load_image("/usr/dt/appconfig/icons/C/DtdirB.m.pm");
+ icon->load_image("@TERMUX_PREFIX@/dt/appconfig/icons/C/DtdirB.m.pm");
2019-05-19 16:32:37 +02:00
icon = new Fl_File_Icon("core", Fl_File_Icon::PLAIN);
- icon->load_image("/usr/dt/appconfig/icons/C/Dtcore.m.pm");
+ icon->load_image("@TERMUX_PREFIX@/dt/appconfig/icons/C/Dtcore.m.pm");
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/dt/appconfig/icons/C/Dtimage.m.pm");
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/dt/appconfig/icons/C/Dtps.m.pm");
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/dt/appconfig/icons/C/DtPrtpr.m.pm");
+ } else if (!access("@TERMUX_PREFIX@/lib/filetype", F_OK)) {
2019-05-19 16:32:37 +02:00
// 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("@TERMUX_PREFIX@/lib/filetype/iconlib/generic.doc.fti");
2019-05-19 16:32:37 +02:00
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
- icon->load_fti("/usr/lib/filetype/iconlib/generic.folder.closed.fti");
+ icon->load_fti("@TERMUX_PREFIX@/lib/filetype/iconlib/generic.folder.closed.fti");
2019-05-19 16:32:37 +02:00
icon = new Fl_File_Icon("core", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/default/iconlib/CoreFile.fti");
+ icon->load_fti("@TERMUX_PREFIX@/lib/filetype/default/iconlib/CoreFile.fti");
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/lib/filetype/system/iconlib/ImageFile.fti");
2019-05-19 16:32:37 +02:00
- if (!access("/usr/lib/filetype/install/iconlib/acroread.doc.fti", F_OK)) {
+ if (!access("@TERMUX_PREFIX@/lib/filetype/install/iconlib/acroread.doc.fti", F_OK)) {
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
2019-05-19 16:32:37 +02:00
icon = new Fl_File_Icon("*.pdf", Fl_File_Icon::PLAIN);
- icon->load_fti("/usr/lib/filetype/install/iconlib/acroread.doc.fti");
+ icon->load_fti("@TERMUX_PREFIX@/lib/filetype/install/iconlib/acroread.doc.fti");
2019-05-19 16:32:37 +02:00
} 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("@TERMUX_PREFIX@/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
2019-05-19 16:32:37 +02:00
}
- if (!access("/usr/lib/filetype/install/iconlib/html.fti", F_OK)) {
+ if (!access("@TERMUX_PREFIX@/lib/filetype/install/iconlib/html.fti", F_OK)) {
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/lib/filetype/iconlib/generic.doc.fti");
+ icon->load_fti("@TERMUX_PREFIX@/lib/filetype/install/iconlib/html.fti");
2019-05-19 16:32:37 +02:00
}
- if (!access("/usr/lib/filetype/install/iconlib/color.ps.idle.fti", F_OK)) {
+ if (!access("@TERMUX_PREFIX@/lib/filetype/install/iconlib/color.ps.idle.fti", F_OK)) {
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/lib/filetype/install/iconlib/color.ps.idle.fti");
2019-05-19 16:32:37 +02:00
}
} 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 = "@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets:/system/xbin:/system/bin";
2019-05-19 16:32:37 +02:00
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, "@TERMUX_PREFIX@/etc/fltk/");
2019-05-19 16:32:37 +02:00
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, "@TERMUX_PREFIX@/tmp/clipboardXXXXXX");
2019-05-19 16:32:37 +02:00
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 @TERMUX_PREFIX@/bin/sh -c '(lpstat -p -d ) 2>&-'", "r")) != NULL) { // try first with SystemV printing system
2019-05-19 16:32:37 +02:00
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("@TERMUX_PREFIX@/etc/printcap", "r"))) { // try next with BSD printing system
2019-05-19 16:32:37 +02:00
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), "@TERMUX_PREFIX@/bin/sh -c \"(lpstat -p '%s' ) 2>&-\" ", printer); // try first with SystemV printing system
2019-05-19 16:32:37 +02:00
if ((lpstat = popen(command, "r")) != NULL) {
if (fgets(status, sizeof(status), lpstat) == 0) { // if no reply
pclose(lpstat);