@@ -334,7 +334,7 @@ end __GetPreference
334334
335335-- Text Formatting Code
336336command textFormatInitialize
337- -- permit use in environment witn no dependencies
337+ -- permit use in environment with no dependencies
338338 local tTabDepth
339339 put __GetPreference("editor,tabdepth" , 3 ) into tTabDepth
340340
@@ -2621,35 +2621,55 @@ end dragEnd
26212621
26222622# Description
26232623# # Returns a line stripped of comments at the end of the line
2624+ # # and inline comments ( /* ... */ )
26242625private function lineStripComments pLine
2625- local tLine
2626+ local tLine , tInComment
26262627 split pLine by quote
26272628
2629+ put false into tInComment
26282630 repeat with tIndex = 1 to the number of elements of pLine step 2
2629- local tDecommented
2630- put __StripComment(pLine [tIndex ]) into tDecommented
2631- put tDecommented after tLine
2632- if pLine [tIndex ] is tDecommented and \
2633- tIndex is not the number of elements of pLine then
2631+ put __StripComment(pLine [tIndex ], tInComment ) after tLine
2632+ if tInComment then exit repeat
2633+ if tIndex is not the number of elements of pLine then
26342634 put quote & pLine [tIndex + 1 ] & quote after tLine
26352635 end if
26362636 end repeat
26372637
26382638 return tLine
26392639end lineStripComments
26402640
2641- private function __StripComment pLine
2641+ private function __StripComment pLine, @xInComment
26422642 local tOffset
2643- repeat for each word tComment in "# -- // /* "
2643+ repeat for each word tComment in "# -- //"
26442644 put offset (tComment , pLine ) into tOffset
26452645 if tOffset is not 0 then
26462646 delete char tOffset to - 1 of pLine
2647+ put true into xInComment
26472648 end if
26482649 end repeat
2650+
2651+ put __StripBlockComment(pLine , xInComment) into pLine
26492652
26502653 return pLine
26512654end __StripComment
26522655
2656+ private function __StripBlockComment pline, @xInComment
2657+ local tOffset , tOffsetEnd
2658+ put offset ("/*" , pLine ) into tOffset
2659+ if tOffset is not 0 then
2660+ put offset ("*/" , pLine , tOffset ) into tOffsetEnd
2661+ if tOffsetEnd is not 0 then
2662+ delete char tOffset to tOffset + tOffsetEnd of pLine
2663+ put __StripBlockComment(pLine , xInComment) into pLine
2664+ else
2665+ delete char tOffset to - 1 of pLine
2666+ put true into xInComment
2667+ end if
2668+ end if
2669+
2670+ return pLine
2671+ end __StripBlockComment
2672+
26532673# ###############################################################################
26542674
26552675command actionCopy
0 commit comments