• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

zXref (version 1.10)

Started by Patrice Terrier, August 14, 2009, 08:25:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bud Meyer

I edited zXref.cfg with Notepad, and afaik all of my bas and inc files were edited with PBEdit.

If you think there might be a line break issue, perhaps you could replace them internally?
1. Replace all $CRLFs with "ENDOFLINE" (or some unique "end of line" code)
2. Replace all $CRs with "ENDOFLINE"
3. Replace all $LFs with "ENDOFLINE"
4. Replace all "ENDOFLINE" with $CRLFs
That way it wouldn't matter what the line breaks start off as, they will all end up the same.

Patrice Terrier

I have posted a new version (ZIP is attached to the first post of this thread), that uses another algo to merge the main source and the include files altogether.

I hope this one will work for everybody, then i could create the final cleaned source code that would decrease the size of the EXE, removing all unused SUB(s) and FUNCTION(s).

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com


Patrice Terrier

Trento-- Ok, thanks!

What about the ohers?
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

I have been able to compile my first Cleaned file, produced by zXref.

I took my Gallery example and i cut the EXE size from 127488 bytes down to 117248 bytes  ;D

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Bud Meyer

No problems here.  8)

Good work! I look forward to being able to trim out unneeded things. A smaller size is nice, and it would be great if it let me compile super-quick like incLean did.   :D

Patrice Terrier

#51
Here is the little magic, that creates the final cleaned code


SUB BuildCleanVersion(bArray() AS LONG)
   LOCAL zFileName AS ASCIIZ * %MAX_PATH, sBuf AS STRING
   LOCAL nDone, nLine, nRemoved AS LONG
   nDone = 0: nLine = 0: nRemoved = 0
   zFileName = gsFilePath + gsFileName
   CALL zUseBuildName(gsFilePath + "$" + MID$(gsFileName, 2, LEN(gsFileName) - 1), 1)
   DO WHILE nDone = 0
      sBuf = zBufin(zFileName, nDone)
      IF nDone = 0 THEN
         nLine += 1
         IF BIT(bArray(0), nLine) = 0 THEN
            zBuild(sBuf + $CRLF, 1)
         ELSE
            nRemoved +=1 ' Removed line counter
         END IF
      END IF
   LOOP
   zBuild("", 0)
END SUB


Short isn't it?

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

Done!

See the first post of this thread.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Trento Castricone

Patrice

Works !

I included the lists below for your reference only.
Savings on this project was:
From: 382K
To:    379k

Thanks much for all your work . . .


================================================================================
My CFG file:
"SCANPATH:   C:\PBWin90\WinAPI_114\private" ' Use ; as delimiter
================================================================================

