Re: Patch for snprintf problem (bug #1000650) 4-th try

Поиск
Список
Период
Сортировка
От Ludek Finstrle
Тема Re: Patch for snprintf problem (bug #1000650) 4-th try
Дата
Msg-id 20060613094617.GA28219@soptik.pzkagis.cz
обсуждение исходный текст
Ответ на Re: Patch for snprintf problem (bug #1000650) 3-rd try  (Ludek Finstrle <luf@pzkagis.cz>)
Ответы Re: Patch for snprintf problem (bug #1000650) 4-th try  (Hiroshi Inoue <inoue@tpf.co.jp>)
Список pgsql-odbc
> > > > buf = "text";
> > > > snprintf(buf,size,"%s append",buf);
> > > >
> > > > buf = "text append" on Windows (MS VC compiler)
> > > > buf = " append" on linux (gcc compiler)
> > > >
> > > > I solve it this way (main idea):
> > > > snprintf(buf + strlen(buf), " append");
> > >
> > > Hmm bad news.
> > > If so, it may be better to use the sequence like the following for example.
> > >
> > >     char    *query_ptr;
> > >     size_t    bufsize_res;
> > >     int    slen;
> > >
> > >     /* Initialize */
> > >     query_ptr = columns_query;
> > >     bufsize_res = sizeof(columns_query);
> > >
> > >     if (..)
> > >     {
> > >         if ((slen = snprintf(query_ptr, bufsize_res, .., )) <= 0)
> > >         {
> > >             .. error_handling ..
> > >         }
> > >         query_ptr += slen;
> > >         bufsize_res -= slen;
> > >     }
> > >
> > >     ...
> >
> > I'm not sure. There are a lot of strcat, my_strcat, schema_strcat calls
> > between snprintf. There is only one place where snprintf could be called
> > after another snprintf.
>
> I change the snprintf_addlen to snprintf_len as you mentioned.
>
> Third try of patch attached.

I make patch againist CVS after yours huge commit. What's your opinion?
Could we fix linux bug? Or do you prefer ifdef or what's your
idea about change these lines:

snprintf(buf,bufsize,"%s adding 1",buf);
strcat(buf," adding 2");
snprintf(buf,bufsize,"%s adding 3",buf);

I think it's hard to maintain code you mentioned above. This calls
are only in catalog information (relatively short query - used not so
often).

Patch attached contains previous psqlodbc_snprintf_3try and
psqlodbc_snprintf_next.

Regards,

Luf

Вложения

В списке pgsql-odbc по дате отправления:

Предыдущее
От: Ludek Finstrle
Дата:
Сообщение: Re: adding psqlodbc driver in ODBCconfig
Следующее
От: "Campbell, Greg"
Дата:
Сообщение: Re: [compgeneral] I cant get the description or default valueof a field