mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
compat: run uncrustify
This is the result of running $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h in the compat directory
This commit is contained in:
parent
1a8916786f
commit
8099050c71
17 changed files with 233 additions and 234 deletions
|
@ -4,10 +4,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
char *
|
char *
|
||||||
canonicalize_file_name (const char * path)
|
canonicalize_file_name (const char *path)
|
||||||
{
|
{
|
||||||
#ifdef PATH_MAX
|
#ifdef PATH_MAX
|
||||||
char *resolved_path = malloc (PATH_MAX+1);
|
char *resolved_path = malloc (PATH_MAX + 1);
|
||||||
if (resolved_path == NULL)
|
if (resolved_path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
struct passwd passwd, *ignored;
|
struct passwd passwd, *ignored;
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !STD_GETPWUID
|
#if ! STD_GETPWUID
|
||||||
#define _POSIX_PTHREAD_SEMANTICS 1
|
#define _POSIX_PTHREAD_SEMANTICS 1
|
||||||
#endif
|
#endif
|
||||||
#if !STD_ASCTIME
|
#if ! STD_ASCTIME
|
||||||
#define _POSIX_PTHREAD_SEMANTICS 1
|
#define _POSIX_PTHREAD_SEMANTICS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_CANONICALIZE_FILE_NAME
|
#if ! HAVE_CANONICALIZE_FILE_NAME
|
||||||
/* we only call this function from C, and this makes testing easier */
|
/* we only call this function from C, and this makes testing easier */
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
char *
|
char *
|
||||||
|
@ -45,7 +45,7 @@ canonicalize_file_name (const char *path);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_GETLINE
|
#if ! HAVE_GETLINE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -57,15 +57,15 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
|
||||||
|
|
||||||
#endif /* !HAVE_GETLINE */
|
#endif /* !HAVE_GETLINE */
|
||||||
|
|
||||||
#if !HAVE_STRCASESTR
|
#if ! HAVE_STRCASESTR
|
||||||
char* strcasestr(const char *haystack, const char *needle);
|
char *strcasestr (const char *haystack, const char *needle);
|
||||||
#endif /* !HAVE_STRCASESTR */
|
#endif /* !HAVE_STRCASESTR */
|
||||||
|
|
||||||
#if !HAVE_STRSEP
|
#if ! HAVE_STRSEP
|
||||||
char *strsep(char **stringp, const char *delim);
|
char *strsep (char **stringp, const char *delim);
|
||||||
#endif /* !HAVE_STRSEP */
|
#endif /* !HAVE_STRSEP */
|
||||||
|
|
||||||
#if !HAVE_TIMEGM
|
#if ! HAVE_TIMEGM
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
time_t timegm (struct tm *tm);
|
time_t timegm (struct tm *tm);
|
||||||
#endif /* !HAVE_TIMEGM */
|
#endif /* !HAVE_TIMEGM */
|
||||||
|
@ -73,7 +73,7 @@ time_t timegm (struct tm *tm);
|
||||||
/* Silence gcc warnings about unused results. These warnings exist
|
/* Silence gcc warnings about unused results. These warnings exist
|
||||||
* for a reason; any use of this needs to be justified. */
|
* for a reason; any use of this needs to be justified. */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define IGNORE_RESULT(x) ({ __typeof__(x) __z = (x); (void)(__z = __z); })
|
#define IGNORE_RESULT(x) ({ __typeof__(x) __z = (x); (void) (__z = __z); })
|
||||||
#else /* !__GNUC__ */
|
#else /* !__GNUC__ */
|
||||||
#define IGNORE_RESULT(x) x
|
#define IGNORE_RESULT(x) x
|
||||||
#endif /* __GNUC__ */
|
#endif /* __GNUC__ */
|
||||||
|
|
|
@ -11,8 +11,9 @@ static const char *template =
|
||||||
"Version: %s\n"
|
"Version: %s\n"
|
||||||
"Libs: -lz\n";
|
"Libs: -lz\n";
|
||||||
|
|
||||||
int main(void)
|
int
|
||||||
|
main (void)
|
||||||
{
|
{
|
||||||
printf(template, ZLIB_VERSION);
|
printf (template, ZLIB_VERSION);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
/* getdelim.c --- Implementation of replacement getdelim function.
|
/* getdelim.c --- Implementation of replacement getdelim function.
|
||||||
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007,
|
* Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007,
|
||||||
2008, 2009 Free Software Foundation, Inc.
|
* 2008, 2009 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 3, or (at
|
* published by the Free Software Foundation; either version 3, or (at
|
||||||
your option) any later version.
|
* your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
General Public License for more details.
|
* General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
02110-1301, USA. */
|
* 02110-1301, USA. */
|
||||||
|
|
||||||
/* Ported from glibc by Simon Josefsson. */
|
/* Ported from glibc by Simon Josefsson. */
|
||||||
|
|
||||||
|
@ -34,22 +34,22 @@
|
||||||
|
|
||||||
#if USE_UNLOCKED_IO
|
#if USE_UNLOCKED_IO
|
||||||
# include "unlocked-io.h"
|
# include "unlocked-io.h"
|
||||||
# define getc_maybe_unlocked(fp) getc(fp)
|
# define getc_maybe_unlocked(fp) getc (fp)
|
||||||
#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
|
#elif ! HAVE_FLOCKFILE || ! HAVE_FUNLOCKFILE || ! HAVE_DECL_GETC_UNLOCKED
|
||||||
# undef flockfile
|
# undef flockfile
|
||||||
# undef funlockfile
|
# undef funlockfile
|
||||||
# define flockfile(x) ((void) 0)
|
# define flockfile(x) ((void) 0)
|
||||||
# define funlockfile(x) ((void) 0)
|
# define funlockfile(x) ((void) 0)
|
||||||
# define getc_maybe_unlocked(fp) getc(fp)
|
# define getc_maybe_unlocked(fp) getc (fp)
|
||||||
#else
|
#else
|
||||||
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
|
# define getc_maybe_unlocked(fp) getc_unlocked (fp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
||||||
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
|
* NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
|
||||||
NULL), pointing to *N characters of space. It is realloc'ed as
|
* NULL), pointing to *N characters of space. It is realloc'ed as
|
||||||
necessary. Returns the number of characters read (not including
|
* necessary. Returns the number of characters read (not including
|
||||||
the null terminator), or -1 on error or EOF. */
|
* the null terminator), or -1 on error or EOF. */
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||||
|
@ -57,41 +57,35 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||||
ssize_t result = -1;
|
ssize_t result = -1;
|
||||||
size_t cur_len = 0;
|
size_t cur_len = 0;
|
||||||
|
|
||||||
if (lineptr == NULL || n == NULL || fp == NULL)
|
if (lineptr == NULL || n == NULL || fp == NULL) {
|
||||||
{
|
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flockfile (fp);
|
flockfile (fp);
|
||||||
|
|
||||||
if (*lineptr == NULL || *n == 0)
|
if (*lineptr == NULL || *n == 0) {
|
||||||
{
|
|
||||||
char *new_lineptr;
|
char *new_lineptr;
|
||||||
*n = 120;
|
*n = 120;
|
||||||
new_lineptr = (char *) realloc (*lineptr, *n);
|
new_lineptr = (char *) realloc (*lineptr, *n);
|
||||||
if (new_lineptr == NULL)
|
if (new_lineptr == NULL) {
|
||||||
{
|
|
||||||
result = -1;
|
result = -1;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
*lineptr = new_lineptr;
|
*lineptr = new_lineptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;) {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = getc_maybe_unlocked (fp);
|
i = getc_maybe_unlocked (fp);
|
||||||
if (i == EOF)
|
if (i == EOF) {
|
||||||
{
|
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make enough space for len+1 (for final NUL) bytes. */
|
/* Make enough space for len+1 (for final NUL) bytes. */
|
||||||
if (cur_len + 1 >= *n)
|
if (cur_len + 1 >= *n) {
|
||||||
{
|
|
||||||
size_t needed_max =
|
size_t needed_max =
|
||||||
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
|
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
|
||||||
size_t needed = 2 * *n + 1; /* Be generous. */
|
size_t needed = 2 * *n + 1; /* Be generous. */
|
||||||
|
@ -99,16 +93,14 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||||
|
|
||||||
if (needed_max < needed)
|
if (needed_max < needed)
|
||||||
needed = needed_max;
|
needed = needed_max;
|
||||||
if (cur_len + 1 >= needed)
|
if (cur_len + 1 >= needed) {
|
||||||
{
|
|
||||||
result = -1;
|
result = -1;
|
||||||
errno = EOVERFLOW;
|
errno = EOVERFLOW;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_lineptr = (char *) realloc (*lineptr, needed);
|
new_lineptr = (char *) realloc (*lineptr, needed);
|
||||||
if (new_lineptr == NULL)
|
if (new_lineptr == NULL) {
|
||||||
{
|
|
||||||
result = -1;
|
result = -1;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/* getline.c --- Implementation of replacement getline function.
|
/* getline.c --- Implementation of replacement getline function.
|
||||||
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 3, or (at
|
* published by the Free Software Foundation; either version 3, or (at
|
||||||
your option) any later version.
|
* your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
General Public License for more details.
|
* General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
02110-1301, USA. */
|
* 02110-1301, USA. */
|
||||||
|
|
||||||
/* Written by Simon Josefsson. */
|
/* Written by Simon Josefsson. */
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
char *found;
|
char *found;
|
||||||
char *string;
|
char *string;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
struct dirent ent;
|
struct dirent ent;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
ssize_t count = 0;
|
ssize_t count = 0;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
char **lineptr = NULL;
|
char **lineptr = NULL;
|
||||||
FILE *stream = NULL;
|
FILE *stream = NULL;
|
||||||
|
|
||||||
count = getline(lineptr, &n, stream);
|
count = getline (lineptr, &n, stream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
char *found;
|
char *found;
|
||||||
const char *haystack, *needle;
|
const char *haystack, *needle;
|
||||||
|
|
||||||
found = strcasestr(haystack, needle);
|
found = strcasestr (haystack, needle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
char *found;
|
char *found;
|
||||||
char **stringp;
|
char **stringp;
|
||||||
const char *delim;
|
const char *delim;
|
||||||
|
|
||||||
found = strsep(stringp, delim);
|
found = strsep (stringp, delim);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
return (int) timegm((struct tm *)0);
|
return (int) timegm ((struct tm *) 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
* don't include it in their library
|
* don't include it in their library
|
||||||
*
|
*
|
||||||
* based on a GPL implementation in OpenTTD found under GPL v2
|
* based on a GPL implementation in OpenTTD found under GPL v2
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation, version 2.
|
* published by the Free Software Foundation, version 2.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
General Public License for more details.
|
* General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
02110-1301, USA. */
|
* 02110-1301, USA. */
|
||||||
|
|
||||||
/* Imported into notmuch by Dirk Hohndel - original author unknown. */
|
/* Imported into notmuch by Dirk Hohndel - original author unknown. */
|
||||||
|
|
||||||
|
@ -24,12 +24,14 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
char *strcasestr(const char *haystack, const char *needle)
|
char *
|
||||||
|
strcasestr (const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
size_t hay_len = strlen(haystack);
|
size_t hay_len = strlen (haystack);
|
||||||
size_t needle_len = strlen(needle);
|
size_t needle_len = strlen (needle);
|
||||||
|
|
||||||
while (hay_len >= needle_len) {
|
while (hay_len >= needle_len) {
|
||||||
if (strncasecmp(haystack, needle, needle_len) == 0)
|
if (strncasecmp (haystack, needle, needle_len) == 0)
|
||||||
return (char *) haystack;
|
return (char *) haystack;
|
||||||
|
|
||||||
haystack++;
|
haystack++;
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
|
/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
* This file is part of the GNU C Library.
|
||||||
|
*
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
* The GNU C Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
The GNU C Library is distributed in the hope that it will be useful,
|
* The GNU C Library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
License along with the GNU C Library; if not, write to the Free
|
* License along with the GNU C Library; if not, write to the Free
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
* 02111-1307 USA. */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* Taken from glibc 2.6.1 */
|
/* Taken from glibc 2.6.1 */
|
||||||
|
|
||||||
char *strsep (char **stringp, const char *delim)
|
char *
|
||||||
|
strsep (char **stringp, const char *delim)
|
||||||
{
|
{
|
||||||
char *begin, *end;
|
char *begin, *end;
|
||||||
|
|
||||||
|
@ -29,16 +30,14 @@ char *strsep (char **stringp, const char *delim)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* A frequent case is when the delimiter string contains only one
|
/* A frequent case is when the delimiter string contains only one
|
||||||
character. Here we don't need to call the expensive `strpbrk'
|
* character. Here we don't need to call the expensive `strpbrk'
|
||||||
function and instead work using `strchr'. */
|
* function and instead work using `strchr'. */
|
||||||
if (delim[0] == '\0' || delim[1] == '\0')
|
if (delim[0] == '\0' || delim[1] == '\0') {
|
||||||
{
|
|
||||||
char ch = delim[0];
|
char ch = delim[0];
|
||||||
|
|
||||||
if (ch == '\0')
|
if (ch == '\0')
|
||||||
end = NULL;
|
end = NULL;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (*begin == ch)
|
if (*begin == ch)
|
||||||
end = begin;
|
end = begin;
|
||||||
else if (*begin == '\0')
|
else if (*begin == '\0')
|
||||||
|
@ -46,18 +45,15 @@ char *strsep (char **stringp, const char *delim)
|
||||||
else
|
else
|
||||||
end = strchr (begin + 1, ch);
|
end = strchr (begin + 1, ch);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
/* Find the end of the token. */
|
/* Find the end of the token. */
|
||||||
end = strpbrk (begin, delim);
|
end = strpbrk (begin, delim);
|
||||||
|
|
||||||
if (end)
|
if (end) {
|
||||||
{
|
|
||||||
/* Terminate the token and set *STRINGP past NUL character. */
|
/* Terminate the token and set *STRINGP past NUL character. */
|
||||||
*end++ = '\0';
|
*end++ = '\0';
|
||||||
*stringp = end;
|
*stringp = end;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
/* No more delimiters; this is the last token. */
|
/* No more delimiters; this is the last token. */
|
||||||
*stringp = NULL;
|
*stringp = NULL;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
/* timegm.c --- Implementation of replacement timegm function.
|
/* timegm.c --- Implementation of replacement timegm function.
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 3, or (at
|
* published by the Free Software Foundation; either version 3, or (at
|
||||||
your option) any later version.
|
* your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
General Public License for more details.
|
* General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
02110-1301, USA. */
|
* 02110-1301, USA. */
|
||||||
|
|
||||||
/* Copyright 2013 Blake Jones. */
|
/* Copyright 2013 Blake Jones. */
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ timegm (struct tm *tm)
|
||||||
|
|
||||||
days = 365 * (tm->tm_year - 70);
|
days = 365 * (tm->tm_year - 70);
|
||||||
for (year = 70; year < tm->tm_year; year++) {
|
for (year = 70; year < tm->tm_year; year++) {
|
||||||
if (leapyear(1900 + year)) {
|
if (leapyear (1900 + year)) {
|
||||||
days++;
|
days++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (month = 0; month < tm->tm_mon; month++) {
|
for (month = 0; month < tm->tm_mon; month++) {
|
||||||
days += monthlen[leapyear(1900 + year)][month];
|
days += monthlen[leapyear (1900 + year)][month];
|
||||||
}
|
}
|
||||||
days += tm->tm_mday - 1;
|
days += tm->tm_mday - 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue