@@ -34,7 +34,7 @@ import std/[os, strutils, paths, tables, parseopt]
34
34
# mies
35
35
36
36
var
37
- versionfl: float = 1.65
37
+ versionfl: float = 1.651
38
38
codetwigst: string = " CodeTwig"
39
39
ct_projectsdirst: string = " projects"
40
40
dec_list_suffikst: string = " dec_list.dat"
@@ -482,7 +482,7 @@ proc substringInSequence(stringsq: seq[string]; substringst: string): bool =
482
482
483
483
484
484
485
- proc containsWithValidBoundaries(tekst, subst: string ; beforesq, aftersq: seq [string ], allowfirstlastbo : bool ): bool =
485
+ proc containsWithValidBoundaries(tekst, subst: string ; beforesq, aftersq: seq [string ]; allowfirstbo, allowlastbo : bool ): bool =
486
486
487
487
# subst within tekst has valid bounds if before and after strings are in seqs
488
488
# allowfirstlastbo means that the subst is allowed as first or last part of tekst
@@ -500,27 +500,40 @@ proc containsWithValidBoundaries(tekst, subst: string; beforesq, aftersq: seq[st
500
500
aftokbo = false
501
501
skipbo = false
502
502
503
+ wisp(" tekst = " , tekst)
504
+ wisp(" subst =" , subst)
505
+ wisp(" beforesq = " , $ beforesq)
506
+ wisp(" aftersq = " , $ aftersq)
507
+ wisp(" tekst.len = " , tekst.len)
508
+ wisp(" allowfirstbo = " , allowfirstbo)
509
+ wisp(" allowlastbo = " , allowlastbo)
510
+
511
+
503
512
substartit = tekst.find(subst)
504
- subendit = substartit + subst.len
513
+ subendit = substartit + subst.len - 1
505
514
506
- wisp(" tekst.len = " , tekst.len)
507
515
wisp(" substartit = " , substartit)
508
516
wisp(" subendit = " , subendit)
509
- wisp( " allowfirstlastbo = " , allowfirstlastbo)
517
+
510
518
511
519
if substartit >= 0 :
512
520
513
- if allowfirstlastbo :
521
+ if allowfirstbo :
514
522
if substartit == 0 :
515
523
forokbo = true
524
+ else :
525
+ if substartit == 0 :
526
+ skipbo = true
527
+
528
+ if allowlastbo:
516
529
if subendit == tekst.len - 1 :
517
530
aftokbo = true
518
531
else :
519
- if substartit == 0 or subendit == tekst.len - 1 :
520
- # no further testing needed
532
+ if subendit == tekst.len - 1 :
521
533
skipbo = true
522
534
523
- if not forokbo and not (substartit == 0 ) and not skipbo:
535
+
536
+ if not forokbo and not skipbo:
524
537
wisp " in for"
525
538
for forst in beforesq:
526
539
forstartit = substartit - forst.len
@@ -531,18 +544,20 @@ proc containsWithValidBoundaries(tekst, subst: string; beforesq, aftersq: seq[st
531
544
forokbo = true
532
545
break
533
546
534
- if not aftokbo and not (subendit == tekst.len - 1 ) and not skipbo:
547
+ if not aftokbo and not skipbo:
535
548
wisp " in aft"
536
549
for aftst in aftersq:
537
550
aftendit = subendit + aftst.len
538
551
wisp(" aftendit = " , aftendit)
539
- if aftendit <= tekst.len:
540
- aftslicest = tekst[subendit .. aftendit - 1 ]
552
+ if aftendit < tekst.len:
553
+ aftslicest = tekst[subendit + 1 .. aftendit]
541
554
wisp(" aftslicest = " , aftslicest)
542
555
if aftslicest == aftst:
543
556
aftokbo = true
544
557
break
545
558
559
+ wisp(" forokbo =" , forokbo)
560
+ wisp(" aftokbo = " , aftokbo)
546
561
547
562
wispbo = false
548
563
@@ -823,7 +838,7 @@ proc createDeclarationList(proj_def_pathst: string) =
823
838
824
839
if sline.len > 2 and not incommentblockbo and not commentclosingbo and not singlecommentbo:
825
840
# if sline.contains(declare2st) and not sline.contains("\"" & declare2st & "\""):
826
- if sline.containsWithValidBoundaries(declare2st, @ [" ." , " (" , " " , " =" , " [" ], @ [" (" , " =" , " " , " ." ], false ) :
841
+ if sline.containsWithValidBoundaries(declare2st, @ [" ." , " (" , " " , " =" , " [" ], @ [" (" , " =" , " " , " ." ], false , true ) :
827
842
828
843
foundcountit += 1
829
844
@@ -2414,5 +2429,5 @@ else:
2414
2429
if true :
2415
2430
var tekst = " aapnootmies"
2416
2431
2417
- echo " containsWithValidBoundaries = " , $ containsWithValidBoundaries(tekst, " noot" , @ [" p" ], @ [" mie " ], false )
2432
+ echo " containsWithValidBoundaries = " , $ containsWithValidBoundaries(tekst, " noot" , @ [" p" ], @ [" mi " ], true , true )
2418
2433
0 commit comments