From 3f929f8595b311d0825b4b0d528608022d608c63 Mon Sep 17 00:00:00 2001
From: rarost <rrost789@gmail.com>
Date: Thu, 27 Feb 2025 15:01:48 +0000
Subject: [PATCH] Added fixes for textfont() and textsize(). Fixed unused var,
 unused func, deprecated func warnings. Added architecture (x86, x86_64)
 detection to Makefile.

---
 Makefile                    | 26 +++++++++++++++-------
 apps/apps.cxx               | 43 ++++++++++++++++++++++++++-----------
 editor/editor.cxx           |  8 ++++++-
 stats/stats.cxx             | 40 +++++++++++++++++++++++-----------
 tc-install/tc-install.cxx   | 15 +++++++++----
 tc-wbarconf/tc-wbarconf.cxx | 17 +++++++++++----
 6 files changed, 108 insertions(+), 41 deletions(-)

diff --git a/Makefile b/Makefile
index 3435602..55c49a9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,11 @@
+ARCH := $(shell uname -m)
+
+
 PREFIX = /usr/local
 INSTDIR = $(DESTDIR)/$(PREFIX)/bin
 
-DIRS = add2file apps cpanel datetool editor \
-	exittc filetool flrun \
-	mirrorpicker mnttool mousetool \
-	network popask popup services \
-	stats swapfile tc-install \
-	tc-wbarconf wallpaper
+DIRS = apps editor stats tc-install tc-wbarconf
+#DIRS = editor
 
 TARGETS = $(foreach dir, $(DIRS),$(dir)/$(dir))
 SRC = $(foreach dir, $(DIRS),$(wildcard $(dir)/*.cxx))
@@ -17,14 +16,25 @@ OBJ = $(SRC:.cxx=.o)
 %.o : %.cxx
 	$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
 
-CXXFLAGS += -Os -s -Wall -Wextra
-CXXFLAGS += -march=i486 -mtune=i686 # change or comment this out on other arches
+CXXFLAGS += -Os -s -Wall -Wextra -Wno-missing-field-initializers
 CXXFLAGS += -fno-rtti -fno-exceptions
 CXXFLAGS += -ffunction-sections -fdata-sections
 
 LDFLAGS += -Wl,-O1 -Wl,-gc-sections
 LDFLAGS += -Wl,-as-needed
 
+# Additional flags for x86
+ifeq ($(ARCH), i686)
+CXXFLAGS += -march=i486 -mtune=i686
+LDFLAGS += "-Wl,-T/usr/local/lib/ldscripts/elf_i386.xbn"
+endif
+
+# Additional flags for x86_64
+ifeq ($(ARCH), x86_64)
+CXXFLAGS += -mtune=generic
+LDFLAGS += "-Wl,-T/usr/local/lib/ldscripts/elf_x86_64.xbn"
+endif
+
 CXXFLAGS += $(shell fltk-config --cxxflags | sed 's@-I@-isystem @')
 LDFLAGS += $(shell fltk-config --ldflags)
 
diff --git a/apps/apps.cxx b/apps/apps.cxx
index 98afe15..a4e5bbf 100644
--- a/apps/apps.cxx
+++ b/apps/apps.cxx
@@ -1,5 +1,9 @@
 // generated by Fast Light User Interface Designer (fluid) version 1.0110
 
+#define Apps_TextFont FL_COURIER
+#define Apps_TextSize 10
+
+
 #include <libintl.h>
 #include "apps.h"
 // (c) Robert Shingledecker 2008-2012
@@ -27,7 +31,8 @@ static string mode, command, msg, mirror, err_extn;
 static string option_type, report_type, update_type; 
 static string copy2fsList, copy2fsFlag, onbootName, onbootList, onbootTitle; 
 static Fl_Text_Buffer *txtBuffer = new Fl_Text_Buffer; 
-static void errhandler(const string &str); 
+// Does not appear to be used.
+//static void errhandler(const string &str); 
 
 static void cursor_normal() {
   window->cursor(FL_CURSOR_DEFAULT);
@@ -63,7 +68,10 @@ brwMulti->clear();
 brwResults->clear();
 boxExtn->label("Select");
 boxResults->label("Results");
-report_type.empty();
+// empty() returns true if report_type is empty.
+// Maybe roberts meant to clear it?
+//report_type.empty();
+report_type.clear();
 btnSingle->label("Add Item");
 btnResults->label("Delete Item from list");
 btnSingle->deactivate();
@@ -195,6 +203,7 @@ boxResults->label("Results");
 cursor_normal();
 }
 
+/* errhandler and friends, appears to be unused.
 Fl_Double_Window *errwindow=(Fl_Double_Window *)0;
 
 Fl_Box *errlabel=(Fl_Box *)0;
@@ -256,6 +265,7 @@ err_extn.replace(0,9,""); // Yes, hardcoded magic value. Bad.
 
 errwindow->show();
 }
+*/ /* End errhandler and friends, appears to be unused. */
 
 static void menuCB(Fl_Widget *, void* userdata) {
   const string userdatastr = userdata ? (char *) userdata : "";
@@ -1198,7 +1208,7 @@ getline(proc_cmdline, cmdline);
 proc_cmdline.close();
 target_boot_option = "lst=";
 int sloc = cmdline.find(target_boot_option);
-if ( sloc == string::npos ) {
+if ( (unsigned)sloc == string::npos ) {
    onbootName = "onboot.lst";
 } else {
    int eloc = cmdline.find(" ",sloc);
@@ -1213,7 +1223,8 @@ chdir(target_dir.c_str()); // we go there to more easily handle errors (delete,
 // first run?
 if (access("../firstrun", F_OK)) {
 	creat("../firstrun", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
-	if (fl_ask("First run - would you like the system to pick the fastest mirror?") == 1)
+//	if (fl_ask("First run - would you like the system to pick the fastest mirror?") == 1)
+	if (fl_choice("First run - would you like the system to pick the fastest mirror?", "No", "Yes", NULL) == 1)
 		mirrorpicker();
 }
 
@@ -1262,7 +1273,8 @@ unlink(testfile.c_str());
       } // Fl_Box* boxSelect
       { brwSelect = new Fl_Browser(5, 52, 200, 325);
         brwSelect->type(2);
-        brwSelect->textfont(4);
+        brwSelect->textfont(Apps_TextFont);
+        brwSelect->textsize(Apps_TextSize);
         brwSelect->callback((Fl_Callback*)brwSelectCB);
       } // Fl_Browser* brwSelect
       { tabs = new Fl_Tabs(210, 27, 475, 350);
@@ -1272,7 +1284,8 @@ unlink(testfile.c_str());
           infoTab->hide();
           infoTab->deactivate();
           { infoDisplay = new Fl_Text_Display(215, 57, 470, 318);
-            infoDisplay->textfont(4);
+            infoDisplay->textfont(Apps_TextFont);
+            infoDisplay->textsize(Apps_TextSize);
             infoDisplay->buffer(txtBuffer);
           } // Fl_Text_Display* infoDisplay
           infoTab->end();
@@ -1281,7 +1294,8 @@ unlink(testfile.c_str());
           filesTab->when(FL_WHEN_CHANGED);
           filesTab->deactivate();
           { filesDisplay = new Fl_Text_Display(215, 52, 470, 323);
-            filesDisplay->textfont(4);
+            filesDisplay->textfont(Apps_TextFont);
+            filesDisplay->textsize(Apps_TextSize);
             filesDisplay->buffer(txtBuffer);
           } // Fl_Text_Display* filesDisplay
           filesTab->end();
@@ -1291,7 +1305,8 @@ unlink(testfile.c_str());
           dependsTab->deactivate();
           { dependsDisplay = new Fl_Text_Display(215, 57, 470, 318);
             dependsDisplay->labelfont(1);
-            dependsDisplay->textfont(4);
+            dependsDisplay->textfont(Apps_TextFont);
+            dependsDisplay->textsize(Apps_TextSize);
             dependsDisplay->buffer(txtBuffer);
           } // Fl_Text_Display* dependsDisplay
           dependsTab->end();
@@ -1300,7 +1315,8 @@ unlink(testfile.c_str());
           sizeTab->hide();
           sizeTab->deactivate();
           { sizeDisplay = new Fl_Text_Display(215, 57, 470, 318);
-            sizeDisplay->textfont(4);
+            sizeDisplay->textfont(Apps_TextFont);
+            sizeDisplay->textsize(Apps_TextSize);
             sizeDisplay->buffer(txtBuffer);
           } // Fl_Text_Display* sizeDisplay
           sizeTab->end();
@@ -1339,7 +1355,8 @@ unlink(testfile.c_str());
       { grpSingle = new Fl_Group(5, 52, 200, 348);
         { brwExtn = new Fl_Browser(5, 52, 200, 325);
           brwExtn->type(2);
-          brwExtn->textfont(4);
+          brwExtn->textfont(Apps_TextFont);
+          brwExtn->textsize(Apps_TextSize);
           brwExtn->callback((Fl_Callback*)brwExtnCB);
         } // Fl_Browser* brwExtn
         { btnSingle = new Fl_Button(5, 380, 75, 20, mygettext("Go"));
@@ -1354,7 +1371,8 @@ unlink(testfile.c_str());
       { grpMulti = new Fl_Group(5, 52, 200, 348);
         { brwMulti = new Fl_Browser(5, 52, 200, 325);
           brwMulti->type(3);
-          brwMulti->textfont(4);
+          brwMulti->textfont(Apps_TextFont);
+          brwMulti->textsize(Apps_TextSize);
           brwMulti->callback((Fl_Callback*)brwMultiCB);
         } // Fl_Browser* brwMulti
         { btnMulti = new Fl_Button(5, 380, 200, 20, mygettext("Process Selected Item(s)"));
@@ -1364,7 +1382,8 @@ unlink(testfile.c_str());
       } // Fl_Group* grpMulti
       { brwResults = new Fl_Browser(210, 52, 475, 325);
         brwResults->type(2);
-        brwResults->textfont(4);
+        brwResults->textfont(Apps_TextFont);
+        brwResults->textsize(Apps_TextSize);
         brwResults->callback((Fl_Callback*)brwResultsCB);
       } // Fl_Browser* brwResults
       { btnResults = new Fl_Button(210, 380, 145, 20, mygettext("Go"));
diff --git a/editor/editor.cxx b/editor/editor.cxx
index bdddbdc..93a8ed1 100644
--- a/editor/editor.cxx
+++ b/editor/editor.cxx
@@ -43,6 +43,10 @@
 //
 // --------------------------- End Log ---------------------------- //
 
+#define Editor_TextFont FL_COURIER
+#define Editor_TextSize 10
+
+
 #define Version "Ver 0.2 1/21/2025"
 
 // Uncomment the next line to disable drag and drop text.
@@ -234,6 +238,7 @@ void linenumbers_cb(Fl_Widget *w, void* v) {
   const Fl_Menu_Item* i = m->mvalue();
   if ( i->value() ) {
     e->editor->linenumber_width(line_num_width);	// enable
+    e->editor->linenumber_font(e->editor->textfont());
     e->editor->linenumber_size(e->editor->textsize());
   } else {
     e->editor->linenumber_width(0);	// disable
@@ -495,7 +500,8 @@ Fl_Window* new_view() {
     m->copy(menuitems, w);
     w->editor = new Fl_Text_Editor(0, 30, 660, 370);
     w->editor->buffer(textbuf);
-    w->editor->textfont(FL_COURIER);
+    w->editor->textfont(Editor_TextFont);
+    w->editor->textsize(Editor_TextSize);
   w->end();
   w->resizable(w->editor);
   w->callback((Fl_Callback *)close_cb, w);
diff --git a/stats/stats.cxx b/stats/stats.cxx
index bff1d3c..d850526 100644
--- a/stats/stats.cxx
+++ b/stats/stats.cxx
@@ -1,5 +1,9 @@
 // generated by Fast Light User Interface Designer (fluid) version 1.0110
 
+#define Stats_TextFont FL_COURIER
+#define Stats_TextSize 10
+
+
 #include <libintl.h>
 #include "stats.h"
 // (c) Robert Shingledecker 2008-2010
@@ -9,7 +13,8 @@
 using namespace std;
 static Fl_Text_Buffer *txtBuffer = new Fl_Text_Buffer(); 
 
-void tabsGroupCB(Fl_Widget*, void*userdata) {
+//void tabsGroupCB(Fl_Widget*, void*userdata) {
+void tabsGroupCB(Fl_Widget*, __attribute__ ((unused)) void*userdata) {
   tabs->value()->do_callback();
 }
 
@@ -84,7 +89,8 @@ textdomain("tinycore");
         o->when(FL_WHEN_CHANGED);
         o->hide();
         { cpuDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          cpuDisplay->textfont(4);
+          cpuDisplay->textfont(Stats_TextFont);
+          cpuDisplay->textsize(Stats_TextSize);
           cpuDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* cpuDisplay
         o->end();
@@ -93,7 +99,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("mem"));
         o->hide();
         { memDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          memDisplay->textfont(4);
+          memDisplay->textfont(Stats_TextFont);
+          memDisplay->textsize(Stats_TextSize);
           memDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* memDisplay
         o->end();
@@ -102,7 +109,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("net"));
         o->hide();
         { netDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          netDisplay->textfont(4);
+          netDisplay->textfont(Stats_TextFont);
+          netDisplay->textsize(Stats_TextSize);
           netDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* netDisplay
         o->end();
@@ -111,7 +119,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("modules"));
         o->hide();
         { modulesDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          modulesDisplay->textfont(4);
+          modulesDisplay->textfont(Stats_TextFont);
+          modulesDisplay->textsize(Stats_TextSize);
           modulesDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* modulesDisplay
         o->end();
@@ -120,7 +129,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("processes"));
         o->hide();
         { processesDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          processesDisplay->textfont(4);
+          processesDisplay->textfont(Stats_TextFont);
+          processesDisplay->textsize(Stats_TextSize);
           processesDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* processesDisplay
         o->end();
@@ -129,7 +139,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("dmesg"));
         o->hide();
         { dmesgDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          dmesgDisplay->textfont(4);
+          dmesgDisplay->textfont(Stats_TextFont);
+          dmesgDisplay->textsize(Stats_TextSize);
           dmesgDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* dmesgDisplay
         o->end();
@@ -138,7 +149,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("mounts"));
         o->hide();
         { mountsDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          mountsDisplay->textfont(4);
+          mountsDisplay->textfont(Stats_TextFont);
+          mountsDisplay->textsize(Stats_TextSize);
           mountsDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* mountsDisplay
         o->end();
@@ -147,7 +159,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("filesystems"));
         o->hide();
         { filesystemsDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          filesystemsDisplay->textfont(4);
+          filesystemsDisplay->textfont(Stats_TextFont);
+          filesystemsDisplay->textsize(Stats_TextSize);
           filesystemsDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* filesystemsDisplay
         o->end();
@@ -156,7 +169,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("boot"));
         o->hide();
         { bootDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          bootDisplay->textfont(4);
+          bootDisplay->textfont(Stats_TextFont);
+          bootDisplay->textsize(Stats_TextSize);
           bootDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* bootDisplay
         o->end();
@@ -165,7 +179,8 @@ textdomain("tinycore");
         o->callback((Fl_Callback*)tabCB, (void*)("installed"));
         o->hide();
         { extensionsDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          extensionsDisplay->textfont(4);
+          extensionsDisplay->textfont(Stats_TextFont);
+          extensionsDisplay->textsize(Stats_TextSize);
           extensionsDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* extensionsDisplay
         o->end();
@@ -173,7 +188,8 @@ textdomain("tinycore");
       { Fl_Group* o = new Fl_Group(0, 5, 660, 350, gettext("bigHomeFiles"));
         o->callback((Fl_Callback*)tabCB, (void*)("big"));
         { bigDisplay = new Fl_Text_Display(0, 0, 660, 335);
-          bigDisplay->textfont(4);
+          bigDisplay->textfont(Stats_TextFont);
+          bigDisplay->textsize(Stats_TextSize);
           bigDisplay->buffer(txtBuffer);
         } // Fl_Text_Display* bigDisplay
         o->end();
diff --git a/tc-install/tc-install.cxx b/tc-install/tc-install.cxx
index ed378d7..9d9bf50 100644
--- a/tc-install/tc-install.cxx
+++ b/tc-install/tc-install.cxx
@@ -1,5 +1,9 @@
 // generated by Fast Light User Interface Designer (fluid) version 1.0303
 
+#define TcInstall_TextFont FL_COURIER
+#define TcInstall_TextSize 10
+
+
 #include <libintl.h>
 #include "tc-install.h"
 // (c) Robert Shingledecker 2011
@@ -15,7 +19,9 @@
 using namespace std;
 static istringstream iss; 
 static string command,msg,heading; 
-static int results, locales_set=0, test4syslinux, test4mkdosfs, test4perl; 
+// results and test4syslinux are not used.
+//static int results, locales_set=0, test4syslinux, test4mkdosfs, test4perl; 
+static int locales_set=0, test4mkdosfs, test4perl; 
 static string image,type,installMode, target,dev,format,path,coreplus,boot,flag, markActive,tcepath; 
 static string warn="Mark active if Tiny Core is the only operation system,\nor Windows and Tiny Core are on the same disk.\nOtherwise use Grub extension after installation."; 
 
@@ -225,7 +231,7 @@ void btnCB(Fl_Widget*, void*userdata) {
   }
 }
 
-void brwCB(Fl_Widget*, void*userdata) {
+void brwCB(Fl_Widget*, __attribute__ ((unused)) void*userdata) {
   if ( brwTarget->value() )
   {
      dev = brwTarget->text(brwTarget->value());
@@ -243,7 +249,7 @@ void brwCB(Fl_Widget*, void*userdata) {
   }
 }
 
-void btnProceedCB(Fl_Widget*, void* userdata) {
+void btnProceedCB(Fl_Widget*, __attribute__ ((unused)) void* userdata) {
   btnProceed->deactivate();
   grpButtons->deactivate();
   cursor_wait();
@@ -579,7 +585,8 @@ int main(int argc, char **argv) {
       { grpBoot = new Fl_Group(25, 30, 435, 325, mygettext("Boot Options"));
         grpBoot->hide();
         { brwBootRef = new Fl_Browser(35, 55, 415, 235, mygettext("Boot Options Reference List"));
-          brwBootRef->textfont(4);
+          brwBootRef->textfont(TcInstall_TextFont);
+          brwBootRef->textsize(TcInstall_TextSize);
           brwBootRef->align(Fl_Align(FL_ALIGN_TOP));
         } // Fl_Browser* brwBootRef
         { options = new Fl_Input(35, 325, 415, 20, mygettext("Enter Spaces Separated Options From Examples Above.\nThese can be edited late\
diff --git a/tc-wbarconf/tc-wbarconf.cxx b/tc-wbarconf/tc-wbarconf.cxx
index f47f82c..ae49570 100644
--- a/tc-wbarconf/tc-wbarconf.cxx
+++ b/tc-wbarconf/tc-wbarconf.cxx
@@ -1,5 +1,9 @@
 // generated by Fast Light User Interface Designer (fluid) version 1.0110
 
+#define TcWbarconf_TextFont FL_COURIER
+#define TcWbarconf_TextSize 10
+
+
 #include <libintl.h>
 #include "tc-wbarconf.h"
 // (c) Robert Shingledecker 2010-2012
@@ -15,7 +19,9 @@
 #include <string.h>
 using namespace std;
 static string home, tcedir, command, selected; 
-static int chosen,results; 
+// results is not used
+//static int chosen,results; 
+static int chosen; 
 static string widgetArray[4]; 
 static string onbootList, wbarXlist, options; 
 static string wbarIcons = "/usr/local/tce.icons"; 
@@ -169,13 +175,15 @@ textdomain("tinycore");
     { grpGUI = new Fl_Group(9, 32, 421, 293);
       { brwWbar = new Fl_Browser(9, 33, 200, 225, gettext("Wbar Icons"));
         brwWbar->type(1);
-        brwWbar->textfont(4);
+        brwWbar->textfont(TcWbarconf_TextFont);
+        brwWbar->textsize(TcWbarconf_TextSize);
         brwWbar->callback((Fl_Callback*)brwWbarCB);
         brwWbar->align(FL_ALIGN_TOP);
       } // Fl_Browser* brwWbar
       { brwXlist = new Fl_Browser(219, 33, 210, 225, gettext("eXclude Icons"));
         brwXlist->type(1);
-        brwXlist->textfont(4);
+        brwXlist->textfont(TcWbarconf_TextFont);
+        brwXlist->textsize(TcWbarconf_TextSize);
         brwXlist->callback((Fl_Callback*)brwXlistCB);
         brwXlist->align(FL_ALIGN_TOP);
       } // Fl_Browser* brwXlist
@@ -214,7 +222,8 @@ textdomain("tinycore");
         txtFromGUI->color((Fl_Color)29);
       } // Fl_Output* txtFromGUI
       { brwOptions = new Fl_Browser(8, 39, 420, 215, gettext("Optionally Enter Additional Unique Options from above:"));
-        brwOptions->textfont(4);
+        brwOptions->textfont(TcWbarconf_TextFont);
+        brwOptions->textsize(TcWbarconf_TextSize);
       } // Fl_Browser* brwOptions
       { txtOptions = new Fl_Input(10, 271, 414, 24);
       } // Fl_Input* txtOptions
