X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Futils.c;h=01be3ea2d839298e08e7652a63d53bf0fa9445c1;hp=8817283d2ac4628b9eec50b24b9aa7557a8f8f41;hb=97787110a2b6e99f80b277dbffdbbc4b0d608a55;hpb=e976d4f3dc0c97ae659d1aa4a472be74d2188ba1 diff --git a/src/utils.c b/src/utils.c index 8817283d..01be3ea2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -703,7 +703,7 @@ unique_create (const char *name, bool binary, char **opened_name) xfree (uname); uname = unique_name (name, false); } - if (opened_name && fp != NULL) + if (opened_name) { if (fp) *opened_name = uname; @@ -1024,9 +1024,9 @@ match_tail (const char *string, const char *tail, bool fold_case) return false; /* tail is longer than string. */ if (!fold_case) - return strcmp (string + pos, tail); + return !strcmp (string + pos, tail); else - return strcasecmp (string + pos, tail); + return !strcasecmp (string + pos, tail); } /* Checks whether string S matches each element of ACCEPTS. A list @@ -1118,56 +1118,6 @@ has_html_suffix_p (const char *fname) return false; } -/* Read a line from FP and return the pointer to freshly allocated - storage. The storage space is obtained through malloc() and should - be freed with free() when it is no longer needed. - - The length of the line is not limited, except by available memory. - The newline character at the end of line is retained. The line is - terminated with a zero character. - - After end-of-file is encountered without anything being read, NULL - is returned. NULL is also returned on error. To distinguish - between these two cases, use the stdio function ferror(). */ - -char * -read_whole_line (FILE *fp) -{ - int length = 0; - int bufsize = 82; - char *line = xmalloc (bufsize); - - while (fgets (line + length, bufsize - length, fp)) - { - length += strlen (line + length); - if (length == 0) - /* Possible for example when reading from a binary file where - a line begins with \0. */ - continue; - - if (line[length - 1] == '\n') - break; - - /* fgets() guarantees to read the whole line, or to use up the - space we've given it. We can double the buffer - unconditionally. */ - bufsize <<= 1; - line = xrealloc (line, bufsize); - } - if (length == 0 || ferror (fp)) - { - xfree (line); - return NULL; - } - if (length + 1 < bufsize) - /* Relieve the memory from our exponential greediness. We say - `length + 1' because the terminating \0 is not included in - LENGTH. We don't need to zero-terminate the string ourselves, - though, because fgets() does that. */ - line = xrealloc (line, length + 1); - return line; -} - /* Read FILE into memory. A pointer to `struct file_memory' are returned; use struct element `content' to access file contents, and the element `length' to know the file length. `content' is *not* @@ -2559,7 +2509,7 @@ const char * test_dir_matches_p() { static struct { - const char *dirlist[3]; + char *dirlist[3]; const char *dir; bool result; } test_array[] = {