Re: cvs: php-src /ext/date php_date.c

From: Date: Thu, 30 Jun 2005 23:17:53 +0000
Subject: Re: cvs: php-src /ext/date php_date.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-32612@lists.php.net to get a copy of this message
Hello Derick, Ilia, why is this usign snprintf when the value is a string? (e.g.: snprintf(buffer, 32, "%s...) why not use stropy or similar? best regards marcus Friday, July 1, 2005, 12:47:39 AM, you wrote: > iliaa Thu Jun 30 18:47:39 2005 EDT > Modified files: > /php-src/ext/date php_date.c > Log: > Fixed compiler warnings. > > http://cvs.php.net/diff.php/php-src/ext/date/php_date.c?r1=1.15&r2=1.16&ty=u > Index: php-src/ext/date/php_date.c > diff -u php-src/ext/date/php_date.c:1.15 php-src/ext/date/php_date.c:1.16 > --- php-src/ext/date/php_date.c:1.15 Thu Jun 30 18:44:28 2005 > +++ php-src/ext/date/php_date.c Thu Jun 30 18:47:39 2005 > @@ -16,7 +16,7 @@ > > +----------------------------------------------------------------------+ > */ > -/* $Id: php_date.c,v 1.15 2005/06/30 22:44:28 iliaa Exp $ */ > +/* $Id: php_date.c,v 1.16 2005/06/30 22:47:39 iliaa Exp $ */ > #include "php.h" > #include "php_streams.h" > @@ -156,55 +156,55 @@ > for (i = 0; i < format_len; i++) { > switch (format[i]) { > /* day */ > - case 'd': snprintf(&buffer, 32, "%02d", (int) > t->d); break; > - case 'D': snprintf(&buffer, 32, "%s", > day_short_names[timelib_day_of_week(t->y, t->m, t->d)]); break; > - case 'j': snprintf(&buffer, 32, "%d", (int) > t->d); break; > - case 'l': snprintf(&buffer, 32, "%s", > day_full_names[timelib_day_of_week(t->y, t->m, t->d)]); break; > - case 'S': snprintf(&buffer, 32, "%s", > english_suffix(t->d)); break; > - case 'w': snprintf(&buffer, 32, "%d", (int) > timelib_day_of_week(t->y, t->m, t->d)); break; > - case 'z': snprintf(&buffer, 32, "%d", (int) > timelib_day_of_year(t->y, t->m, t->d)); break; > + case 'd': snprintf(buffer, 32, "%02d", (int) > t->d); break; > + case 'D': snprintf(buffer, 32, "%s", > day_short_names[timelib_day_of_week(t->y, t->m, t->d)]); break; > + case 'j': snprintf(buffer, 32, "%d", (int) > t->d); break; > + case 'l': snprintf(buffer, 32, "%s", > day_full_names[timelib_day_of_week(t->y, t->m, t->d)]); break; > + case 'S': snprintf(buffer, 32, "%s", > english_suffix(t->d)); break; > + case 'w': snprintf(buffer, 32, "%d", (int) > timelib_day_of_week(t->y, t->m, t->d)); break; > + case 'z': snprintf(buffer, 32, "%d", (int) > timelib_day_of_year(t->y, t->m, t->d)); break; > /* week */ > - case 'W': snprintf(&buffer, 32, "%d", (int) > isoweek); break; /* iso weeknr */ > - case 'o': snprintf(&buffer, 32, "%d", (int) > isoyear); break; /* iso year */ > + case 'W': snprintf(buffer, 32, "%d", (int) > isoweek); break; /* iso weeknr */ > + case 'o': snprintf(buffer, 32, "%d", (int) > isoyear); break; /* iso year */ > /* month */ > - case 'F': snprintf(&buffer, 32, "%s", > mon_full_names[t->m - 1]); break; > - case 'm': snprintf(&buffer, 32, "%02d", (int) > t->m); break; > - case 'M': snprintf(&buffer, 32, "%s", > mon_short_names[t->m - 1]); break; > - case 'n': snprintf(&buffer, 32, "%d", (int) > t->m); break; > - case 't': snprintf(&buffer, 32, "%d", (int) > timelib_days_in_month(t->y, t->m)); break; > + case 'F': snprintf(buffer, 32, "%s", > mon_full_names[t->m - 1]); break; > + case 'm': snprintf(buffer, 32, "%02d", (int) > t->m); break; > + case 'M': snprintf(buffer, 32, "%s", > mon_short_names[t->m - 1]); break; > + case 'n': snprintf(buffer, 32, "%d", (int) > t->m); break; > + case 't': snprintf(buffer, 32, "%d", (int) > timelib_days_in_month(t->y, t->m)); break; > /* year */ > - case 'L': snprintf(&buffer, 32, "%d", > timelib_is_leap((int) t->y)); break; > - case 'y': snprintf(&buffer, 32, "%02d", (int) > t->y % 100); break; > - case 'Y': snprintf(&buffer, 32, "%04d", (int) > t->y); break; > + case 'L': snprintf(buffer, 32, "%d", > timelib_is_leap((int) t->y)); break; > + case 'y': snprintf(buffer, 32, "%02d", (int) > t->y % 100); break; > + case 'Y': snprintf(buffer, 32, "%04d", (int) > t->y); break; > /* time */ > - case 'a': snprintf(&buffer, 32, "%s", t->h > >= 12 ? "pm" : "am"); break; > - case 'A': snprintf(&buffer, 32, "%s", t->h > >= 12 ? "PM" : "AM"); break; > - case 'B': snprintf(&buffer, 32, "[B > unimplemented]"); break; > - case 'g': snprintf(&buffer, 32, "%d", (t->h > % 12) ? (int) t->h % 12 : 12); break; > - case 'G': snprintf(&buffer, 32, "%d", (int) > t->h); break; > - case 'h': snprintf(&buffer, 32, "%02d", > (t->h % 12) ? (int) t->h % 12 : 12); break; > - case 'H': snprintf(&buffer, 32, "%02d", (int) > t->h); break; > - case 'i': snprintf(&buffer, 32, "%02d", (int) > t->i); break; > - case 's': snprintf(&buffer, 32, "%02d", (int) > t->s); break; > + case 'a': snprintf(buffer, 32, "%s", t->h >= > 12 ? "pm" : "am"); break; > + case 'A': snprintf(buffer, 32, "%s", t->h >= > 12 ? "PM" : "AM"); break; > + case 'B': snprintf(buffer, 32, "[B > unimplemented]"); break; > + case 'g': snprintf(buffer, 32, "%d", (t->h % 12) > ? (int) t->h % 12 : 12); break; > + case 'G': snprintf(buffer, 32, "%d", (int) > t->h); break; > + case 'h': snprintf(buffer, 32, "%02d", (t->h % > 12) ? (int) t->h % 12 : 12); break; > + case 'H': snprintf(buffer, 32, "%02d", (int) > t->h); break; > + case 'i': snprintf(buffer, 32, "%02d", (int) > t->i); break; > + case 's': snprintf(buffer, 32, "%02d", (int) > t->s); break; > /* timezone */ > - case 'I': snprintf(&buffer, 32, "%d", localtime > ? offset->is_dst : 0); break; > - case 'O': snprintf(&buffer, 32, "%c%02d%02d", > + case 'I': snprintf(buffer, 32, "%d", localtime ? > offset->is_dst : 0); break; > + case 'O': snprintf(buffer, 32, "%c%02d%02d", > > localtime ? ((offset->offset < 0) ? '-' : '+') : '+', > > localtime ? abs(offset->offset / 3600) : 0, > > localtime ? abs((offset->offset % 3600) / 60) : 0 > ); > break; > - case 'T': snprintf(&buffer, 32, "%s", localtime > ? offset->abbr : "GMT"); break; > - case 'e': snprintf(&buffer, 32, "%s", localtime > ? t->tz_info->name : "UTC"); break; > - case 'Z': snprintf(&buffer, 32, "%d", localtime > ? offset->offset : 0); break; > + case 'T': snprintf(buffer, 32, "%s", localtime ? > offset->abbr : "GMT"); break; > + case 'e': snprintf(buffer, 32, "%s", localtime ? > t->tz_info->name : "UTC"); break; > + case 'Z': snprintf(buffer, 32, "%d", localtime ? > offset->offset : 0); break; > /* full date/time */ > - case 'c': snprintf(&buffer, 32, > "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", > + case 'c': snprintf(buffer, 32, > "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", > (int) t->y, (int) > t->m, (int) t->d, > (int) t->h, (int) > t->i, (int) t->s, > > localtime ? ((offset->offset < 0) ? '-' : '+') : '+', > @@ -212,7 +212,7 @@ > > localtime ? abs((offset->offset % 3600) / 60) : 0 > ); > break; > - case 'r': snprintf(&buffer, 32, "%3s, %02d %3s %04d > %02d:%02d:%02d %c%02d%02d", > + case 'r': snprintf(buffer, 32, "%3s, %02d %3s %04d > %02d:%02d:%02d %c%02d%02d", > > day_short_names[timelib_day_of_week(t->y, t->m, t->d)], > > (int) t->d, mon_short_names[t->m - 1], > > (int) t->y, (int) t->h, (int) t->i, (int) t->s, > @@ -221,7 +221,7 @@ > > localtime ? abs((offset->offset % 3600) / 60) : 0 > ); > break; > - case 'U': snprintf(&buffer, 32, "%lld", (long > long) t->sse); break; > + case 'U': snprintf(buffer, 32, "%lld", (long long) > t->sse); break; > case '\\': if (i < format_len) i++; buffer[0] = format[i]; > buffer[1] = '\0'; break; -- Best regards, Marcus mailto:mail@marcus-boerger.de

« previous php.cvs (#32612) next »