CVS: spip/ecrire inc_db_mysql.php3, 1.12, 1.13 inc_import.php3, 1.22, 1.23

Update of /home/spip-cvs/spip/ecrire
In directory miel:/tmp/cvs-serv6824/ecrire

Modified Files:
  inc_db_mysql.php3 inc_import.php3
Log Message:
optimisations restauration

Index: inc_db_mysql.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_db_mysql.php3,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- inc_db_mysql.php3 15 Mar 2003 23:42:42 -0000 1.12
+++ inc_db_mysql.php3 26 Oct 2003 23:27:58 -0000 1.13
@@ -12,7 +12,6 @@
function spip_query_db($query) {
   global $spip_mysql_link;
   static $tt = 0;
-
   $my_admin = (($GLOBALS['connect_statut'] == '0minirezo') OR ($GLOBALS['auteur_session']['statut'] == '0minirezo'));
   $my_profile = ($GLOBALS['mysql_profile'] AND $my_admin);
   $my_debug = ($GLOBALS['mysql_debug'] AND $my_admin);
@@ -53,11 +52,20 @@
     $db = '`'.$db.'`.';

   // changer les noms des tables ($table_prefix)
- if (eregi('[[:space:]](VALUES|WHERE)[[:space:]].*$', $query, $regs)) {
- $suite = $regs[0];
- $query = substr($query, 0, -strlen($suite));
+ if ($GLOBALS['flag_pcre']) {
+ if (preg_match('/\s(VALUES|WHERE)\s/i', $query, $regs)) {
+ $suite = strstr($query, $regs[0]);
+ $query = substr($query, 0, -strlen($suite));
+ }
+ $query = preg_replace('/([,\s])spip_/', '\1'.$db.$GLOBALS['table_prefix'].'_', $query) . $suite;
+ }
+ else {
+ if (eregi('[[:space:]](VALUES|WHERE)[[:space:]]', $query, $regs)) {
+ $suite = strstr($query, $regs[0]);
+ $query = substr($query, 0, -strlen($suite));
+ }
+ $query = ereg_replace('([[:space:],])spip_', '\1'.$db.$GLOBALS['table_prefix'].'_', $query) . $suite;
   }
- $query = ereg_replace('([[:space:],])spip_', '\1'.$db.$GLOBALS['table_prefix'].'_', $query) . $suite;

   return $query;
}

Index: inc_import.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_import.php3,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- inc_import.php3 26 Oct 2003 21:22:25 -0000 1.22
+++ inc_import.php3 26 Oct 2003 23:27:58 -0000 1.23
@@ -11,51 +11,38 @@

function xml_fetch_tag($f, &$before, $gz=false) {
   global $buf, $pos, $abs_pos;
+ static $buf_len = 1000;
   $_fread = ($gz) ? gzread : fread;
   $_feof = ($gz) ? gzeof : feof;
   $_ftell = ($gz) ? gztell : ftell;
- $buf_len = 1024;
- $q = $pos;
- for (;:wink: {
- $p = $q;
- $q = strpos($buf, '<', $p);
- if (!$q AND substr($buf, $p, 1) != '<') {
- if ($_feof($f)) return false;
- $before .= substr($buf, $p);
-// $abs_pos = $_ftell($f);
- $buf = $_fread($f, $buf_len);
- $q = 0;
- continue;
- }
- $before .= substr($buf, $p, $q - $p);
- if (++$q >= strlen($buf)) {
- if ($_feof($f)) return false;
-// $abs_pos = $_ftell($f);
- $buf = $_fread($f, $buf_len);
- $q = 0;
- }
- break;
- }
+ $p = $pos;

+ $q = @strpos($buf, '<', $p);
+ while (!$q AND $buf{$p} != '<') {
+ if ($_feof($f)) return false;
+ $before .= substr($buf, $p);
+ $buf = $_fread($f, $buf_len);
+ $p = 0;
+ $q = strpos($buf, '<');
+ }
+ $before .= substr($buf, $p, $q - $p);
   $tag = '';
- for (;:wink: {
- $p = $q;
- $q = strpos($buf, '>', $p);
- if (!$q AND substr($buf, $p, 1) != '>') {
- if ($_feof($f)) return false;
- $tag .= substr($buf, $p);
-// $abs_pos = $_ftell($f);
- $buf = $_fread($f, $buf_len);
- $q = 0;
- continue;
- }
- $pos = $q + 1;
- $tag .= substr($buf, $p, $q - $p);
- $before = str_replace('&amp;', '&', str_replace('&lt;', '<', $before));
- $abs_pos = $_ftell($f) - strlen($buf);
- return $tag;
+ $p = ++$q;
+ $q = @strpos($buf, '>', $p);
+ while (!$q AND $buf{$p} != '>') {
+ if ($_feof($f)) return false;
+ $tag .= substr($buf, $p);
+ $buf = $_fread($f, $buf_len);
+ $p = 0;
+ $q = strpos($buf, '>');
   }
+ $pos = $q + 1;
+ $tag .= substr($buf, $p, $q - $p);
+ $before = str_replace('&amp;', '&', str_replace('&lt;', '<', $before));
+ $abs_pos = $_ftell($f) - strlen($buf);
+ return $tag;
}
+

function xml_parse_tag($texte) {
   list($tag, $atts) = split('[[:space:]]+', $texte, 2);