CiaronJohn Posted January 8, 2020 Share Posted January 8, 2020 (edited) Hi All, I have this sample C code. I would like to get some insights regarding my problem My script should (1) detecting pragma - this is easy (2) I would like to detect if pragma is enclosing a specific function - (e.g. UB Func3 in line 28-36), not its declaration as in line 1-7 #pragma section #pragma mode=far static void Func1(); static void Func2(); static void Func3(); #pragma section=default #pragma mode=default /****************************************************************************************************************/ /* ??? : UB Func1( void ) */ /****************************************************************************************************************/ UB Func1( void ) { UB rtn, jdg ; rtn = 0; return ( rtn ) ; } /****************************************************************************************************************/ /* ??? : UB Func2( void ) */ /****************************************************************************************************************/ UB Func2( void ) { return ( SCRAP_METHODVER ) ; } #pragma ghs section text=".ra_scrap" /****************************************************************************************************************/ /* ??? : UB Func3( void ) */ /****************************************************************************************************************/ UB Func3( void ) { /* some code */ } #pragma ghs section text=default reason: i would like to comment this pragma. Thanks. sample.au3 Edited January 8, 2020 by CiaronJohn Link to comment Share on other sites More sharing options...
markyrocks Posted January 8, 2020 Share Posted January 8, 2020 I'd probably start off with https://www.autoitscript.com/autoit3/docs/libfunctions/_FileReadToArray.htm Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
CiaronJohn Posted January 8, 2020 Author Share Posted January 8, 2020 thanks @markyrocks, I can now edit the file, here's my logic expandcollapse popup$aArrayB = FileReadToArray($sourceCode[1]) Local $iLineCountA = @extended If @error Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. Else For $i = 1 To $iLineCountA -1 If StringInStr ($aArrayB[$i], '#pragma') Then $iPragma_Count = $iPragma_Count + 1 ; Pragma counter EndIf Next EndIf ;~ Condition if Pragma is found If $iPragma_Count > 0 Then ReDim $iLine_Count[$iLineCountA] ; Getting Line number of pragma For $i = 1 To $iLineCountA -1 If StringInStr ($aArrayB[$i], '#pragma') Then $iLine_Count[$x] = $i $x = $x + 1 EndIf Next $iFunction_Definition_Count = 0 ReDim $iLine_Count[$x + 1] ; Loop for number of pragma found For $x = 0 To (UBound($iLine_Count) -1) ; loop for checking in-between of two consecutive pragmas If $iLine_Count[$x] <> "" Then For $k = $iLine_Count[$x] To $iLine_Count[$x+1] ; if next line is another pragma, proceed to next iteration of line If StringInStr ($aArrayB[$k], '関数名') Then $iFunction_Definition_Count = $iFunction_Definition_Count + 1 EndIf Next If $iFunction_Definition_Count = 1 Then _FileWriteToLine($sourceCode[1], $iLine_Count[$x] + 1, '/* ' & $aArrayB[$iLine_Count[$x]]& ' */', 1) _FileWriteToLine($sourceCode[1], $iLine_Count[$x+1] +1, '/* ' & $aArrayB[$iLine_Count[$x + 1]]& ' */', 1) ; checking if there are EndIf $iFunction_Definition_Count = 0 EndIf Next EndIf i will now create logic if there are 2 or more pragmas enclosing #pragma section=".ra_scrap" #pragma text=".ra_scrap" /****************************************************************************************************************/ /* ??? : UB Func3( void ) */ /****************************************************************************************************************/ UB Func3( void ) { /* some code */ } #pragma section=default #pragma text=default thanks Link to comment Share on other sites More sharing options...
markyrocks Posted January 9, 2020 Share Posted January 9, 2020 can't really help out without code posted being error free you have variables in there that arnt defined the necessary includes ect. Probably on youre own from here. It appears to be overly complex for what your trying to accomplish but theres no way to tell without seeing it all. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
CiaronJohn Posted January 9, 2020 Author Share Posted January 9, 2020 its ok, i did it. C code is confidential since it is from a client. Thanks. Link to comment Share on other sites More sharing options...
markyrocks Posted January 9, 2020 Share Posted January 9, 2020 1 hour ago, CiaronJohn said: its ok, i did it. C code is confidential since it is from a client. Thanks. I'm not talking about the c code I'm talking about the autoit code. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
CiaronJohn Posted January 9, 2020 Author Share Posted January 9, 2020 AutoIT code will still result from error even if i send all the complete autoIT script, since most of its parameters are coming from confidential files. Link to comment Share on other sites More sharing options...
markyrocks Posted January 9, 2020 Share Posted January 9, 2020 Just now, CiaronJohn said: AutoIT code will still result from error even if i send all the complete autoIT script, since most of its parameters are coming from confidential files. When I say I need to see where a variable is coming from I'm referring to the declaration and subsequent changes. I don't want to see your confidential files. Sounds like someone needs a refund. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now