url.cpp (TeXmacs-2.1.1-src) | : | url.cpp (TeXmacs-2.1.2-src) | ||
---|---|---|---|---|
skipping to change at line 104 | skipping to change at line 104 | |||
} | } | |||
} | } | |||
if (occurs ("*", s)) return url_wildcard (s); | if (occurs ("*", s)) return url_wildcard (s); | |||
#ifdef WINPATHS | #ifdef WINPATHS | |||
if (N(s)==2 && ends (s, ":")) | if (N(s)==2 && ends (s, ":")) | |||
s->resize(1); // remove the ':' after unit letter | s->resize(1); // remove the ':' after unit letter | |||
#endif | #endif | |||
return as_url (tree (s)); | return as_url (tree (s)); | |||
} | } | |||
static void | ||||
skip_ipv6 (string s, int& i) { | ||||
i++; | ||||
while (i<N(s) && (s[i] == ':' || | ||||
(s[i] >= '0' && s[i] <= '9') || | ||||
(s[i] >= 'a' && s[i] <= 'f') || | ||||
(s[i] >= 'A' && s[i] <= 'F'))) i++; | ||||
if (i<N(s) && s[i] == ']') i++; | ||||
} | ||||
static url | static url | |||
url_get_name (string s, int type= URL_STANDARD, int i=0) { | url_get_name (string s, int type= URL_STANDARD, int i=0) { | |||
char sep= (type == URL_SYSTEM)? URL_CONCATER: '/'; | char sep= (type == URL_SYSTEM)? URL_CONCATER: '/'; | |||
int start= i, n= N(s); | int start= i, n= N(s); | |||
while ((i<n) && (s[i] != sep) && (s[i] != '/')) i++; | while ((i<n) && (s[i] != sep) && (s[i] != '/')) { | |||
if (s[i] == '[') skip_ipv6 (s, i); else i++; } | ||||
url u= url_get_atom (s (start, i), type); | url u= url_get_atom (s (start, i), type); | |||
// url u= tree (s (start, i)); | // url u= tree (s (start, i)); | |||
if (i == n) return u; | if (i == n) return u; | |||
if (start == i) return url_get_name (s, type, i+1); | if (start == i) return url_get_name (s, type, i+1); | |||
return u * url_get_name (s, type, i+1); | return u * url_get_name (s, type, i+1); | |||
} | } | |||
static url | static url | |||
url_get_path (string s, int type= URL_STANDARD, int i=0) { | url_get_path (string s, int type= URL_STANDARD, int i=0) { | |||
char sep= (type == URL_SYSTEM)? URL_SEPARATOR: ':'; | char sep= (type == URL_SYSTEM)? URL_SEPARATOR: ':'; | |||
int start= i, n= N(s); | int start= i, n= N(s); | |||
if (i == n) return url_none (); | if (i == n) return url_none (); | |||
while ((i<n) && (s[i] != sep)) i++; | while ((i<n) && (s[i] != sep)) { | |||
if (s[i] == '[') skip_ipv6 (s, i); else i++; } | ||||
url u= url_general (s (start, i), type); | url u= url_general (s (start, i), type); | |||
if (i == n) return u; | if (i == n) return u; | |||
if (start == i) return url_get_path (s, type, i+1); | if (start == i) return url_get_path (s, type, i+1); | |||
return u | url_get_path (s, type, i+1); | return u | url_get_path (s, type, i+1); | |||
} | } | |||
/****************************************************************************** | /****************************************************************************** | |||
* Rooted url constructors | * Rooted url constructors | |||
******************************************************************************/ | ******************************************************************************/ | |||
skipping to change at line 217 | skipping to change at line 229 | |||
return url_root ("blank") * u; | return url_root ("blank") * u; | |||
} | } | |||
/****************************************************************************** | /****************************************************************************** | |||
* Generic url constructor | * Generic url constructor | |||
******************************************************************************/ | ******************************************************************************/ | |||
static bool | static bool | |||
heuristic_is_path (string name, int type) { | heuristic_is_path (string name, int type) { | |||
char sep= (type==0)? URL_SEPARATOR: ':'; | char sep= (type==0)? URL_SEPARATOR: ':'; | |||
int i, n= N(name); | int i= 0, n= N(name); | |||
for (i=0; i<n; i++) | while (i<n) | |||
if (name[i] == sep) | if (name[i] == '[') skip_ipv6 (name, i); | |||
return true; | else if (name[i] == sep) return true; | |||
else i++; | ||||
return false; | return false; | |||
} | } | |||
static bool | static bool | |||
heuristic_is_default (string name, int type) { | heuristic_is_default (string name, int type) { | |||
#ifdef WINPATHS | #ifdef WINPATHS | |||
// FIXME: we probably should take into account 'type' too | // FIXME: we probably should take into account 'type' too | |||
if (N(name) < 2) return false; | if (N(name) < 2) return false; | |||
if ((name[0] == '\\') && (name[1] == '\\')) return true; | if ((name[0] == '\\') && (name[1] == '\\')) return true; | |||
return | return | |||
skipping to change at line 481 | skipping to change at line 494 | |||
return is_concat (u) && is_root (u[1]) && is_name (u[2]); | return is_concat (u) && is_root (u[1]) && is_name (u[2]); | |||
} | } | |||
bool | bool | |||
is_name_in_path (url u) { | is_name_in_path (url u) { | |||
if (is_name (u)) return true; | if (is_name (u)) return true; | |||
return is_concat (u) && is_root (u[1], "default") && is_name (u[2]); | return is_concat (u) && is_root (u[1], "default") && is_name (u[2]); | |||
} | } | |||
bool | bool | |||
is_path (url u) { | ||||
if (is_atomic (u)) return true; | ||||
if ((!is_or (u)) && (!is_concat (u))) return false; | ||||
return is_path (u[1]) && is_path (u[2]); | ||||
} | ||||
bool | ||||
is_rooted_path (url u) { | ||||
return is_rooted (u) && is_path (u); | ||||
} | ||||
bool | ||||
is_ramdisc (url u) { | is_ramdisc (url u) { | |||
return is_concat (u) && is_root (u[1], "ramdisc"); | return is_concat (u) && is_root (u[1], "ramdisc"); | |||
} | } | |||
/****************************************************************************** | /****************************************************************************** | |||
* Conversion routines for urls | * Conversion routines for urls | |||
******************************************************************************/ | ******************************************************************************/ | |||
string | string | |||
as_string (url u, int type) { | as_string (url u, int type) { | |||
End of changes. 5 change blocks. | ||||
18 lines changed or deleted | 19 lines changed or added |