Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjgnoel committed Aug 26, 2019
2 parents 5e9b389 + c18f2f3 commit 53ba7b1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library.bib
library_fixed.bib
*.exe
*.exe
mendeleyBibFix
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ It should work correctly for files generated by Mendeley Desktop v1.16.1. Still

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"

You will need to compile this code to run it. A compiled version for windows is included on the release page of Github. If you are going to compile it yourself with gcc, then you will need the -std=c99 option
You will need to compile this code to run it. A compiled version for Windows is included on the release page of Github. If you are going to compile it yourself with `gcc`, then you will need the `-std=c99` option (e.g., command like “gcc -o mendeleyBibFix mendeleyBibFix.c -std=c99”).

Call syntax (windows):
mendeleyBibFix.exe [OUTPUT_FILENAME] [INPUT_FILENAME]
The full call syntax is as follows:
* Call syntax (Windows):
`mendeleyBibFix.exe [OUTPUT_FILENAME] [INPUT_FILENAME]`
* Call syntax (Linux or macOS):
`./mendeleyBibFix [OUTPUT_FILENAME] [INPUT_FILENAME]`

Both arguments are optional. If there is only one argument, then it is assumed to be the output filename. The default input filename is "library.bib", and the default output filename is "library_fixed.bib". If you're happy with the defaults then you can just double-click on the executable in the directory with "library.bib".
Both arguments are optional. If there is only one argument, then it is assumed to be the output filename. The default input filename is "library.bib" (which is the default name of the bib-file that Mendeley generates), and the default output filename is "library_fixed.bib".

You can run the script in one of two ways:
1) Open a command window and navigate to the folder containing both the bib-file and the executable (e.g., cd "C:\Users\Documents..."). Then enter (for Windows) "mendeleyBibFix.exe OUTPUT_FILENAME INPUT_FILENAME". You can omit the filename arguments if your bib-file is called library.bib and you want the script to create library_fixed.bib.
2) If you're happy with the default arguments, and if the executable is placed in the same directory as the bib-file "library.bib", then you can just double-click on the executable
2 changes: 1 addition & 1 deletion build_mendeleyBibFix.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
gcc mendeleyBibFix.c -std=c99 -g -o "mendeleyBibFix.exe"
gcc mendeleyBibFix.c -std=c99 -o "mendeleyBibFix.exe"
2 changes: 2 additions & 0 deletions build_mendeleyBibFix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
gcc mendeleyBibFix.c -std=c99 -Wall -o "mendeleyBibFix"
10 changes: 6 additions & 4 deletions mendeleyBibFix.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
* 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"
*
* You will need to compile this code to run it. A compiled version for windows is
* You will need to compile this code to run it. A compiled version for Windows is
* included on the release page of Github. If you are going to compile it yourself with gcc,
* then you will need the -std=c99 option
*
* Call syntax (windows):
* Call syntax (Windows):
* mendeleyBibFix.exe [OUTPUT_FILENAME] [INPUT_FILENAME]
* Call syntax (Linux or macOS):
* ./mendeleyBibFix [OUTPUT_FILENAME] [INPUT_FILENAME]
*
* Both arguments are optional. If there is only one argument, then it is assumed to be
* the output filename. The default input filename is "library.bib", and the default
Expand Down Expand Up @@ -240,7 +242,7 @@ int main(int argc, char *argv[])
curBibEntry = malloc((curBibLength + 1)*sizeof(char));
if(curBibEntry == NULL)
{
fprintf(stderr,"ERROR: Memory could not be allocated to copy bib entry %u.\n", numEntry);
fprintf(stderr,"ERROR: Memory could not be allocated to copy bib entry %lu.\n", numEntry);
exit(EXIT_FAILURE);
}
for(curBibInd = 0; curBibInd < curBibLength; curBibInd++)
Expand Down Expand Up @@ -381,7 +383,7 @@ int main(int argc, char *argv[])

fprintf(outputFile, "%s", outputContent);
fclose(outputFile);
printf("Successfully wrote and closed output file with %u entries.\n", numEntry);
printf("Successfully wrote and closed output file with %lu entries.\n", numEntry);

// Cleanup
free(inputContent);
Expand Down

0 comments on commit 53ba7b1

Please sign in to comment.