Changeset 206 for trunk/libdjvu/GURL.cpp


Ignore:
Timestamp:
Jul 25, 2007, 5:59:35 PM (14 years ago)
Author:
Eugene Romanenko
Message:

DJVU plugin: djvulibre updated to version 3.5.19

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libdjvu/GURL.cpp

    r17 r206  
    66//C-
    77//C- This software is subject to, and may be distributed under, the
    8 //C- GNU General Public License, Version 2. The license should have
     8//C- GNU General Public License, either Version 2 of the license,
     9//C- or (at your option) any later version. The license should have
    910//C- accompanied the software or you may obtain a copy of the license
    1011//C- from the Free Software Foundation at http://www.fsf.org .
     
    1516//C- GNU General Public License for more details.
    1617//C-
    17 //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
    18 //C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech
    19 //C- Software authorized us to replace the original DjVu(r) Reference
    20 //C- Library notice by the following text (see doc/lizard2002.djvu):
     18//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
     19//C- Lizardtech Software.  Lizardtech Software has authorized us to
     20//C- replace the original DjVu(r) Reference Library notice by the following
     21//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
    2122//C-
    2223//C-  ------------------------------------------------------------------
     
    2728//C- |
    2829//C- | This software is subject to, and may be distributed under, the
    29 //C- | GNU General Public License, Version 2. The license should have
     30//C- | GNU General Public License, either Version 2 of the license,
     31//C- | or (at your option) any later version. The license should have
    3032//C- | accompanied the software or you may obtain a copy of the license
    3133//C- | from the Free Software Foundation at http://www.fsf.org .
     
    5254//C- +------------------------------------------------------------------
    5355//
    54 // $Id: GURL.cpp,v 1.21 2005/12/24 12:45:01 leonb Exp $
    55 // $Name: $
     56// $Id: GURL.cpp,v 1.24 2007/03/25 20:48:32 leonb Exp $
     57// $Name: release_3_5_19 $
    5658
    5759#ifdef HAVE_CONFIG_H
     
    160162#endif
    161163
     164#ifdef OS2
     165#define _tcsrchr strrchr
     166#endif
    162167
    163168#ifdef HAVE_NAMESPACES
     
    830835   const char * ptrurl = url;
    831836   for(const char *ptr = ptrurl; *ptr; ptr++)
    832       if (*ptr=='?')
    833       {
     837     if (*ptr=='?')
     838       {
    834839         url.setat(ptr-ptrurl, 0);
    835840         break;
    836       }
     841       }
    837842}
    838843
     
    930935   const GUTF8String xurl(get_string());
    931936   const int protocol_length=protocol(xurl).length();
    932    const int xurl_length=xurl.length();
    933937   const char * const url_ptr=xurl;
    934938   const char * ptr, * xslash;
     
    946950     if(xslash[0] != '/')
    947951     {
    948        xslash=url_ptr+xurl_length;
     952       xslash=ptr;
    949953     }
    950954   }
    951    return GURL::UTF8(
    952 // ifdef WIN32
    953 // (*(xslash-1) == colon)?
    954 //   (GUTF8String(xurl,(int)(xslash-url_ptr))+"/" ):
    955 // endif
    956      (GUTF8String(xurl,(int)(xslash-url_ptr))+"/"));
     955   return GURL::UTF8(GUTF8String(xurl,(int)(xslash-url_ptr))+"/"+ptr);
    957956}
    958957
     
    960959GURL::operator==(const GURL & gurl2) const
    961960{
    962   bool retval=false;
    963961  const GUTF8String g1(get_string());
    964   const int g1_length=g1.length();
    965962  const GUTF8String g2(gurl2.get_string());
    966   const int g2_length=g2.length();
    967   if(g1_length == g2_length) // exactly equal
    968   {
    969         retval=(g1==g2);
    970   }else if(g1_length+1 == g2_length) // g1 is g2 with a slash at the end
    971   {
    972     retval=(g2[g1_length] == '/')&&!g1.cmp(g2,g1_length);
    973   }else if(g2_length+1 == g1_length)  // g2 is g1 with a slash at the end
    974   {
    975     retval=(g1[g2_length] == '/')&&!g1.cmp(g2,g2_length);
    976   }
    977   return retval;
     963  const char *s1 = (const char*)g1;
     964  const char *s2 = (const char*)g2;
     965  int n1=0;
     966  int n2=0;
     967  while (s1[n1] && !is_argument(s1+n1))
     968    n1 += 1;
     969  while (s2[n2] && !is_argument(s2+n2))
     970    n2 += 1;
     971  if (n1 == n2)
     972    return !strcmp(s1+n1,s2+n2) && !strncmp(s1,s2,n1);
     973  if (n1 == n2+1 && s1[n2]=='/')
     974    return !strcmp(s1+n1,s2+n2) && !strncmp(s1,s2,n2);
     975  if (n2 == n1+1 && s2[n1]=='/')
     976    return !strcmp(s1+n1,s2+n2) && !strncmp(s1,s2,n1);   
     977  return false;
    978978}
    979979
     
    12041204{
    12051205  if(GURL::UTF8(xurl).is_valid())
    1206   {
    1207     url=xurl;
    1208   }else
    1209   {
    1210     const char *c=xurl;
    1211     if(c[0] == slash)
    1212     {
    1213       GURL base(codebase);
    1214       for(GURL newbase=base.base();newbase!=base;newbase=base.base())
    1215       {
    1216         base=newbase;
    1217       }
    1218       url=base.get_string(true)+GURL::encode_reserved(xurl);
    1219     }else
    1220     {
    1221       url=beautify_path(codebase.get_string(true)+GUTF8String(slash)+GURL::encode_reserved(xurl));
    1222     }
    1223   }
     1206    {
     1207      url=xurl;
     1208    }
     1209  else
     1210    {
     1211      // split codebase
     1212      const char *buffer = codebase;
     1213      GUTF8String all(buffer);
     1214      GUTF8String suffix;
     1215      GUTF8String path;
     1216      GUTF8String prefix;
     1217      const int protocol_length=GURL::protocol(all).length();
     1218      const char *start = buffer + pathname_start(all,protocol_length);
     1219      if (start > buffer)
     1220        prefix = GUTF8String(buffer, start-buffer);
     1221      const char *ptr = start;
     1222      while (*ptr && !is_argument(ptr))
     1223        ptr++;
     1224      if (*ptr)
     1225        suffix = GUTF8String(ptr);
     1226      if (ptr > start)
     1227        path = GUTF8String(start, ptr-start);
     1228      // append xurl to path
     1229      const char *c = xurl;
     1230      if(c[0] == slash)
     1231        path = GURL::encode_reserved(xurl);
     1232      else
     1233        path = path + GUTF8String(slash)+GURL::encode_reserved(xurl);
     1234      // construct url
     1235      url = beautify_path(prefix + path + suffix);
     1236    }
    12241237}
    12251238
     
    17571770    *s = 0;
    17581771  }
    1759 #elif defined(WIN32) || defined(OS2) // WIN32 implementation
     1772#elif defined(WIN32) || defined(OS2) // WIN32 implementation (ER: and OS/2)
    17601773  // Handle base
    17611774  strcpy(string_buffer, (char const *)(from ? expand_name(from) : GOS::cwd()));
     
    17951808          drv[2]= dot ;
    17961809          drv[3]=0;
    1797           // todo !!!
    1798           //GetFullPathName(drv, maxlen, string_buffer, &s);
     1810          // !!! ER todo !!! GetFullPathName(drv, maxlen, string_buffer, &s);
    17991811          strcpy(string_buffer,(const char *)GUTF8String(string_buffer).getNative2UTF8());
    18001812          s = string_buffer;
     
    18321844        {
    18331845          fname += 2;
    1834           char *back=NULL;//_tcsrchr(string_buffer,backslash);
    1835           char *forward=NULL;//_tcsrchr(string_buffer,slash);
     1846          char *back=_tcsrchr(string_buffer,backslash);
     1847          char *forward=_tcsrchr(string_buffer,slash);
    18361848          if(back>forward)
    18371849          {
     
    18471859        for(;*s;s++)
    18481860          EMPTY_LOOP;
    1849         char* back = NULL;//_tcsrchr(s2,backslash);//MBCS DBCS
     1861        char* back = _tcsrchr(s2,backslash);//MBCS DBCS
    18501862        if ((s>string_buffer)&&(*(s-1)!= slash)&&
    18511863            (back == NULL || (back!=NULL && s-1 != back) ))//MBCS DBCS
     
    18651877      for(;*s;s++)
    18661878        EMPTY_LOOP;
    1867       char* back = NULL;//_tcsrchr(s2,backslash);//MBCS DBCS
     1879      char* back = _tcsrchr(s2,backslash);//MBCS DBCS
    18681880      if ((s>string_buffer)&&(*(s-1)!= slash)
    18691881          &&(back == NULL || (back!=NULL && s-1 != back) ))//MBCS DBCS
Note: See TracChangeset for help on using the changeset viewer.