X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/c7396ac5dedeca5d791113782ae72b4bb67692e3..09792322d9224b0407783a19c2dd57fd1a8bbd52:/src/src/string.c diff --git a/src/src/string.c b/src/src/string.c index ece200bcc..0e73e2c79 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2009 */ +/* Copyright (c) University of Cambridge 1995 - 2012 */ /* See the file NOTICE for conditions of use and distribution. */ /* Miscellaneous string-handling functions. Some are not required for @@ -210,7 +210,6 @@ return yield; -#ifndef COMPILE_UTILITY /************************************************* * Interpret escape sequence * *************************************************/ @@ -227,6 +226,9 @@ Returns: the value of the character escape int string_interpret_escape(uschar **pp) { +#ifdef COMPILE_UTILITY +const uschar *hex_digits= CUS"0123456789abcdef"; +#endif int ch; uschar *p = *pp; ch = *(++p); @@ -262,7 +264,6 @@ else switch(ch) *pp = p; return ch; } -#endif /* COMPILE_UTILITY */ @@ -332,6 +333,7 @@ while (*t != 0) *tt = 0; return ss; } +#endif /* COMPILE_UTILITY */ /************************************************* * Undo printing escapes in string * @@ -398,7 +400,6 @@ while (*p) return ss; } -#endif /* COMPILE_UTILITY */ @@ -414,7 +415,7 @@ Returns: copy of string in new store */ uschar * -string_copy(uschar *s) +string_copy(const uschar *s) { int len = Ustrlen(s) + 1; uschar *ss = store_get(len); @@ -715,7 +716,7 @@ uschar buffer[STRING_SPRINTF_BUFFER_SIZE]; va_start(ap, format); if (!string_vformat(buffer, sizeof(buffer), format, ap)) log_write(0, LOG_MAIN|LOG_PANIC_DIE, - "string_sprintf expansion was longer than %d", sizeof(buffer)); + "string_sprintf expansion was longer than " SIZE_T_FMT, sizeof(buffer)); va_end(ap); return string_copy(buffer); } @@ -1133,7 +1134,8 @@ return yield; BOOL string_vformat(uschar *buffer, int buflen, const char *format, va_list ap) { -enum { L_NORMAL, L_SHORT, L_LONG, L_LONGLONG, L_LONGDOUBLE }; +/* We assume numbered ascending order, C does not guarantee that */ +enum { L_NORMAL=1, L_SHORT=2, L_LONG=3, L_LONGLONG=4, L_LONGDOUBLE=5, L_SIZE=6 }; BOOL yield = TRUE; int width, precision; @@ -1203,7 +1205,7 @@ while (*fp != 0) } } - /* Skip over 'h', 'L', 'l', and 'll', remembering the item length */ + /* Skip over 'h', 'L', 'l', 'll' and 'z', remembering the item length */ if (*fp == 'h') { fp++; length = L_SHORT; } @@ -1222,6 +1224,8 @@ while (*fp != 0) length = L_LONG; } } + else if (*fp == 'z') + { fp++; length = L_SIZE; } /* Handle each specific format type. */ @@ -1251,6 +1255,7 @@ while (*fp != 0) case L_NORMAL: sprintf(CS p, newformat, va_arg(ap, int)); break; case L_LONG: sprintf(CS p, newformat, va_arg(ap, long int)); break; case L_LONGLONG: sprintf(CS p, newformat, va_arg(ap, LONGLONG_T)); break; + case L_SIZE: sprintf(CS p, newformat, va_arg(ap, size_t)); break; } while (*p) p++; break;