ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] synaptic и  g++ 3.2.1 строки и итераторы
@ 2002-09-25  9:47 Alexey Dyachenko
  2002-09-25 13:42 ` Dmitry V. Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dyachenko @ 2002-09-25  9:47 UTC (permalink / raw)
  To: ALT Linux Mailing List

[-- Attachment #1: Type: text/plain, Size: 932 bytes --]

Добрый день всем!

Мне тут понадобился работающий графический клиент для apt и я немного
похакал synaptic для сборки gcc 3.2.
Патч прилагается.


Вот только при этом получил я ОЧЕНЬ неприятную новость.

std::string::iterator !=  const char *

То есть в gcc 3.2 basic_string::iterator объявлен как
typedef __gnu_cxx::__normal_iterator<pointer, basic_string>  iterator; 


В stlport это объявлеятся как 
  typedef const value_type*                const_iterator;                                          
  typedef value_type*                      iterator;

и по моему здесь прав stlport.

Сейчас у меня с собой нет ни страуструпа, ни стандарта, так что точно
посмотреть не могу. Кто точно знает -- киньте пожалуйста кусок из
стандарта или просто скажите, кто из них прав.

Если прав stlport -- тогда срочно сяду собирать пакет для сизифа.
Хотя это надо бы сделать в любом случае -- вещь полезная.


С уважением, Алексей Дьяченко.



[-- Attachment #2: synaptic-0.16-alt-gcc32.patch --]
[-- Type: text/plain, Size: 4388 bytes --]

diff -Naur synaptic-0.16/common/i18n.h synaptic-0.16-gcc32/common/i18n.h
--- synaptic-0.16/common/i18n.h	2001-01-26 01:19:12 +0100
+++ synaptic-0.16-gcc32/common/i18n.h	2002-09-25 10:17:24 +0200
@@ -13,8 +13,8 @@
 #else
 /* Stubs that do something close enough.  */
 # define textdomain(String) (String)
-# define gettext(String) (String)
-# define dgettext(Domain,Message) (Message)
+//# define gettext(String) (String)
+//# define dgettext(Domain,Message) (Message)
 # define dcgettext(Domain,Message,Type) (Message)
 # define bindtextdomain(Domain,Directory) (Domain)
 # define _(String) (String)
diff -Naur synaptic-0.16/common/indexcopy.cc synaptic-0.16-gcc32/common/indexcopy.cc
--- synaptic-0.16/common/indexcopy.cc	2001-08-15 21:44:09 +0200
+++ synaptic-0.16-gcc32/common/indexcopy.cc	2002-09-25 10:28:33 +0200
@@ -402,7 +402,7 @@
       return;
    
    // Not a dists type.
-   if (stringcmp(Path.begin(),Path.begin()+strlen("dists/"),"dists/") != 0)
+   if (stringcmp( &( *Path.begin() ),&*( Path.begin()+strlen("dists/"),"dists/" ) ) != 0)
       return;
       
    // Isolate the dist
diff -Naur synaptic-0.16/common/indexcopy.h synaptic-0.16-gcc32/common/indexcopy.h
--- synaptic-0.16/common/indexcopy.h	2001-07-24 00:01:08 +0200
+++ synaptic-0.16-gcc32/common/indexcopy.h	2002-09-25 10:27:24 +0200
@@ -16,6 +16,9 @@
 class pkgTagSection;
 class FileFd;
 
+using std::string;
+using std::vector;
+
 class IndexCopy
 {
    protected:
diff -Naur synaptic-0.16/common/rcdscanner.cc synaptic-0.16-gcc32/common/rcdscanner.cc
--- synaptic-0.16/common/rcdscanner.cc	2001-07-24 00:01:08 +0200
+++ synaptic-0.16-gcc32/common/rcdscanner.cc	2002-09-25 10:26:17 +0200
@@ -136,7 +136,7 @@
     string File = _config->FindFile("Dir::Etc::sourcelist");
 
     // Open the stream for reading
-    ifstream F(File.c_str(),ios::in | ios::nocreate);
+    ifstream F(File.c_str(),ios::in );
     if (!F != 0)
 	return _error->Errno("ifstream::ifstream","Opening %s",File.c_str());
     
diff -Naur synaptic-0.16/common/rconfiguration.h synaptic-0.16-gcc32/common/rconfiguration.h
--- synaptic-0.16/common/rconfiguration.h	2001-01-24 19:09:28 +0100
+++ synaptic-0.16-gcc32/common/rconfiguration.h	2002-09-25 10:30:38 +0200
@@ -11,7 +11,7 @@
 
 bool RWriteConfigFile(Configuration &Conf);
 
-bool RInitConfiguration(string confFileName);
+bool RInitConfiguration(std::string confFileName);
 
 bool RReadFilterData(Configuration &config);
 bool RFilterDataOutFile(ofstream &out);
diff -Naur synaptic-0.16/common/rpackage.cc synaptic-0.16-gcc32/common/rpackage.cc
--- synaptic-0.16/common/rpackage.cc	2001-08-10 20:38:22 +0200
+++ synaptic-0.16-gcc32/common/rpackage.cc	2002-09-25 10:09:45 +0200
@@ -164,8 +164,10 @@
 
 static char *parseDescription(string descr)
 {
-    const char *end;
-    const char *p;
+//    const char *end;
+//    const char *p;
+	string::iterator end;
+	string::iterator p;
     char *pp = (char*)descrBuffer;
     int state = 0;
     
diff -Naur synaptic-0.16/common/rpackagelister.cc synaptic-0.16-gcc32/common/rpackagelister.cc
--- synaptic-0.16/common/rpackagelister.cc	2001-08-10 20:38:22 +0200
+++ synaptic-0.16-gcc32/common/rpackagelister.cc	2002-09-25 10:13:30 +0200
@@ -783,7 +783,7 @@
     // Populate it with the source selection
     for (I = List.begin(); I != List.end(); I++)
     {
-	new pkgAcqIndex(&Fetcher,I);
+	new pkgAcqIndex(&Fetcher,&(*I));
 	if (_error->PendingError() == true)
 	    return false;
     }
diff -Naur synaptic-0.16/wings/rwsummarywindow.cc synaptic-0.16-gcc32/wings/rwsummarywindow.cc
--- synaptic-0.16/wings/rwsummarywindow.cc	2001-08-10 20:38:22 +0200
+++ synaptic-0.16-gcc32/wings/rwsummarywindow.cc	2002-09-25 10:35:24 +0200
@@ -13,6 +13,8 @@
 #include <WINGs/WINGs.h>
 #include "rwsummarywindow.h"
 
+#include <iostream>
+
 
 
 void RWSummaryWindow::handleKeyPress(XEvent *event, void *clientData)
@@ -255,7 +257,7 @@
 	    lines++;
 	}
 	if (left <= 0) {
-	    cout << "BUFFER OVERFLOW DETECTED, ABORTING" << endl;
+		std::cout << "BUFFER OVERFLOW DETECTED, ABORTING" << std::endl;
 	    abort();
 	}
 	
diff -Naur synaptic-0.16/wings/rwwindow.h synaptic-0.16-gcc32/wings/rwwindow.h
--- synaptic-0.16/wings/rwwindow.h	2001-01-25 00:24:35 +0100
+++ synaptic-0.16-gcc32/wings/rwwindow.h	2002-09-25 10:32:43 +0200
@@ -7,6 +7,8 @@
 
 #include <string>
 
+using std::string;
+
 class RWWindow {   
 protected:
    WMWindow *_win;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [devel] synaptic и  g++ 3.2.1 строки и итераторы
  2002-09-25  9:47 [devel] synaptic и g++ 3.2.1 строки и итераторы Alexey Dyachenko
@ 2002-09-25 13:42 ` Dmitry V. Levin
  2002-09-25 16:57   ` Alexey Dyachenko
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry V. Levin @ 2002-09-25 13:42 UTC (permalink / raw)
  To: ALT Linux Mailing List

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

On Wed, Sep 25, 2002 at 11:47:33AM +0200, Alexey Dyachenko wrote:
> Мне тут понадобился работающий графический клиент для apt и я немного
> похакал synaptic для сборки gcc 3.2.
> Патч прилагается.
> 
> Вот только при этом получил я ОЧЕНЬ неприятную новость.
> 
> std::string::iterator !=  const char *

Это уже очень давно не новость.

> То есть в gcc 3.2 basic_string::iterator объявлен как
> typedef __gnu_cxx::__normal_iterator<pointer, basic_string>  iterator; 
> 
> В stlport это объявлеятся как 
>   typedef const value_type*                const_iterator;                                          
>   typedef value_type*                      iterator;
> 
> и по моему здесь прав stlport.

Нет; итератор - это целиком и полностью implementation-defined.
Вообще говоря, по стандарту реализация std::string не гарантирует,
что std::string::iterator указывает на область памяти, содержащую строку
(да еще и NULL-terminated).

> Если прав stlport -- тогда срочно сяду собирать пакет для сизифа.
> Хотя это надо бы сделать в любом случае -- вещь полезная.

Конечно.

> --- synaptic-0.16/common/indexcopy.cc	2001-08-15 21:44:09 +0200
> +++ synaptic-0.16-gcc32/common/indexcopy.cc	2002-09-25 10:28:33 +0200
> @@ -402,7 +402,7 @@
>        return;
>     
>     // Not a dists type.
> -   if (stringcmp(Path.begin(),Path.begin()+strlen("dists/"),"dists/") != 0)
> +   if (stringcmp( &( *Path.begin() ),&*( Path.begin()+strlen("dists/"),"dists/" ) ) != 0)

скобки тут лишние (хотя и не вредные).
когда-нибудь этот код может перестать работать (равно как и код apt'а),
по причине использования негарантированного свойства итератора.


--
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [devel] synaptic и  g++ 3.2.1 строки и итераторы
  2002-09-25 13:42 ` Dmitry V. Levin
