Ignore:
Timestamp:
Jul 2, 2013, 7:27:06 PM (12 years ago)
Author:
Herwig Bauernfeind
Message:

Samba Server 3.5: Update branch to 3.5.20

Location:
branches/samba-3.5.x/lib/replace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/lib/replace/libreplace.m4

    r414 r773  
    109109AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
    110110AC_CHECK_FUNCS(waitpid wait4 strlcpy strlcat initgroups memmove strdup)
    111 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2)
     111AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2 dprintf vdprintf)
    112112AC_CHECK_FUNCS(isatty chown lchown link readlink symlink realpath)
    113113AC_HAVE_DECL(setresuid, [#include <unistd.h>])
     
    229229AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
    230230
     231AC_CHECK_FUNCS(memmem)
     232
    231233# this test disabled as we don't actually need __VA_ARGS__ yet
    232234AC_TRY_CPP([
  • branches/samba-3.5.x/lib/replace/replace.c

    r414 r773  
    682682}
    683683#endif
     684
     685
     686#ifndef HAVE_MEMMEM
     687void *rep_memmem(const void *haystack, size_t haystacklen,
     688                 const void *needle, size_t needlelen)
     689{
     690        if (needlelen == 0) {
     691                return discard_const(haystack);
     692        }
     693        while (haystacklen >= needlelen) {
     694                char *p = memchr(haystack, *(const char *)needle,
     695                                 haystacklen-(needlelen-1));
     696                if (!p) return NULL;
     697                if (memcmp(p, needle, needlelen) == 0) {
     698                        return p;
     699                }
     700                haystack = p+1;
     701                haystacklen -= (p - (const char *)haystack) + 1;
     702        }
     703        return NULL;
     704}
     705#endif
     706
     707#if !defined(HAVE_VDPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     708int rep_vdprintf(int fd, const char *format, va_list ap)
     709{
     710        char *s = NULL;
     711        int ret;
     712
     713        vasprintf(&s, format, ap);
     714        if (s == NULL) {
     715                errno = ENOMEM;
     716                return -1;
     717        }
     718        ret = write(fd, s, strlen(s));
     719        free(s);
     720        return ret;
     721}
     722#endif
     723
     724#if !defined(HAVE_DPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     725int rep_dprintf(int fd, const char *format, ...)
     726{
     727        int ret;
     728        va_list ap;
     729
     730        va_start(ap, format);
     731        ret = vdprintf(fd, format, ap);
     732        va_end(ap);
     733
     734        return ret;
     735}
     736#endif
     737
  • branches/samba-3.5.x/lib/replace/replace.h

    r414 r773  
    141141#endif
    142142
     143#ifndef HAVE_MEMMEM
     144#define memmem rep_memmem
     145void *rep_memmem(const void *haystack, size_t haystacklen,
     146                 const void *needle, size_t needlelen);
     147#endif
     148
    143149#ifndef HAVE_MKTIME
    144150#define mktime rep_mktime
     
    351357#endif
    352358
    353 #ifndef HAVE_VASPRINTF
     359#if !defined(HAVE_VDPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     360#define vdprintf rep_vdprintf
     361int rep_vdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
     362#endif
     363
     364#if !defined(HAVE_DPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     365#define dprintf rep_dprintf
     366int rep_dprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
     367#endif
     368
     369#if !defined(HAVE_VASPRINTF) || !defined(HAVE_C99_VSNPRINTF)
    354370#define vasprintf rep_vasprintf
    355371int rep_vasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
     
    366382#endif
    367383
    368 #ifndef HAVE_ASPRINTF
     384#if !defined(HAVE_ASPRINTF) || !defined(HAVE_C99_VSNPRINTF)
    369385#define asprintf rep_asprintf
    370386int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
     387#endif
     388
     389#if !defined(HAVE_C99_VSNPRINTF)
     390#ifdef REPLACE_BROKEN_PRINTF
     391/*
     392 * We do not redefine printf by default
     393 * as it breaks the build if system headers
     394 * use __attribute__((format(printf, 3, 0)))
     395 * instead of __attribute__((format(__printf__, 3, 0)))
     396 */
     397#define printf rep_printf
     398#endif
     399int rep_printf(const char *, ...) PRINTF_ATTRIBUTE(1,2);
     400#endif
     401
     402#if !defined(HAVE_C99_VSNPRINTF)
     403#define fprintf rep_fprintf
     404int rep_fprintf(FILE *stream, const char *, ...) PRINTF_ATTRIBUTE(2,3);
    371405#endif
    372406
  • branches/samba-3.5.x/lib/replace/snprintf.c

    r414 r773  
    11881188}
    11891189
    1190  int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
     1190 int rep_vsnprintf (char *str, size_t count, const char *fmt, va_list args)
    11911191{
    11921192        return dopr(str, count, fmt, args);
     
    12011201 */
    12021202#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
    1203  int snprintf(char *str,size_t count,const char *fmt,...)
     1203 int rep_snprintf(char *str,size_t count,const char *fmt,...)
    12041204{
    12051205        size_t ret;
     
    12141214
    12151215#ifndef HAVE_C99_VSNPRINTF
    1216  int printf(const char *fmt, ...)
     1216 int rep_printf(const char *fmt, ...)
    12171217{
    12181218        va_list ap;
     
    12351235
    12361236#ifndef HAVE_C99_VSNPRINTF
    1237  int fprintf(FILE *stream, const char *fmt, ...)
     1237 int rep_fprintf(FILE *stream, const char *fmt, ...)
    12381238{
    12391239        va_list ap;
     
    12571257#endif
    12581258
    1259 #ifndef HAVE_VASPRINTF
    1260  int vasprintf(char **ptr, const char *format, va_list ap)
     1259#if !defined(HAVE_VASPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     1260 int rep_vasprintf(char **ptr, const char *format, va_list ap)
    12611261{
    12621262        int ret;
     
    12791279#endif
    12801280
    1281 
    1282 #ifndef HAVE_ASPRINTF
    1283  int asprintf(char **ptr, const char *format, ...)
     1281#if !defined(HAVE_ASPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     1282 int rep_asprintf(char **ptr, const char *format, ...)
    12841283{
    12851284        va_list ap;
  • branches/samba-3.5.x/lib/replace/test/testsuite.c

    r414 r773  
    10151015        return true;
    10161016}
     1017
     1018static int test_memmem(void)
     1019{
     1020        char *s;
     1021
     1022        printf("test: memmem\n");
     1023
     1024        s = memmem("foo", 3, "fo", 2);
     1025        if (strcmp(s, "foo") != 0) {
     1026                printf(__location__ ": Failed memmem\n");
     1027                return false;
     1028        }
     1029
     1030        s = memmem("foo", 3, "", 0);
     1031        if (strcmp(s, "foo") != 0) {
     1032                printf(__location__ ": Failed memmem\n");
     1033                return false;
     1034        }
     1035
     1036        s = memmem("foo", 4, "o", 1);
     1037        if (strcmp(s, "oo") != 0) {
     1038                printf(__location__ ": Failed memmem\n");
     1039                return false;
     1040        }
     1041
     1042        s = memmem("foobarfodx", 11, "fod", 3);
     1043        if (strcmp(s, "fodx") != 0) {
     1044                printf(__location__ ": Failed memmem\n");
     1045                return false;
     1046        }
     1047
     1048        printf("success: memmem\n");
     1049
     1050        return true;
     1051}
     1052
    10171053
    10181054struct torture_context;
     
    10661102        ret &= test_utime();
    10671103        ret &= test_utimes();
     1104        ret &= test_memmem();
    10681105
    10691106        return ret;
Note: See TracChangeset for help on using the changeset viewer.