================================================================================
XRef report: @FIND-IT PRO.BAS + include files. Generated 08-18-2009, 13:44:15
22236 lines scanned in 0.827 seconds (1613253 lines/minute)
================================================================================
MAIN + INCLUDE FILES
--------------------------------------------------------------------------------
C:\PDSU\NEW VERSION\@Find-It Pro.bas                      [Main source file]
C:\PBWin90\WinAPI\COMMCTRL.INC (not scanned)              [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSMEM.INC (not scanned)            [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSENUMS.INC (not scanned)          [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSTYPES.INC (not scanned)          [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSINIT.INC (not scanned)           [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSPIXELFORMATS.INC (not scanned)   [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSCOLOR.INC (not scanned)          [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSMETAHEADER.INC (not scanned)     [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSIMAGING.INC (not scanned)        [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSCOLORMATRIX.INC (not scanned)    [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSEFFECTS.INC (not scanned)        [@Find-It Pro.bas]
C:\PBWin90\WinAPI\GDIPLUSFLAT.INC (not scanned)           [@Find-It Pro.bas]
C:\PBWin90\WinAPI\COMMCTRL.INC (not scanned)              [@Find-It Pro.bas]
================================================================================

================================================================================
PowerBASIC for Windows
PB/Win  Version 9.01
Copyright (c) 1996-2009 PowerBasic Inc.
Venice, Florida USA
All Rights Reserved

Primary source:  C:\PDSU\NEWVER~1\Find-It Pro.bas   {151430 total lines}
Target compilation:  Find-It Pro.exe
Compile time:  3.9 seconds, at 2329692 lines/minute

118604 bytes compiled code, 67774 bytes RTLibrary,
9156 bytes string literals, and 17492 bytes dgroup.
Executable stack size:  1048576 bytes.
Disk image: 390656 bytes   Memory image: 94422 bytes.

Component Files:
----------------
C:\PDSU\NEWVER~1\Find-It Pro.bas
C:\PBWIN90\WINAPI\INITCTRL.INC
C:\PBWIN90\WINAPI~3\COMMCTRL.INC
C:\PBWIN90\WINAPI~3\WINDOWS.INC
C:\PBWIN90\WINAPI~3\WINDEF.INC
C:\PBWIN90\WINAPI~3\WINNT.INC
C:\PBWIN90\WINAPI~3\CTYPE.INC
C:\PBWIN90\WINAPI~3\BASETSD.INC
C:\PBWIN90\WINAPI~3\GUIDDEF.INC
C:\PBWIN90\WINAPI~3\KTMTYPES.INC
C:\PBWIN90\WINAPI~3\WINERROR.INC
C:\PBWIN90\WINAPI~3\WINBASE.INC
C:\PBWIN90\WINAPI~3\WINGDI.INC
C:\PBWIN90\WINAPI~3\WINUSER.INC
C:\PBWIN90\WINAPI~3\TVOUT.INC
C:\PBWIN90\WINAPI~3\WINNLS.INC
C:\PBWIN90\WINAPI~3\WINCON.INC
C:\PBWIN90\WINAPI~3\WINVER.INC
C:\PBWIN90\WINAPI~3\WINREG.INC
C:\PBWIN90\WINAPI~3\WTYPES.INC
C:\PBWIN90\WINAPI~3\REASON.INC
C:\PBWIN90\WINAPI~3\WINNETWK.INC
C:\PBWIN90\WINAPI~3\CDERR.INC
C:\PBWIN90\WINAPI~3\DDE.INC
C:\PBWIN90\WINAPI~3\DDEML.INC
C:\PBWIN90\WINAPI~3\DLGS.INC
C:\PBWIN90\WINAPI~3\LZEXPAND.INC
C:\PBWIN90\WINAPI~3\MMSYSTEM.INC
C:\PBWIN90\WINAPI~3\NB30.INC
C:\PBWIN90\WINAPI~3\RPC.INC
C:\PBWIN90\WINAPI~3\RPCDCE.INC
C:\PBWIN90\WINAPI~3\RPCDCEP.INC
C:\PBWIN90\WINAPI~3\RPCNSI.INC
C:\PBWIN90\WINAPI~3\RPCASYNC.INC
C:\PBWIN90\WINAPI~3\SHELLAPI.INC
C:\PBWIN90\WINAPI~3\WINPERF.INC
C:\PBWIN90\WINAPI~3\WINSPOOL.INC
C:\PBWIN90\WINAPI~3\WINDOWSX.INC
C:\PBWIN90\WINAPI~3\OBJIDL.INC
C:\PBWIN90\WINAPI~3\OLE2.INC
C:\PBWIN90\WINAPI~3\OBJBASE.INC
C:\PBWIN90\WINAPI~3\UNKNWN.INC
C:\PBWIN90\WINAPI~3\OAIDL.INC
C:\PBWIN90\WINAPI~3\CGUID.INC
C:\PBWIN90\WINAPI~3\URLMON.INC
C:\PBWIN90\WINAPI~3\OLEIDL.INC
C:\PBWIN90\WINAPI~3\SERVPROV.INC
C:\PBWIN90\WINAPI~3\MSXML.INC
C:\PBWIN90\WINAPI~3\PROPIDL.INC
C:\PBWIN90\WINAPI~3\OLEAUTO.INC
C:\PBWIN90\WINAPI_114\PRIVATE\DATE ROUTINES.INC
C:\PBWIN90\WINAPI_114\GDIPLUS.INC
C:\PBWIN90\WINAPI~3\GDIPLUSMEM.INC
C:\PBWIN90\WINAPI~3\GDIPLUSENUMS.INC
C:\PBWIN90\WINAPI~3\GDIPLUSTYPES.INC
C:\PBWIN90\WINAPI~3\GDIPLUSINIT.INC
C:\PBWIN90\WINAPI~3\GDIPLUSPIXELFORMATS.INC
C:\PBWIN90\WINAPI~3\GDIPLUSCOLOR.INC
C:\PBWIN90\WINAPI~3\GDIPLUSMETAHEADER.INC
C:\PBWIN90\WINAPI~3\GDIPLUSIMAGING.INC
C:\PBWIN90\WINAPI~3\GDIPLUSCOLORMATRIX.INC
C:\PBWIN90\WINAPI~3\GDIPLUSFLAT.INC
C:\PBWIN90\WINAPI_114\LISTVIEWCTRL.INC
C:\PBWIN90\WINAPI_114\WININET.INC
================================================================================

Bud Meyer

Almost there..

This block of code went missing from $CleanedSourceFile:  (Odd that a single, entire function would go missing.)
CALLBACK FUNCTION BrowseForFolderProc () AS LONG
   IF CBMSG = %BFFM_INITIALIZED THEN
       DIALOG SEND CBHNDL, %BFFM_SETSELECTION, %TRUE, CBLPARAM
   ELSEIF CBMSG = %BFFM_SELCHANGED THEN
       DIM zBuffer AS ASCIIZ * %MAX_PATH
       CALL SHGetPathFromIDList(BYVAL CBWPARAM, zBuffer)
       'IF ISFALSE CBWPARAM OR ISFALSE LEN(zBuffer) OR ISFALSE (GETATTR(zBuffer) AND %SUBDIR) OR MID$(zBuffer,2,1) <> ":" THEN  ' Not a local or mapped drive
       '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
       'ELSEIF (GETATTR(zBuffer) AND %SYSTEM) AND RIGHT$(zBuffer,2) <> ":\" THEN ' exclude system folders, allow root directories
       '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
       'END IF
   END IF
END FUNCTION  


So I pasted it manually, and it compiled, but my program immediately crashes when I try to run it.   :(

The @ComboSourceFile still compiles and runs correctly.

Patrice Terrier

I do not have DDT code myself, thus i have checked only with plain SDK.

CALLBACK FUNCTION is typical DDT ...

You will have to give me an example, or look yourself into the code.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Bud Meyer

now that you point it out, I realized maybe it shouldn't have been a CALLBACK anyway, so I changed it to this:
FUNCTION BrowseForFolderProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lpData AS LONG) AS LONG
    IF wMsg = %BFFM_INITIALIZED THEN
        DIALOG SEND hWnd, %BFFM_SETSELECTION, %TRUE, lpData
    ELSEIF wMsg = %BFFM_SELCHANGED THEN
        DIM zBuffer AS ASCIIZ * %MAX_PATH
        CALL SHGetPathFromIDList(BYVAL wParam, zBuffer)
        'IF ISFALSE CBWPARAM OR ISFALSE LEN(zBuffer) OR ISFALSE (GETATTR(zBuffer) AND %SUBDIR) OR MID$(zBuffer,2,1) <> ":" THEN  ' Not a local or mapped drive
        '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
        'ELSEIF (GETATTR(zBuffer) AND %SYSTEM) AND RIGHT$(zBuffer,2) <> ":\" THEN ' exclude system folders, allow root directories
        '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
        'END IF
    END IF
END FUNCTION


However, it's still missing from the $SourceFile.

And looking into the crashing problem, it turns out that many of my (non-DDT) functions have been omitted as well. It appears that most/all of them are EXPORTed (it's a DLL), so maybe zXref doesn't take those into account..

Paul Squires

Hi Patrice,

For fun, I ran zXref on the FireFly3 source code (241094 lines) and it created a 4.8 meg main file in about 38 seconds. There was not much to clean in the source code so the resulting FireFly3.exe only went from 2397 bytes to 2393 bytes. The best thing was that the source compiled without any modifications or errors. Pretty cool.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Patrice Terrier

#58
METHOD and OOP have not been done either.

Indeed EXPORTED SUB or FUNCTION should not be removed it is a mistake of my own.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

José Roca

 
Patrice,

The exclusion of the function BrowseForFolderProc must be because, being a callback function, it is not directly called from code. You must also take into account that functions pointed using CODEPTR must be included.