Mercurial > hg > easyhg
comparison src/mainwindow.cpp @ 606:372b191247da
Add carriage return to hgignore file before new material, if it didn't end with one before
author | Chris Cannam |
---|---|
date | Tue, 03 Jul 2012 11:39:03 +0100 |
parents | 10ef94e51f44 |
children | d35ed7488ccd |
comparison
equal
deleted
inserted
replaced
605:ab92f695f776 | 606:372b191247da |
---|---|
764 return; | 764 return; |
765 } | 765 } |
766 | 766 |
767 f.open(QFile::ReadOnly); | 767 f.open(QFile::ReadOnly); |
768 bool glob = false; | 768 bool glob = false; |
769 bool cr = false; // whether the last line examined ended with a CR | |
769 while (!f.atEnd()) { | 770 while (!f.atEnd()) { |
770 QByteArray ba = f.readLine(); | 771 QByteArray ba = f.readLine(); |
771 QString s = QString::fromLocal8Bit(ba).trimmed(); | 772 QString s = QString::fromLocal8Bit(ba); |
773 cr = (s.endsWith('\n') || s.endsWith('\r')); | |
774 s = s.trimmed(); | |
772 if (s.startsWith("syntax:")) { | 775 if (s.startsWith("syntax:")) { |
773 if (s.endsWith("glob")) { | 776 if (s.endsWith("glob")) { |
774 glob = true; | 777 glob = true; |
775 } else { | 778 } else { |
776 glob = false; | 779 glob = false; |
779 } | 782 } |
780 f.close(); | 783 f.close(); |
781 | 784 |
782 f.open(QFile::Append); | 785 f.open(QFile::Append); |
783 QTextStream out(&f); | 786 QTextStream out(&f); |
787 | |
788 if (!cr) { | |
789 out << endl; | |
790 } | |
784 | 791 |
785 if (!glob) { | 792 if (!glob) { |
786 out << "syntax: glob" << endl; | 793 out << "syntax: glob" << endl; |
787 } | 794 } |
788 | 795 |