Skip to content

Commit a54300f

Browse files
committed
parseDiffChunk bug
1 parent 656cb82 commit a54300f

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

GLFileView.m

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ + (NSString *)parseDiffChunk:(NSString *)txt
368368
NSMutableString *res=[NSMutableString string];
369369

370370
NSString *line;
371-
int l_line,l_end;
372-
int r_line,r_end;
371+
int l_line;
372+
int r_line;
373373

374374
line=[lines nextObject];
375375
DLog(@"-=%@=-",line);
@@ -381,19 +381,11 @@ + (NSString *)parseDiffChunk:(NSString *)txt
381381
NSArray *pos_l=[[pos objectAtIndex:0] componentsSeparatedByString:@","];
382382
NSArray *pos_r=[[pos objectAtIndex:1] componentsSeparatedByString:@","];
383383

384-
l_end=l_line=abs([[pos_l objectAtIndex:0]integerValue]);
385-
if ([pos_l count]>1) {
386-
l_end=l_line+[[pos_l objectAtIndex:1]integerValue];
387-
}
388-
389-
r_end=r_line=[[pos_r objectAtIndex:0]integerValue];
390-
if ([pos_r count]>1) {
391-
r_end=r_line+[[pos_r objectAtIndex:1]integerValue];
392-
}
393-
384+
l_line=abs([[pos_l objectAtIndex:0]integerValue]);
385+
r_line=[[pos_r objectAtIndex:0]integerValue];
386+
394387
[res appendString:[NSString stringWithFormat:@"<tr class='header'><td colspan='3'>%@</td></tr>",line]];
395-
do{
396-
line=[lines nextObject];
388+
while((line=[lines nextObject])){
397389
NSString *s=[line substringToIndex:1];
398390
if([s isEqualToString:@" "]){
399391
[res appendString:[NSString stringWithFormat:@"<tr><td class='l'>%d</td><td class='r'>%d</td>",l_line++,r_line++]];
@@ -405,7 +397,7 @@ + (NSString *)parseDiffChunk:(NSString *)txt
405397
if(![s isEqualToString:@"\\"]){
406398
[res appendString:[NSString stringWithFormat:@"<td class='code'>%@</td></tr>",[line substringFromIndex:1]]];
407399
}
408-
}while((l_line<l_end) || (r_line<r_end));
400+
}
409401
return res;
410402
}
411403

0 commit comments

Comments
 (0)