360
int DiffModel::parseEdDiff( const QStringList& /*list*/ )
370
int DiffModel::parseEdDiff( const QStringList& list )
362
372
kdDebug() << "Ed diff parsing:" << endl;
364
KMessageBox::information( 0, i18n( "Sorry not yet implemented" ) );
376
QStringList::ConstIterator it = list.begin();
378
if ( it == list.end() )
379
return 0; // Nothing to parse, should not happen though
381
while ( it != list.end() )
384
kdDebug() << "Line is:" << line << endl;
385
if ( line.find( QRegExp( "^[0-9]+[acd]" ), 0 ) == 0 )
387
kdDebug() << "Found a added/removed/changed part" << endl;
388
// Only startline with operator, nothing else
389
// Number of lines is the same as number of lines changed
390
while( line.find( QRegExp( "^." ), 0 ) != 0 )
392
kdDebug() << "A/C/D: Line is: " << line << endl;
397
else if ( line.find( QRegExp( "^[0-9]+,[0-9]a" ), 0 ) == 0 )
399
kdDebug() << "Found a added line with number of lines to add." << endl;
400
// Hmmm... i wonder if this ever occurs...
401
while( line.find( QRegExp( "^." ), 0 ) != 0 )
403
kdDebug() << "Added: Line is: " << line << endl;
404
// Add lines until we reach a line that starts with a '.'
409
else if ( line.find( QRegExp( "^[0-9]+,[0-9]c" ), 0 ) == 0 )
411
kdDebug() << "Found a changed line with number of lines changed." << endl;
412
// Startline, endline, operator change
413
// Number of lines in the change has changed
414
// so could be added or deleted in disguise (sp?)
415
while( line.find( QRegExp( "^." ), 0 ) != 0 )
417
kdDebug() << "Change: Line is: " << line << endl;
422
else if ( line.find( QRegExp( "^[0-9]+,[0-9]d" ), 0 ) == 0 )
424
kdDebug() << "Found a delete line with number of lines to delete." << endl;
425
// Startline, endline, operator delete
426
while( line.find( QRegExp( "^." ), 0 ) != 0 )
428
kdDebug() << "Delete: Line is: " << line << endl;
435
kdDebug() << "Oops something is screwed here..." << endl;
436
kdDebug() << line << endl;
442
// KMessageBox::information( 0, i18n( "Sorry not yet implemented" ) );
500
int DiffModel::parseRCSDiff( const QStringList& /*list*/ )
580
int DiffModel::parseRCSDiff( const QStringList& list )
502
582
kdDebug() << "RCS diff parsing:" << endl;
504
KMessageBox::information( 0, i18n( "Sorry not yet implemented" ) );
584
/* A rcs diff has one or 2 lines describing the changes */
585
/* Unfortunately there is no char that indicates the textlines */
586
/* from the difftype + linenos lines */
587
/* Another problem is the fact that the deleted lines are not itself */
588
/* in the difffile/diffoutput */
589
/* But i guess that was not needed for rcs, since the RCS- */
590
/* server/program knows the original */
591
/* Anyway a line looks like this: */
592
/* aLINENUMBER NUMBEROFLINES -> added NUMBEROFLINES lines in newfile at LINENUMBER, the added lines will follow this statement*/
593
/* dLINENUMBER NUMBEROFLINES -> deleted in NUMBEROFLINES in oldfile at LINENUMBER */
596
QStringList::ConstIterator it = list.begin();
597
int linenoA, linenoB, nolinesA, nolinesB;
599
if ( it == list.end() )
600
return 0; // No lines to parse
602
kdDebug() << "There are lines..." << endl;
604
DiffHunk* hunk = new DiffHunk( linenoA, linenoB );
605
hunks.append( hunk );
607
while( it != list.end() )
610
kdDebug() << "Line is: " << line << endl;
612
if ( line.find( QRegExp( "^a[0-9]+ [0-9]+" ), 0 ) == 0 )
614
kdDebug() << "Added line found." << endl;
616
line.replace( 0, 1, "" ); // Strip the 'a'
617
if ( (pos = QRegExp( "^[0-9]+" ).match( line, 0, &len ) ) < 0 ) return 1;
618
linenoB = line.mid(pos, len).toInt();
619
line.replace( pos, len+1, "" ); // Also strip the extra ' '
620
if ( (pos = QRegExp( "^[0-9]+" ).match( line, 0, &len ) ) < 0 ) return 1;
621
nolinesB = line.mid(pos, len).toInt();
623
DiffHunk* hunk = new DiffHunk( 0, linenoB );
624
hunks.append( hunk );
626
Difference* diff = new Difference( 0, linenoB ); // A is unknown
627
diff->type = Difference::Insert;
632
while ( ( it != list.end() ) && ( line.find( QRegExp( "^[ad][0-9]+ [0-9]+" ), 0 ) != 0 ) )
634
// Add it to the difference
635
kdDebug() << "AddDestinationLine( " << line << " )" << endl;
636
diff->addDestinationLine( line );
641
--it; // We went too far, correcting it here...
644
else if ( line.find( QRegExp( "^d[0-9]+ [0-9]+" ), 0 ) == 0 )
646
kdDebug() << "Delete line found." << endl;
647
// We dont have the actual deleted lines in the diffoutput/difffile
648
// This will be a big problem in the viewerclass...
650
line.replace( 0, 1, "" ); // Strip the 'd'
651
if ( (pos = QRegExp( "^[0-9]+" ).match( line, 0, &len ) ) < 0 ) return 1;
652
linenoA = line.mid(pos, len).toInt();
653
line.replace( pos, len+1, "" ); // Also strip the extra ' '
654
if ( (pos = QRegExp( "^[0-9]+" ).match( line, 0, &len ) ) < 0 ) return 1;
655
nolinesA = line.mid(pos, len).toInt();
657
// Next lines are commented out because in delete the lines are not here
658
// so there is nothing to add but an empty diff and an empty hunk so for
659
// now this is omitted. Maybe we could ask the user for the original file
660
// so we can indicate the deleted lines.
662
// DiffHunk* hunk = new DiffHunk( 0, linenoB );
663
// hunks.append( hunk );
665
// Difference diff = new Difference( linenoA, 0 );
666
// diff->type = Difference::Delete;
668
// We should now add the source lines, unfortunately there are none...
670
// hunk->add( diff );
674
kdDebug() << "Oops, something is wrong here..." << endl;
675
return 1; // faulty output or something went wrong during parsing
680
// KMessageBox::information( 0, i18n( "Sorry not yet implemented" ) );