Skip to content

Commit

Permalink
Fixed removal of file field to delete whole line
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
adamjgnoel committed Apr 26, 2017
1 parent 75f37ce commit ba9e4a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
13 changes: 8 additions & 5 deletions mendeleyBibFix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ba9e4a0

Please sign in to comment.