diff --git a/CHANGES b/CHANGES index c0200c0..3044900 100644 --- a/CHANGES +++ b/CHANGES @@ -3,7 +3,7 @@ to fdupes. Every item on the list includes, inside square brackets, a list of indentifiers referring to the people who contributed that particular item. When more than one person is listed the person who contributed the patch or idea appears first, followed by -those who've otherwise worked on that item. For a list of +those who've otherwise worked on that item. For a list of contributors names and identifiers please see the CONTRIBUTORS file. Changes from 2.2.0 to 2.2.1: @@ -64,7 +64,7 @@ Changes from 1.51 to 1.6.0: - Speed up file comparison. [SB, ST] - Fix bug where fdupes fails to consistently ignore hardlinks, depending on file processing order, when F_CONSIDERHARDLINKS flag is not set. [AL] -- Fix bug in is_hardlink(): Proper traversal of duplicates is done via +- Fix bug in is_hardlink(): Proper traversal of duplicates is done via dupe->duplicates, not via dupe->next. [AL] - Revise md5.c to compile under OSX. [TH] - Remove EXTERNAL_MD5 configuration option. [ID] @@ -87,7 +87,7 @@ Changes from 1.40 to 1.50-PR2 - Added "--noprompt" option for totally automated deletion of duplicate files. - Now sorts duplicates (old to new) for consistent order when - listing or deleteing duplicate files. + listing or deleting duplicate files. - Now tests for early matching of files, which should help speed up the matching process when large files are involved. - Added warning whenever a file cannot be deleted. [CHL, AL] @@ -106,7 +106,7 @@ Changes from 1.40 to 1.50-PR2 Changes from 1.31 to 1.40 -- Added option to omit the first file in each group +- Added option to omit the first file in each group of matches. [LM, AL] - Added escaping of filenames containing spaces when sameline option is specified. [AL] @@ -118,7 +118,7 @@ Changes from 1.31 to 1.40 Changes from 1.30 to 1.31 - Added interactive option to preserve all files during - delete procedure (something similar was already in + delete procedure (something similar was already in place, but now it's official). [AL] - Updated delete procedure prompt format. [AL] - Cosmetic code changes. [AL] @@ -140,7 +140,7 @@ Changes from 1.12 to 1.20 scanned were named pipes or sockets. [FD] - Fix against security risk resulting from the use of a temporary file to store md5sum output. [FD, AL] -- Using an external md5sum program is now optional. Started +- Using an external md5sum program is now optional. Started using L. Peter Deutsh's MD5 library instead. [FD, AL] - Added hardlinks option to distinguish between hard links and actual duplicate files. [FD, AL] @@ -149,7 +149,7 @@ Changes from 1.12 to 1.20 Changes from 1.11 to 1.12 -- Improved handling of extremely long input on preserve +- Improved handling of extremely long input on preserve prompt (delete option). [SSD, AL] Changes from 1.1 to 1.11 diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 6ea7e2b..101809e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,12 +1,12 @@ -The following people have contributed in some way to the development +The following people have contributed in some way to the development of fdupes. Please see the CHANGES file for detailed information on their contributions. Names are listed in alphabetical order. [AB] Adrian Bridgett [AL] Adrian Lopez [CHL] Charles Longeau - [FD] Frank DENIS, a.k.a. - Jedi/Sector One, a.k.a. + [FD] Frank DENIS, a.k.a. + Jedi/Sector One, a.k.a. DJ Chrysalis [JB] Jean-Baptiste [KK] Kresimir Kukulj diff --git a/INSTALL.enduser b/INSTALL.enduser index da819bf..666e078 100644 --- a/INSTALL.enduser +++ b/INSTALL.enduser @@ -39,6 +39,6 @@ followed by "make" and "sudo make install" as before. A test directory is included so that you may familiarise yourself with the way fdupes operates. You may test the program before -installing it by issuing a command such as "./fdupes testdir" +installing it by issuing a command such as "./fdupes testdir" or "./fdupes -r testdir", just to name a couple of examples. Refer to the documentation for information on valid options. diff --git a/README b/README index 258b305..a19c0d2 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Introduction -------------------------------------------------------------------- FDUPES is a program for identifying duplicate files residing -within specified directories. +within specified directories. Usage @@ -92,10 +92,10 @@ subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/dir.c b/dir.c index 0a445b5..d24d78d 100644 --- a/dir.c +++ b/dir.c @@ -27,7 +27,7 @@ char *getworkingdirectory() char *result; char *new_result; char *cwd; - + size = 1024; result = 0; diff --git a/errormsg.c b/errormsg.c index e21afdf..3d454a9 100644 --- a/errormsg.c +++ b/errormsg.c @@ -31,4 +31,6 @@ void errormsg(char *message, ...) fprintf(stderr, "\r%40s\r%s: ", "", program_name); vfprintf(stderr, message, ap); + + va_end(ap); } diff --git a/fdupes-help.7 b/fdupes-help.7 index 42d9df0..b45ccee 100644 --- a/fdupes-help.7 +++ b/fdupes-help.7 @@ -4,65 +4,69 @@ fdupes-help \- fdupes interactive mode reference .SH "INTRODUCTION" -.PP When run interactively .RB ( "" "as " "fdupes --delete" ), fdupes will show a list of duplicates and prompt the user for further action. .PP -The user can tell fdupes which files to keep or delete by tagging them accordingly. Once tagged, the user can instruct fdupes to delete any files that have been tagged for deletion. This can be done incrementally, if desired, successively tagging and deleting a limited number of files at a time until no more duplicates remain to be processed. +The user can tell fdupes which files to keep or delete by tagging them +accordingly. Once tagged, the user can instruct fdupes to delete any files +that have been tagged for deletion. This can be done incrementally, if +desired, successively tagging and deleting a limited number of files at a +time until no more duplicates remain to be processed. There are several ways to tag files in fdupes: individually using the .IR cursor , -by providing a list of files to keep, or by selecting files that match particular search criteria and tagging those as desired. Each of these approaches is discussed in detail in the sections below. +by providing a list of files to keep, or by selecting files that match +particular search criteria and tagging those as desired. Each of these +approaches is discussed in detail in the sections below. .SH "SCROLLING THE LIST" -.PP The list of duplicates can be scrolled as follows: -.B -.IP "PAGE DOWN" +.TP +.B "PAGE DOWN" Scroll down to the next page. -.B -.IP "PAGE UP" +.TP +.B "PAGE UP" Scroll up to preceding page. -.B -.IP "SHIFT + DOWN" +.TP +.B "SHIFT + DOWN" Scroll down by one line. Not supported on some terminals. -.B -.IP "SHIFT + UP" +.TP +.B "SHIFT + UP" Scroll up by one line. Not supported on some terminals. .SH "MOVING THE CURSOR" -.PP -The cursor tells fdupes which file and/or set of duplicates to act on, as described in the next section. The cursor's position can be changed as follows: +The cursor tells fdupes which file and/or set of duplicates to act on, as +described in the next section. The cursor's position can be changed as follows: -.B -.IP "DOWN" +.TP +.B "DOWN" Advance cursor to the next file on the list. -.B -.IP "UP" +.TP +.B "UP" Move cursor back to the previous file. -.B -.IP "TAB" +.TP +.B "TAB" Advance cursor to the next set of duplicates. -.B -.IP "BACKSPACE" +.TP +.B "BACKSPACE" Move cursor back to the previous set. -.B -.IP "F3" +.TP +.B "F3" Advance cursor to the next .I selected set, if any. -.B -.IP "F2" +.TP +.B "F2" Move cursor back to the previous .I selected set, if any. @@ -70,29 +74,33 @@ set, if any. .PP It is also possible to jump directly to a particular set: -.B -.IP "'goto '" +.TP +.B "'goto '" Move cursor to the top of the set indicated by .IR index . .SH "TAGGING FILES USING THE CURSOR" -.PP -Individual files can be tagged using the keys below. These keys all act on the current file, as identified by the cursor. +Individual files can be tagged using the keys below. +These keys all act on the current file, as identified by the cursor. -.B -.IP "SHIFT + RIGHT" +.TP +.B "SHIFT + RIGHT" Tag current file for keeping. -.B -.IP "SHIFT + LEFT" +.TP +.B "SHIFT + LEFT" Tag current file for deletion. -.B -.IP "'?'" +.TP +.B "'?'" Remove tag from current file. .PP -Entire sets of files can be tagged by providing a list of indices in a comma-separated list. Files in the current set whose indices appear on the list will be tagged for keeping, while any other files in that set will be tagged for deletion. As with individual files, the current set is identified by the cursor. +Entire sets of files can be tagged by providing a list of indices in a +comma-separated list. Files in the current set whose indices appear on the +list will be tagged for keeping, while any other files in that set will be +tagged for deletion. As with individual files, the current set is identified +by the cursor. .PP As an example, given the following list of duplicates: @@ -126,84 +134,88 @@ will tag all files for keeping. .PP There is one more command to deal with files in the current set: -.B -.IP "'rg'" +.TP +.B "'rg'" Remove tags from all files in current set. .SH "FILE SELECTION COMMANDS" -.PP -Another way to tag files is to first select them according to particular search criteria and then tell fdupes what to do with them. The following commands can be used to select files for tagging: +Another way to tag files is to first select them according to particular +search criteria and then tell fdupes what to do with them. The following +commands can be used to select files for tagging: -.B -.IP "'sel '" +.TP +.B "'sel '" Select any files whose paths contain the given text. -.B -.IP "'selb '" +.TP +.B "'selb '" Select any files whose paths begin with the given text. -.B -.IP "'sele '" +.TP +.B "'sele '" Select any files whose paths end with the given text. -.B -.IP "'selm '" +.TP +.B "'selm '" Select any file whose path matches the given text exactly. -.B -.IP "'selr '" +.TP +.B "'selr '" Select any files whose paths match the given .I regular expression (see below). -.B -.IP "'dsel '" +.TP +.B "'dsel '" Deselect any files whose paths contain the given text. -.B -.IP "'dselb '" +.TP +.B "'dselb '" Deselect any files whose paths begin with the given text. -.B -.IP "'dsele '" +.TP +.B "'dsele '" Deselect any files whose paths end with the given text. -.B -.IP "'dselm '" +.TP +.B "'dselm '" Deselect any file whose path matches the given text exactly. -.B -.IP "'dselr '" +.TP +.B "'dselr '" Deselect any files whose paths match the given .I regular expression (see below). -.B -.IP "'csel'" +.TP +.B "'csel'" Clear all selections. -.B -.IP "'isel'" -Invert selections within selected sets. For example, if files 1 and 4 in a set of 5 are selected, +.TP +.B "'isel'" +Invert selections within selected sets. For example, if files 1 and 4 in a +set of 5 are selected, .B isel -will deselect files 1 and 4, and select files 2, 3, and 5. Immediately repeating the same command will deselect files 2, 3, and 5, and select files 1 and 4, restoring selections to their previous state. +will deselect files 1 and 4, and select files 2, 3, and 5. Immediately +repeating the same command will deselect files 2, 3, and 5, and select +files 1 and 4, restoring selections to their previous state. .SH "TAGGING SELECTED FILES" -.PP -Once some files have been selected using the commands described above, the following commands can be used to tag selected files as desired: -.B -.IP "'ks'" +Once some files have been selected using the commands described above, +the following commands can be used to tag selected files as desired: +.TP +.B "'ks'" Tag selected files for keeping. -.B -.IP "'ds'" +.TP +.B "'ds'" Tag selected files for deletion. -.B -.IP "'rs'" +.TP +.B "'rs'" Remove all tags from selected files. .SH "DELETING DUPLICATES" @@ -212,20 +224,25 @@ Once tagged for deletion, files can be deleted by pressing DELETE or using the .B 'prune' -command. Fdupes will delete any files that are tagged for deletion and delist any sets whose remaining files have been tagged for keeping. For safety, fdupes will refuse to act on sets for which all files have been tagged for deletion. To handle these cases, tag at least one file for keeping and run the delete command again. +command. Fdupes will delete any files that are tagged for deletion and delist +any sets whose remaining files have been tagged for keeping. For safety, +fdupes will refuse to act on sets for which all files have been tagged for +deletion. To handle these cases, tag at least one file for keeping and run +the delete command again. .SH "OTHER COMMANDS" -.B -.IP "'exit', 'quit'" +.TP +.B "'exit', 'quit'" Exit the program. -.B -.IP "'help'" +.TP +.B "'help'" Display this help text. .SH "REGULAR EXPRESSIONS" -.PP -A regular expression is a sequence of characters defining a search pattern against which other character sequences can be compared. Strings of characters that follow the pattern defined by an expression are said to +A regular expression is a sequence of characters defining a search pattern +against which other character sequences can be compared. Strings of characters +that follow the pattern defined by an expression are said to .I match the expression, whereas strings that break the pattern do not. @@ -233,7 +250,9 @@ the expression, whereas strings that break the pattern do not. The syntax for regular expressions used by fdupes is known as the .B Perl Compatible Regular Expression -syntax. A detailed description of regular expression syntax is beyond the scope of this document. For detailed information the user is encouraged to consult the +syntax. A detailed description of regular expression syntax is beyond the +scope of this document. For detailed information the user is encouraged +to consult the .I PCRE2 documentation: @@ -245,8 +264,8 @@ https://www.pcre.org/current/doc/html/pcre2syntax.html .PP Briefly, here are some examples of regular expressions: -.B -.IP "abc123" +.TP +.B "abc123" Will match any string containing the sequence .IR abc123 , such as @@ -256,53 +275,60 @@ such as and .IR xabc123x . -.B -.IP "^abc123" +.TP +.B "^abc123" Will match any string beginning with .IR abc123 , -such as +such as .IR abc123 " and " abc123x , but not .IR xabc123 " or " xabc123x . -The character '^' has special meaning, telling the program to match only those strings that begin with the pattern that follows. +The character '^' has special meaning, telling the program to match only +those strings that begin with the pattern that follows. -.B -.IP "abc123$" +.TP +.B "abc123$" Will match any string that ends with .IR abc123 , such as .IR abc123 " and " xabc123 , but not .IR abc123x " or " xabc123x . -The character '$' has special meaning, telling the program to match only those strings that end with the preceding pattern. +The character '$' has special meaning, telling the program to match only +those strings that end with the preceding pattern. -.B -.IP "^abc123$" +.TP +.B "^abc123$" Will match the string .I abc123 and no other. -.B -.IP "ab.123" +.TP +.B "ab.123" Will match any string containing .I abc123 as in the first example, but it will also match strings containing -.IR abz123 , -.IR ab0123 , +.IR abz123 , +.IR ab0123 , .IR ab_123 , -etc. The character '.' has special meaning, acting as a placeholder that will match any character in that position. +etc. The character '.' has special meaning, acting as a placeholder that +will match any character in that position. -.B -.IP "^a.*3$" -Will match any string beginning with the letter a and ending with the number 3, such as +.TP +.B "^a.*3$" +Will match any string beginning with the letter a and ending with the +number 3, such as .IR abc123 , .IR a3 , and .IR a0b1c2d3 . -Here the character '*' tells the program to accept any number of appearances (including none) for the preceding item (here, any character matching the placeholder character '.'). The characters '^' and '$' have the same meaning as in previous examples. +Here the character '*' tells the program to accept any number of appearances +(including none) for the preceding item (here, any character matching the +placeholder character '.'). The characters '^' and '$' have the same meaning +as in previous examples. -.B -.IP "abc\ed+" +.TP +.B "abc\ed+" Will match any string containing the characters .B abc followed immediately by one or more decimal digits, such as @@ -311,18 +337,23 @@ but not .IR abcd123 or .I "abc 123" -(note the space). Here \ed is a placeholder for any decimal digit, while the character '+' tells the program to match one or more appearances of the preceding character or placeholder (here, \ed). - -.B -.IP "\ew+\ed+" -Will match any string containing one or more "word" characters followed immediately by one or more decimal digits, such as +(note the space). Here \ed is a placeholder for any decimal digit, while the +character '+' tells the program to match one or more appearances of the +preceding character or placeholder (here, \ed). + +.TP +.B "\ew+\ed+" +Will match any string containing one or more "word" characters followed +immediately by one or more decimal digits, such as .IR abc123 " and " abcd3210 , but not .IR "abc 123" -(note the space). Here \ew is a placeholder for a "word" character, and \ed and '+' have the same meaning as in the preceding example. +(note the space). Here \ew is a placeholder for a "word" character, and \ed +and '+' have the same meaning as in the preceding example. .PP -This is just scratching the surface of what can be done with regular expressions. Consult the PCRE2 documentation for a complete reference. +This is just scratching the surface of what can be done with regular +expressions. Consult the PCRE2 documentation for a complete reference. .SH "SEE ALSO" The fdupes man page, diff --git a/fdupes.1 b/fdupes.1 index 8116830..09c7e6c 100644 --- a/fdupes.1 +++ b/fdupes.1 @@ -1,6 +1,6 @@ .TH FDUPES 1 .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection -.\" other parms are allowed: see man(7), man(1) +.\" other params are allowed: see man(7), man(1) .SH NAME fdupes \- finds duplicate files in a given set of directories .SH SYNOPSIS @@ -13,7 +13,7 @@ fdupes \- finds duplicate files in a given set of directories .SH "DESCRIPTION" Searches the given path for duplicate files. Such files are found by -comparing file sizes and MD5 signatures, followed by a +comparing file sizes and MD5 signatures, followed by a byte-by-byte comparison. .SH OPTIONS @@ -118,8 +118,9 @@ Don't consider files with different owner/group or permission bits as duplicates .TP .B -o --order\fR=\fIWORD\fR Order files according to WORD: -time - sort by modification time, ctime - sort by status change time, name - sort by -filename. +time - sort by modification time, +ctime - sort by status change time, +name - sort by filename. .TP .B -i --reverse Reverse order while sorting. diff --git a/fdupes.c b/fdupes.c index 76a7136..593ce83 100644 --- a/fdupes.c +++ b/fdupes.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" @@ -79,7 +79,7 @@ ordertype_t ordertype = ORDER_MTIME; #define MD5_DIGEST_LENGTH 16 typedef struct _filetree { - file_t *file; + file_t *file; struct _filetree *left; struct _filetree *right; } filetree_t; @@ -126,10 +126,10 @@ dev_t getdevice(char *filename) { ino_t getinode(char *filename) { struct stat s; - + if (stat(filename, &s) != 0) return 0; - return s.st_ino; + return s.st_ino; } char *fmttime(time_t t) { @@ -168,9 +168,9 @@ char **cloneargs(int argc, char **argv) int findarg(char *arg, int start, int argc, char **argv) { int x; - + for (x = start; x < argc; x++) - if (strcmp(argv[x], arg) == 0) + if (strcmp(argv[x], arg) == 0) return x; return x; @@ -335,7 +335,7 @@ int grokdir(char *dir, file_t **filelistp, struct stat *logfile_status) if (lastchar >= 0 && dir[lastchar] != '/') strcat(newfile->d_name, "/"); strcat(newfile->d_name, dirinfo->d_name); - + if (ISFLAG(flags, F_EXCLUDEHIDDEN)) { fullname = strdup(newfile->d_name); if (fullname == 0) @@ -360,7 +360,7 @@ int grokdir(char *dir, file_t **filelistp, struct stat *logfile_status) free(newfile); continue; } - + if (!S_ISDIR(info.st_mode) && (((info.st_size == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) || info.st_size < minsize || (info.st_size > maxsize && maxsize != -1)))) { free(newfile->d_name); free(newfile); @@ -436,6 +436,7 @@ md5_byte_t *getcrcsignatureuntil(char *filename, off_t fsize, off_t max_read) file = fopen(filename, "rb"); if (file == NULL) { + free(digest); errormsg("error opening file %s\n", filename); return NULL; } @@ -500,9 +501,9 @@ void md5copy(md5_byte_t *to, const md5_byte_t *from) void purgetree(filetree_t *checktree) { if (checktree->left != NULL) purgetree(checktree->left); - + if (checktree->right != NULL) purgetree(checktree->right); - + free(checktree); } @@ -513,7 +514,7 @@ int registerfile(filetree_t **branch, file_t *file) errormsg("out of memory!\n"); exit(1); } - + (*branch)->file = file; (*branch)->left = NULL; (*branch)->right = NULL; @@ -580,7 +581,10 @@ int is_same_file(file_t *file_a, file_t *file_b) filename_b = strdup(file_b->d_name); if (filename_b == 0) + { + free(filename_a); return -1; + } /* get file basenames */ basename_a = basename(filename_a); @@ -808,7 +812,7 @@ void summarizematches(file_t *files) printf("%d duplicate files (in %d sets), occupying %.1f kilobytes\n\n", numfiles, numsets, numbytes / 1000.0); else printf("%d duplicate files (in %d sets), occupying %.1f megabytes\n\n", numfiles, numsets, numbytes / (1000.0 * 1000.0)); - + } } @@ -837,7 +841,7 @@ void printmatches(file_t *files) printf("\n"); } - + files = files->next; } } @@ -860,7 +864,7 @@ char *revisefilename(char *path, int seq) strcpy(scratch, path); dot = strrchr(scratch, '.'); - if (dot) + if (dot) { *dot = 0; sprintf(newpath, "%s%s%d.%s", scratch, REVISE_APPEND, seq, dot + 1); @@ -926,7 +930,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile) char *errorstring; curfile = files; - + while (curfile) { if (curfile->hasdupes) { counter = 1; @@ -937,10 +941,10 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile) counter++; tmpfile = tmpfile->duplicates; } - + if (counter > max) max = counter; } - + curfile = curfile->next; } @@ -970,7 +974,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile) counter = 1; dupelist[counter] = files; - if (prompt) + if (prompt) { if (ISFLAG(flags, F_SHOWTIME)) printf("[%d] [%s] %s\n", counter, fmttime(files->mtime), files->d_name); @@ -1057,20 +1061,20 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile) } for (x = 1; x <= counter; x++) preserve[x] = 0; - + token = strtok(preservestr, " ,\n"); - + while (token != NULL) { if (strcasecmp(token, "all") == 0 || strcasecmp(token, "a") == 0) for (x = 0; x <= counter; x++) preserve[x] = 1; - + number = 0; sscanf(token, "%d", &number); if (number > 0 && number <= counter) preserve[number] = 1; - + token = strtok(NULL, " ,\n"); } - + for (sum = 0, x = 1; x <= counter; x++) sum += preserve[x]; } while (sum < 1); /* make sure we've preserved at least one file */ @@ -1084,7 +1088,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile) hashdb_begintransaction(db); #endif - for (x = 1; x <= counter; x++) { + for (x = 1; x <= counter; x++) { if (preserve[x]) { printf(" [+] %s\n", dupelist[x]->d_name); @@ -1172,7 +1176,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile) hashdb_committransaction(db); #endif } - + files = files->next; } @@ -1233,7 +1237,7 @@ int sort_pairs_by_filename(file_t *f1, file_t *f2) return !ISFLAG(flags, F_REVERSE) ? strvalue : -strvalue; } -void registerpair(file_t **matchlist, file_t *newmatch, +void registerpair(file_t **matchlist, file_t *newmatch, int (*comparef)(file_t *f1, file_t *f2)) { file_t *traverse; @@ -1248,7 +1252,7 @@ void registerpair(file_t **matchlist, file_t *newmatch, if (comparef(newmatch, traverse) <= 0) { newmatch->duplicates = traverse; - + if (back == 0) { *matchlist = newmatch; /* update pointer to head of list */ @@ -1266,14 +1270,14 @@ void registerpair(file_t **matchlist, file_t *newmatch, if (traverse->duplicates == 0) { traverse->duplicates = newmatch; - + if (back == 0) traverse->hasdupes = 1; - + break; } } - + back = traverse; traverse = traverse->duplicates; } @@ -1472,9 +1476,12 @@ int main(int argc, char **argv) { char *endptr; char *cachehome; char *cachepath; +#ifndef NO_NCURSES + SCREEN *screen = NULL; +#endif #ifdef HAVE_GETOPT_H - static struct option long_options[] = + static struct option long_options[] = { { "omitfirst", 0, 0, 'f' }, { "recurse", 0, 0, 'r' }, @@ -1816,9 +1823,9 @@ int main(int argc, char **argv) { exit(0); } - if (!checktree) + if (!checktree) registerfile(&checktree, curfile); - else + else match = checkmatch(&checktree, checktree, curfile); if (match != NULL) { @@ -1827,7 +1834,7 @@ int main(int argc, char **argv) { curfile = curfile->next; continue; } - + file2 = fopen((*match)->d_name, "rb"); if (!file2) { fclose(file1); @@ -1885,7 +1892,8 @@ int main(int argc, char **argv) { #ifndef NO_NCURSES if (!ISFLAG(flags, F_PLAINPROMPT)) { - if (newterm(getenv("TERM"), stdout, stdin) != 0) + screen = newterm(NULL, stdout, stdin); + if (screen != NULL) { deletefiles_ncurses(files, logfile); } @@ -1918,11 +1926,11 @@ int main(int argc, char **argv) { } } - else + else if (ISFLAG(flags, F_SUMMARIZEMATCHES)) summarizematches(files); - + else printmatches(files); @@ -1943,5 +1951,11 @@ int main(int argc, char **argv) { purgetree(checktree); +#ifndef NO_NCURSES + if (screen) { + delscreen(screen); + } +#endif + return 0; } diff --git a/fdupes.h b/fdupes.h index f145fd4..84bd1f8 100644 --- a/fdupes.h +++ b/fdupes.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef FDUPES_H diff --git a/filegroup.h b/filegroup.h index 640da51..bf24095 100644 --- a/filegroup.h +++ b/filegroup.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef FILEGROUP_H diff --git a/getrealpath.c b/getrealpath.c index edd907b..7473e33 100644 --- a/getrealpath.c +++ b/getrealpath.c @@ -148,7 +148,10 @@ char *getrealpath(const char *path, unsigned int options) basename = malloc(strlen(path) + 1); if (basename == 0) + { + free(dirname); return 0; + } sdirname(dirname, path); sbasename(basename, path); diff --git a/log.c b/log.c index b5f16e8..9983621 100644 --- a/log.c +++ b/log.c @@ -25,7 +25,7 @@ #define LOG_HEADER "[fdupes log]\n" -/* Open log file in append mode. If file exists, make sure it is a valid fdupes log file. +/* Open log file in append mode. If file exists, make sure it is a valid fdupes log file. */ struct log_info *log_open(char *filename, int *error) { diff --git a/mbstowcs_escape_invalid.c b/mbstowcs_escape_invalid.c index 5964e8f..f444df8 100644 --- a/mbstowcs_escape_invalid.c +++ b/mbstowcs_escape_invalid.c @@ -97,7 +97,7 @@ size_t mbstowcs_escape_invalid(wchar_t *dest, const char *src, size_t n) if (i == 0) ++x; - + i = 0; reset_mbstate(&state); @@ -119,7 +119,7 @@ size_t mbstowcs_escape_invalid(wchar_t *dest, const char *src, size_t n) i = 0; } - + if (src[x] == L'\0' && i > 0) /* output final incomplete sequence */ { @@ -132,7 +132,7 @@ size_t mbstowcs_escape_invalid(wchar_t *dest, const char *src, size_t n) } else put_invalid_sequence(0, src + (x - i), &dx, i, 0); - } + } } if (dest != 0) diff --git a/md5/README b/md5/README index 84a7f14..0ac4f4d 100644 --- a/md5/README +++ b/md5/README @@ -1,4 +1,4 @@ -The MD5 library code residing within this directory was written -by L. Peter Deutsch. Although distributed here with fdupes, the -license for his MD5 library is different from the fdupes license. +The MD5 library code residing within this directory was written +by L. Peter Deutsch. Although distributed here with fdupes, the +license for his MD5 library is different from the fdupes license. Please look md5.c or md5.h for licensing information. diff --git a/md5/md5.c b/md5/md5.c index 3e8b694..56ed3d9 100644 --- a/md5/md5.c +++ b/md5/md5.c @@ -38,7 +38,7 @@ tom - Tom Hoover 2015-02-04 tom Added #ifdef __APPLE__ for proper compilation under OSX. - 2002-05-31 chl Relocated string.h to avoid memcpy warning. + 2002-05-31 chl Relocated string.h to avoid memcpy warning. 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). 1999-05-03 lpd Original version. diff --git a/md5/md5.h b/md5/md5.h index 6614ef4..e70158c 100644 --- a/md5/md5.h +++ b/md5/md5.h @@ -62,7 +62,7 @@ typedef struct md5_state_s { } md5_state_t; #ifdef __cplusplus -extern "C" +extern "C" { #endif diff --git a/ncurses-commands.c b/ncurses-commands.c index 40e1ea2..1920853 100644 --- a/ncurses-commands.c +++ b/ncurses-commands.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" diff --git a/ncurses-commands.h b/ncurses-commands.h index 99c22af..a1346d8 100644 --- a/ncurses-commands.h +++ b/ncurses-commands.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NCURSESCOMMANDS_H diff --git a/ncurses-getcommand.c b/ncurses-getcommand.c index 7b009bf..31cd256 100644 --- a/ncurses-getcommand.c +++ b/ncurses-getcommand.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" diff --git a/ncurses-getcommand.h b/ncurses-getcommand.h index 9a06917..3c4f81a 100644 --- a/ncurses-getcommand.h +++ b/ncurses-getcommand.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NCURSESGETCOMMAND_H diff --git a/ncurses-interface.c b/ncurses-interface.c index adc70df..7d7cb3f 100644 --- a/ncurses-interface.c +++ b/ncurses-interface.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" @@ -622,13 +622,13 @@ void deletefiles_ncurses(file_t *files, char *logfile) timestamp_width = ISFLAG(flags, F_SHOWTIME) ? 19 : 0; linestyle = getlinestyle(groups + groupindex, x); - + if (linestyle == linestyle_groupheader) { wattron(filewin, A_BOLD); if (groups[groupindex].selected) wattron(filewin, A_REVERSE); - wprintw(filewin, "Set %d of %d:\n", groupindex + 1, totalgroups); + wprintw(filewin, "Set %zd of %d:\n", groupindex + 1, totalgroups); if (groups[groupindex].selected) wattroff(filewin, A_REVERSE); wattroff(filewin, A_BOLD); @@ -1038,7 +1038,7 @@ void deletefiles_ncurses(file_t *files, char *logfile) { for (x = 0; x < groups[cursorgroup].filecount; ++x) { - if (groups[cursorgroup].files[x].action == FILEACTION_UNRESOLVED || + if (groups[cursorgroup].files[x].action == FILEACTION_UNRESOLVED || groups[cursorgroup].files[x].action == FILEACTION_ERROR ) { @@ -1269,6 +1269,9 @@ void deletefiles_ncurses(file_t *files, char *logfile) switch (wch) { case '?': + if (cursorgroup >= totalgroups) + break; + if (groups[cursorgroup].files[cursorfile].action == FILEACTION_UNRESOLVED) break; @@ -1282,6 +1285,9 @@ void deletefiles_ncurses(file_t *files, char *logfile) break; case '\n': + if (cursorgroup >= totalgroups) + break; + deletecount = 0; preservecount = 0; diff --git a/ncurses-interface.h b/ncurses-interface.h index a2f5805..72f5509 100644 --- a/ncurses-interface.h +++ b/ncurses-interface.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NCURSESINTERFACE_H diff --git a/ncurses-print.c b/ncurses-print.c index 7366529..dcf6654 100644 --- a/ncurses-print.c +++ b/ncurses-print.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" @@ -95,7 +95,7 @@ void putline(WINDOW *window, const char *str, const int line, const int columns, { linewidth += positive_wcwidth(dest[linestart + linelength]); ++linelength; - } + } } waddnwstr(window, dest + linestart, linelength); diff --git a/ncurses-print.h b/ncurses-print.h index 0efc2ef..e415d72 100644 --- a/ncurses-print.h +++ b/ncurses-print.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NCURSESPRINT_H diff --git a/ncurses-prompt.c b/ncurses-prompt.c index 7ee03b6..5948017 100644 --- a/ncurses-prompt.c +++ b/ncurses-prompt.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" @@ -74,7 +74,11 @@ int format_prompt(struct prompt_info *prompt, wchar_t *format, ...) newtext = (wchar_t*)realloc(prompt->text, (size + 3) * sizeof(wchar_t)); if (newtext == 0) + { + va_end(aq); + va_end(ap); return 0; + } prompt->text = newtext; prompt->allocated = size + 1; diff --git a/ncurses-prompt.h b/ncurses-prompt.h index f7f9e29..b37de4e 100644 --- a/ncurses-prompt.h +++ b/ncurses-prompt.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NCURSESPROMPT_H diff --git a/ncurses-status.c b/ncurses-status.c index 1afb284..9dda8e5 100644 --- a/ncurses-status.c +++ b/ncurses-status.c @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" diff --git a/ncurses-status.h b/ncurses-status.h index 8bdcc68..2d0a285 100644 --- a/ncurses-status.h +++ b/ncurses-status.h @@ -11,12 +11,12 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NCURSESSTATUS_H diff --git a/sigint.c b/sigint.c index 0a17473..39dd379 100644 --- a/sigint.c +++ b/sigint.c @@ -33,5 +33,5 @@ void register_sigint_handler() memset(&action, 0, sizeof(struct sigaction)); action.sa_handler = sigint_handler; - sigaction(SIGINT, &action, 0); + sigaction(SIGINT, &action, 0); } \ No newline at end of file