mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Add pg_strnlen() a portable implementation of strlen.
As the OS version is likely going to be more optimized, fall back to it if available, as detected by configure.
This commit is contained in:
@ -43,6 +43,8 @@
|
||||
#endif
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "common/string.h"
|
||||
|
||||
#ifndef NL_ARGMAX
|
||||
#define NL_ARGMAX 16
|
||||
#endif
|
||||
@ -790,16 +792,6 @@ bad_format:
|
||||
target->failed = true;
|
||||
}
|
||||
|
||||
static size_t
|
||||
pg_strnlen(const char *str, size_t maxlen)
|
||||
{
|
||||
const char *p = str;
|
||||
|
||||
while (maxlen-- > 0 && *p)
|
||||
p++;
|
||||
return p - str;
|
||||
}
|
||||
|
||||
static void
|
||||
fmtstr(char *value, int leftjust, int minlen, int maxwidth,
|
||||
int pointflag, PrintfTarget *target)
|
||||
|
Reference in New Issue
Block a user