mirror of
https://github.com/nmap/nmap.git
synced 2025-12-17 05:09:00 +00:00
Fixed indentation & style.
indent -nut -i2 -kr -br -brs -brf -l0 -bad -npcs -nprs -ncs nbase_str.c + manual adjustements.
This commit is contained in:
@@ -106,17 +106,25 @@ const char *p;
|
|||||||
char *needle, *q, *foundto;
|
char *needle, *q, *foundto;
|
||||||
|
|
||||||
/* Should crash if !pneedle -- this is OK */
|
/* Should crash if !pneedle -- this is OK */
|
||||||
if (!*pneedle) return (char *) haystack;
|
if (!*pneedle)
|
||||||
if (!haystack) return NULL;
|
return (char *)haystack;
|
||||||
|
if (!haystack)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
needlelen = (unsigned int)strlen(pneedle);
|
needlelen = (unsigned int)strlen(pneedle);
|
||||||
if (needlelen >= sizeof(buf)) {
|
if (needlelen >= sizeof(buf))
|
||||||
needle = (char *)safe_malloc(needlelen + 1);
|
needle = (char *)safe_malloc(needlelen + 1);
|
||||||
} else needle = buf;
|
else
|
||||||
p = pneedle; q = needle;
|
needle = buf;
|
||||||
|
|
||||||
|
p = pneedle;
|
||||||
|
q = needle;
|
||||||
|
|
||||||
while ((*q++ = tolower((int)(unsigned char)*p++)))
|
while ((*q++ = tolower((int)(unsigned char)*p++)))
|
||||||
;
|
;
|
||||||
p = haystack - 1; foundto = needle;
|
|
||||||
|
p = haystack - 1;
|
||||||
|
foundto = needle;
|
||||||
while (*++p) {
|
while (*++p) {
|
||||||
if (tolower((int)(unsigned char)*p) == *foundto) {
|
if (tolower((int)(unsigned char)*p) == *foundto) {
|
||||||
if (!*++foundto) {
|
if (!*++foundto) {
|
||||||
@@ -125,7 +133,8 @@ needlelen = (unsigned int) strlen(pneedle);
|
|||||||
free(needle);
|
free(needle);
|
||||||
return (char *)(p - needlelen + 1);
|
return (char *)(p - needlelen + 1);
|
||||||
}
|
}
|
||||||
} else foundto = needle;
|
} else
|
||||||
|
foundto = needle;
|
||||||
}
|
}
|
||||||
if (needlelen >= sizeof(buf))
|
if (needlelen >= sizeof(buf))
|
||||||
free(needle);
|
free(needle);
|
||||||
@@ -141,8 +150,7 @@ int Strncpy(char *dest, const char *src, size_t n) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
|
int Vsnprintf(char *s, size_t n, const char *fmt, va_list ap) {
|
||||||
{
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = vsnprintf(s, n, fmt, ap);
|
ret = vsnprintf(s, n, fmt, ap);
|
||||||
@@ -153,8 +161,7 @@ int Vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Snprintf(char *s, size_t n, const char *fmt, ...)
|
int Snprintf(char *s, size_t n, const char *fmt, ...) {
|
||||||
{
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -213,6 +220,7 @@ int alloc_vsprintf(char **strp, const char *fmt, va_list va) {
|
|||||||
printable (as defined by isprint()) */
|
printable (as defined by isprint()) */
|
||||||
int stringisprintable(const char *str, int strlength) {
|
int stringisprintable(const char *str, int strlength) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < strlength; i++)
|
for (i = 0; i < strlength; i++)
|
||||||
if (!isprint((int)(unsigned char)str[i]))
|
if (!isprint((int)(unsigned char)str[i]))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -223,6 +231,7 @@ int stringisprintable(const char *str, int strlength) {
|
|||||||
/* Convert non-printable characters to replchar in the string */
|
/* Convert non-printable characters to replchar in the string */
|
||||||
void replacenonprintable(char *str, int strlength, char replchar) {
|
void replacenonprintable(char *str, int strlength, char replchar) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < strlength; i++)
|
for (i = 0; i < strlength; i++)
|
||||||
if (!isprint((int)(unsigned char)str[i]))
|
if (!isprint((int)(unsigned char)str[i]))
|
||||||
str[i] = replchar;
|
str[i] = replchar;
|
||||||
|
|||||||
Reference in New Issue
Block a user