From 607965bae3f13c54b488ee41c3b43ccb8199d882 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Sun, 7 Jun 2026 19:33:07 +0900
Subject: Improvement to qt3 --> TQt conversion script

Co-authored-by: Alexander Golubev <fatzer2@gmail.com>
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 .../qt3-tqt/convert_existing_qt3_app_to_tqt        | 29 ++++++++++------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/conversions/qt3-tqt/convert_existing_qt3_app_to_tqt b/conversions/qt3-tqt/convert_existing_qt3_app_to_tqt
index ef35e69..d72ba7d 100755
--- a/conversions/qt3-tqt/convert_existing_qt3_app_to_tqt
+++ b/conversions/qt3-tqt/convert_existing_qt3_app_to_tqt
@@ -1,15 +1,12 @@
 #!/bin/bash
 
-find ./ -type f -iname "*.c*" -o -iname "*.h*" -o -iname "*.ui*" -o -name "*.kcfg" -o -name "*.ypp" -not -iwholename '*.git*' |\
-tr "\n" "\0" |\
-xargs -r0 sed -i \
- -e 's/^Q\([A-Z]\)\([_a-zA-Z]\)/TQ\1\2/g' \
- -e 's/\([^_]\)Q\([A-Z]\)\([_a-zA-Z]\)/\1TQ\2\3/g' \
- -e 's/Qt/TQt/g' \
- -e 's/TTQ/TQ/g' \
- -e 's/TTQ/TQ/g' \
- -e 's/TTQ/TQ/g' \
- -e 's/TTQ/TQ/g'
+find ./ -type f '(' -iname "*.c*" -o -iname "*.h*" -o -iname "*.ui*" -o -name "*.kcfg" -o -name "*.ypp" ')' ! -ipath '*.git*' -print0 |\
+xargs -r0 perl -pi \
+ -e 's/(^|[^_T])Q([A-Z][_a-zA-Z])/$1TQ$2/g;' \
+ -e 's/\bQt/TQt/g;' \
+ -e 's/\bQ_OBJECT\b/TQ_OBJECT/g;' \
+ -e 's/\bSIGNAL\b/TQ_SIGNAL/g;' \
+ -e 's/\bSLOT\b/TQ_SLOT/g;'
 
 # Move the library
 find ./ -type f -iname "*" -not -iwholename '*.git*' -print0 |\
@@ -373,12 +370,12 @@ xargs -r0 sed -i \
 
 # Additional changes for TDE R14.2.0+
 find ./ -type f -iname "*" -not -iwholename '*.git*' -print0 |\
-xargs -r0 sed -i \
- -e "s|\bguiThread\b|coreThread|g" \
- -e "s|\bguiThreadAwake\b|coreThreadAwake|g" \
- -e "s|\bfinishGuiThread\b|finishCoreThread|g" \
- -e "s|\bisGuiThread\b|isCoreThread|g" \
- -e "s|\bwakeUpGuiThread\b|wakeUpCoreThread|g"
+xargs -r0 perl -pi \
+ -e 's|\bguiThread\b|coreThread|g;' \
+ -e 's|\bguiThreadAwake\b|coreThreadAwake|g;' \
+ -e 's|\bfinishGuiThread\b|finishCoreThread|g;' \
+ -e 's|\bisGuiThread\b|isCoreThread|g;' \
+ -e 's|\bwakeUpGuiThread\b|wakeUpCoreThread|g;'
 
 # Headers
 find ./ -type f -iname "*" -not -iwholename '*.git*' -print0 |\
-- 
cgit v1.2.3

