From ba9e4a02fe475647245ad733a94a57af45e88b99 Mon Sep 17 00:00:00 2001 From: Adam Noel Date: Wed, 26 Apr 2017 12:03:26 -0400 Subject: [PATCH] Fixed removal of file field to delete whole line "File" removal was only scanning until the next "}," instead of the end of the line, so accented names in filenames led to improperly removed file fields --- LICENSE | 2 +- README.md | 2 +- mendeleyBibFix.c | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/LICENSE b/LICENSE index b54e606..4d5d20b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016, Adam Noel +Copyright (c) 2016-2017, Adam Noel All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index a214b73..4a89ab6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This is a simple function intended to correct bib-files that are automatically g * removes all appearances of the "annote" field, which is used by Mendeley for personal annotations to the entry * removes all appearances of the "file" field, which lists the location of a local soft copy -It should work correctly for files generated by Mendeley Desktop v1.16.1. Still works as of v1.17.8. +It should work correctly for files generated by Mendeley Desktop v1.16.1. Still works as of v1.17.9. A number of fixes are hard-coded, i.e., it expects to know where the braces are. So this code runs very fast (bib files with hundreds of entries are fixed in a small fraction of a second) but may not be "future-proof" diff --git a/mendeleyBibFix.c b/mendeleyBibFix.c index 4af10bc..8ceecf7 100644 --- a/mendeleyBibFix.c +++ b/mendeleyBibFix.c @@ -20,7 +20,7 @@ * - removes braces around months * * It should work correctly for files generated by Mendeley Desktop v1.16.1. - * Still functioning as of v1.17.8. + * Still functioning as of v1.17.9. * * A number of fixes are hard-coded, i.e., it expects to know where the braces are. * So this code runs very fast (bib files with hundreds of entries are fixed in a @@ -38,14 +38,17 @@ * output filename is "library_fixed.bib". If you're fine with the defaults, then * you can also just double-click on the executable without needing a terminal open. * - * Copyright 2016 Adam Noel. All rights reserved. + * Copyright 2016-2017 Adam Noel. All rights reserved. * Distributed under the New BSD license. See LICENSE.txt for license details. * * Created June 15, 2016 - * Current version v1.2 (2017-03-17) + * Current version v1.2.1 (2017-04-26) * * Revision history: * + * Revision v1.2.1 (2017-04-26) + * - fixed removal of "file" field to properly deal with accented names in the file name + * * Revision v1.2 (2017-03-17) * - added removal of "file" field, which lists location of local soft copy * @@ -306,8 +309,8 @@ int main(int argc, char *argv[]) curBibLength -= indEOL - curBibInd; curBibInd--; // Correct index so that line after annote is read correctly } else if(!strncmp(&curBibEntry[curBibInd+1], "file =",6)) - { // Entry has a filename. Erase the whole field - indEOL = findEndOfField(curBibEntry, curBibInd+1); + { // Entry has a filename. Erase the whole line + indEOL = findEndOfLine(curBibEntry, curBibInd+1); memmove(&curBibEntry[curBibInd+1], &curBibEntry[indEOL+1], curBibLength - indEOL + 1); curBibLength -= indEOL - curBibInd;