@ 2002-09-25 16:57   ` Alexey Dyachenko
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dyachenko @ 2002-09-25 16:57 UTC (permalink / raw)
  To: ALT Linux Mailing List

On Wed, Sep 25, 2002 at 05:42:15PM +0400, Dmitry V. Levin wrote:
> On Wed, Sep 25, 2002 at 11:47:33AM +0200, Alexey Dyachenko wrote:
> > Вот только при этом получил я ОЧЕНЬ неприятную новость.
> > 
> > std::string::iterator !=  const char *
> 
> Это уже очень давно не новость.

Увы, следить за всем, что происходит вокруг просто не успеваю.
Сейчас занялся изучением Tcl и от плюсов немного отошел.


> > То есть в gcc 3.2 basic_string::iterator объявлен как
> > typedef __gnu_cxx::__normal_iterator<pointer, basic_string>  iterator; 
> > 
> > В stlport это объявлеятся как 
> >   typedef const value_type*                const_iterator;                                          
> >   typedef value_type*                      iterator;
> > 
> > и по моему здесь прав stlport.
> 
> Нет; итератор - это целиком и полностью implementation-defined.
> Вообще говоря, по стандарту реализация std::string не гарантирует,
> что std::string::iterator указывает на область памяти, содержащую строку
> (да еще и NULL-terminated).

Достал таки стандарт, действительно -- implementation defined.
Извиняюсь за ложную тревогу, пора снова садиться за книги.


> 
> > Если прав stlport -- тогда срочно сяду собирать пакет для сизифа.
> > Хотя это надо бы сделать в любом случае -- вещь полезная.
> 
> Конечно.


Если нет других желающих собирать -- попробую собрать на следующей неделе,
к выходным надо на работе сдать проект, так что сейчас времени  у меня не
много.

> 
> > --- synaptic-0.16/common/indexcopy.cc	2001-08-15 21:44:09 +0200
> > +++ synaptic-0.16-gcc32/common/indexcopy.cc	2002-09-25 10:28:33 +0200
> > @@ -402,7 +402,7 @@
> >        return;
> >     
> >     // Not a dists type.
> > -   if (stringcmp(Path.begin(),Path.begin()+strlen("dists/"),"dists/") != 0)
> > +   if (stringcmp( &( *Path.begin() ),&*( Path.begin()+strlen("dists/"),"dists/" ) ) != 0)
> 
> скобки тут лишние (хотя и не вредные).
> когда-нибудь этот код может перестать работать (равно как и код apt'а),
> по причине использования негарантированного свойства итератора.

Если можно -- объясни поподробней, где негарантированное свойство?
вроде * для итератора -- самый что ни на есть гарантированный оператор,
возвращающий объект. Для string итератор вроде должен быть random_access
(хотя я в этом сейчас поклясться не могу) и к нему + тоже должен быть
применим.

По хорошему -- конечно все это надо переписать нормально, но мне нужен был
быстрый результат, так что сделал "hack" в его оригинальном смысле
"hack  1. /n./ Originally, a quick job that produces what is needed, but not well."

Надеюсь, мантейнерам synaptic мой патч облегчит работу.


С уважением, Алексей Дьяченко.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-25 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-25  9:47 [devel] synaptic и g++ 3.2.1 строки и итераторы Alexey Dyachenko
2002-09-25 13:42 ` Dmitry V. Levin
2002-09-25 16:57   ` Alexey Dyachenko

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git