X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fmisc.c;h=d907fb957f99fc4b6503664ccebcc40d95b1d744;hp=14bc240746900d6a63b262c03fc3cbf70807b886;hb=adf99a601d58f213370cef8cd0e5bd9a0f92dc74;hpb=2a6284cf1a380b55f3ad2bf71a63946e2595b812 diff --git a/common/misc.c b/common/misc.c index 14bc240..d907fb9 100644 --- a/common/misc.c +++ b/common/misc.c @@ -11,16 +11,18 @@ $Id$ $Log$ - Revision 1.1.1.1.6.1 2001/11/25 23:04:51 short - * new common/misc.c/ - * g{,v}asprintf() - "asprintf()" compatibility emulation - * ARRAY_LEN() - sizeof(x)/sizeof(*x) - * SAFE_STRNCPY{,_SIZEOF}() - strncpy with variable-size autodetection - * G_GNUC_PRINTF - GCC attribute from glib - * N_(x) - missing in localization macros + Revision 1.1.1.1.6.2 2001/11/27 21:18:41 short + Update: orig2001_11_25_22_56 -> orig2001_11_27_05_17 + Branch merged, dead - Revision 1.1.1.1 2001/11/25 21:59:04 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.1.2.1 2001/11/27 04:37:59 short + Update: orig2001_11_25_22_56 -> orig2001_11_27_05_17 + + Revision 1.1.1.2 2001/11/27 04:19:24 short + :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 05:17 CET 2001 + + Revision 1.20 2001/11/26 18:06:08 pkot + Checking for *printf functions, N_(x) for localization, generic ARRAY_LEN, SAFE_STRNCPY, G_GNUC_PRINTF (Jan Kratochvil) Revision 1.19 2001/11/22 17:56:53 pkot smslib update. sms sending @@ -64,8 +66,8 @@ int GetLine(FILE *File, char *Line, int count) if (fgets(Line, count, File)) { ptr = Line + strlen(Line) - 1; - while ( (*ptr == '\n' || *ptr == '\r') && ptr>=Line) - *ptr--='\0'; + while ( (*ptr == '\n' || *ptr == '\r') && ptr >= Line) + *ptr-- = '\0'; return strlen(Line); } @@ -137,46 +139,46 @@ inline char *GetModel (const char *num) #ifndef HAVE_VASPRINTF /* Adapted from snprintf(3) man page: */ -int gvasprintf(char **destp,const char *fmt,va_list ap) +int gvasprintf(char **destp, const char *fmt, va_list ap) { -int n,size=0x100; -char *p,*pnew; + int n, size = 0x100; + char *p, *pnew; - if (!(p=malloc(size))) { - *destp=NULL; + if (!(p = malloc(size))) { + *destp = NULL; return(-1); - } + } for (;;) { /* Try to print in the allocated space. */ - n=gvsprintf(p,size,fmt,ap); + n = gvsprintf(p, size, fmt, ap); /* If that worked, return the string. */ - if (n>-1 && n -1 && n < size) { + *destp = p; return(n); - } + } /* Else try again with more space. */ - if (n>-1) /* glibc 2.1 */ - size=n+1; /* precisely what is needed */ + if (n > -1) /* glibc 2.1 */ + size = n + 1; /* precisely what is needed */ else /* glibc 2.0 */ - size*=2; /* twice the old size */ - if (!(pnew=realloc(p,size))) { + size *= 2; /* twice the old size */ + if (!(pnew = realloc(p, size))) { free(p); - *destp=NULL; + *destp = NULL; return(-1); - } - p=pnew; + } + p = pnew; } } #endif #ifndef HAVE_ASPRINTF -int gasprintf(char **destp,const char *fmt,...) +int gasprintf(char **destp, const char *fmt,...) { -va_list ap; -int r; + va_list ap; + int r; va_start(ap,fmt); - r=gvasprintf(destp,fmt,ap); + r = gvasprintf(destp, fmt, ap); va_end(ap); return(r); }