summaryrefslogtreecommitdiffabout
path: root/microkde/kurl.cpp
Unidiff
Diffstat (limited to 'microkde/kurl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kurl.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/microkde/kurl.cpp b/microkde/kurl.cpp
index 2574e25..122ad71 100644
--- a/microkde/kurl.cpp
+++ b/microkde/kurl.cpp
@@ -34,13 +34,15 @@
34#else 34#else
35#include <unistd.h> 35#include <unistd.h>
36#endif 36#endif
37#include <qurl.h> 37#include <q3url.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qstringlist.h> 39#include <qstringlist.h>
40#include <qregexp.h> 40#include <qregexp.h>
41//US#include <qstylesheet.h> 41//US#include <qstylesheet.h>
42#include <qmap.h> 42#include <qmap.h>
43#include <qtextcodec.h> 43#include <qtextcodec.h>
44//Added by qt3to4:
45#include <Q3CString>
44 46
45static const QString fileProt = "file"; 47static const QString fileProt = "file";
46 48
@@ -57,7 +59,7 @@ static QString encode( const QString& segment, bool encode_slash, int encoding_h
57 else 59 else
58 encode_string = "<>#@\"&%?={}|^~[]\'`\\:+"; 60 encode_string = "<>#@\"&%?={}|^~[]\'`\\:+";
59 61
60 QCString local; 62 Q3CString local;
61 if (encoding_hint==0) 63 if (encoding_hint==0)
62 local = segment.local8Bit(); 64 local = segment.local8Bit();
63 else 65 else
@@ -100,7 +102,7 @@ static QString encode( const QString& segment, bool encode_slash, int encoding_h
100 102
101 } 103 }
102 else 104 else
103 new_segment[ new_length++ ] = local[i]; 105 new_segment[ new_length++ ] = character;
104 } 106 }
105 107
106 QString result = QString(new_segment, new_length); 108 QString result = QString(new_segment, new_length);
@@ -205,7 +207,7 @@ static void decode( const QString& segment, QString &decoded, QString &encoded,
205 if (!textCodec) 207 if (!textCodec)
206 textCodec = QTextCodec::codecForLocale(); 208 textCodec = QTextCodec::codecForLocale();
207 209
208 QCString csegment = textCodec->fromUnicode(segment); 210 Q3CString csegment = textCodec->fromUnicode(segment);
209 // Check if everything went ok 211 // Check if everything went ok
210 if (textCodec->toUnicode(csegment) != segment) 212 if (textCodec->toUnicode(csegment) != segment)
211 { 213 {
@@ -278,7 +280,7 @@ static void decode( const QString& segment, QString &decoded, QString &encoded,
278 array.setRawData(new_segment, new_length); 280 array.setRawData(new_segment, new_length);
279 decoded = textCodec->toUnicode( array, new_length ); 281 decoded = textCodec->toUnicode( array, new_length );
280 array.resetRawData(new_segment, new_length); 282 array.resetRawData(new_segment, new_length);
281 QCString validate = textCodec->fromUnicode(decoded); 283 Q3CString validate = textCodec->fromUnicode(decoded);
282 284
283 if (strcmp(validate.data(), new_segment) != 0) 285 if (strcmp(validate.data(), new_segment) != 0)
284 { 286 {
@@ -419,7 +421,7 @@ KURL::KURL( const char * url, int encoding_hint )
419 parse( QString::fromLatin1(url), encoding_hint ); 421 parse( QString::fromLatin1(url), encoding_hint );
420} 422}
421 423
422KURL::KURL( const QCString& url, int encoding_hint ) 424KURL::KURL( const Q3CString& url, int encoding_hint )
423{ 425{
424 reset(); 426 reset();
425 parse( QString::fromLatin1(url), encoding_hint ); 427 parse( QString::fromLatin1(url), encoding_hint );
@@ -460,7 +462,7 @@ QDataStream & operator>> (QDataStream & s, KURL & a)
460} 462}
461 463
462#ifndef QT_NO_NETWORKPROTOCOL 464#ifndef QT_NO_NETWORKPROTOCOL
463KURL::KURL( const QUrl &u ) 465KURL::KURL( const Q3Url &u )
464{ 466{
465 *this = u; 467 *this = u;
466} 468}
@@ -589,13 +591,13 @@ void KURL::parse( const QString& _url, int encoding_hint )
589 QChar x = buf[pos++]; 591 QChar x = buf[pos++];
590 if ( x == '/' ) 592 if ( x == '/' )
591 goto Node9; 593 goto Node9;
592 if ( !isalpha( (int)x ) ) 594 if ( !x.isLetter() )
593 goto NodeErr; 595 goto NodeErr;
594 596
595 // Node 2: Accept any amount of (alpha|digit|'+'|'-') 597 // Node 2: Accept any amount of (alpha|digit|'+'|'-')
596 // '.' is not currently accepted, because current KURL may be confused. 598 // '.' is not currently accepted, because current KURL may be confused.
597 // Proceed with :// :/ or : 599 // Proceed with :// :/ or :
598 while( pos < len && (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) || 600 while( pos < len && ( buf[pos].isLetter() || buf[pos].isDigit() ||
599 buf[pos] == '+' || buf[pos] == '-')) pos++; 601 buf[pos] == '+' || buf[pos] == '-')) pos++;
600 602
601 if ( pos+2 < len && buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' ) 603 if ( pos+2 < len && buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' )
@@ -769,11 +771,11 @@ void KURL::parse( const QString& _url, int encoding_hint )
769 if ( pos == len ) 771 if ( pos == len )
770 goto NodeErr; 772 goto NodeErr;
771 start = pos; 773 start = pos;
772 if ( !isdigit( buf[pos++] ) ) 774 if ( !buf[pos++].isDigit() )
773 goto NodeErr; 775 goto NodeErr;
774 776
775 // Node 8b: Accept any amount of digits 777 // Node 8b: Accept any amount of digits
776 while( pos < len && isdigit( buf[pos] ) ) pos++; 778 while( pos < len && buf[pos].isDigit() ) pos++;
777 port = QString( buf + start, pos - start ); 779 port = QString( buf + start, pos - start );
778 m_iPort = port.toUShort(); 780 m_iPort = port.toUShort();
779 if ( pos == len ) 781 if ( pos == len )
@@ -848,7 +850,7 @@ KURL& KURL::operator=( const char * _url )
848} 850}
849 851
850#ifndef QT_NO_NETWORKPROTOCOL 852#ifndef QT_NO_NETWORKPROTOCOL
851KURL& KURL::operator=( const QUrl & u ) 853KURL& KURL::operator=( const Q3Url & u )
852{ 854{
853 m_strProtocol = u.protocol(); 855 m_strProtocol = u.protocol();
854 m_strUser = u.user(); 856 m_strUser = u.user();
@@ -1374,7 +1376,7 @@ KURL KURL::join( const KURL::List & lst )
1374 KURL u(*it); 1376 KURL u(*it);
1375 if (it != first) 1377 if (it != first)
1376 { 1378 {
1377 if (!u.m_strRef_encoded) u.m_strRef_encoded = tmp.url(); 1379 if (u.m_strRef_encoded.isEmpty()) u.m_strRef_encoded = tmp.url();
1378 else u.m_strRef_encoded += "#" + tmp.url(); // Support more than one suburl thingy 1380 else u.m_strRef_encoded += "#" + tmp.url(); // Support more than one suburl thingy
1379 } 1381 }
1380 tmp = u; 1382 tmp = u;
@@ -1418,7 +1420,7 @@ QString KURL::fileName( bool _strip_trailing_slash ) const
1418 // unencoded one. 1420 // unencoded one.
1419 int i = m_strPath_encoded.findRev( '/', len - 1 ); 1421 int i = m_strPath_encoded.findRev( '/', len - 1 );
1420 QString fileName_encoded = m_strPath_encoded.mid(i+1); 1422 QString fileName_encoded = m_strPath_encoded.mid(i+1);
1421 n += fileName_encoded.contains("%2f", false); 1423 n += fileName_encoded.count("%2f", Qt::CaseInsensitive);
1422 } 1424 }
1423 int i = len; 1425 int i = len;
1424 do { 1426 do {