diff --git a/.gitignore b/.gitignore index dc389f0..a0f212d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ library.bib library_fixed.bib -*.exe \ No newline at end of file +*.exe +mendeleyBibFix diff --git a/README.md b/README.md index b25569b..03ab4c6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build_mendeleyBibFix.bat b/build_mendeleyBibFix.bat index a59c938..dd9e036 100644 --- a/build_mendeleyBibFix.bat +++ b/build_mendeleyBibFix.bat @@ -1,2 +1,2 @@ @echo off -gcc mendeleyBibFix.c -std=c99 -g -o "mendeleyBibFix.exe" \ No newline at end of file +gcc mendeleyBibFix.c -std=c99 -o "mendeleyBibFix.exe" diff --git a/build_mendeleyBibFix.sh b/build_mendeleyBibFix.sh new file mode 100755 index 0000000..b0ac15c --- /dev/null +++ b/build_mendeleyBibFix.sh @@ -0,0 +1,2 @@ +#!/bin/sh +gcc mendeleyBibFix.c -std=c99 -Wall -o "mendeleyBibFix" diff --git a/mendeleyBibFix.c b/mendeleyBibFix.c index 8e6154c..64f3e34 100644 --- a/mendeleyBibFix.c +++ b/mendeleyBibFix.c @@ -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 @@ -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++) @@ -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);