@@ -24,26 +24,17 @@ def concatText(text1, text2):
2424 header1 = lines1 [0 ]
2525 header2 = lines2 [0 ]
2626
27- # --- Extract packet count (2nd word) ---
28- count1 = int (header1 .split ()[1 ][:- 1 ])
29- count2 = int (header2 .split ()[1 ][:- 1 ])
30-
31- # --- Compute new count ---
32- total_packets = count1 + count2
33-
34- # --- Replace the 2nd word in header1 ---
35- header1_parts = header1 .split ()
36- header1_parts [1 ] = str (total_packets )+ ","
37- new_header1 = " " .join (header1_parts )
27+ # --- Extract packet count (2nd word) - this will be recalculated ---
28+ # We don't use these counts directly anymore, but extract the header structure
3829
3930 # --- Get bodies (all lines after header) ---
4031 body1 = lines1 [1 :]
4132
4233 # Extract the first effect from header2 (everything after "Pkt_count: #,")
4334 # The header format is: "Pkt_count: 78, Size: 0, Strip_id: 0, Set_id: 0..."
4435 header2_effect = None
45- if ", " in header2 :
46- parts = header2 .split (", " , 1 ) # Split only on first comma
36+ if "\n " in header2 :
37+ parts = header2 .split ("\n " , 1 ) # Split only on first comma
4738 if len (parts ) > 1 :
4839 header2_effect = parts [1 ] # Everything after "Pkt_count: #,"
4940
@@ -96,6 +87,18 @@ def concatText(text1, text2):
9687 pass
9788 body2_updated .append (line )
9889
90+ # --- Calculate actual packet count (all effects including header effects) ---
91+ # Count all effect lines: body1 + header2 effect (if exists) + body2
92+ total_packets = len (body1 ) # Body1 effects
93+ if header2_effect :
94+ total_packets += 1 # Header2 effect
95+ total_packets += len (body2 ) # Body2 effects
96+
97+ # --- Replace the 2nd word in header1 with the correct count ---
98+ header1_parts = header1 .split ()
99+ header1_parts [1 ] = str (total_packets )
100+ new_header1 = " " .join (header1_parts )
101+
99102 # --- Re-assemble the merged text ---
100103 newText = "\n " .join ([new_header1 ] + body1 + body2_updated )
101104
0 commit comments